private Entry CreateChemotherapyPartEntry(ChemotherapyPartPreviewViewModel model)
        {
            if (model == default)
            {
                throw new ArgumentNullException(nameof(model));
            }

            IEntryBuilder entryBuilder = EhrManager.EntryBuilder.Clear()
                                         .AddItems(
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.DiagnoseDate)).Build())
                .AddValue(EhrManager.DATEBuilder.Clear().AddDate(model.DiagnoseDate).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.ExpandDiagnose)).Build())
                .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.ExpandDiagnose).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.ECOG)).Build())
                .AddValue(EhrManager.INTBuilder.Clear().AddValue(model.ECOG).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Staging)).Build())
                .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.Staging).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.TNM)).Build())
                .AddValue(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(model.TNM).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.TherapyType)).Build())
                .AddValue(EhrManager.INTBuilder.Clear().AddValue(model.TherapyType).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.EvalAfterCycle)).Build())
                .AddValue(EhrManager.INTBuilder.Clear().AddValue(model.EvalAfterCycle).Build()).Build(),
                EhrManager.ElementBuilder.Clear()
                .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Interval)).Build())
                .AddValue(EhrManager.INTBuilder.Clear().AddValue(model.Interval).Build()).Build()
                );

            if (model.AddDiags != default && model.AddDiags.Count > 0)
            {
                entryBuilder.AddItems(model.AddDiags.Where(d => d != default).Select(d => CreateDiagCluster(d, nameof(model.AddDiags))).ToArray());
            }

            if (model.Histology != default)
            {
                entryBuilder.AddItems(CreateHistologyCluster(model.Histology, nameof(model.Histology)));
            }

            if (model.GenMarkers != default && model.GenMarkers.Count > 0)
            {
                entryBuilder.AddItems(model.GenMarkers
                                      .Where(gm => gm != default)
                                      .Select(gm => CreateGenMarkerCluster(gm, nameof(model.GenMarkers))).ToArray());
            }

            if (model.Evaluation != default && model.Evaluation.Choices != default && model.Evaluation.Choices.Count > 0)
            {
                Cluster[] choiceCluster = model.Evaluation.Choices.Where(c => c != default).Select(c => CreateChoiceCluster(c, nameof(model.Evaluation.Choices))).ToArray();

                entryBuilder.AddItems(EhrManager.ClusterBuilder.Clear()
                                      .AddName(EhrManager.SimpleTextBuilder.Clear().AddOriginalText(nameof(model.Evaluation)).Build())
                                      .AddParts(choiceCluster)
                                      .Build());
            }

            return(entryBuilder.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,
                };
            }));
        }