/// <summary> /// The issuances are saved in a single DrugManager. /// The drugManager associated the prescribed drug and the patient registry /// </summary> /// <param name="prescibedMedication">List of drug Issuances . /// drug inssuance consist of drug,administration,dosage and frequency</param> public void savePrescribedMedication(List <DrugIssuance> prescibedMedication) { DrugIssuance drugIssuance; DrugManager drugManager = new DrugManager { Clinic_registry_manager = SingletonClinicRegistry.GetInstance(db) }; foreach (DrugIssuance issuance in prescibedMedication) { drugIssuance = new DrugIssuance { IssuedDrug = db.Drugs.Find(issuance.IssuedDrug.Drug_id), Medication_administration = db.DrugAdministrations.Find(issuance.Medication_administration.Administration_Id), Medication_dosage = db.DrugDosages.Find(issuance.Medication_dosage.Dosage_id), Medication_frequency = db.DrugFrequencies.Find(issuance.Medication_frequency.Frequency_id), Medication_end_date = issuance.Medication_end_date, Medication_start_date = issuance.Medication_start_date, Medication_manager = drugManager }; db.DrugInssuances.Add(drugIssuance); } db.SaveChanges(); }
/// <summary> /// is an auxilliary function and receives a single ICD object as a param /// aaociated the code to the disease object and consequently /// to the clincRegistry instance /// </summary> /// <param name="disCode">ICD code object</param> private void saveDiagnosisAUX(CID_DiseaseCode disCode) { CIDCode diseaseCode = db.CIDCodes.Where(x => x.CID_DiseaseCode.DiseaseCode == disCode.DiseaseCode && x.CID_DiseaseCode.CIDCategory.CID_CategorID == disCode.CIDCategory.CID_CategorID).FirstOrDefault(); Disease disease = new Disease { Disease_start_date = DateTime.Now, Disease_is_active = true }; ClinicRegistryManager registry = SingletonClinicRegistry.GetInstance(db); try { Diagnosis diagnosis = new Diagnosis { Diagnosis_CID_code = diseaseCode, Diagnosis_disease = disease, ClinicRegistry_Manager = registry }; db.Diagnoses.Add(diagnosis); db.SaveChanges(); //db.Entry(diagnosis).State = EntityState.Detached; } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } }
/// <summary> /// Save the received observation either from treatmentplan or observations panel /// </summary> /// <param name="observationList">includes observation body and subject</param> public void SaveObservation(List <string> observationList) { bool ISclassified = observationList[2] == "True" ? true : false; db.Observations.Add(new Observations { subject = observationList[0], ObservationBody = observationList[1], IsClassified = ISclassified, clinicalRegistry = SingletonClinicRegistry.GetInstance(db) }); db.SaveChanges(); }
/// <summary> /// first step --add mcdt /// second step- add mcdt_staff_manager considering null staff to be later filled by labTec /// third step- add mcdt-staff-manager to the MCDT manager /// </summary> /// <param name="mcdt"></param> private void SavePrescribedMcdtAUX(MCDT mcdt) { MCDTStaffManager MCDT_staffManager = db.MCDTStaffManagers.Add(new MCDTStaffManager { mcdt = mcdt }); MCDTManager mcdtManager = db.MCDTManagers.Add( new MCDTManager { MCDTStaffManager = MCDT_staffManager, clinicRegistryManager = SingletonClinicRegistry.GetInstance(db) }); db.SaveChanges(); }