/// <summary> /// 根据日期查询透析记录单简要信息列表 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IActionResult> GetPatVisitListJson(GetPatVisitListJsonInput input /*DateTime visitDate*/) { var list = _patVisitApp.GetList().Where(t => t.F_VisitDate == input.visitDate); //患者 var p = (from c in await _patientApp.GetList() where list.Any(t => t.F_Pid.Equals(c.F_Id)) select c).ToList(); //耗材 var m = (from c in await _materialApp.GetList() where list.Any(t => c.F_Id.Equals(t.F_DialyzerType1) || c.F_Id.Equals(t.F_DialyzerType2)) select c).ToList(); //药品 var d = (from c in await _drugsApp.GetList() where list.Any(t => c.F_Id.Equals(t.F_HeparinType)) select c).ToList(); //查询治疗记录 var data = new List <PatVisitListResult>(); foreach (var item in list) { var temp = new PatVisitListResult { Id = item.F_Id, Pid = item.F_Pid, GroupName = item.F_GroupName, DialysisBedNo = item.F_DialysisBedNo }; var patient = p.FirstOrDefault(t => t.F_Id.Equals(item.F_Pid)); if (patient == null) { continue; } temp.Name = patient.F_Name ?? ""; temp.Gender = patient.F_Gender ?? ""; temp.VisitDate = item.F_VisitDate.ToDateString(); temp.VisitNo = item.F_VisitNo.ToInt(); temp.DialysisNo = patient.F_DialysisNo.ToInt(); temp.DialysisType = item.F_DialysisType ?? ""; temp.DialyzerType1 = item.F_DialyzerType1 == null ? "" : m.First(t => t.F_Id.Equals(item.F_DialyzerType1)).F_MaterialName; temp.DialyzerType2 = item.F_DialyzerType2 == null ? "" : m.First(t => t.F_Id.Equals(item.F_DialyzerType2)).F_MaterialName; temp.VascularAccess = item.F_VascularAccess ?? ""; temp.HeparinType = item.F_HeparinType == null ? "" : d.First(t => t.F_Id.Equals(item.F_HeparinType)).F_DrugName; temp.BirthDay = patient.F_BirthDay.ToDateString(); temp.AgeDesc = patient.F_BirthDay == null ? "" : ((int)((DateTime.Now - patient.F_BirthDay.ToDate()).TotalDays / 365)).ToString() + "岁"; temp.StartTime = item.F_DialysisStartTime == null ? "" : item.F_DialysisStartTime.ToDateTimeString(); temp.EndTime = item.F_DialysisEndTime == null ? "" : item.F_DialysisEndTime.ToDateTimeString(); temp.Py = (patient.F_PY ?? "").ToLower(); temp.StartPerson = item.F_StartPerson; temp.EndPerson = item.F_EndPerson; temp.CheckPerson = item.F_CheckPerson; temp.PuncturePerson = item.F_PuncturePerson; data.Add(temp); } return(Ok(data)); }
/// <summary> /// 根据代码、名称、拼音查询药品简要信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IActionResult> GetList([FromQuery] BaseInput input) { var data = (from r in await _drugsApp.GetList(input == null ? "" : input.KeyValue) select new { id = r.F_Id, code = r.F_DrugCode, name = r.F_DrugName, spec = r.F_DrugSpec, unit = r.F_DrugUnit, miniAmount = r.F_DrugMiniAmount, miniPackage = r.F_DrugMiniPackage, miniSpec = r.F_DrugMiniSpec, administration = r.F_DrugAdministration, spell = r.F_DrugSpell, supplier = r.F_DrugSupplier, price = r.F_Charges }).ToList(); return(Ok(data)); }
public async Task <IActionResult> SubmitForm([FromBody] ImportDto input) { ImportMasterEntity masterEntity; var details = new List <ImportDetailEntity>(); if (input.KeyValue.IsEmpty()) //新增 { masterEntity = new ImportMasterEntity { F_Contacts = input.Master.F_Contacts, F_Costs = input.Master.F_Costs, F_ImpClass = input.Master.F_ImpClass, F_ImpDate = input.Master.F_ImpDate?.ToDate() ?? DateTime.Now, F_ImpNo = input.Master.F_ImpNo, F_ImpType = input.Master.F_ImpType, F_Storage = input.Master.F_Storage, F_Supplier = input.Master.F_Storage, F_SupplierPhone = input.Master.F_SupplierPhone }; } else//修改 { masterEntity = await _importMasterApp.GetForm(input.KeyValue); masterEntity.F_Contacts = input.Master.F_Contacts; masterEntity.F_Costs = input.Master.F_Costs; masterEntity.F_ImpClass = input.Master.F_ImpClass; masterEntity.F_ImpDate = input.Master.F_ImpDate?.ToDate() ?? DateTime.Now; masterEntity.F_ImpNo = input.Master.F_ImpNo; masterEntity.F_ImpType = input.Master.F_ImpType; masterEntity.F_Storage = input.Master.F_Storage; masterEntity.F_Supplier = input.Master.F_Storage; masterEntity.F_SupplierPhone = input.Master.F_SupplierPhone; } var masterId = await _importMasterApp.SubmitForm(masterEntity, input.KeyValue); switch (input.Master.F_ImpClass) { case "药品入库": { var drugs = (await _drugsApp.GetList()).ToList(); details = (from item in input.Details let amount = item.F_Amount.ToInt() where amount != 0 let drug = drugs.FirstOrDefault(t => t.F_Id == item.F_ItemId) where drug != null select new ImportDetailEntity { F_Id = item.F_Id, F_ImpId = masterId, F_ItemId = item.F_ItemId, F_Amount = amount, F_Code = drug.F_DrugCode, F_Charges = drug.F_Charges, F_Name = drug.F_DrugName, F_Unit = drug.F_DrugUnit, F_Spec = drug.F_DrugSpec, F_TotalCharges = (drug.F_Charges * amount).ToFloat(2) }).ToList(); await _importDetailApp.InsertBatch(details); break; } case "耗材入库": var materials = (await _materialApp.GetList()).ToList(); details = (from item in input.Details let amount = item.F_Amount.ToInt() where amount != 0 let material = materials.FirstOrDefault(t => t.F_Id == item.F_ItemId) where material != null select new ImportDetailEntity { F_Id = item.F_Id, F_ImpId = masterId, F_ItemId = item.F_ItemId, F_Amount = amount, F_Code = material.F_MaterialCode, F_Charges = material.F_Charges, F_Name = material.F_MaterialName, F_Unit = material.F_MaterialUnit, F_Spec = material.F_MaterialSpec, F_TotalCharges = (material.F_Charges * amount).ToFloat(2) }).ToList(); await _importDetailApp.InsertBatch(details); break; } //更新主记录总金额 masterEntity = await _importMasterApp.GetForm(masterId); masterEntity.F_Costs = details.Sum(t => t.F_TotalCharges); await _importMasterApp.UpdateForm(masterEntity); return(Success("操作成功。")); }
public async Task <IActionResult> GetListJson(string keyword) { var data = await _drugsApp.GetList(keyword); return(Content(data.ToJson())); }