public static async Task <string> obtain(string doctorProofJson, string walletIdentifier) { bool res = await DoctorProofFacilitator.verifyDoctorProof( doctorProofJson); if (!res) { return("The doctor proof json that was provided is not valid!"); } EHRBackupModel model = EHRBackupModel.importFromJsonFile(walletIdentifier); return(model.toJson()); }
static public async Task <string> backupEHR(string walletId, string ehrJson) { // encrypt ehr data CipherFacilitator cipher = new CipherFacilitator(); string encryptedEHR = cipher.encrypt(ehrJson); string relPath = walletId + "ESjson.temp"; IOFacilitator.createFile(encryptedEHR, relPath); IpfsFacilitator ipfs = new IpfsFacilitator(); string localPath = IOFacilitator.homePath() + relPath; string ipfsPath = await ipfs.addFile(localPath); ShellFacilitator.Bash("rm -f " + localPath); EHRBackupModel model = new EHRBackupModel(ipfsPath, cipher.getKey(), cipher.getIV()); model.exportToJsonFile(walletId); return(model.toJson()); }