public PrescriptionTabbedPage(PrescriptionViewModel model = null) { var viewModel = model ?? new PrescriptionViewModel(new Prescription { ID = "0129845562", Items = "Yaz 0,02; Potahované tablety 20mg", DateTime = DateTime.Now, State = "Vydaný", Doctor = "Zdeněk Hřib" }); Title = viewModel.ID; Children.Add(new PrescriptionDetailPage() { BindingContext = viewModel }); Children.Add(new CuresPage() { BindingContext = viewModel }); Children.Add(new NotesPage() { BindingContext = viewModel }); Children.Add(new PatientPage() { BindingContext = viewModel }); Children.Add(new DoctorPage() { BindingContext = viewModel }); }
public IActionResult Add(PrescriptionViewModel prescriptionVm) { TestDatabasePleaseDelete.Doctors.ElementAt(IndexOfDoctor) .Prescriptions.Add(prescriptionVm); return(RedirectToAction("Index")); }
public IActionResult Add(PrescriptionViewModel prescriptionVm) { var dto = _vMMapper.Map(prescriptionVm); _doctorManager.AddNewPrescription(dto, DoctorId); return(RedirectToAction("Index", new { doctorId = DoctorId })); }
public ActionResult AddDrugItem(int drugId, int Quantity, int appointId) { DrugItem drugItemInDb = db.DrugItems.Where(r => r.ReferenceNumber == appointId) .Where(d => d.Drug.Id == drugId).FirstOrDefault(); if (drugItemInDb != null) { drugItemInDb.OrderQuantity = drugItemInDb.OrderQuantity + Quantity; drugItemInDb.Total = drugItemInDb.OrderQuantity * drugItemInDb.Price; } else { DrugItem drugItem = new DrugItem(); drugItem.Drug = db.Drugs.Find(drugId); drugItem.Price = drugItem.Drug.RetailPrice; drugItem.OrderQuantity = Quantity; drugItem.Total = drugItem.Price * Quantity; drugItem.ReferenceNumber = appointId; db.DrugItems.Add(drugItem); } db.SaveChanges(); Appointment appointment = db.Appointments.Find(appointId); PrescriptionViewModel PresVM = new PrescriptionViewModel(); PresVM.AppointmentReference = appointId; PresVM.Drugs = db.Drugs.Take(5).ToList(); PresVM.DoctorId = appointment.DoctorId; PresVM.PatientId = appointment.PatientId; PresVM.DrugItems = db.DrugItems.Where(x => x.ReferenceNumber == appointId).ToList(); return(View("CreatePrescription", PresVM)); }
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")); }
// 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 async Task <IActionResult> PrescriptionInfo(Guid id) { var prescription = await _polyclinicContext.Prescriptions.FindAsync(id); if (prescription is null) { ViewBag.Message = "Error! No Prescription found."; return(View()); } var prescriptionViewModel = new PrescriptionViewModel { Id = prescription.Id, Cure = prescription.Cure, DateOfPrescription = prescription.DateOfPrescription, Comment = prescription.Comment, ValidTill = prescription.ValidTill, PatientId = prescription.PatientId, DoctorId = prescription.DoctorId, VisitId = prescription.VisitId, }; ViewBag.Patient = await _polyclinicContext.Patients.FindAsync(prescriptionViewModel.PatientId); ViewBag.Doctor = await _polyclinicContext.Doctors.FindAsync(prescriptionViewModel.DoctorId); return(View(prescriptionViewModel)); }
// GET: Prescription/Details/5 public ActionResult Details(int id) { IBL bl = new BLImplement(); var pvm = new PrescriptionViewModel(bl.getAllPrescriptions().FirstOrDefault(x => x.Id == id)); ViewBag.Patient = pvm.Patient; return(View(pvm)); }
public IActionResult Add(PrescriptionViewModel prescriptionVM) { var dto = _ViewModelMapper.Map(prescriptionVM); _DoctorManager.AddNewPrescription(dto, int.Parse(TempData["DoctorId"].ToString())); return(RedirectToAction("Index", new { doctorId = int.Parse(TempData["DoctorId"].ToString()) })); }
public ActionResult CreatePrescription() { var prescription = new PrescriptionViewModel { PresCategorySelectList = _prescriptionServices.GetCategoryListItems() }; return(PartialView("_CreatePrescription", prescription)); }
public IActionResult Add(PrescriptionViewModel prescriptionVM) { int doctorId = int.Parse(TempData["doctorId"].ToString()); var prescriptionDto = _mapper.Map(prescriptionVM); _doctorService.AddNewPrescription(prescriptionDto, doctorId); return(RedirectToAction("Index", new { doctorId = doctorId })); }
public ActionResult CreatePrescription(int appointId) { Appointment appointment = db.Appointments.Find(appointId); PrescriptionViewModel PresVM = new PrescriptionViewModel(); PresVM.AppointmentReference = appointId; PresVM.Drugs = db.Drugs.Take(5).ToList(); PresVM.DoctorId = appointment.DoctorId; PresVM.PatientId = appointment.PatientId; return(View(PresVM)); }
public ActionResult AddPrescription(int id) { var prescription = _db.Prescriptions.Where(a => a.PrescriptionId == id).FirstOrDefault(); var model = new PrescriptionViewModel { Id = id, patientName = prescription.appointment.patient.User.Name, patientPhoneNumber = prescription.appointment.patient.User.PhoneNumber, appointmentTime = prescription.appointment.AppointmentTime.ToString("dd-MMMM-yy hh:mm tt") }; return(View(model)); }
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 ClearPrescription(int prescriptionId, double subTotal) { Prescription prescription = db.Prescriptions.Include(pa => pa.Patient) .Where(p => p.Id == prescriptionId).FirstOrDefault(); List <DrugItem> drugItems = db.DrugItems.Include(d => d.Drug) .Where(p => p.ReferenceNumber == prescription.AppointmentReference).ToList(); string outOfStockMessage = null; foreach (DrugItem item in drugItems) { Drug drugInStock = db.Drugs.Find(item.Drug.Id); if (drugInStock.Quantity < item.OrderQuantity) { outOfStockMessage = "There are only " + drugInStock.Quantity + " items of " + item.Drug.BrandName + " remaining in stock"; break; } else { drugInStock.Quantity = drugInStock.Quantity - item.OrderQuantity; } } prescription.IsPaid = true; if (outOfStockMessage == null) { prescription.IsCleared = true; db.SaveChanges(); } PrescriptionViewModel PresVM = new PrescriptionViewModel(); PresVM.DrugItems = db.DrugItems.Include(d => d.Drug) .Where(p => p.ReferenceNumber == prescription.AppointmentReference).ToList(); PresVM.AppointmentReference = prescription.AppointmentReference; PresVM.PatientName = prescription.Patient.FirstName + " " + prescription.Patient.Surname; PresVM.PrescriptionId = prescriptionId; PresVM.IsPaid = true; PresVM.IsCleared = prescription.IsCleared; PresVM.SubTotal = subTotal; ViewBag.Role = "pharmacist"; ViewBag.StockMessage = outOfStockMessage; return(View("ViewPrescription", PresVM)); }
public ActionResult Create() { var patient = (Patient)TempData["patient"]; var doctor = (Doctor)TempData["doctor"]; Prescription r = new Prescription(patient, doctor); MedicineModel Model = new MedicineModel(); SelectList MedicineNames = new SelectList(Model.GetNames()); ViewBag.MedicineNames = MedicineNames; PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor); TempData["MedicineNames"] = MedicineNames; TempData["prescription"] = r; TempData["patient"] = patient; TempData["doctor"] = doctor; return(View(viewModel)); }
public ActionResult CreatePrescription(PrescriptionViewModel prescriptionviewmodel) { if (!ModelState.IsValid) { return(PartialView("_CreatePrescription", prescriptionviewmodel)); } var prescription = new Prescription() { CatId = prescriptionviewmodel.PrescriptionCatid, PrescriptionDetails = prescriptionviewmodel.PrescriptionDetails, Unit = prescriptionviewmodel.PrescUnit }; _prescriptionServices.InsertPrescription(prescription); _unitOfWork.Commit(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
public bool addNewPrescription(PrescriptionViewModel prescription) { int count = 0; using (Entities.Entities ctx = new Entities.Entities()) { Prescription prescriptionEntity = ctx.Prescriptions.Create(); prescriptionEntity.PatientID = prescription.PatientID; prescriptionEntity.MedicineID = prescription.DoctorID; prescriptionEntity.DoctorID = prescription.DoctorID; prescriptionEntity.AppointmentID = prescription.AppointmentID; prescriptionEntity.Notice = prescription.Notice; prescriptionEntity.Dose = prescription.Dose; ctx.Prescriptions.Add(prescriptionEntity); count = ctx.SaveChanges(); } return(count > 0 ? true : false); }
public bool updatePrescription(PrescriptionViewModel prescription) { int count = 0; using (Entities.Entities ctx = new Entities.Entities()) { Prescription prescriptionEntity = ctx.Prescriptions.Find(prescription.PrescriptionID); if (prescriptionEntity == null) { return(false); } prescriptionEntity.Notice = prescription.Notice; prescriptionEntity.Dose = prescription.Dose; ctx.Entry(prescriptionEntity).State = System.Data.Entity.EntityState.Modified; count = ctx.SaveChanges(); } return(count > 0 ? true : false); }
public ActionResult IssueDrugs() { List <Prescription> PrescriptionsInDb = db.Prescriptions.Include(p => p.Patient).Where(p => p.IsPaid == true) .Where(x => x.IsCleared == false).ToList(); List <PrescriptionViewModel> PressVMList = new List <PrescriptionViewModel>(); foreach (Prescription item in PrescriptionsInDb) { PrescriptionViewModel pressVM = new PrescriptionViewModel(); pressVM.AppointmentReference = item.AppointmentReference; pressVM.PrescriptionId = item.Id; pressVM.AppointmentReference = item.AppointmentReference; pressVM.PatientName = item.Patient.FirstName + " " + item.Patient.Surname; PressVMList.Add(pressVM); ViewBag.Role = "pharmacist"; } return(View("PrescriptionList", PressVMList)); }
public async Task <IActionResult> AddPrescription(PrescriptionViewModel model, string chooseAction) { if (!ModelState.IsValid) { var visit = await _polyclinicContext.Visits.FindAsync(model.VisitId); ViewBag.Visit = visit; return(View()); } var prescription = new Prescription { Id = Guid.NewGuid(), Cure = model.Cure, DateOfPrescription = model.DateOfPrescription, Comment = model.Comment, ValidTill = model.ValidTill, DoctorId = model.DoctorId, VisitId = model.VisitId, PatientId = model.PatientId, }; var prescriptionTracker = await _polyclinicContext.Prescriptions.AddAsync(prescription); if (prescriptionTracker.State == EntityState.Added) { await _polyclinicContext.SaveChangesAsync(); if (chooseAction == "Save") { return(RedirectToAction("ShowMyVisits", "Doctor")); } var visit = await _polyclinicContext.Visits.FindAsync(model.VisitId); return(RedirectToAction("AddPrescription", "Visit", visit)); } return(Content("Internal error! Prescription Entity is not added.")); }
public ActionResult SelectPrescription(int prescriptionId, string role) { Prescription prescription = db.Prescriptions.Include(pa => pa.Patient).Where(p => p.Id == prescriptionId).FirstOrDefault(); PrescriptionViewModel PresVM = new PrescriptionViewModel(); PresVM.DrugItems = db.DrugItems.Include(d => d.Drug) .Where(p => p.ReferenceNumber == prescription.AppointmentReference).ToList(); PresVM.AppointmentReference = prescription.AppointmentReference; PresVM.PatientName = prescription.Patient.FirstName + " " + prescription.Patient.Surname; PresVM.PrescriptionId = prescriptionId; PresVM.IsPaid = false; PresVM.IsCleared = false; double subTotal = 0; foreach (DrugItem item in PresVM.DrugItems) { subTotal += item.Total; } PresVM.SubTotal = subTotal; ViewBag.Role = role; return(View("ViewPrescription", PresVM)); }
public ActionResult FinishPrescription(PrescriptionViewModel pvm) { List <DrugItem> DrugItems = db.DrugItems.Where(d => d.ReferenceNumber == pvm.AppointmentReference).ToList(); Doctor doctor = db.Doctors.Find(pvm.DoctorId); Patient patient = db.Patients.Find(pvm.PatientId); Prescription prescription = new Prescription(); prescription.IssuedDate = DateTime.Today; prescription.Issuer = doctor; prescription.Patient = patient; prescription.Disease = pvm.Disease; prescription.Description = pvm.Description; prescription.DrugItems = DrugItems; prescription.AppointmentReference = pvm.AppointmentReference; prescription.IsPaid = false; prescription.IsCleared = false; db.Prescriptions.Add(prescription); db.SaveChanges(); return(RedirectToAction("SelectAppointment", "Appointment", new { appointmentId = pvm.AppointmentReference, role = "doctor", IsPrescriptionPresent = true })); }
private void WritePrescriptionHeader(PrescriptionViewModel prescription) { graphics.DrawString("Lekarz wystawiajacy: " + prescription.DoctorName, FONT, XBrushes.Black, new XPoint(column, line), XStringFormats.BaseLineLeft); IncreaseLine(1); graphics.DrawString("Data wystawienia: " + prescription.CreationTime.ToString("yyyy-MM-dd"), FONT, XBrushes.Black, new XPoint(column, line), XStringFormats.BaseLineLeft); IncreaseLine(1); graphics.DrawString("Calkowity koszt:" + prescription.TotalCost + " zl", FONT, XBrushes.Black, new XPoint(column, line), XStringFormats.BaseLineLeft); IncreaseLine(1); }
public ActionResult ConfirmPrescriptionCharge(int prescriptionId, double subTotal, PaymentType PaymentType) { if (PaymentType == 0) { PaymentType = PaymentType.Cash; } Prescription prescription = db.Prescriptions.Include(pa => pa.Patient).Where(p => p.Id == prescriptionId).FirstOrDefault(); prescription.IsPaid = true; db.SaveChanges(); Payment payment = new Payment(); payment.Prescription = prescription; payment.PaymentDate = DateTime.Today; payment.PaymentType = PaymentType; payment.Amount = subTotal; string userId = User.Identity.GetUserId(); payment.Cashier = db.StaffMembers.Find(userId); db.Payments.Add(payment); db.SaveChanges(); PrescriptionViewModel PresVM = new PrescriptionViewModel(); PresVM.DrugItems = db.DrugItems.Include(d => d.Drug) .Where(p => p.ReferenceNumber == prescription.AppointmentReference).ToList(); PresVM.AppointmentReference = prescription.AppointmentReference; PresVM.PatientName = prescription.Patient.FirstName + " " + prescription.Patient.Surname; PresVM.PrescriptionId = prescriptionId; PresVM.IsPaid = true; PresVM.SubTotal = subTotal; ViewBag.Role = "cashier"; return(View("ViewPrescription", PresVM)); }
public ActionResult Create(PrescriptionViewModel model) { ViewBag.Date = DateTime.Now.ToShortDateString(); return(View("Prescription", model)); }
public PrescriptionDTO Map(PrescriptionViewModel Prescription) => _mapper.Map <PrescriptionDTO>(Prescription);
public ActionResult AddPrescription(PrescriptionViewModel model) { if (ModelState.IsValid && model.days != null) { var prescription = _db.Prescriptions.Where(p => p.PrescriptionId == model.Id).FirstOrDefault(); PdfDocument doc = new PdfDocument(); //Add a page. PdfPage page = doc.Pages.Add(); //Create PDF graphics for the page PdfGraphics graphics = page.Graphics; //Set the standard font PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10); graphics.DrawString("Patient Name : " + prescription.appointment.patient.User.Name, font, PdfBrushes.Black, new PointF(0, 0)); graphics.DrawString("Appoiment Time " + prescription.appointment.AppointmentTime.ToString("dd-MMMM-yyyy hh:mm tt"), font, PdfBrushes.Black, new PointF(0, 12)); graphics.DrawString("Doctor Name : " + prescription.appointment.doctor.User.Name, font, PdfBrushes.Black, new PointF(0, 24)); graphics.DrawString("Doctor Contact No : " + prescription.appointment.doctor.User.PhoneNumber, font, PdfBrushes.Black, new PointF(0, 36)); //Create a PdfGrid. PdfGrid pdfGrid = new PdfGrid(); //Create a DataTable. DataTable dataTable = new DataTable(); //Add columns to the DataTable dataTable.Columns.Add("Medicine Name"); dataTable.Columns.Add("Quantity"); dataTable.Columns.Add("Days"); dataTable.Columns.Add("Times"); for (int i = 0; i < model.times.Count; i++) { dataTable.Rows.Add(new object[] { model.medicines[i], model.quantity[i], model.days[i], model.times[i] }); } //Assign data source. pdfGrid.DataSource = dataTable; PdfGridBuiltinStyleSettings tableStyleOption = new PdfGridBuiltinStyleSettings(); tableStyleOption.ApplyStyleForBandedRows = true; tableStyleOption.ApplyStyleForHeaderRow = true; pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable4Accent4, tableStyleOption); //Draw grid to the page of PDF document. pdfGrid.Draw(page, new PointF(0, 50)); string filePathString = "~/Images/" + model.Id + ".pdf"; // Open the document in browser after saving it doc.Save(Server.MapPath(filePathString)); //close the document doc.Close(true); _db.Entry(prescription).State = EntityState.Modified; prescription.FileURL = filePathString; _db.SaveChanges(); TempData["Success"] = "Prescription added for appointment no. " + model.Id; return(RedirectToAction("Index", "DoctorAccount")); } return(View(model)); }
private ChromelyResponse PrintPrescription(ChromelyRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (request.PostData == null) { throw new Exception("Post data is null or invalid."); } string jsonString = request.PostData.ToString(); PrescriptionViewModel data = JsonSerializer.Deserialize <PrescriptionViewModel>(jsonString, new JsonSerializerOptions { AllowTrailingCommas = true, PropertyNameCaseInsensitive = true, }); var doctor = data.Doctor; var patient = data.Patient; var prescription = data.Prescription; var medicines = data.Medicines; var openTimes = data.OpenTimes; string appDirectory = AppDomain.CurrentDomain.BaseDirectory; string templateHtml = $"{appDirectory}/wwwroot/templates/dt.html"; string html = Utils.ReadTemplate(templateHtml); string dayOfWeek = Utils.GetDayOfWeek(DateTime.Now); string date = DateTime.Now.Day.ToString(); string month = DateTime.Now.Month.ToString(); string year = DateTime.Now.Year.ToString(); string time = DateTime.Now.ToString("HH:mm"); html = html.Replace("{date}", date); html = html.Replace("{dayOfWeek}", dayOfWeek); html = html.Replace("{date}", date); html = html.Replace("{month}", month); html = html.Replace("{year}", year); html = html.Replace("{time}", time); string patientIdCode = $"{patient.Id}"; html = html.Replace("{patientIdCode}", patientIdCode); string patientOrderNumber = $"{patient.OrderNumber}"; html = html.Replace("{patientOrderNumber}", patientOrderNumber); string patientName = patient.FullName; html = html.Replace("{patientName}", patientName); string patientAge = patient.Age != 0 ? $"{patient.Age}" : "......."; html = html.Replace("{patientAge}", patientAge); if (patient.Gender.Equals(GenderConstants.Male, StringComparison.OrdinalIgnoreCase)) { html = html.Replace("{isMale}", "checked").Replace("{isFemale}", ""); } else if (patient.Gender.Equals(GenderConstants.Female, StringComparison.OrdinalIgnoreCase)) { html = html.Replace("{isMale}", "").Replace("{isFemale}", "checked"); } else { html = html.Replace("{isMale}", "").Replace("{isFemale}", ""); } string patientAddress = !string.IsNullOrWhiteSpace(patient.Address) ? patient.Address : "................................................................................................."; html = html.Replace("{patientAddress}", patientAddress); string patientPhoneNumber = !string.IsNullOrWhiteSpace(patient.PhoneNumber) ? patient.PhoneNumber : "........................................................."; html = html.Replace("{patientPhoneNumber}", patientPhoneNumber); string diagnosis = !string.IsNullOrWhiteSpace(prescription.Diagnosis) ? prescription.Diagnosis : ""; string otherDiagnosis = !string.IsNullOrWhiteSpace(prescription.OtherDiagnosis) ? prescription.OtherDiagnosis : ""; string separator = (!string.IsNullOrEmpty(diagnosis) && !string.IsNullOrEmpty(otherDiagnosis)) ? ", " : ""; string diagnosisName = (!string.IsNullOrEmpty(diagnosis) || !string.IsNullOrEmpty(otherDiagnosis)) ? $"{diagnosis}{separator}{otherDiagnosis}" : "..................................................................................." + "..................................................................................."; html = html.Replace("{diagnosisName}", diagnosisName); string medicineHtmls = ""; if (medicines != null && medicines.Count > 0) { int index = 1; foreach (var medicine in medicines) { string medicineHtml = @"<div class=""prescription-item row""> <div class=""col-9""><b class=""fs-16"">{index} </b><i> {medicineName}</div> <div class=""col-3""> Số lượng: {medicineQuantity} {medicineUnit}</i></div> <div class=""col-12 font-italic""> {medicineTakeMethod} {medicineTakePeriod} <u>{medicineTakeTimes}</u> lần, lần <u>{amountPerTime}</u> {medicineUnit}, {mealTime} ăn. <u>Lưu ý:</u> {medicineNote} </div> </div>"; medicineHtml = medicineHtml.Replace("{index}", $"{index}"); string ingredient = !string.IsNullOrWhiteSpace(medicine.Ingredient) ? $"({medicine.Ingredient})" : ""; string medicineName = $"<b>{medicine.MedicineName}</b> {medicine.NetWeight} {ingredient}"; medicineHtml = medicineHtml.Replace("{medicineName}", medicineName); string quantity = medicine.Quantity != null? medicine.Quantity.ToString() : ".............."; medicineHtml = medicineHtml.Replace("{medicineQuantity}", quantity); string unit = medicine.Unit; medicineHtml = medicineHtml.Replace("{medicineUnit}", unit); string takePeriod = medicine.TakePeriod.ToLower(); medicineHtml = medicineHtml.Replace("{medicineTakePeriod}", takePeriod); string takeMethod = medicine.TakeMethod; medicineHtml = medicineHtml.Replace("{medicineTakeMethod}", takeMethod); string takeTimes = medicine.TakeTimes != null? medicine.TakeTimes.ToString() : ".............."; medicineHtml = medicineHtml.Replace("{medicineTakeTimes}", takeTimes); string amountPerTime = medicine.AmountPerTime != null? medicine.AmountPerTime.ToString() : ".............."; medicineHtml = medicineHtml.Replace("{amountPerTime}", amountPerTime); string mealTime = !string.IsNullOrWhiteSpace(medicine.MealTime) ? medicine.MealTime : "......................"; medicineHtml = medicineHtml.Replace("{mealTime}", mealTime); string medicineNote = !string.IsNullOrWhiteSpace(medicine.Note) ? medicine.Note : "........................................................................... "; medicineHtml = medicineHtml.Replace("{medicineNote}", medicineNote); medicineHtmls += medicineHtml; index++; } } html = html.Replace("{medicines}", medicineHtmls); string appointmentHtml = @"<u class=""font-weight-bold"">Tái khám:</u> {appointmentDays}, Thứ {thu}, ngày {ngay} tháng {thang} năm {nam}."; if (!string.IsNullOrWhiteSpace(patient.AppointmentDate)) { appointmentHtml = Utils.GetDateString(patient.AppointmentDate, appointmentHtml); string days = Utils.DiffDate(prescription.DateCreated, patient.AppointmentDate); string appointmentDays = !string.IsNullOrWhiteSpace(days) ? $"{days} ngày" : "........................................"; appointmentHtml = appointmentHtml.Replace("{appointmentDays}", appointmentDays); } else { appointmentHtml = @"<u class=""font-weight-bold"">Tái khám: </u> ........................................, Thứ ........, ngày .......... tháng .......... năm 20..............."; } html = html.Replace("{appointmentDate}", appointmentHtml); string dateCreatedHtml = "Thứ {thu}, ngày {ngay} tháng {thang} năm {nam}"; if (!string.IsNullOrWhiteSpace(prescription.DateCreated)) { dateCreatedHtml = Utils.GetDateString(prescription.DateCreated, dateCreatedHtml); } else { dateCreatedHtml = dateCreatedHtml .Replace("{thu}", dayOfWeek) .Replace("{ngay}", date) .Replace("{thang}", month) .Replace("{nam}", year); } html = html.Replace("{dateCreated}", dateCreatedHtml); string prescriptionNote = !string.IsNullOrWhiteSpace(prescription.Note) ? prescription.Note.Replace("\n", "<br />") : "....................................................................................." + "....................................................................................."; html = html.Replace("{prescriptionNote}", prescriptionNote); if (openTimes.Count > 0) { string openTimeHtmls = ""; foreach (var openTime in openTimes) { string openClosedTime = openTime.OpenClosedTime; if (openClosedTime.StartsWith("-")) { openTimeHtmls += $"<span>{openClosedTime}</span>"; } else { openTimeHtmls += $"<span>- {openClosedTime}</span>"; } } html = html.Replace("{openTimes}", openTimeHtmls); } else { html = html.Replace("{openTimes}", ""); } string doctorName = doctor.FullName.ToUpper(); if (doctorName.Contains("TRẦN ĐĂNG KHOA")) { doctorName = doctorName.Replace("TRẦN ĐĂNG KHOA", "") + " <b>TRẦN ĐĂNG KHOA</b>"; } html = html.Replace("{doctorName}", doctorName); string indexHtml = $"{appDirectory}/wwwroot/index.html"; Utils.WriteTemplate(indexHtml, html); string url = $"file:///{appDirectory}/wwwroot/index.html"; var converter = Utils.CreateA4Converter(); string savePath = Utils.GetSavePath(appDirectory, "DT"); Utils.ConvertPdfFromUrl(converter, url, savePath); Utils.PrintPdf(savePath); ChromelyResponse response = new ChromelyResponse(request.Id) { Data = new { Message = $"In đơn thuốc thành công lúc {DateTime.Now:dd/MM/yyyy HH:mm:ss}!", } }; return(response); }
public PrescriptionDto Map(PrescriptionViewModel prescription) => _Mapper.Map <PrescriptionDto>(prescription);