public async Task <ActionResult> Insert_PescriptionItem(PrescriptionDrugCreateVM vm) { //## This will create a Template for a Specific Drug Brand. ie: 'Ibuprofen 200mg Tablet 4 Times a Day for 7 days' if (vm is null || vm.DrugBrandId < 1 || vm.BrandDoseTemplateId < 1) { return(Json("error")); } var result = await _prescriptionService.Insert_PescriptionItem(vm); return(Json(result)); }
/// <summary>This will Insert a New drug Item in the Prescription</summary> /// <param name="vm">PrescriptionDrugCreateVM View Model</param> /// <returns>A String- semi-colon separated value</returns> public async Task <string> Insert_PescriptionItem(PrescriptionDrugCreateVM vm) { //## First insert this new Prescription Item in the table var newPrescriptionItem = new PrescriptionDrugs() { PrescriptionId = vm.PrescriptionId, DrugBrandId = vm.DrugBrandId, BrandDoseTemplateId = vm.BrandDoseTemplateId, //Notes = vm.Notes }; if (vm.AdviseInstructionId > 0) { newPrescriptionItem.AdviseInstructionId = vm.AdviseInstructionId; } await _pasContext.PrescriptionDrugs.AddAsync(newPrescriptionItem); await _pasContext.SaveChangesAsync(); //## Now get the Intake Pattern from Pattern table- to return to UI- to show in the Prescription Preview var newItemId = newPrescriptionItem.Id; var details = await _pasContext.BrandDoseTemplates .Include(bd => bd.IntakePattern) .AsNoTracking() .Where(bd => bd.Id == vm.BrandDoseTemplateId) .Select(bd => new PrescriptionDrugViewVM() { PrescriptionItemId = newItemId, //## Will need this to Delete this Item- if required IntakeTemplate = bd.IntakePattern.Pattern, //## this could be in Bangla or English }) .FirstOrDefaultAsync(); string result = $"{newItemId};{details.IntakeTemplate}"; return(result); }
public Task <int> AddDrugToPrescription(PrescriptionDrugCreateVM prescriptionDrug) { throw new NotImplementedException(); }