// GET: Patient/Edit/5 public ActionResult Create(FormCollection collection) { string MedicineName = collection.Get("name"); var patient = (Patient)TempData["patient"]; var doctor = (Doctor)TempData["doctor"]; DateTime start = DateTime.Parse(collection.Get("start")); DateTime end = DateTime.Parse(collection.Get("end")); var prescription = (Prescription)TempData["prescription"]; var MedicinesNames = (SelectList)TempData["MedicineNames"]; MedicineModel medicineModel = new MedicineModel(); PrescriptionModel prescriptionModel = new PrescriptionModel(); MedicineTimes medicine = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end); List <MedicineTimes> medicines = new List <MedicineTimes>(); prescriptionModel.AddMedicine(medicines, medicine); PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines); ViewBag.MedicineNames = MedicinesNames; TempData["viewModel"] = viewModel; TempData["prescription"] = prescription; TempData["doctor"] = doctor; TempData["medicines"] = medicines; return(RedirectToAction("Edit")); }
public void AppendPrescriptions(DoctorResponse response, int id) { using (var connection = new SqlConnection(connectionString)) using (var command = new SqlCommand()) { command.Connection = connection; connection.Open(); var transaction = connection.BeginTransaction(); command.Transaction = transaction; command.CommandText = "SELECT IdPrescription, Date, DueDate, FirstName, LastName " + "FROM Prescription " + "JOIN Patient ON Prescription.IdPatient = Patient.IdPatient " + "WHERE IdDoctor = @Id " + "ORDER BY Date DESC;"; command.Parameters.AddWithValue("Id", id); var reader2 = command.ExecuteReader(); response.Prescriptions = new List <PrescriptionModel>(); while (reader2.Read()) { PrescriptionModel prescription = new PrescriptionModel(); prescription.IdPerscription = int.Parse(reader2["IdPrescription"].ToString()); prescription.Date = reader2["Date"].ToString(); prescription.DueDate = reader2["DueDate"].ToString(); prescription.PatientsFirstName = reader2["FirstName"].ToString(); prescription.PatientsLastName = reader2["LastName"].ToString(); response.Prescriptions.Add(prescription); } reader2.Close(); } }
public async Task AddPrescription(PrescriptionModel prescription) { if (prescription.ID == 0) { using (HttpResponseMessage response = await _apiHelper.ApiClient.PostAsJsonAsync("/api/Prescription/Add", prescription)) { if (response.IsSuccessStatusCode) { // Log Successful Call } else { throw new Exception(response.ReasonPhrase); } } } else { using (HttpResponseMessage response = await _apiHelper.ApiClient.PostAsJsonAsync("/api/Prescription/Edit", prescription)) if (response.IsSuccessStatusCode) { // Log successful call } else { throw new Exception(response.ReasonPhrase); } } }
public void Edit(PrescriptionModel prescription) { PrescriptionData data = new PrescriptionData(); string prescriberId = RequestContext.Principal.Identity.GetUserId(); data.EditPrescription(prescription, prescriberId); }
public void AddPrescription(PrescriptionModel prescription, string presciberId) { SqlDataAccess sql = new SqlDataAccess(); try { sql.StartTransaction("PrescriptionDataManagerUpdated"); sql.SaveDataInTransaction("dbo.spPrescription_Add", new { PatientId = prescription.PatientID.ToString(), DrugName = prescription.DrugName, Dosage = prescription.Dosage, PrescriberId = presciberId, RenewalDate = prescription.RenewalDate }); sql.CommitTransaction(); } catch (Exception) { sql.RollbackTransation(); throw; } /* var output = sql.SaveData<PrescriptionModel>("dbo.spPrescription_Add", new { PatientId = prescription.PatientID.ToString(), DrugName = prescription.DrugName, Dosage = prescription.Dosage, * PrescriberId = prescription.PrescriberId, RenewalDate = prescription.RenewalDate}, "PrescriptionDataMangerUpdated");*/ }
public ActionResult Edit(FormCollection collection) { var doctor = (Doctor)TempData["doctor"]; var patient = (Patient)TempData["patient"]; var medicines = (List <MedicineTimes>)TempData["medicines"]; var prescription = (Prescription)TempData["prescription"]; string MedicineName = collection.Get("name"); DateTime start = new DateTime(); DateTime end = new DateTime(); if (!DateTime.TryParse(collection.Get("start"), out start) && !DateTime.TryParse(collection.Get("end"), out end) || MedicineName == "" && Request.Form["Add"] == null) { TempData["prescription"] = prescription; TempData["medicines"] = medicines; return(RedirectToAction("Check", "Interactions")); } var MedicinesNames = (SelectList)TempData["MedicineNames"]; MedicineModel medicineModel = new MedicineModel(); PrescriptionModel prescriptionModel = new PrescriptionModel(); MedicineTimes medicine = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end); //PrescriptionMedicine rm = new PrescriptionMedicine(patient.TZ,MedicineNames, start, end); prescriptionModel.AddMedicine(medicines, medicine); PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines); ViewBag.MedicineNames = MedicinesNames; TempData["viewModel"] = viewModel; return(RedirectToAction("Edit")); }
public ActionResult Prescribe(int patientId) { var Prescription = new PrescriptionModel { PatientId = patientId }; return(View(Prescription)); }
public void SetPrescription(PrescriptionModel prescription) { SelectedItem = prescription; _prescription = prescription; if (_prescription.Id == 0) { IsEidtEnabled = true; } }
public ActionResult Finish() { var medicines = (List <MedicineTimes>)TempData["medicines"]; var prescription = (Prescription)TempData["prescription"]; PrescriptionModel Model = new PrescriptionModel(); Model.AddPrescription(medicines, prescription); Model.AddListMedicines(medicines, prescription); return(View()); }
public void SavePrescription(PrescriptionModel prescriptionModel) { var prescriptionEntity = _patientsContext.Prescription.FirstOrDefault(p => p.ConsultationId == prescriptionModel.ConsultationId); if (prescriptionEntity != null) { prescriptionEntity.DrugId = prescriptionModel.DrugId; prescriptionEntity.Dosage = prescriptionModel.Dosage; } Save(); }
public ActionResult Create() { ViewBag.Date = DateTime.Now.ToShortDateString(); PrescriptionViewModel model = new PrescriptionViewModel(); for (int i = 0; i < 10; i++) { PrescriptionModel p = new PrescriptionModel(); p.SerialNumber = i + 1; model.prescriptions.prescriptionDetailList.Add(p); } return(View(model)); }
public ActionResult Addprescription(PrescriptionModel model, HttpPostedFileBase image1) { if (image1 != null) { model.PrescriptionImage = new byte[image1.ContentLength]; image1.InputStream.Read(model.PrescriptionImage, 0, image1.ContentLength); } _context.PrescriptionModels.Add(model); _context.SaveChanges(); //return View(model); return(View("Success")); }
// GET: Prescription details public ActionResult Prescription() { string id = Request.QueryString["id"]; if (string.IsNullOrEmpty(id)) { return(View("PatientList", "Pharmacy", null)); } List <FormExamineMedicine> medicinelist = _unitOfWork.FormExamineMedicineRepository.Get(x => x.FormExamine.FormMedicalID.Value.ToString() == id && x.RowStatus == 0).ToList(); PrescriptionModel prescriptionModel = new PrescriptionModel(); prescriptionModel.FormMedicalID = long.Parse(id); //get stock var _ids = medicinelist.Select(x => x.ProductID).Distinct(); var _stockCollections = _unitOfWork.ProductInGudangRepository.Get(x => _ids.Contains(x.ProductId)).Select(x => new { x.ProductId, x.stock }); foreach (var item in medicinelist) { FormExamineMedicineModel medicineModel = Mapper.Map <FormExamineMedicine, FormExamineMedicineModel>(item); FormExamineMedicineDetail detail = _unitOfWork.FormExamineMedicineDetailRepository.Get(x => x.FormExamineMedicineID.Value == item.ID && x.RowStatus == 0).FirstOrDefault(); if (detail != null) { medicineModel.Detail = Mapper.Map <FormExamineMedicineDetail, FormExamineMedicineDetailModel>(detail); } if (medicineModel.MedicineJenis != null) { switch (medicineModel.MedicineJenis.ToLower()) { case "racikan": medicineModel.Detail.ProcessType = "Racik"; break; case "non racikan": medicineModel.Detail.ProcessType = "Request"; break; default: medicineModel.Detail.ProcessType = string.Empty; break; } } prescriptionModel.Medicines.Add(medicineModel); } return(View(prescriptionModel)); }
public ActionResult CreatePrescription(Prescription prescription) { if (ModelState.IsValid) { using (PrescriptionModel prm = new PrescriptionModel()) { prm.Prescriptions.Add(prescription); prm.SaveChanges(); return(RedirectToAction("DentistPanel")); //} } } return(View()); }
public void SelectPrescription() { selectedPrescription = new PrescriptionModel { ID = SelectedPrescription.ID, DrugName = SelectedPrescription.DrugName, Dosage = SelectedPrescription.Dosage, RenewalDate = SelectedPrescription.RenewalDate }; PrescriptionId = SelectedPrescription.ID; DrugName = SelectedPrescription.DrugName; Dosage = SelectedPrescription.Dosage; RenewalDate = SelectedPrescription.RenewalDate; }
public ActionResult Prescription(PrescriptionModel model) { var request = new PharmacyRequest { Data = model, Account = Account }; PharmacyResponse _response = new PharmacyResponse(); // do the validation _response = new PharmacyValidator(_unitOfWork, _context).Validate(request); ViewBag.Response = $" {_response.Status.ToString().Trim()};{_response.Message}".TrimStart(); return(View(model)); }
/* public bool CanAddPrescription * { * get{ * bool output = false; * * if (DrugName.Length > 0 && Dosage > 0 & RenewalDate != null) * { * output = true; * } * return output; * } * * }*/ public async Task AddPrescription() { ErrorMessage = ""; var prescription = new PrescriptionModel { PatientID = Int32.Parse(PatientId), DrugName = DrugName, Dosage = Dosage, PrescriberId = PrescriberId, RenewalDate = RenewalDate }; await _prescriptionEndpoint.AddPrescription(prescription); }
public async Task <IActionResult> AddPrescription([FromBody] PrescriptionModel prescriptionModel) { if (ModelState.IsValid) { if (prescriptionModel == null) { return(BadRequest($"{nameof(prescriptionModel)} can not be null.")); } var prescription = _mapper.Map <Prescription>(prescriptionModel); prescription.DoctorId = GetCurrentUserId(); _unitOfWork.Prescriptions.Add(prescription); int result = await _unitOfWork.SaveChangesAsync(); if (result < 1) { return(NoContent()); } return(Ok(prescription)); } return(BadRequest(ModelState)); }
public void EditPrescription(PrescriptionModel prescription, string presciberId) { SqlDataAccess sql = new SqlDataAccess(); try { sql.StartTransaction("PrescriptionDataManagerUpdated"); sql.SaveDataInTransaction("dbo.spPrescription_Edit", new { PrescriptionId = prescription.ID, Dosage = prescription.Dosage, PrescriberId = presciberId, RenewalDate = prescription.RenewalDate }); sql.CommitTransaction(); } catch (Exception) { sql.RollbackTransation(); throw; } }
public async Task AddPrescription() { //ErrorMessage = ""; if (PrescriptionId != 0 && DrugName != SelectedPrescription.DrugName) { dynamic settings = new ExpandoObject(); settings.WindowStartupLocation = WindowStartupLocation.CenterOwner; settings.ResizeMode = ResizeMode.NoResize; settings.Title = "System Error"; _status.UpdateMessage("Unauthorized", "Changing medication name is not allowed. Please create a new prescription"); await _window.ShowDialog(_status, null, settings); DrugName = selectedPrescription.DrugName; } else { var prescription = new PrescriptionModel { ID = PrescriptionId, PatientID = PatientDetailBox.First().ID, DrugName = DrugName, Dosage = Dosage, PrescriberId = PrescriberId, RenewalDate = RenewalDate }; await _prescriptionEndpoint.AddPrescription(prescription); ResetPrescription(); await ViewDetails(prescription.PatientID); } }
public async Task <IActionResult> Post(PrescriptionModel model) { var prescription = new mp_prescription(); prescription.clinician_id = model.clinician_id; prescription.profile_id = model.profile_id; prescription.pharmacy_id = model.pharmacy_id; prescription.comment = model.comment; prescription.created_by = ""; var prescription_id = _prescriptionService.AddPrescription(prescription); var drug_text = ""; var prescription_drugs = new List <mp_prescription_drug>(); for (var i = 0; i < model.drugs.Count; i++) { prescription_drugs.Add(new mp_prescription_drug { drug = model.drugs[i].drug, dosage = model.drugs[i].dosage, prescription_id = prescription_id }); drug_text += model.drugs[i].drug + " " + model.drugs[i].dosage + ","; } _prescriptionService.AddPrescriptionDrugs(prescription_drugs); //get the profile information var profile = _profileService.Get(prescription.profile_id); var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 7, read = 0, user_id = profile.user_id, notification = "Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details.", title = "New Prescription" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime", $"Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details."); if (prescription.pharmacy_id.HasValue) { //get the email of the pharmacy var pharmacy = _pharmacyService.Get().FirstOrDefault(e => e.id == prescription.pharmacy_id.Value); if (pharmacy != null && !string.IsNullOrEmpty(pharmacy.email)) { await _emailSender.SendEmailAsync(pharmacy.email, "New Prescription - MySpace MyTime", $"The following prescriptions have been sent for " + profile.last_name + " " + profile.first_name + " - " + profile.unique_id.ToString("D10") + " .<br/>" + drug_text); } } return(Ok(200)); }
public static Prescription ToDataModel(this PrescriptionModel model) { return(new Prescription() { Id = model.Id, CustomerId = model.CustomerId, VisionFarLeft = model.VisionFarLeft, VisionFarRight = model.VisionFarRight, VisionNearLeft = model.VisionNearLeft, VisionNearRight = model.VisionNearRight, BMirrorFarLeft = model.BMirrorFarLeft, BMirrorFarRight = model.BMirrorFarRight, BMirrorNearLeft = model.BMirrorNearLeft, BMirrorNearRight = model.BMirrorNearRight, PMirrorFarLeft = model.PMirrorFarLeft, PMirrorFarRight = model.PMirrorFarRight, PMirrorNearLeft = model.PMirrorNearLeft, PMirrorNearRight = model.PMirrorNearRight, AMirrorFarLeft = model.AMirrorFarLeft, AMirrorFarRight = model.AMirrorFarRight, AMirrorNearLeft = model.AMirrorNearLeft, AMirrorNearRight = model.AMirrorNearRight, OKFarLeft = model.OKFarLeft, OKFarRight = model.OKFarRight, OKNearLeft = model.OKNearLeft, OKNearRight = model.OKNearRight, DegreeFarLeft = model.DegreeFarLeft, DegreeFarRight = model.DegreeFarRight, DegreeNearLeft = model.DegreeNearLeft, DegreeNearRight = model.DegreeNearRight, DFarLeft = model.DFarLeft, DFarRight = model.DFarRight, DNearLeft = model.DNearLeft, DNearRight = model.DNearRight, MainEye = model.MainEye, MirrorModelFar = model.MirrorModelFar, MirrorModelNear = model.MirrorModelNear, MirrorModelFarAmount = model.MirrorModelFarAmount, MirrorModelNearAmount = model.MirrorModelNearAmount, BracketModelFar = model.BracketModelFar, BracketModelNear = model.BracketModelNear, BracketModelFarAmount = model.BracketModelFarAmount, BracketModelNearAmount = model.BracketModelNearAmount, AdeModel = model.AdeModel, CareProduct = model.CareProduct, AdeAmount = model.AdeAmount, TotalAmount = model.TotalAmount, AmountPaid = model.AmountPaid, AmountNotPaid = model.AmountNotPaid, OptometristA = model.OptometristA, OptometristB = model.OptometristB, CreateDate = model.CreateDate, Checker = model.Checker, Comments = model.Comments, // Requirment = model.Requirment, LightCheck = model.LightCheck, R1mmLeft = model.R1mmLeft, R1DLeft = model.R1DLeft, R1AXLeft = model.R1AXLeft, R2mmLeft = model.R2mmLeft, R2DLeft = model.R2DLeft, R2AXLeft = model.R2AXLeft, AVGmmLeft = model.AVGmmLeft, AVGDLeft = model.AVGDLeft, AVGAXLeft = model.AVGAXLeft, CYLmmLeft = model.CYLmmLeft, CYLDLeft = model.CYLDLeft, CYLAXLeft = model.CYLAXLeft, R1mmRight = model.R1mmRight, R1DRight = model.R1DRight, R1AXRight = model.R1AXRight, R2mmRight = model.R2mmRight, R2DRight = model.R2DRight, R2AXRight = model.R2AXRight, AVGmmRight = model.AVGmmRight, AVGDRight = model.AVGDRight, AVGAXRight = model.AVGAXRight, CYLmmRight = model.CYLmmRight, CYLDRight = model.CYLDRight, CYLAXRight = model.CYLAXRight, // // HorLocationFar = model.HorLocationFar, HorLocationNear = model.HorLocationNear, VerLocationFar = model.VerLocationFar, VerLocationNear = model.VerLocationNear, ACCal = model.ACCal, ACTD = model.ACTD, PRA = model.PRA, NRA = model.NRA, BCC = model.BCC, RightAdjustWidth = model.RightAdjustWidth, RightAdjustSensitivity = model.RightAdjustSensitivity, LeftAdjustWidth = model.LeftAdjustWidth, LeftAdjustSensitivity = model.LeftAdjustSensitivity, BothAdjustWidth = model.BothAdjustWidth, BothAdjustSensitivity = model.BothAdjustSensitivity, CheckWayAdjustWidth = model.CheckWayAdjustWidth, CheckWayAdjustSensitivity = model.CheckWayAdjustSensitivity, InosculateFunction = model.InosculateFunction, StereoFunction = model.StereoFunction, NPC = model.NPC, ChromaticVision = model.ChromaticVision, }); }
public ActionResult Addprescription() { PrescriptionModel b1 = new PrescriptionModel(); return(View(b1)); }
/// <summary> /// 验证参数 /// </summary> /// <param name="context"></param> /// <returns></returns> ResponseDto Validate(PrescriptionContext context) { var request = context.Request; var prescriptionBiz = new PrescriptionBiz(); if (request.PatientAge <= 0) { return(Failed(ErrorCode.Empty, "年龄必须大于0")); } if (request.PatientAge > 120) { return(Failed(ErrorCode.Empty, "年龄超过最大120岁限制")); } if (!string.IsNullOrEmpty(request.PatientSymptoms) && request.PatientSymptoms.Length > 1000) { return(Failed(ErrorCode.Empty, "患者症状超过最大长度限制")); } context.InformationModel.AppointmentGuid = request.AppointmentGuid; context.InformationModel.PatientName = request.PatientName; context.InformationModel.PatientGender = request.PatientGender.ToString(); context.InformationModel.PatientAge = request.PatientAge; context.InformationModel.PatientPhone = request.PatientPhone; context.InformationModel.HasAllergy = request.HasAllergy; context.InformationModel.HasChronicDisease = request.HasChronicDisease; context.InformationModel.PatientProvince = request.PatientProvince; context.InformationModel.PatientCity = request.PatientCity; context.InformationModel.PatientDistrict = request.PatientDistrict; context.InformationModel.PatientAddress = request.PatientAddress; context.InformationModel.ReceptionType = request.ReceptionType.ToString(); context.InformationModel.ClinicalDiagnosis = request.ClinicalDiagnosis; context.InformationModel.PatientSymptoms = request.PatientSymptoms; context.InformationModel.DoctorGuid = context.AppointmentModel.DoctorGuid; context.InformationModel.HospitalGuid = context.AppointmentModel.HospitalGuid; context.InformationModel.OfficeGuid = context.AppointmentModel.OfficeGuid; var prescriptions = request.BasePrescriptions; if (string.IsNullOrEmpty(context.InformationModel.InformationGuid)) { if (prescriptions.Count <= 0) { return(Failed(ErrorCode.Empty, "处方数据为空,请检查")); } context.InformationModel.InformationGuid = Guid.NewGuid().ToString("N"); context.InformationModel.PaidStatus = PrescriptionInformationPaidStatus .NotPaid.ToString(); context.InformationModel.AppointmentTime = DateTime.Now; context.InformationModel.CreatedBy = UserID; context.InformationModel.LastUpdatedBy = UserID; } else { context.InformationModel.LastUpdatedDate = DateTime.Now; if (prescriptions.Count <= 0) { return(Success()); } } if (prescriptions.Any(d => d.Receptions.Count <= 0)) { return(Failed(ErrorCode.Empty, "存在药品数据为空的处方,请检查")); } var duplicatePreNameExists = prescriptions.GroupBy(d => d.PrescriptionName?.Trim()) .Any(g => g.Count() > 1); if (duplicatePreNameExists) { return(Failed(ErrorCode.Empty, "处方名称有重复,请检查")); } #region 随机生成七位纯数字处方编号 var uniquePrescriptions = (ConcurrentBag <string>)null; lock (locker) { uniquePrescriptions = prescriptionBiz.GetUniquePrescriptionNos(prescriptions.Count); } #endregion foreach (var prescription in prescriptions) { var prescriptionModel = new PrescriptionModel(); lock (locker) { var precriptionTotalFee = prescription.Receptions .Sum(d => d.ItemPrice * d.ItemQuantity); context.InformationModel.TotalCost += precriptionTotalFee; prescriptionModel.TotalCost = precriptionTotalFee; } var name = prescription.PrescriptionName; if (string.IsNullOrEmpty(name?.Trim())) { return(Failed(ErrorCode.Empty, "存在名称为空的处方,请检查")); } if (name.Length > 50) { return(Failed(ErrorCode.Empty, $"处方【{name}】名称超过最大长度限制,请检查")); } if (context.dbPrescriptionModels.Count > 0) { if (context.dbPrescriptionModels.Any(d => d.PrescriptionName.Equals(name))) { return(Failed(ErrorCode.Empty, "已提交,请勿重复提交")); } } var pewscriptionGuid = Guid.NewGuid().ToString("N"); if (!uniquePrescriptions.TryTake(out var no)) { return(Failed(ErrorCode.Empty, "服务器操作繁忙,请稍后重试")); } prescriptionModel.PrescriptionGuid = pewscriptionGuid; prescriptionModel.InformationGuid = context.InformationModel.InformationGuid; prescriptionModel.PrescriptionName = name; prescriptionModel.PrescriptionNo = no; prescriptionModel.Status = PrescriptionStatusEnum.Obligation.ToString(); prescriptionModel.CreatedBy = UserID; prescriptionModel.LastUpdatedBy = UserID; context.PrescriptionModels.Add(prescriptionModel); foreach (var reception in prescription.Receptions) { if (string.IsNullOrEmpty(reception.ItemName?.Trim())) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在名称为空的药品,请检查")); } if (reception.ItemName.Length > 50) { return(Failed(ErrorCode.Empty, $"药品【{reception.ItemName}】名称超过最大长度限制,请检查")); } if (!string.IsNullOrEmpty(reception.ItemSpecification?.Trim())) { if (reception.ItemSpecification.Length > 50) { return(Failed(ErrorCode.Empty, $"药品【{reception.ItemName}】名称超过最大长度限制,请检查")); } } if (reception.ItemPrice < 0) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在单价小于0的药品,请检查")); } if (reception.ItemQuantity < 1) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在数量小于1的药品,请检查")); } if (reception.ItemType == ReceptionRecipeTypeEnum.Drug) { if (!reception.DrugFrequencyQuantity.HasValue) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在用药频度数量需提供,请检查")); } if (reception.DrugFrequencyQuantity.Value <= 0) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在用药频度数量小于0的药品,请检查")); } if (!reception.DrugFrequencyQuantity.HasValue) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在用药频度数量需提供,请检查")); } if (reception.DrugFrequencyTimes.Value <= 0) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在用药频度小于0的药品,请检查")); } if (string.IsNullOrEmpty(reception.DrugFrequencyUnit?.Trim())) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在用药频度单位为空的药品,请检查")); } if (reception.DrugFrequencyUnit.Length > 50) { return(Failed(ErrorCode.Empty, $"处方【{name}】下存在用药频度单位超过最大长度限制,请检查")); } } context.RecipeModels.Add(new PrescriptionRecipeModel() { RecipeGuid = Guid.NewGuid().ToString("N"), PrescriptionGuid = pewscriptionGuid, ItemType = reception.ItemType.ToString(), ItemName = reception.ItemName, ItemSpecification = reception.ItemSpecification, ItemPrice = reception.ItemPrice, ItemQuantity = reception.ItemQuantity, DrugDosage = reception.DrugDosage, DrugFrequencyQuantity = reception.DrugFrequencyQuantity, DrugFrequencyTimes = reception.DrugFrequencyTimes, DrugFrequencyUnit = reception.DrugFrequencyUnit, DrugUsage = reception.DrugUsage, LastUpdatedBy = UserID, CreatedBy = UserID }); } } return(Success()); }
public ActionResult Prescribtion(PrescriptionModel model) { try { var prescription = new PrescriptionModel { PatientId = model.PatientId, Cause = model.Cause, Comment = model.Comment, ReferDiagonstics = model.ReferDiagonstics, ReferDoctor = model.ReferDoctor, PrescribtionDate = model.PrescribtionDate, NextVisitDate = model.NextVisitDate }; _prescriptionService.Insert(prescription); if (model.MedicalTests.Any()) { foreach (var test in model.MedicalTests) { _medicalTestService.Insert(new MedicalTestModel { TestName = test.TestName, PrescriptionId = prescription.Id, CreatedDate = DateTime.UtcNow, UpdatedDate = DateTime.UtcNow }); } } if (model.Medicines.Any()) { foreach (var medicine in model.Medicines) { _medicineForPrescriptionService.Insert(new MedicineForPrescription { DailyTimes = medicine.DailyTimes, Name = medicine.Name, Quantity = medicine.Quantity, Days = medicine.Days, //PrescriptionModel = prescription, CreatedDate = DateTime.UtcNow, UpdatedDate = DateTime.UtcNow }); } } return(Json(new { error = false, message = "Data saved successfully" })); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }