public List <MedicineViewModel> Read(MedicineBindingModel model) { if (model == null) { return(_medicineStorage.GetFullList()); } if (model.Id.HasValue) { return(new List <MedicineViewModel> { _medicineStorage.GetElement(model) }); } return(_medicineStorage.GetFilteredList(model)); }
public List <ReportDiseasesViewModel> GetDiseases(ReportBindingModel model) { var drugCourseList = _drugCourseStorage.GetFilteredList(new DrugCourseBindingModel { DateFrom = model.DateFrom, DateTo = model.DateTo, Id = model.DoctorId }); var listAll = new List <ReportDiseasesViewModel>(); foreach (var drugCourse in drugCourseList) { foreach (var dc in drugCourse.DrugCourseDiseases) { var doctor = _doctorStorage.GetElement(new DoctorBindingModel { Id = drugCourse.DoctorId }); listAll.Add(new ReportDiseasesViewModel { Type = "Выписка о приёме препарата " + _medicineStorage.GetElement(new MedicineBindingModel { Id = drugCourse.MedicineId }).Name, DiseaseName = dc.Value.Item1, DateFormed = drugCourse.FormedDate, Length = dc.Value.Item2, DoctorName = doctor.F_Name + " " + doctor.L_Name }); } } var listSymptomatics = _symptomaticStorage.GetFilteredList(new SymptomaticsBindingModel { DateFrom = model.DateFrom, DateTo = model.DateTo }); foreach (var sympt in listSymptomatics) { foreach (var dc in sympt.SymptomaticDiseases) { var doctor = _doctorStorage.GetElement(new DoctorBindingModel { Id = sympt.DoctorId }); listAll.Add(new ReportDiseasesViewModel { Type = "Выписка о симптоме " + sympt.SymptomName, DiseaseName = dc.Value.Item1, DateFormed = sympt.IssueDate, Length = dc.Value.Item2, DoctorName = doctor.F_Name + " " + doctor.L_Name }); } } return(listAll); }
public void LinkingMedicine(MedicineLinkingBindingModel model) { var medicine = _medicineStorage.GetElement(new MedicineBindingModel { Id = model.MedicineId }); var receipt = _receiptStorage.GetElement(new ReceiptBindingModel { Id = model.ReceiptId }); if (medicine == null) { throw new Exception("Не найдено лекарство"); } if (receipt == null) { throw new Exception("Не найдено выписка"); } _receiptStorage.Update(new ReceiptBindingModel { Id = receipt.Id, Dose = receipt.Dose, PerDose = receipt.PerDose, MedicineId = model.MedicineId, SymptomaticsId = receipt.SymptomaticsId }); }
public void Linking(DrugCourseLinkingBindingModel model) { var drugCourse = _drugCourseStorage.GetElement(new DrugCourseBindingModel { Id = model.DrugCourseId }); var medicine = _medicineStorage.GetElement(new MedicineBindingModel { Id = model.MedicineId }); if (drugCourse == null) { throw new Exception("Не найдена выдача"); } if (medicine == null) { throw new Exception("Не найдено выписка"); } if (drugCourse.MedicineId.HasValue) { throw new Exception("Данное лекарство уже привязано к симптоматике"); } _drugCourseStorage.Update(new DrugCourseBindingModel { Id = drugCourse.Id, Length = drugCourse.Length, FormedDate = drugCourse.FormedDate, DrugCourseDiseases = drugCourse.DrugCourseDiseases, DoctorId = drugCourse.DoctorId, MedicineId = model.MedicineId }); _medicineStorage.Update(new MedicineBindingModel { Id = medicine.Id, Class = medicine.Class, Name = medicine.Name, DrugCourseId = model.DrugCourseId }); }