Ejemplo n.º 1
0
 protected virtual List <SexOption> GetDefaultSexes() =>
 new List <SexOption>()
 {
     new SexOption()
     {
         Id = null, Name = MedicDataLocalization.Get(MedicDataLocalization.NoSelection)
     }
 };
Ejemplo n.º 2
0
 protected virtual List <HealthRegionOption> GetDefaultHealthRegions() =>
 new List <HealthRegionOption>()
 {
     new HealthRegionOption()
     {
         Id = null, Name = MedicDataLocalization.Get(MedicDataLocalization.NoSelection)
     }
 };
Ejemplo n.º 3
0
        public async Task <IActionResult> Index(PlannedSearch search, int page = 1)
        {
            try
            {
                PlannedWhereBuilder plannedWhereBuilder = new PlannedWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                List <PlannedPreviewViewModel> plannings = await GetPage(search, plannedWhereBuilder, searchParams, page);

                string plannedCountKey = $"{MedicConstants.Planned} - {searchParams}";

                if (!base.MedicCache.TryGetValue(plannedCountKey, out int planningsCount))
                {
                    planningsCount = await PlannedService
                                     .GetPlanningsCountAsync(plannedWhereBuilder);

                    base.MedicCache.Set(plannedCountKey, planningsCount);
                }

                List <SexOption> sexOptions = base.GetDefaultSexes();
                sexOptions.AddRange(await base.GetSexesAsync());

                List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions();
                healthRegions.AddRange(await base.GetHealthRegionsAsync());

                return(View(new PlannedPageIndexModel()
                {
                    Plannings = plannings,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.Plannings),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.Plannings),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.PlanningsSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, planningsCount),
                    TotalResults = planningsCount,
                    Sexes = sexOptions,
                    HealthRegions = healthRegions
                }));
            }
            catch (Exception ex)
            {
                Task <int> _ = MedicLoggerService.SaveAsync(new Log()
                {
                    Message = ex.Message,
                    InnerExceptionMessage = ex?.InnerException?.Message ?? null,
                    Source     = ex.Source,
                    StackTrace = ex.StackTrace,
                    Date       = DateTime.Now
                });

                throw ex;
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Index(TransferSearch search, int page = 1)
        {
            try
            {
                TransferWhereBuilder plannedWhereBuilder = new TransferWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                List <TransferPreviewViewModel> trasnfers = await GetPage(search, plannedWhereBuilder, searchParams, page);

                string trasnferCountKey = $"{MedicConstants.Transfers} - {searchParams}";

                if (!base.MedicCache.TryGetValue(trasnferCountKey, out int trasnfersCount))
                {
                    trasnfersCount = await TransferService
                                     .GetTrasnfersCountAsync(plannedWhereBuilder);

                    base.MedicCache.Set(trasnferCountKey, trasnfersCount);
                }

                return(View(new TransferPageIndexModel()
                {
                    Transfers = trasnfers,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.Transfers),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.Transfers),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.TransfersSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, trasnfersCount),
                    TotalResults = trasnfersCount
                }));
            }
            catch (Exception ex)
            {
                Task <int> _ = MedicLoggerService.SaveAsync(new Log()
                {
                    Message = ex.Message,
                    InnerExceptionMessage = ex?.InnerException?.Message ?? null,
                    Source     = ex.Source,
                    StackTrace = ex.StackTrace,
                    Date       = DateTime.Now
                });

                throw ex;
            }
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Planned(int id)
        {
            try
            {
                PlannedViewModel model;
                string           error = default;

                if (id < 1)
                {
                    model = default;
                    error = MedicDataLocalization.Get(MedicDataLocalization.InvalidId);
                }
                else
                {
                    model = await GetModelById(id);
                }

                return(View(new PlannedPagePlannedModel()
                {
                    Title = MedicDataLocalization.Get(MedicDataLocalization.Planned),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.Planned),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.PlannedSummary),
                    Planned = model,
                    Error = error
                }));
            }
            catch (Exception ex)
            {
                Task <int> _ = MedicLoggerService.SaveAsync(new Log()
                {
                    Message = ex.Message,
                    InnerExceptionMessage = ex?.InnerException?.Message ?? null,
                    Source     = ex.Source,
                    StackTrace = ex.StackTrace,
                    Date       = DateTime.Now
                });

                throw;
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Patient(int id)
        {
            try
            {
                PatientViewModel model;
                string           error;

                if (id < 1)
                {
                    model = default;
                    error = MedicDataLocalization.Get(MedicDataLocalization.InvalidId);
                }
                else
                {
                    model = await GetModelById(id);
                }

                return(View(new PatientPagePatientModel()
                {
                    Patient = model,
                    Title = PatientLocalization.Get(PatientLocalization.PatientData),
                    Description = PatientLocalization.Get(PatientLocalization.PatientData),
                    Keywords = PatientLocalization.Get(PatientLocalization.PatientViewMetaData),
                }));
            }
            catch (Exception ex)
            {
                Task <int> _ = MedicLoggerService.SaveAsync(new Log()
                {
                    Message = ex.Message,
                    InnerExceptionMessage = ex?.InnerException?.Message ?? null,
                    Source     = ex.Source,
                    StackTrace = ex.StackTrace,
                    Date       = DateTime.Now
                });

                throw;
            }
        }
        public async Task <IActionResult> Index(ProtocolDrugTherapySearch search, int page = 1)
        {
            try
            {
                ProtocolDrugTherapyWhereBuilder protocolDrugTherapyWhereBuilder = new ProtocolDrugTherapyWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                List <ProtocolDrugTherapyPreviewViewModel> protocolDrugTherapies = await GetPage(search, protocolDrugTherapyWhereBuilder, searchParams, page);

                string protocolDrugTherapiesCountKey = $"{MedicConstants.ProtocolDrugTherapies} - {searchParams}";

                if (!base.MedicCache.TryGetValue(protocolDrugTherapiesCountKey, out int protocolDrugTherapiesCount))
                {
                    protocolDrugTherapiesCount = await ProtocolDrugTherapyService
                                                 .GetProtocolDrugTherapiesCountAsync(protocolDrugTherapyWhereBuilder);

                    base.MedicCache.Set(protocolDrugTherapiesCountKey, protocolDrugTherapiesCount);
                }

                List <string> atcNames = new List <string>()
                {
                    default
                };

                if (!base.MedicCache.TryGetValue(MedicConstants.AtcNames, out List <string> addedAtcNames))
                {
                    addedAtcNames = await DrugProtocolService.GetDrugProtocolATCNames();

                    addedAtcNames.Sort((x, y) => x.CompareTo(y));

                    base.MedicCache.Set(MedicConstants.AtcNames, addedAtcNames);
                }

                atcNames.AddRange(addedAtcNames);

                List <SexOption> sexOptions = base.GetDefaultSexes();
                sexOptions.AddRange(await base.GetSexesAsync());

                List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions();
                healthRegions.AddRange(await base.GetHealthRegionsAsync());

                return(View(new ProtocolDrugTherapyPageIndexModel()
                {
                    ProtocolDrugTherapies = protocolDrugTherapies,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.ProtocolDrugTherapies),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.ProtocolDrugTherapies),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.ProtocolDrugTherapiesSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, protocolDrugTherapiesCount),
                    TotalResults = protocolDrugTherapiesCount,
                    Sexes = sexOptions,
                    HealthRegions = healthRegions,
                    ATCNames = atcNames
                }));
            }
            catch (Exception ex)
            {
                Task <int> _ = MedicLoggerService.SaveAsync(new Log()
                {
                    Message = ex.Message,
                    InnerExceptionMessage = ex?.InnerException?.Message ?? null,
                    Source     = ex.Source,
                    StackTrace = ex.StackTrace,
                    Date       = DateTime.Now
                });

                throw;
            }
        }
Ejemplo n.º 8
0
 public IActionResult CPFile() => View(new FileUploadPageCPFile()
 {
     Title       = MedicDataLocalization.Get(MedicDataLocalization.CPFile),
     Description = MedicDataLocalization.Get(MedicDataLocalization.CPFile),
     Keywords    = MedicDataLocalization.Get(MedicDataLocalization.CPFileSummary)
 });
Ejemplo n.º 9
0
        public async Task <IActionResult> Index(OutSearch search, int page = 1)
        {
            try
            {
                OutWhereBuilder outWhereBuilder = new OutWhereBuilder(search);

                string searchParams = search != default ? search.ToString() : default;

                string outsCountKey = $"{MedicConstants.OutsCount} - {searchParams}";

                List <OutPreviewViewModel> outs = await GetPage(search, outWhereBuilder, searchParams, page);

                if (!base.MedicCache.TryGetValue(outsCountKey, out int outsCount))
                {
                    outsCount = await OutService.GetOutsCountAsync(outWhereBuilder);

                    base.MedicCache.Set(outsCountKey, outsCount);
                }

                List <SexOption> sexOptions = base.GetDefaultSexes();
                sexOptions.AddRange(await base.GetSexesAsync());

                List <HealthRegionOption> healthRegions = base.GetDefaultHealthRegions();
                healthRegions.AddRange(await base.GetHealthRegionsAsync());

                List <UsedDrugCodeOption> usedDrugs = new List <UsedDrugCodeOption>()
                {
                    new UsedDrugCodeOption()
                    {
                        Key = string.Empty, Code = MedicDataLocalization.Get(MedicDataLocalization.NoSelection)
                    }
                };

                if (!MedicCache.TryGetValue(MedicConstants.UsedDrugs, out List <UsedDrugCodeOption> drugs))
                {
                    drugs = await UsedDrugService.UsedDrugsByCodeAsync();

                    MedicCache.Set(MedicConstants.UsedDrugs, drugs);
                }

                usedDrugs.AddRange(drugs);

                return(View(new OutPageIndexModel()
                {
                    Outs = outs,
                    Title = MedicDataLocalization.Get(MedicDataLocalization.OutsView),
                    Description = MedicDataLocalization.Get(MedicDataLocalization.OutsView),
                    Keywords = MedicDataLocalization.Get(MedicDataLocalization.OutsSummary),
                    Search = search,
                    CurrentPage = page,
                    TotalPages = base.TotalPages((int)search.Length, outsCount),
                    TotalResults = outsCount,
                    Sexes = sexOptions,
                    UsedDrugCodes = usedDrugs,
                    HealthRegions = healthRegions
                }));
            }
            catch (Exception ex)
            {
                Task <int> _ = MedicLoggerService.SaveAsync(new Log()
                {
                    Message = ex.Message,
                    InnerExceptionMessage = ex?.InnerException?.Message ?? null,
                    Source     = ex.Source,
                    StackTrace = ex.StackTrace,
                    Date       = DateTime.Now
                });

                throw;
            }
        }