public ActionResult Detail(string id) { var intId = 0; int.TryParse(id, out intId); try { DTODiagnosis dtodiagnosis = diagnosisRepository.GetDTODiagnosisById(intId); IEnumerable <vMedicineDiagnosis> medicineRecords = objPrescription.GetPrescriptionDiagnosis(intId); if (dtodiagnosis == null) { return(RedirectToAction("Error404", "Error")); } diagnosisModel = new DiagnosisModels { dtodiagnosis = dtodiagnosis, medicineRecords = medicineRecords }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View(diagnosisModel)); }
public ActionResult Print(string id) { var intId = 0; int.TryParse(id, out intId); PrintPrescriptionModels viewModel = null; try { IDiagnosisRepository diagnosisRepository = new DiagnosisRepository(); DTODiagnosis dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(intId); ViewData["PatientTel"] = dtoDiagnosis.Patient_Tel; IEnumerable <vMedicineDiagnosis> medicineRecords = objPrescription.GetPrescriptionDiagnosis(intId); if (dtoDiagnosis == null) { return(RedirectToAction("Error404", "Error")); } viewModel = new PrintPrescriptionModels { dtoDiagnosis = dtoDiagnosis, medicineRecords = medicineRecords }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View("Print", "_LayoutPrint", viewModel)); }
public ActionResult Edit(string id) { DiagnosisEdit objFrm = new DiagnosisEdit(); var intId = 0; int.TryParse(id, out intId); try { DTODiagnosis dtodiagnosis = diagnosisRepository.GetDTODiagnosisById(intId); if (dtodiagnosis == null) { return(RedirectToAction("Error404", "Error")); } else { var symptomTypes = diagnosisRepository.GetSymptomType(); var employeeLists = employeeRepository.Get(); diagnosisModel = new DiagnosisModels { dtodiagnosis = dtodiagnosis, diagnosisEdit = objFrm, symptomTypes = symptomTypes, EmployeeLists = employeeLists, checkPost = false }; } } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("", Translator.UnexpectedError); } return(View(diagnosisModel)); }
/*For Get DTODiagnosis Record by Id*/ public DTODiagnosis GetDTODiagnosisById(int id) { DTODiagnosis objReturn = new DTODiagnosis(); try { objReturn = db.DTODiagnosis.Where(x => x.Id == id && x.Status != 0).FirstOrDefault(); } catch (DbEntityValidationException exp) { log.Error(exp); } return(objReturn); }
public ActionResult DeleteConfirmed(int id) { string resultTrans = "success"; try { var prescriptionList = diagnosisRepository.GetPrescriptionByDiagnosisId(id); if (prescriptionList.Count() == 0) { DTODiagnosis dtodiagnosis = diagnosisRepository.GetDTODiagnosisById(id); Diagnosis originDiagnosis = diagnosisRepository.GetDiagnosisById(id); var newDiagnosis = ObjectCopier.Copy <Diagnosis>(originDiagnosis); newDiagnosis.Status = 0;//For Delete diagnosisRepository.UpdateFieldChangedOnly(originDiagnosis, newDiagnosis); /*For Add New Record to LogTable*/ var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; int userId = objSession.UserId; logTran.UserId = userId; logTran.ProcessType = "Delete Diagnosis"; logTran.Description = "Delete Diagnosis, Patient Name :" + dtodiagnosis.Patient_Name; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); } else { resultTrans = "failure"; return(Json(new { result = resultTrans, proccessType = "Delete", Id = id, strName = Translator.ThisDiagnosis, strUsed = Translator.MsgPrescription })); } } catch (Exception ex) { log.Error(ex); resultTrans = "failure"; } return(Json(new { result = resultTrans, proccessType = "Delete", Id = id })); }
public ActionResult Edit(string id) { var itemAdd = new PrescriptionAdd(); IDiagnosisRepository diagnosisRepository = new DiagnosisRepository(); IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); PrescriptionModels viewModel = null; try { int intId = 0; int.TryParse(id, out intId); IEnumerable <MedicineType> medicineTypeRecords = objMedicineType.Get(); IEnumerable <Usage> usageRecords = objMedicineType.GetUsage(); DTODiagnosis dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(intId); IEnumerable <vMedicineDiagnosis> medicineRecords = objPrescription.GetPrescriptionDiagnosis(intId); IMedicineTypeRepository medicineTypeRepository = new MedicineTypeRepository(); var usageSelectBox = medicineTypeRepository.GetUsageSelectBox(); ViewData["usageSelectBox"] = usageSelectBox; viewModel = new PrescriptionModels { validAdd = itemAdd, checkPost = false, dtoDiagnosis = dtoDiagnosis, medicineTypeRecords = medicineTypeRecords, medicineRecords = medicineRecords, usageRecords = usageRecords, }; } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } return(View(viewModel)); }
public ActionResult Edit(MyClinic.Infrastructure.PrescriptionAdd itemAdd) { this.GetUserProfile(); bool checkError = true; PrescriptionModels viewModel = null; DTODiagnosis dtoDiagnosis = null; IEnumerable <MedicineType> medicineTypeRecords = null; IEnumerable <vMedicineDiagnosis> medicineRecords = null; string diffString = ""; try { IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); IDiagnosisRepository diagnosisRepository = new DiagnosisRepository(); dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(itemAdd.DiagnosisId); medicineRecords = objPrescription.GetPrescriptionDiagnosis(itemAdd.DiagnosisId); if (ModelState.IsValid) { var intTotal = 0; if (itemAdd.MedicineId != null) { intTotal = itemAdd.MedicineId.Count(); } foreach (var record in medicineRecords) { bool blnFound = false; for (int intIndex = 0; intIndex < intTotal; intIndex++) { var intId = 0; if (int.TryParse(itemAdd.Id[intIndex], out intId)) { if (intId == record.Id) { blnFound = true; Prescription itemOld = new Prescription(); itemOld.DiagnosisId = record.DiagnosisId; itemOld.Id = record.Id; itemOld.MedicineId = record.MedicineId; itemOld.Qty = record.Qty; //itemOld.MedicineType = record.MedicineType; itemOld.Morning = record.Morning; itemOld.Noon = record.Noon; itemOld.Night = record.Night; itemOld.Remark = record.Remark; itemOld.UsageId = record.UsageId; Prescription itemNew = new Prescription(); int itemId = 0; int.TryParse(itemAdd.Id[intIndex], out itemId); itemNew.DiagnosisId = record.DiagnosisId; itemNew.Id = itemId; int MedicineId = 0; int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId); itemNew.MedicineId = MedicineId; itemNew.Qty = itemAdd.Qty[intIndex]; //itemNew.MedicineType = itemAdd.MedicineType[intIndex]; itemNew.Morning = itemAdd.Morning[intIndex]; itemNew.Noon = itemAdd.Noon[intIndex]; itemNew.Night = itemAdd.Night[intIndex]; itemNew.Remark = itemAdd.Remark[intIndex]; itemNew.UsageId = int.Parse(itemAdd.UsageId[intIndex]); itemNew.Status = record.Status; diffString = diffString + itemOld.EnumeratePropertyDifferencesInString(itemNew); objPrescription.Update(itemNew); } } } if (blnFound == false) { objPrescription.Delete(record.Id); } } for (int intIndex = 0; intIndex < intTotal; intIndex++) { int itemId = 0; int.TryParse(itemAdd.Id[intIndex], out itemId); if (itemId == 0) { Prescription itemGet = new Prescription(); itemGet.DiagnosisId = itemAdd.DiagnosisId; int MedicineId = 0; int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId); itemGet.MedicineId = MedicineId; itemGet.Qty = itemAdd.Qty[intIndex]; //itemGet.MedicineType = itemAdd.MedicineType[intIndex]; itemGet.Morning = itemAdd.Morning[intIndex]; itemGet.Noon = itemAdd.Noon[intIndex]; itemGet.Night = itemAdd.Night[intIndex]; itemGet.Remark = itemAdd.Remark[intIndex]; itemGet.UsageId = int.Parse(itemAdd.UsageId[intIndex]); itemGet.Status = (int)MyClinic.Core.Enums.RecordStatus.Active; objPrescription.Add(itemGet); } } /*For Add New Record to LogTable*/ logTran.UserId = this.objProfile.UserId; logTran.ProcessType = "Edit Prescription"; logTran.Description = "Edit Prescription value as follow: " + diffString; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); return(RedirectToAction("Detail", "Prescription", new { id = itemAdd.DiagnosisId })); checkError = false; } medicineTypeRecords = objMedicineType.Get(); } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } if (checkError == true) { viewModel = new PrescriptionModels { validAdd = itemAdd, checkPost = true, checkError = checkError, dtoDiagnosis = dtoDiagnosis, medicineTypeRecords = medicineTypeRecords, medicineRecords = medicineRecords }; return(View(viewModel)); } else { return(RedirectToAction("Index", "Diagnosis")); } }
public ActionResult Add(MyClinic.Infrastructure.PrescriptionAdd itemAdd) { Prescription itemGet = new Prescription(); var objSessionDiagnosis = Session["diagnosis"] as MyClinic.Infrastructure.Diagnosis; this.GetUserProfile(); bool checkError = true; PrescriptionModels viewModel = null; DTODiagnosis dtoDiagnosis = null; IEnumerable <MedicineType> medicineTypeRecords = null; try { IMedicineTypeRepository objMedicineType = new MedicineTypeRepository(); IDiagnosisRepository diagnosisRepository = new DiagnosisRepository(); dtoDiagnosis = diagnosisRepository.GetDTODiagnosisById(itemAdd.DiagnosisId); /*For Add Diagnosis to Table */ diagnosisRepository.Add(objSessionDiagnosis); itemGet.DiagnosisId = objSessionDiagnosis.Id; //Save Image SaveUploadImge(Session.SessionID, objSessionDiagnosis.Id); if (ModelState.IsValid) { var intTotal = 0; if (itemAdd.MedicineId != null) { intTotal = itemAdd.MedicineId.Count(); } for (int intIndex = 0; intIndex < intTotal; intIndex++) { int MedicineId = 0; int.TryParse(itemAdd.MedicineId[intIndex], out MedicineId); itemGet.MedicineId = MedicineId; itemGet.Qty = itemAdd.Qty[intIndex]; //itemGet.MedicineType = itemAdd.MedicineType[intIndex]; itemGet.Morning = itemAdd.Morning[intIndex]; itemGet.Noon = itemAdd.Noon[intIndex]; itemGet.Night = itemAdd.Night[intIndex]; itemGet.Remark = itemAdd.Remark[intIndex]; itemGet.UsageId = int.Parse(itemAdd.UsageId[intIndex]); itemGet.Status = (int)MyClinic.Core.Enums.RecordStatus.Active; objPrescription.Add(itemGet); } Session["diagnosis"] = null; /*For Add New Record to LogTable*/ logTran.UserId = this.objProfile.UserId; logTran.ProcessType = "Add Prescription"; logTran.Description = "Add Prescription"; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); /*this.GetUserProfile(); * var test = this.objProfile;*/ return(RedirectToAction("Detail", "Prescription", new { id = itemGet.DiagnosisId })); //checkError = false; } medicineTypeRecords = objMedicineType.Get(); } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("error", Translator.UnexpectedError); } if (checkError == true) { viewModel = new PrescriptionModels { validAdd = itemAdd, checkPost = true, checkError = checkError, dtoDiagnosis = dtoDiagnosis, medicineTypeRecords = medicineTypeRecords }; return(View(viewModel)); } else { return(RedirectToAction("Index", "User")); } }
public ActionResult Edit(DiagnosisEdit objFrm) { bool checkError = true; /* start check Disease_Name is correct*/ var objectDisease = diseaseRepository.GetDiseaseById(objFrm.DiseaseId); if (objectDisease != null) { if (string.IsNullOrEmpty(objFrm.Disease_Name) == false && string.IsNullOrEmpty(objectDisease.Name) == false) { if (objFrm.Disease_Name.Trim() != objectDisease.Name.Trim()) { ModelState.AddModelError("Disease_Name", Translator.MsgInvalidDiseaseName); } } else { ModelState.AddModelError("Disease_Name", Translator.MsgInvalidDiseaseName); } } else { ModelState.AddModelError("Disease_Name", Translator.MsgInvalidDiseaseName); } /*End check Disease_Name */ try { Diagnosis originDiagnosis = diagnosisRepository.GetDiagnosisById(objFrm.Id); if (ModelState.IsValid) { Diagnosis newDiagnosis = Utilities.ObjectCopier.Copy <Diagnosis>(originDiagnosis); var objSession = Session["user"] as MyClinic.Infrastructure.SessUser; //newDiagnosis.Status = objFrm.Status; newDiagnosis.DiagnoseCycle = objFrm.DiagnoseCycle; newDiagnosis.ExpiredDate = objFrm.ExpiredDate; newDiagnosis.Symptom = objFrm.Symptom; newDiagnosis.SymptomType = objFrm.SymptomType; newDiagnosis.DiseaseId = objFrm.DiseaseId; newDiagnosis.DiagnoseBy = objFrm.DiagnoseBy; string diffString = originDiagnosis.EnumeratePropertyDifferencesInString(newDiagnosis); diagnosisRepository.UpdateFieldChangedOnly(originDiagnosis, newDiagnosis); /*For Add New Record to LogTable*/ logTran.UserId = objSession.UserId; logTran.ProcessType = "Edit User"; logTran.Description = "Edit User value as follow: " + diffString; logTran.LogDate = DateTime.Now; logRepository.Add(logTran); checkError = false; } if (checkError == true) { DTODiagnosis dtodiagnosis = diagnosisRepository.GetDTODiagnosisById(objFrm.Id); dtodiagnosis.Status = objFrm.Status; dtodiagnosis.DiagnoseCycle = objFrm.DiagnoseCycle; dtodiagnosis.ExpiredDate = objFrm.ExpiredDate; dtodiagnosis.Symptom = objFrm.Symptom; var symptomTypes = diagnosisRepository.GetSymptomType(); var employeeLists = employeeRepository.Get(); diagnosisModel = new DiagnosisModels { symptomTypes = symptomTypes, dtodiagnosis = dtodiagnosis, diagnosisEdit = objFrm, EmployeeLists = employeeLists, checkPost = true }; return(View(diagnosisModel)); } else { return(RedirectToAction("Index", "Diagnosis")); } } catch (Exception ex) { log.Error(ex); ModelState.AddModelError("", Translator.UnexpectedError); } return(View()); }