private Entry CreatePracticeEntry(PracticePreviewViewModel model) { if (model == default) { throw new ArgumentNullException(nameof(model)); } return(EhrManager.EntryBuilder .Clear() .AddItems( EhrManager.ElementBuilder.Clear() .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Branch)).Build()) .AddValue(EhrManager.INTBuilder.Clear().AddValue(model.Branch).Build()).Build(), EhrManager.ElementBuilder.Clear() .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Number)).Build()) .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Number).Build()).Build(), EhrManager.ElementBuilder.Clear() .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Code)).Build()) .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Code).Build()).Build(), EhrManager.ElementBuilder.Clear() .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Name)).Build()) .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Name).Build()).Build(), EhrManager.ElementBuilder.Clear() .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.HealthRegion)).Build()) .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.HealthRegion).Build()).Build(), EhrManager.ElementBuilder.Clear() .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Address)).Build()) .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Address).Build()).Build() ).Build()); }
public async Task <ProtocolDrugTherapyViewModel> GetProtocolDrugTherapyAsync(int id) { if (id < 1) { throw new ArgumentException(nameof(id)); } return(await Task <ProtocolDrugTherapyViewModel> .Run(() => { ProtocolDrugTherapy protocolDrugTherapy = MedicContext.ProtocolDrugTherapies .Include(pdt => pdt.PatientBranch) .ThenInclude(pb => pb.HealthRegion) .Include(pdt => pdt.PatientHRegion) .Include(pdt => pdt.CPFile) .ThenInclude(cp => cp.FileType) .SingleOrDefault(pdt => pdt.Id == id); if (protocolDrugTherapy == default) { return default; } PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == protocolDrugTherapy.PatientId); PracticePreviewViewModel practice = MedicContext.Practices .ProjectTo <PracticePreviewViewModel>(Configuration) .SingleOrDefault(p => p.Id == protocolDrugTherapy.PracticeId); DiagPreviewViewModel diag = base.GetDiag <DiagPreviewViewModel>(d => d.Id == protocolDrugTherapy.DiagId); HematologyPartPreviewViewModel hematologyPart = MedicContext.HematologyParts .ProjectTo <HematologyPartPreviewViewModel>(Configuration) .SingleOrDefault(hp => hp.Id == protocolDrugTherapy.Id); ChemotherapyPartPreviewViewModel chemotherapyPart = MedicContext.ChemotherapyParts .ProjectTo <ChemotherapyPartPreviewViewModel>(Configuration) .SingleOrDefault(cp => cp.Id == protocolDrugTherapy.ChemotherapyPartId); List <DrugProtocolPreviewViewModel> drugProtocols = MedicContext.DrugProtocols .Where(dp => dp.ProtocolDrugTherapyId == protocolDrugTherapy.Id) .ProjectTo <DrugProtocolPreviewViewModel>(Configuration) .ToList(); List <AccompanyingDrugPreviewViewModel> accompanyingDrugs = MedicContext.AccompanyingDrugs .Where(ad => ad.ProtocolDrugTherapyId == protocolDrugTherapy.Id) .ProjectTo <AccompanyingDrugPreviewViewModel>(Configuration) .ToList(); HealthcarePractitionerSummaryViewModel chairman = base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == protocolDrugTherapy.ChairmanId); return new ProtocolDrugTherapyViewModel() { Id = protocolDrugTherapy.Id, Patient = patient, PatientBranch = protocolDrugTherapy?.PatientBranch?.HealthRegion?.Name ?? default, PatientHRegion = protocolDrugTherapy?.PatientHRegion?.Name ?? default, Practice = practice, NumberOfDecision = protocolDrugTherapy.NumberOfDecision, DecisionDate = protocolDrugTherapy.DecisionDate, PracticeCodeProtocol = protocolDrugTherapy.PracticeCodeProtocol, NumberOfProtocol = protocolDrugTherapy.NumberOfProtocol, ProtocolDate = protocolDrugTherapy.ProtocolDate, Diag = diag, Height = protocolDrugTherapy.Height, Weight = protocolDrugTherapy.Weight, BSA = protocolDrugTherapy.BSA, TherapyLine = protocolDrugTherapy.TherapyLine, Scheme = protocolDrugTherapy.Scheme, CycleCount = protocolDrugTherapy.CycleCount, HematologyPart = hematologyPart, ChemotherapyPart = chemotherapyPart, DrugProtocols = drugProtocols, AccompanyingDrugs = accompanyingDrugs, Chairman = chairman, Sign = protocolDrugTherapy.Sign, CPFile = protocolDrugTherapy?.CPFile?.FileType.Name, }; })); }