Ejemplo n.º 1
0
        public List <PubMlstMatchInfo> Match(FromToQuery fromTo)
        {
            var matches = new List <PubMlstMatchInfo>();

            var matchingIsolates = _db.MeningoIsolates.Include(i => i.Sending).Where(i =>
                                                                                     i.Sending.SamplingDate == null && i.Sending.ReceivingDate >= fromTo.From && i.Sending.ReceivingDate <= fromTo.To ||
                                                                                     i.Sending.SamplingDate >= fromTo.From && i.Sending.SamplingDate <= fromTo.To).ToList();

            foreach (var isolate in matchingIsolates)
            {
                var pubMlstMatchInfo = new PubMlstMatchInfo
                {
                    IsolateId        = isolate.MeningoIsolateId,
                    StemNumber       = isolate.StemNumberWithPrefix,
                    LaboratoryNumber = isolate.LaboratoryNumberWithPrefix
                };
                var pubMlstIsolate =
                    isolate.StemNumber.HasValue
                        ? _pubMlstService.GetIsolateByReference(isolate.StemNumberWithPrefix)
                        : null;

                if (pubMlstIsolate != null)
                {
                    pubMlstIsolate = CreateOrUpdatePubMlstIsolate(isolate, pubMlstIsolate);
                    _db.MarkAsModified(isolate);
                    _db.SaveChanges();

                    pubMlstMatchInfo.NeisseriaPubMlstIsolateId = pubMlstIsolate.NeisseriaPubMlstIsolateId;
                    pubMlstMatchInfo.PubMlstId = pubMlstIsolate.PubMlstId;
                }

                matches.Add(pubMlstMatchInfo);
            }
            return(matches);
        }
Ejemplo n.º 2
0
        private ExportDefinition <Sender> CreateExportDefinition(FromToQuery query)
        {
            var export   = new ExportDefinition <Sender>();
            var sendings = db.Sendings.Include(s => s.Isolate).Where
                               (s => (s.SamplingDate == null && s.ReceivingDate >= query.From && s.ReceivingDate <= query.To) ||
                               (s.SamplingDate >= query.From && s.SamplingDate <= query.To)).ToList();

            Func <Sender, long>   senderSendingCount      = sender => sendings.Count(s => sender.SenderId == s.SenderId);
            Func <Sender, String> senderLaboratoryNumbers =
                sender => String.Join(",", sendings.Where(s => sender.SenderId == s.SenderId).Select(s => s.Isolate.LaboratoryNumber));
            Func <Sender, String> senderStemNumbers =
                sender => String.Join(",", sendings.Where(s => sender.SenderId == s.SenderId).Select(s => s.Isolate.StemNumber.HasValue ? s.Isolate.StemNumber.ToString() : "-"));

            export.AddField(s => s.SenderId);
            export.AddField(s => s.Name);
            export.AddField(s => s.Department);
            export.AddField(s => s.StreetWithNumber);
            export.AddField(s => s.PostalCode);
            export.AddField(s => s.City);
            export.AddField(s => s.Phone1);
            export.AddField(s => s.Phone2);
            export.AddField(s => s.Fax);
            export.AddField(s => s.Email);
            export.AddField(s => s.Remark);
            export.AddField(s => senderSendingCount(s), "Anzahl Einsendungen");
            export.AddField(s => senderStemNumbers(s), "Stammnummern");
            export.AddField(s => senderLaboratoryNumbers(s), "Labornummern");

            return(export);
        }
Ejemplo n.º 3
0
        protected override IEnumerable <Sending> SendingsMatchingExportQuery(FromToQuery query, ExportType exportType)
        {
            var samplingLocations = exportType == ExportType.Rki || exportType == ExportType.Iris
                ? new List <SamplingLocation> {
                SamplingLocation.Blood, SamplingLocation.Liquor
            }
                : new List <SamplingLocation> {
                SamplingLocation.Blood, SamplingLocation.Liquor, SamplingLocation.Other
            };

            var filteredSendings = NotDeletedSendings()
                                   .Include(s => s.Patient)
                                   .Where
                                       (s => samplingLocations.Contains(s.SamplingLocation) &&
                                       ((s.SamplingDate == null && s.ReceivingDate >= query.From && s.ReceivingDate <= query.To) ||
                                        (s.SamplingDate >= query.From && s.SamplingDate <= query.To))
                                       );

            if (exportType == ExportType.Iris)
            {
                var overseas = EnumEditor.GetEnumDescription(State.Overseas);
                filteredSendings = filteredSendings.Where(s => !s.Patient.County.Equals(overseas));

                var nonHaemophilus = new List <Evaluation>
                {
                    Evaluation.HaemophilusParainfluenzae,
                    Evaluation.NoGrowth,
                    Evaluation.NoHaemophilusSpecies,
                    Evaluation.HaemophilusSpeciesNoHaemophilusInfluenzae,
                    Evaluation.NoHaemophilusInfluenzae
                };
                filteredSendings = filteredSendings.Where(s => !nonHaemophilus.Contains(s.Isolate.Evaluation));
            }
            return(filteredSendings.OrderBy(s => s.Isolate.StemNumber).ToList());
        }
Ejemplo n.º 4
0
        public ActionResult PubMlstMatch(FromToQuery fromTo)
        {
            var matcher = new PubMlstMatcher(db, new PubMlstService());
            var result  = matcher.Match(fromTo);

            return(View("PubMlstMatchResult", result));
        }
Ejemplo n.º 5
0
        protected ActionResult ExportToExcel <T>(FromToQuery query, List <T> list, ExportDefinition <T> exportDefinition,
                                                 string prefix, Action <DataTable> postProcessDataTable = null)
        {
            var tempFile = Path.GetTempFileName();

            CreateExcelFile.CreateExcelDocument(list, exportDefinition, tempFile, postProcessDataTable);
            return(File(System.IO.File.ReadAllBytes(tempFile),
                        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                        $"{prefix}-Export_{query.From:yyyyMMdd}-{query.To:yyyyMMdd}.xlsx"));
        }
Ejemplo n.º 6
0
        private List <Sender> SendersMatchingExportQuery(FromToQuery query)
        {
            var senderIds = db.Sendings.Where(s => !s.Deleted)
                            .Include(s => s.Patient)
                            .Where
                                (s => (s.SamplingDate == null && s.ReceivingDate >= query.From && s.ReceivingDate <= query.To) ||
                                (s.SamplingDate >= query.From && s.SamplingDate <= query.To))
                            .Select(s => s.SenderId)
                            .ToList();

            return(NotDeletedSenders().Where(s => senderIds.Contains(s.SenderId)).ToList());
        }
Ejemplo n.º 7
0
        public ActionResult LaboratoryExport(FromToQuery query)
        {
            if (query.From == DateTime.MinValue)
            {
                var lastYear    = DateTime.Now.Year - 1;
                var exportQuery = new FromToQuery
                {
                    From = new DateTime(lastYear, 1, 1),
                    To   = new DateTime(lastYear, 12, 31)
                };
                return(View(exportQuery));
            }

            var sendings = SendingsMatchingExportQuery(query, ExportType.Laboratory).ToList();

            return(ExportToExcel(query, sendings, CreateLaboratoryExportDefinition(), "Labor"));
        }
Ejemplo n.º 8
0
        public ActionResult IrisExport(FromToQuery query)
        {
            if (query.From == DateTime.MinValue)
            {
                var lastYear    = DateTime.Now.Year - 1;
                var exportQuery = new FromToQuery
                {
                    From = new DateTime(lastYear, 1, 1),
                    To   = new DateTime(lastYear, 12, 31)
                };
                return(View(exportQuery));
            }

            var sendings = SendingsMatchingExportQuery(query, ExportType.Iris).ToList();

            return(ExportToExcel(query, sendings, new MeningoSendingIrisExport(), "Iris"));
        }
Ejemplo n.º 9
0
        public ActionResult StateAuthorityExport(FromToQuery query)
        {
            if (query.From == DateTime.MinValue)
            {
                var lastYear    = DateTime.Now.Year - 1;
                var exportQuery = new FromToQueryWithAdjustment
                {
                    From = new DateTime(lastYear, 1, 1),
                    To   = new DateTime(lastYear, 12, 31)
                };
                return(View(exportQuery));
            }

            var sendings = SendingsMatchingExportQuery(query, ExportType.Rki).ToList();
            var counties = db.Counties.OrderBy(c => c.ValidSince).ToList();

            return(ExportToExcel(query, sendings, new MeningoStateAuthorityExport(counties), "LGA"));
        }
Ejemplo n.º 10
0
        protected override IEnumerable <MeningoSending> SendingsMatchingExportQuery(FromToQuery query, ExportType exportType)
        {
            var queryResult = NotDeletedSendings()
                              .Include(s => s.Patient)
                              .Include(s => s.Isolate)
                              .Include(s => s.Isolate.NeisseriaPubMlstIsolate)
                              .Where
                                  (s => (s.SamplingDate == null && s.ReceivingDate >= query.From && s.ReceivingDate <= query.To) ||
                                  (s.SamplingDate >= query.From && s.SamplingDate <= query.To)
                                  ).OrderBy(s => s.Isolate.StemNumber).ToList();

            if (exportType == ExportType.Iris || exportType == ExportType.Rki)
            {
                queryResult = queryResult.Where(s => s.Invasive == YesNo.Yes && MeningococciFound(s)).ToList();
            }

            return(queryResult);
        }
Ejemplo n.º 11
0
 protected abstract IEnumerable <TSending> SendingsMatchingExportQuery(FromToQuery query, ExportType additionalFilters);