Beispiel #1
0
        public async Task <InClinicProcedureViewModel> GetInClinicProcedureAsync(int id)
        {
            if (id < 0)
            {
                throw new ArgumentException(nameof(id));
            }

            return(await Task <InClinicProcedureViewModel> .Run(() =>
            {
                InClinicProcedure inClinicProcedure = MedicContext.InClinicProcedures
                                                      .Include(icp => icp.PatientBranch)
                                                      .ThenInclude(pb => pb.HealthRegion)
                                                      .Include(icp => icp.PatientHealthRegion)
                                                      .SingleOrDefault(icp => icp.Id == id);

                if (inClinicProcedure == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == inClinicProcedure.PatientId);

                HealthcarePractitionerSummaryViewModel sender =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == inClinicProcedure.SenderId);

                CeasedClinicalViewModel ceasedClinical = base.GetCeasedClinical <CeasedClinicalViewModel>(cc => cc.Id == inClinicProcedure.CeasedClinicalPathId);

                DiagPreviewViewModel firstMainDiag = base.GetDiag <DiagPreviewViewModel>(d => d.Id == inClinicProcedure.FirstMainDiagId);

                DiagPreviewViewModel secondMainDiag = base.GetDiag <DiagPreviewViewModel>(d => d.Id == inClinicProcedure.SecondMainDiagId);

                return new InClinicProcedureViewModel()
                {
                    Id = inClinicProcedure.Id,
                    Patient = patient,
                    PatientBranch = inClinicProcedure?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHealthRegion = inClinicProcedure.PatientHealthRegion.Name,
                    Sender = sender,
                    APrSend = inClinicProcedure.APrSend,
                    TypeProcSend = inClinicProcedure.TypeProcSend,
                    DateSend = inClinicProcedure.DateSend,
                    CPrPriem = inClinicProcedure.CPrPriem,
                    APrPriem = inClinicProcedure.APrPriem,
                    TypeProcPriem = inClinicProcedure.TypeProcPriem,
                    ProcRefuse = inClinicProcedure.ProcRefuse,
                    CeasedClinicalPath = ceasedClinical,
                    IZNumChild = inClinicProcedure.IZNumChild,
                    IZYearChild = inClinicProcedure.IZYearChild,
                    FirstVisitDate = inClinicProcedure.FirstVisitDate,
                    PlanVisitDate = inClinicProcedure.PlanVisitDate,
                    VisitDoctorUniqueIdentifier = inClinicProcedure.VisitDoctorUniqueIdentifier,
                    VisitDoctorName = inClinicProcedure.VisitDoctorName,
                    FirstMainDiag = firstMainDiag,
                    SecondMainDiag = secondMainDiag,
                    PatientStatus = inClinicProcedure.PatientStatus,
                    NZOKPay = inClinicProcedure.NZOKPay
                };
            }));
        }
Beispiel #2
0
        public async Task <DispObservationViewModel> GetDispObservationAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentException(nameof(id));
            }

            return(await Task <DispObservationViewModel> .Run(() =>
            {
                DispObservation dispObservation = MedicContext.DispObservations
                                                  .Include(disp => disp.PatientBranch)
                                                  .ThenInclude(pb => pb.HealthRegion)
                                                  .Include(disp => disp.PatientHRegion)
                                                  .SingleOrDefault(disp => disp.Id == id);

                if (dispObservation == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == dispObservation.PatientId);

                HealthcarePractitionerSummaryViewModel doctor =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == dispObservation.DoctorId);

                List <MDISummaryViewModel> MDIs = MedicContext.MDIs
                                                  .Where(m => m.DispObservationId == dispObservation.Id)
                                                  .ProjectTo <MDISummaryViewModel>(Configuration)
                                                  .ToList();

                DiagPreviewViewModel firstMainDiag = GetDiag <DiagPreviewViewModel>(d => d.Id == dispObservation.MainDiagFirstId);

                DiagPreviewViewModel secondMainDiag = GetDiag <DiagPreviewViewModel>(d => d.Id == dispObservation.MainDiagSecondId);

                return new DispObservationViewModel()
                {
                    Id = dispObservation.Id,
                    Patient = patient,
                    PatientBranch = dispObservation?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHRegion = dispObservation?.PatientHRegion?.Name ?? default,
                    Doctor = doctor,
                    DispNum = dispObservation.DispNum,
                    DispDate = dispObservation.DispDate,
                    AprCode = dispObservation.AprCode,
                    DiagDate = dispObservation.DiagDate,
                    DispanserDate = dispObservation.DispanserDate,
                    DispVisit = dispObservation.DispVisit,
                    MDIs = MDIs,
                    FirstMainDiag = firstMainDiag,
                    SecondMainDiag = secondMainDiag,
                    Anamnesa = dispObservation.Anamnesa,
                    HState = dispObservation.HState,
                    Therapy = dispObservation.Therapy,
                    Sign = dispObservation.Sign,
                    NZOKPay = dispObservation.NZOKPay
                };
            }));
        }
Beispiel #3
0
        public async Task <PlannedViewModel> GetPlannedAsync(int id)
        {
            return(await Task <PlannedViewModel> .Run(() =>
            {
                Planned planned = MedicContext.Plannings
                                  .Include(p => p.PatientBranch)
                                  .ThenInclude(pb => pb.HealthRegion)
                                  .Include(p => p.PatientHRegion)
                                  .Include(p => p.CPFile)
                                  .ThenInclude(cp => cp.FileType)
                                  .SingleOrDefault(p => p.Id == id);

                if (planned == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == planned.PatientId);

                HealthcarePractitionerSummaryViewModel sender =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == planned.SenderId);

                List <DiagnosePreviewViewModel> sendDiagnose = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.SendPlannedId == planned.Id);

                List <DiagnosePreviewViewModel> diagnose = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.PlannedId == planned.Id);

                return new PlannedViewModel()
                {
                    Id = planned.Id,
                    Patient = patient,
                    PatientBranch = planned?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHRegion = planned?.PatientHRegion?.Name ?? default,
                    InType = planned.InType,
                    Sender = sender,
                    SendDate = planned.SendDate,
                    SendDiagnoses = sendDiagnose,
                    SendUrgency = planned.SendUrgency,
                    SendClinicalPath = planned.SendClinicalPath,
                    SendAPr = planned.SendAPr,
                    InAPr = planned.InAPr,
                    UniqueIdentifier = planned.UniqueIdentifier,
                    ExaminationDate = planned.ExaminationDate,
                    PlannedEntryDate = planned.PlannedEntryDate,
                    PlannedNumber = planned.PlannedNumber,
                    Diagnoses = diagnose,
                    Urgency = planned.Urgency,
                    ClinicalPath = planned.ClinicalPath,
                    NZOKPay = planned.NZOKPay,
                    CPFile = planned?.CPFile?.FileType?.Name ?? default
                };
            }));
        }
Beispiel #4
0
        public IActionResult Summary(string type, PatientSummaryViewModel model, PatientService service)
        {
            model.Title = type.FirstCharToUpper();
            if (type.Equals("national"))
            {
                model.Summary = service.GetDataSummaryNational();
            }
            else if (type.Equals("regional"))
            {
                model.Summary = service.GetDataSummaryRegional();
            }
            else if (type.Equals("facility"))
            {
                model.Summary = service.GetDataSummaryFacility();
            }
            else if (type.Equals("agency"))
            {
                model.Summary = service.GetDataSummaryAgency();
            }

            return(View(model));
        }
        public async Task <CommissionAprViewModel> GetCommissionAprAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentException(nameof(id));
            }

            return(await Task <CommissionAprViewModel> .Run(() =>
            {
                CommissionApr commissionApr = MedicContext.CommissionAprs
                                              .Include(ca => ca.PatientBranch)
                                              .ThenInclude(pb => pb.HealthRegion)
                                              .Include(ca => ca.PatientHRegion)
                                              .SingleOrDefault(ca => ca.Id == id);

                if (commissionApr == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == commissionApr.PatientId);

                HealthcarePractitionerSummaryViewModel sender =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == commissionApr.SenderId);

                HealthcarePractitionerSummaryViewModel chairman =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == commissionApr.ChairmanId);

                DiagPreviewViewModel mainDiag = base.GetDiag <DiagPreviewViewModel>(d => d.Id == commissionApr.MainDiagId);

                List <DiagPreviewViewModel> addedDiag = base.GetDiags <DiagPreviewViewModel>(d => d.CommissionAprId == commissionApr.Id);

                APr38PreviewViewModel APr38 = MedicContext.APr38s
                                              .ProjectTo <APr38PreviewViewModel>(Configuration)
                                              .SingleOrDefault(apr => apr.Id == commissionApr.APr38Id);

                APr05PreviewViewModel APr05 = MedicContext.APr05s
                                              .ProjectTo <APr05PreviewViewModel>(Configuration)
                                              .SingleOrDefault(apr => apr.Id == commissionApr.APr05Id);

                return new CommissionAprViewModel()
                {
                    Id = commissionApr.Id,
                    Patient = patient,
                    PatientBranch = commissionApr?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHRegion = commissionApr.PatientHRegion.Name,
                    Sender = sender,
                    AprSend = commissionApr.AprSend,
                    SendDate = commissionApr.SendDate,
                    AprPriem = commissionApr.AprPriem,
                    SpecCommission = commissionApr.SpecCommission,
                    NoDecision = commissionApr.NoDecision,
                    DecisionDate = commissionApr.DecisionDate,
                    Chairman = chairman,
                    MainDiag = mainDiag,
                    AddDiags = addedDiag,
                    APr38 = APr38,
                    APr05 = APr05,
                    Sign = commissionApr.Sign,
                    NZOKPay = commissionApr.NZOKPay
                };
            }));
        }
        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,
                };
            }));
        }
Beispiel #7
0
        protected Entry CreatePatientEntry(PatientSummaryViewModel model)
        {
            if (model == default)
            {
                throw new ArgumentNullException(nameof(model));
            }

            IEntryBuilder entryPatientBuilder = EhrManager.EntryBuilder.Clear();

            entryPatientBuilder.AddItems(
                EhrManager.ElementBuilder
                .Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.IdentityNumber)).Build())
                .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.IdentityNumber).Build())
                .Build(),
                EhrManager.ElementBuilder
                .Clear().AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Sex)).Build())
                .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Sex).Build())
                .Build()
                );

            if (!string.IsNullOrWhiteSpace(model.FirstName))
            {
                entryPatientBuilder
                .AddItems(
                    EhrManager.ElementBuilder.Clear()
                    .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.FirstName)).Build())
                    .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.FirstName).Build()).Build());
            }

            if (!string.IsNullOrWhiteSpace(model.SecondName))
            {
                entryPatientBuilder
                .AddItems(
                    EhrManager.ElementBuilder.Clear()
                    .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.SecondName)).Build())
                    .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.SecondName).Build()).Build());
            }

            if (!string.IsNullOrWhiteSpace(model.LastName))
            {
                entryPatientBuilder.AddItems(
                    EhrManager.ElementBuilder.Clear()
                    .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.LastName)).Build())
                    .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.LastName).Build()).Build());
            }

            if (!string.IsNullOrWhiteSpace(model.Address))
            {
                entryPatientBuilder.AddItems(
                    EhrManager.ElementBuilder.Clear()
                    .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Address)).Build())
                    .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Address).Build()).Build());
            }

            if (model.BirthDate != default)
            {
                entryPatientBuilder.AddItems(
                    EhrManager.ElementBuilder.Clear()
                    .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.BirthDate)).Build())
                    .AddValue(EhrManager.DATEBuilder.Clear().AddDate(model.BirthDate).Build()).Build());
            }

            if (!string.IsNullOrWhiteSpace(model.Notes))
            {
                entryPatientBuilder.AddItems(
                    EhrManager.ElementBuilder.Clear()
                    .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Notes)).Build())
                    .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Notes).Build()).Build());
            }

            return(entryPatientBuilder.Build());
        }
        public async Task <PathProcedureViewModel> GetPathProcedureByIdAsync(int id)
        {
            return(await Task <PathProcedureViewModel> .Run(() =>
            {
                PathProcedure pathProcedure = MedicContext.PathProcedures
                                              .Include(pp => pp.PatientBranch)
                                              .ThenInclude(pb => pb.HealthRegion)
                                              .Include(pp => pp.PatientHRegion)
                                              .SingleOrDefault(pp => pp.Id == id);

                if (pathProcedure == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == pathProcedure.PatientId);

                HealthcarePractitionerSummaryViewModel sender =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == pathProcedure.SenderId);

                CeasedClinicalViewModel CeasedProcedure = base.GetCeasedClinical <CeasedClinicalViewModel>(cc => cc.Id == pathProcedure.CeasedProcedureId);

                CeasedClinicalViewModel CeasedClinicalPath = base.GetCeasedClinical <CeasedClinicalViewModel>(cc => cc.Id == pathProcedure.CeasedClinicalPathId);

                DiagPreviewViewModel firstMainDiag = base.GetDiag <DiagPreviewViewModel>(d => d.Id == pathProcedure.FirstMainDiagId);

                DiagPreviewViewModel secondMainDiag = base.GetDiag <DiagPreviewViewModel>(d => d.Id == pathProcedure.SecondMainDiagId);

                List <ProcedureSummaryViewModel> doneNewProcedures = base.GetProcedures <ProcedureSummaryViewModel>(pr => pr.PathProcedureId == pathProcedure.Id);

                List <ClinicUsedDrugViewModel> usedDrugs = MedicContext.ClinicUsedDrugs
                                                           .Where(ud => ud.PathProcedureId == pathProcedure.Id)
                                                           .ProjectTo <ClinicUsedDrugViewModel>(Configuration)
                                                           .ToList();

                List <ClinicProcedureViewModel> clinicProcedure = MedicContext.ClinicProcedures
                                                                  .Where(cp => cp.PathProcedureId == pathProcedure.Id)
                                                                  .ProjectTo <ClinicProcedureViewModel>(Configuration)
                                                                  .ToList();

                List <DoneProcedureViewModel> doneProcedures = MedicContext.DoneProcedures
                                                               .Where(dp => dp.PathProcedureId == pathProcedure.Id)
                                                               .ProjectTo <DoneProcedureViewModel>(Configuration)
                                                               .ToList();

                return new PathProcedureViewModel()
                {
                    Id = pathProcedure.Id,
                    Patient = patient,
                    PatientBranch = pathProcedure?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHRegion = pathProcedure?.PatientHRegion?.Name ?? default,
                    Sender = sender,
                    CPrSend = pathProcedure.CPrSend,
                    APrSend = pathProcedure.APrSend,
                    TypeProcSend = pathProcedure.TypeProcSend,
                    DateSend = pathProcedure.DateSend,
                    CPrPriem = pathProcedure.CPrPriem,
                    APrPriem = pathProcedure.APrPriem,
                    MedicalWard = pathProcedure.MedicalWard,
                    TypeProcPriem = pathProcedure.TypeProcPriem,
                    ProcRefuse = pathProcedure.ProcRefuse,
                    CeasedProcedure = CeasedProcedure,
                    CeasedClinicalPath = CeasedClinicalPath,
                    IZNumChild = pathProcedure.IZNumChild,
                    IZYearChild = pathProcedure.IZYearChild,
                    FirstVisitDate = pathProcedure.FirstVisitDate,
                    DatePlanPriem = pathProcedure.DatePlanPriem,
                    VisitDoctorUniqueIdentifier = pathProcedure.VisitDoctorUniqueIdentifier,
                    VisitDoctorName = pathProcedure.VisitDoctorName,
                    FirstMainDiag = firstMainDiag,
                    SecondMainDiag = secondMainDiag,
                    DateProcedureBegins = pathProcedure.DateProcedureBegins,
                    DateProcedureEnd = pathProcedure.DateProcedureEnd,
                    DoneNewProcedures = doneNewProcedures,
                    UsedDrugs = usedDrugs,
                    ClinicProcedures = clinicProcedure,
                    DoneProcedures = doneProcedures,
                    AllDoneProcedures = pathProcedure.AllDoneProcedures,
                    AllDrugCost = pathProcedure.AllDrugCost,
                    PatientStatus = pathProcedure.PatientStatus,
                    OutUniqueIdentifier = pathProcedure.OutUniqueIdentifier,
                    Sign = pathProcedure.Sign,
                    NZOKPay = pathProcedure.NZOKPay
                };
            }));
        }
Beispiel #9
0
        public async Task <InViewModel> GetInAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentException(nameof(id));
            }

            return(await Task <InViewModel> .Run(() =>
            {
                In inEntity = MedicContext.Ins
                              .Include(i => i.PatientBranch)
                              .ThenInclude(pb => pb.HealthRegion)
                              .Include(i => i.PatientHRegion)
                              .Include(i => i.CPFile)
                              .ThenInclude(cp => cp.FileType)
                              .SingleOrDefault(i => i.Id == id);

                if (inEntity == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = MedicContext.Patients
                                                  .ProjectTo <PatientSummaryViewModel>(Configuration)
                                                  .SingleOrDefault(p => p.Id == inEntity.PatientId);

                HealthcarePractitionerSummaryViewModel sender = MedicContext.HealthcarePractitioners
                                                                .ProjectTo <HealthcarePractitionerSummaryViewModel>(Configuration)
                                                                .SingleOrDefault(hp => hp.Id == inEntity.SenderId);

                List <DiagnosePreviewViewModel> sendDiagnoses = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.SendInId == inEntity.Id);

                List <DiagnosePreviewViewModel> diagnoses = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.InId == inEntity.Id);

                return new InViewModel()
                {
                    Id = inEntity.Id,
                    Patient = patient,
                    PatientBranch = inEntity?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHRegion = inEntity.PatientHRegion.Name,
                    Sender = sender,
                    InType = inEntity.InType,
                    SendDate = inEntity.SendDate,
                    SendDiagnoses = sendDiagnoses,
                    SendUrgency = inEntity.SendUrgency,
                    SendAPr = inEntity.SendAPr,
                    SendClinicalPath = inEntity.SendClinicalPath,
                    UniqueIdentifier = inEntity.UniqueIdentifier,
                    ExaminationDate = inEntity.ExaminationDate,
                    PlannedEntryDate = inEntity.PlannedEntryDate,
                    PlannedNumber = inEntity.PlannedNumber,
                    Diagnoses = diagnoses,
                    Urgency = inEntity.Urgency,
                    InAPr = inEntity.InAPr,
                    ClinicalPath = inEntity.ClinicalPath,
                    NZOKPay = inEntity.NZOKPay,
                    InMedicalWard = inEntity.InMedicalWard,
                    EntryDate = inEntity.EntryDate,
                    Severity = inEntity.Severity,
                    Delay = inEntity.Delay,
                    Payer = inEntity.Payer,
                    AgeInDays = inEntity.AgeInDays,
                    WeightInGrams = inEntity.WeightInGrams,
                    BirthWeight = inEntity.BirthWeight,
                    MotherIZYear = inEntity.MotherIZYear,
                    MotherIZNo = inEntity.MotherIZNo,
                    IZYear = inEntity.IZYear,
                    IZNo = inEntity.IZNo,
                    CPFile = inEntity?.CPFile?.FileType?.Name ?? default
                };
            }));
        }
Beispiel #10
0
        public async Task <OutViewModel> GetOutAsync(int id)
        {
            if (id < 1)
            {
                throw new ArgumentException(nameof(id));
            }

            return(await Task <OutViewModel> .Run(() =>
            {
                Out outEntity = MedicContext.Outs
                                .Include(o => o.PatientBranch)
                                .ThenInclude(pb => pb.HealthRegion)
                                .Include(o => o.PatientHRegion)
                                .Include(o => o.CPFile)
                                .ThenInclude(cp => cp.FileType)
                                .SingleOrDefault(o => o.Id == id);

                if (outEntity == default)
                {
                    return default;
                }

                PatientSummaryViewModel patient = base.GetPatient <PatientSummaryViewModel>(p => p.Id == outEntity.PatientId);

                HealthcarePractitionerSummaryViewModel sender =
                    base.GetHealthcarePractitioner <HealthcarePractitionerSummaryViewModel>(hp => hp.Id == outEntity.SenderId);

                List <DiagnosePreviewViewModel> sendDiagnoses = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.SendOutId == outEntity.Id);

                List <DiagnosePreviewViewModel> diagnoses = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.OutId == outEntity.Id);

                DiagnosePreviewViewModel dead = base.GetDiagnose <DiagnosePreviewViewModel>(d => d.Id == outEntity.DeadId);

                HistologicalResultSummaryViewModel histologicalResult = MedicContext.HistologicalResults
                                                                        .ProjectTo <HistologicalResultSummaryViewModel>(Configuration)
                                                                        .SingleOrDefault(hr => hr.Id == outEntity.HistologicalResultId);

                EpicrisisSummaryViewModel epicrisis = MedicContext.Epicrises
                                                      .ProjectTo <EpicrisisSummaryViewModel>(Configuration)
                                                      .SingleOrDefault(e => e.Id == outEntity.EpicrisisId);

                DiagnosePreviewViewModel outMainDiagnose = base.GetDiagnose <DiagnosePreviewViewModel>(d => d.Id == outEntity.OutMainDiagnoseId);

                List <DiagnosePreviewViewModel> outDiagnoses = base.GetDiagnoses <DiagnosePreviewViewModel>(d => d.OutOutId == outEntity.Id);

                List <UsedDrugSummaryViewModel> usedDrugs = MedicContext.UsedDrugs
                                                            .Where(ud => ud.OutId == outEntity.Id)
                                                            .ProjectTo <UsedDrugSummaryViewModel>(Configuration)
                                                            .ToList();

                List <ProcedureSummaryViewModel> procedures = base.GetProcedures <ProcedureSummaryViewModel>(p => p.OutId == outEntity.Id);

                return new OutViewModel()
                {
                    Id = outEntity.Id,
                    Patient = patient,
                    PatientBranch = outEntity?.PatientBranch?.HealthRegion?.Name ?? default,
                    PatientHRegion = outEntity?.PatientHRegion?.Name ?? default,
                    Sender = sender,
                    InType = outEntity.InType,
                    SendDate = outEntity.SendDate,
                    SendDiagnoses = sendDiagnoses,
                    SendUrgency = outEntity.SendUrgency,
                    SendClinicalPath = outEntity.SendClinicalPath,
                    SendAPr = outEntity.SendAPr,
                    PlannedNumber = outEntity.PlannedNumber,
                    InAPr = outEntity.InAPr,
                    UniqueIdentifier = outEntity.UniqueIdentifier,
                    ExaminationDate = outEntity.ExaminationDate,
                    Diagnoses = diagnoses,
                    Urgency = outEntity.Urgency,
                    ClinicalPath = outEntity.ClinicalPath,
                    NZOKPay = outEntity.NZOKPay,
                    InMedicalWard = outEntity.InMedicalWard,
                    EntryDate = outEntity.EntryDate,
                    Severity = outEntity.Severity,
                    Delay = outEntity.Delay,
                    Payer = outEntity.Payer,
                    AgeInDays = outEntity.AgeInDays,
                    WeightInGrams = outEntity.WeightInGrams,
                    BirthWeight = outEntity.BirthWeight,
                    MotherIZYear = outEntity.MotherIZYear,
                    MotherIZNo = outEntity.MotherIZNo,
                    IZYear = outEntity.IZYear,
                    IZNo = outEntity.IZNo,
                    OutMedicalWard = outEntity.OutMedicalWard,
                    OutUniqueIdentifier = outEntity.OutUniqueIdentifier,
                    OutDate = outEntity.OutDate,
                    OutType = outEntity.OutType,
                    Dead = dead,
                    BirthPractice = outEntity.BirthPractice,
                    BirthNumber = outEntity.BirthNumber,
                    BirthGestWeek = outEntity.BirthGestWeek,
                    OutClinicalPath = outEntity.OutClinicalPath,
                    OutAPr = outEntity.OutAPr,
                    HistologicalResult = histologicalResult,
                    Epicrisis = epicrisis,
                    OutMainDiagnose = outMainDiagnose,
                    OutDiagnoses = outDiagnoses,
                    UsedDrugs = usedDrugs,
                    Procedures = procedures,
                    BedDays = outEntity.BedDays,
                    HLDateFrom = outEntity.HLDateFrom,
                    HLNumber = outEntity.HLNumber,
                    HLTotalDays = outEntity.HLTotalDays,
                    StateAtDischarge = outEntity.StateAtDischarge,
                    Laparoscopic = outEntity.Laparoscopic,
                    EndCourse = outEntity.EndCourse,
                    CPFile = outEntity?.CPFile?.FileType?.Name ?? default
                };
            }));
        }