コード例 #1
0
        public ActionResult AddDoctorNotes(DoctorNote note)
        {
            note.BranchId  = (int)Session["UserBranchId"];
            note.UserId    = (int)Session["UserId"];
            note.DateAdded = DateTime.Now;
            db.DoctorNotes.Add(note);
            db.SaveChanges();

            return(RedirectToAction("DoctorNotesList", new { id = note.IpdOpdNo }));
        }
コード例 #2
0
        internal bool Save(DoctorNote note)
        {
            if (note.Id == 0)
            {
                var x = Connection.Insert(note);
                return(x > 0);
            }
            else
            {
                return(Connection.Update(note));
            }
            //sql = "update hlc_DoctorNote set"

            //return ExecuteSql(sql);
        }
コード例 #3
0
        public ActionResult Edit(DoctorNote viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var returnMsg = "There was an error updating this comment.";

            viewModel.DateEntered = DateTime.Now;
            viewModel.UserId      = (Session["User"] as User)?.UserId;

            if (_noteRepository.Save(viewModel))
            {
                returnMsg = $"Comment was edited successfully.";
            }

            //return RedirectToAction("Search", "Home", new {msg = returnMsg });
            return(RedirectToAction("View", new { id = viewModel.Id }));
        }
コード例 #4
0
        public IActionResult AddNewPatientRecord(AddNewPatientRecordViewModel addNewPatientRecordViewModel)
        {
            ViewBag.DoctorName = HttpContext.Session.GetString(Globals.currentUserName);
            if (!string.IsNullOrEmpty(addNewPatientRecordViewModel.DoctorsNote.PurposeOfVisit))
            {
                var noteViewModel = addNewPatientRecordViewModel.DoctorsNote;
                var doctorNote    = new DoctorNote
                {
                    PurposeOfVisit      = noteViewModel.PurposeOfVisit,
                    Description         = noteViewModel.Description,
                    FinalDiagnosis      = noteViewModel.FinalDiagnosis,
                    FurtherInstructions = noteViewModel.FurtherInstructions,
                    DoctorName          = HttpContext.Session.GetString(Globals.currentUserName),
                    DoctorMinsc         = HttpContext.Session.GetString(Globals.currentUserID),
                    DateOfRecord        = DateTime.Now
                };
                string encryptionKey;
                var    encryptedData = EncryptionService.getEncryptedAssetData(JsonConvert.SerializeObject(doctorNote), out encryptionKey);

                var asset = new AssetSaved <string>
                {
                    Data     = encryptedData,
                    RandomId = _random.Next(0, 100000),
                    Type     = AssetType.DoctorNote
                };

                var metadata = new MetaDataSaved <double>();
                metadata.AccessList = new Dictionary <string, string>();

                //store the data encryption key in metadata encrypted with sender and reciever agree key
                var doctorSignPrivateKey  = HttpContext.Session.GetString(Globals.currentDSPriK);
                var doctorAgreePrivateKey = HttpContext.Session.GetString(Globals.currentDAPriK);
                var patientAgreePublicKey = HttpContext.Session.GetString(Globals.currentPAPubK);
                var patientSignPublicKey  = HttpContext.Session.GetString(Globals.currentPSPubK);
                var doctorSignPublicKey   = EncryptionService.getSignPublicKeyStringFromPrivate(doctorSignPrivateKey);
                var doctorAgreePublicKey  = EncryptionService.getAgreePublicKeyStringFromPrivate(doctorAgreePrivateKey);
                metadata.AccessList[doctorSignPublicKey] =
                    EncryptionService.getEncryptedEncryptionKey(encryptionKey, doctorAgreePrivateKey, doctorAgreePublicKey);
                metadata.AccessList[patientSignPublicKey] =
                    EncryptionService.getEncryptedEncryptionKey(encryptionKey, doctorAgreePrivateKey, patientAgreePublicKey);

                _bigChainDbService.SendCreateTransferTransactionToDataBase <string, double>(asset, metadata, doctorSignPrivateKey, patientSignPublicKey);
            }

            if (!string.IsNullOrEmpty(addNewPatientRecordViewModel.Prescription.DrugName))
            {
                var prescriptionViewModel = addNewPatientRecordViewModel.Prescription;
                var prescription          = new Prescription
                {
                    PrescribingDate = prescriptionViewModel.PrescribingDate,
                    Superscription  = prescriptionViewModel.Superscription,
                    DrugName        = prescriptionViewModel.DrugName,
                    Dosage          = prescriptionViewModel.Dosage,
                    //StartDate = prescriptionViewModel.StartDate,
                    EndDate         = prescriptionViewModel.EndDate,
                    Refill          = prescriptionViewModel.Refill,
                    Substitution    = prescriptionViewModel.Substitution,
                    DoctorName      = HttpContext.Session.GetString(Globals.currentUserName),
                    DoctorMinsc     = HttpContext.Session.GetString(Globals.currentUserID),
                    DirectionForUse = prescriptionViewModel.DirectionForUse
                };

                string encryptionKey;
                var    encryptedData = EncryptionService.getEncryptedAssetData(JsonConvert.SerializeObject(prescription), out encryptionKey);

                var asset = new AssetSaved <string>
                {
                    Data     = encryptedData,
                    RandomId = _random.Next(0, 100000),
                    Type     = AssetType.Prescription
                };

                var metadata = new MetaDataSaved <PrescriptionMetadata>
                {
                    AccessList = new Dictionary <string, string>(),
                    data       = new PrescriptionMetadata
                    {
                        RefillRemaining = prescription.Refill,
                        LastIssueQty    = -1
                    }
                };

                //store the data encryption key in metadata encrypted with sender and reciever agree key
                var doctorSignPrivateKey  = HttpContext.Session.GetString(Globals.currentDSPriK);
                var doctorAgreePrivateKey = HttpContext.Session.GetString(Globals.currentDAPriK);
                var patientAgreePublicKey = HttpContext.Session.GetString(Globals.currentPAPubK);
                var patientSignPublicKey  = HttpContext.Session.GetString(Globals.currentPSPubK);
                var doctorSignPublicKey   = EncryptionService.getSignPublicKeyStringFromPrivate(doctorSignPrivateKey);
                var doctorAgreePublicKey  = EncryptionService.getAgreePublicKeyStringFromPrivate(doctorAgreePrivateKey);
                metadata.AccessList[doctorSignPublicKey] =
                    EncryptionService.getEncryptedEncryptionKey(encryptionKey, doctorAgreePrivateKey, doctorAgreePublicKey);
                metadata.AccessList[patientSignPublicKey] =
                    EncryptionService.getEncryptedEncryptionKey(encryptionKey, doctorAgreePrivateKey, patientAgreePublicKey);

                _bigChainDbService.SendCreateTransferTransactionToDataBase <string, PrescriptionMetadata>(asset, metadata, doctorSignPrivateKey, patientSignPublicKey);
            }

            //There is a test result that exists
            if (!string.IsNullOrEmpty(addNewPatientRecordViewModel.TestRequisition.ReasonForTest))
            {
                //File exists
                if (addNewPatientRecordViewModel.TestRequisition.AttachedFile != null)
                {
                    var    file             = addNewPatientRecordViewModel.TestRequisition.AttachedFile;
                    string base64FileString = "";

                    // Convert "file" into base64 string "base64FileString" to save into database
                    using (var ms = new MemoryStream())
                    {
                        file.CopyTo(ms);
                        var fileBytes = ms.ToArray();
                        base64FileString = Convert.ToBase64String(fileBytes);
                    }
                    //encrypt file and store in ipfs
                    var encryptionKey = EncryptionService.getNewAESEncryptionKey();
                    var encryptedFile = EncryptionService.getEncryptedAssetDataKey(base64FileString, encryptionKey);
                    var id            = _bigChainDbService.UploadTextToIPFS(encryptedFile);

                    var testRequisition = new TestRequisitionAsset
                    {
                        AttachedFile = new FileData
                        {
                            Data      = id,
                            Type      = file.ContentType,
                            Extension = file.ContentType.Split('/').Last(),
                            Name      = file.FileName
                        },
                        ReasonForTest = addNewPatientRecordViewModel.TestRequisition.ReasonForTest,
                        TestType      = addNewPatientRecordViewModel.TestRequisition.TestType,
                        DateOrdered   = DateTime.Now
                    };
                    var encryptedData = EncryptionService.getEncryptedAssetDataKey(JsonConvert.SerializeObject(testRequisition), encryptionKey);

                    var asset = new AssetSaved <string>
                    {
                        Data     = encryptedData,
                        RandomId = _random.Next(0, 100000),
                        Type     = AssetType.TestRequisition
                    };

                    var metadata = new MetaDataSaved <double>();
                    metadata.AccessList = new Dictionary <string, string>();

                    //store the data encryption key in metadata encrypted with sender and reciever agree key
                    var doctorSignPrivateKey  = HttpContext.Session.GetString(Globals.currentDSPriK);
                    var doctorAgreePrivateKey = HttpContext.Session.GetString(Globals.currentDAPriK);
                    var patientAgreePublicKey = HttpContext.Session.GetString(Globals.currentPAPubK);
                    var patientSignPublicKey  = HttpContext.Session.GetString(Globals.currentPSPubK);
                    var doctorSignPublicKey   = EncryptionService.getSignPublicKeyStringFromPrivate(doctorSignPrivateKey);
                    var doctorAgreePublicKey  = EncryptionService.getAgreePublicKeyStringFromPrivate(doctorAgreePrivateKey);
                    metadata.AccessList[doctorSignPublicKey] =
                        EncryptionService.getEncryptedEncryptionKey(encryptionKey, doctorAgreePrivateKey, doctorAgreePublicKey);
                    metadata.AccessList[patientSignPublicKey] =
                        EncryptionService.getEncryptedEncryptionKey(encryptionKey, doctorAgreePrivateKey, patientAgreePublicKey);

                    _bigChainDbService.SendCreateTransferTransactionToDataBase <string, double>(asset, metadata, doctorSignPrivateKey, patientSignPublicKey);
                }
            }

            return(RedirectToAction("PatientOverview"));
        }