コード例 #1
0
        internal IndexedHashtable toChemHemSpecimens(string[] response, ref string fromDate, ref string toDate)
        {
            IndexedHashtable result = new IndexedHashtable(response.Length);

            for (int i = 0; i < response.Length; i++)
            {
                string[]    flds     = StringUtils.split(response[i], StringUtils.CARET);
                LabSpecimen specimen = new LabSpecimen();
                specimen.Id             = flds[0];
                specimen.ReportDate     = VistaTimestamp.toUtcString(flds[2]);
                specimen.CollectionDate = VistaTimestamp.toUtcString(flds[1]);
                if (i == 0)
                {
                    fromDate = specimen.CollectionDate;
                }
                if (i == response.Length - 1)
                {
                    toDate = specimen.CollectionDate;
                }
                specimen.Name            = flds[3];
                specimen.AccessionNumber = flds[4];
                if (flds.Length > 6)
                {
                    specimen.Site = flds[5];
                }
                if (flds.Length > 7)
                {
                    specimen.Facility = new SiteId(flds[7], flds[6]);
                }
                string key = flds[1] + '^' + flds[4];
                result.Add(key, specimen);
            }
            return(result);
        }
コード例 #2
0
        private LabTest BuildLabTest(LabSpecimen labSpecimen, LabTestName labTestNameCodedConcept)
        {
            var labTest = labSpecimen.AddLabTest(new LabTestInfoBuilder().WithLabTestName(labTestNameCodedConcept));

            Session.SaveOrUpdate(labTest);
            return(labTest);
        }
コード例 #3
0
        public void CreateLabSpecimen_GivenValidArguments_CreatesLabSpecimen()
        {
            var activityType          = new Mock <ActivityType>();
            var lookupValueRepository = new Mock <ILookupValueRepository>();

            lookupValueRepository
            .Setup(l => l.GetLookupByWellKnownName <ActivityType>(It.IsAny <string>()))
            .Returns(activityType.Object);

            var labSpecimenRepository = new Mock <ILabSpecimenRepository>();

            var labSpecimenFactory = new LabSpecimenFactory(
                labSpecimenRepository.Object,
                lookupValueRepository.Object);

            var visit        = new Mock <Visit>();
            var clinicalCase = new Mock <ClinicalCase>();
            var patient      = new Mock <Patient>();

            visit.Setup(v => v.ClinicalCase).Returns(clinicalCase.Object);
            clinicalCase.Setup(c => c.Patient).Returns(patient.Object);

            LabSpecimen labSpecimen = labSpecimenFactory.CreateLabSpecimen(visit.Object);

            Assert.IsNotNull(labSpecimen);
        }
コード例 #4
0
        private LabSpecimen BuildLabSpecimen(Visit visit,
                                             ActivityType activityType)
        {
            var labSpecimen = new LabSpecimen(visit, activityType);

            Session.SaveOrUpdate(labSpecimen);
            return(labSpecimen);
        }
コード例 #5
0
ファイル: LabSpecimenTO.cs プロジェクト: OSEHRA/mdws
 public LabSpecimenTO(LabSpecimen mdo)
 {
     this.id = mdo.Id;
     this.name = StringUtils.stripInvalidXmlCharacters(mdo.Name);
     this.collectionDate = mdo.CollectionDate;
     this.accessionNum = mdo.AccessionNumber;
     this.site = mdo.Site;
     if (mdo.Facility != null)
     {
         this.facility = new TaggedText(mdo.Facility.Name);
     }
 }
コード例 #6
0
ファイル: LabSpecimenTO.cs プロジェクト: monkeyglasses/mdws
 public LabSpecimenTO(LabSpecimen mdo)
 {
     this.id             = mdo.Id;
     this.name           = StringUtils.stripInvalidXmlCharacters(mdo.Name);
     this.collectionDate = mdo.CollectionDate;
     this.accessionNum   = mdo.AccessionNumber;
     this.site           = mdo.Site;
     if (mdo.Facility != null)
     {
         this.facility = new TaggedText(mdo.Facility.Name);
     }
 }
コード例 #7
0
ファイル: VistaChemHemDao.cs プロジェクト: OSEHRA/mdo
 internal IndexedHashtable toChemHemSpecimens(string[] response, ref string fromDate, ref string toDate)
 {
     IndexedHashtable result = new IndexedHashtable(response.Length);
     for (int i = 0; i < response.Length; i++)
     {
         string[] flds = StringUtils.split(response[i], StringUtils.CARET);
         LabSpecimen specimen = new LabSpecimen();
         specimen.Id = flds[0];
         specimen.ReportDate = VistaTimestamp.toUtcString(flds[2]);
         specimen.CollectionDate = VistaTimestamp.toUtcString(flds[1]);
         if (i == 0)
         {
             fromDate = specimen.CollectionDate;
         }
         if (i == response.Length-1)
         {
             toDate = specimen.CollectionDate;
         }
         specimen.Name = flds[3];
         specimen.AccessionNumber = flds[4];
         if (flds.Length > 6)
         {
             specimen.Site = flds[5];
         }
         if (flds.Length > 7)
         {
             specimen.Facility = new SiteId(flds[7], flds[6]);
         }
         string key = flds[1] + '^' + flds[4];
         result.Add(key, specimen);
     }
     return result;
 }
コード例 #8
0
ファイル: CdwChemHemDao.cs プロジェクト: govtmirror/RAPTOR-1
        internal ChemHemReport buildChemHemReport(IDataReader reader)
        {
            string patientIcn          = DbReaderUtil.getValue(reader, reader.GetOrdinal("PatientICN"));
            string testName            = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemTestName"));    // LabResult.LabTest.ShortName
            string resultValue         = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemResultValue")); // LabResult.Value
            string refHigh             = DbReaderUtil.getValue(reader, reader.GetOrdinal("RefHigh"));            // LabResult.LabTest.hiRef
            string refLow              = DbReaderUtil.getValue(reader, reader.GetOrdinal("RefLow"));             // LabResult.LabTest.lowRef
            string abnormal            = DbReaderUtil.getValue(reader, reader.GetOrdinal("Abnormal"));           // LabResult.BoundaryStatus
            string loinc               = DbReaderUtil.getValue(reader, reader.GetOrdinal("LOINC"));              // LabResult.LabTest.Loinc
            string component           = DbReaderUtil.getValue(reader, reader.GetOrdinal("Component"));          // LabResult.LabTest.Name
            string labTestType         = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabTestType"));        //LabResult.LabTest.Category
            string labChemTestSid      = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("LabChemTestSID"));
            string labChemTestIen      = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemTestIEN"));
            string labChemIen          = DbReaderUtil.getValue(reader, reader.GetOrdinal("LabChemIEN")); // LabTest.Id
            string labChemSid          = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("LabChemSID"));
            string siteCode            = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n"));
            string labChemCompleteDate = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("LabChemCompleteDateTime"));

            SiteId facility = new SiteId()
            {
                Id = siteCode
            };

            LabTest labTest = new LabTest()
            {
                Id        = labChemTestIen,
                Name      = testName,
                ShortName = labTestType,
                DataId    = labChemTestSid,
                HiRef     = refHigh,
                LowRef    = refLow,
                Loinc     = loinc
            };

            LabResult labResult = new LabResult()
            {
                Value          = resultValue,
                BoundaryStatus = abnormal,
                Test           = labTest
            };

            LabResult[] labResults = new LabResult[1];
            labResults[0] = labResult;

            LabSpecimen labSpecimen = new LabSpecimen()
            {
                Id             = labChemIen,
                Name           = DbReaderUtil.getValue(reader, reader.GetOrdinal("Specimen")),
                CollectionDate = labChemCompleteDate,
                Site           = siteCode
            };

            ChemHemReport report = new ChemHemReport()
            {
                Id        = labChemSid,
                Specimen  = labSpecimen,
                Facility  = facility,
                Results   = labResults,
                Timestamp = labChemCompleteDate
            };

            return(report);
        }
コード例 #9
0
        /*
         * In order to get the correct results with the correct reports using the DDR calls and RPCs
         * available, we are going to use the user specified fromDate but use today as the toDate (like
         * CPRS does) and retrieve all the specimens with in that time period. Then, we will find the
         * reports, match them up with their specimens and lastly filter those results using our original
         * date range
         */
        public ChemHemReport[] getChemHemReports(string dfn, string fromDate, string toDate)
        {
            if (!String.IsNullOrEmpty(toDate) && toDate.IndexOf(".") == -1)
            {
                toDate += ".235959";
            }

            IndexedHashtable specimens = getChemHemSpecimens(dfn, fromDate, toDate, "3");

            if (specimens == null || specimens.Count == 0)
            {
                return(null);
            }

            ArrayList lst = new ArrayList();
            //string nextDate = VistaTimestamp.fromUtcString(today);
            string nextDate = VistaTimestamp.fromUtcString(toDate);

            // Due to comment above, we want to loop through "ORWLRR INTERIMG" RPC until we
            // get as many reports as the DDR call above told us we would
            // TBD - this while statement screams infinite loop (i.e. what happens if we don't get all the
            // reports the DDR call above said we would?) Should we put an arbitrarily large stop in here?
            // e.g. if count > 1,000,000 then throw an exception that we didn't get what VistA said we should?
            int i = 0;

            while (lst.Count < specimens.Count)
            {
                LabSpecimen specimen = (LabSpecimen)specimens.GetValue(i);
                // ORWLRR INTERIMG rpc and function below updates nextDate for subsequent calls so LEAVE REF ALONE
                string        nextDateBefore = nextDate;
                ChemHemReport rpt            = getChemHemReport(dfn, ref nextDate);
                if (rpt != null)
                {
                    if ((rpt.Specimen != null) && (rpt.Specimen.AccessionNumber == specimen.AccessionNumber))
                    {
                        i++;
                        rpt.Id        = specimen.Id;
                        rpt.Facility  = specimen.Facility;
                        rpt.Specimen  = specimen;
                        rpt.Timestamp = specimen.ReportDate;
                        lst.Add(rpt);
                    }
                }
                // if the next date variable was not changed below, it means we are no longer looping through
                // the reports so we should go ahead and break out of this loop - should take care of
                // infinite loop concerns
                if (nextDate.Equals(nextDateBefore))
                {
                    break;
                }
            }
            // At last, filter the reports based on their timestamps
            ArrayList filteredList = new ArrayList();
            double    startDate    = Convert.ToDouble(fromDate);
            double    stopDate     = Convert.ToDouble(toDate);

            ChemHemReport[] rpts = (ChemHemReport[])lst.ToArray(typeof(ChemHemReport));
            foreach (ChemHemReport report in rpts)
            {
                // if the report doesn't have a timestamp, we will just add it to our list
                if (String.IsNullOrEmpty(report.Timestamp))
                {
                    filteredList.Add(report);
                    continue;
                }
                double reportTimeStamp = Convert.ToDouble(report.Timestamp);
                if (startDate <= reportTimeStamp && reportTimeStamp <= stopDate)
                {
                    filteredList.Add(report);
                }
            }
            return((ChemHemReport[])filteredList.ToArray(typeof(ChemHemReport)));
        }
コード例 #10
0
ファイル: SaveLabRequestHandler.cs プロジェクト: girish66/REM
        private bool MapProperties(LabSpecimenDto dto, LabSpecimen entity)
        {
            var labSpecimenType = _mappingHelper.MapLookupField <LabSpecimenType> (dto.LabSpecimenType);

            entity.ReviseLabSpecimenType(labSpecimenType);
            entity.ReviseLabReceivedDate(dto.LabReceivedDate);
            entity.ReviseCollectedHereIndicator(dto.CollectedHereIndicator);

            // TODO: This needs to be rethought when the domain for Lab is redone.
            var labTest = entity.LabTests.FirstOrDefault(lt => lt.LabTestInfo.LabTestName.WellKnownName == dto.LabTestName.WellKnownName);

            if (labTest == null && entity.LabTests.Count > 0)
            {
                //right now there is only every one lab test per lab specimen?
                entity.RemoveLabTest(entity.LabTests.ElementAt(0));
            }
            var labTestInfo = new LabTestInfoBuilder()
                              .WithLabTestName(_mappingHelper.MapLookupField <LabTestName> (dto.LabTestName))
                              .WithTestReportDate(dto.LabTestDate)
                              .WithLabTestNote(dto.LabTestNote);

            if (labTest == null)
            {
                labTest = entity.AddLabTest(labTestInfo);
            }
            else
            {
                labTest.ReviseLabTestInfo(labTestInfo);
            }

            var result = new AggregateNodeCollectionMapper <LabResultDto, LabTest, LabResult> (dto.LabResults, labTest, labTest.LabResults)
                         .MapAddedItem(
                (lrdto, lt) =>
            {
                CodedConcept labTestResultNameCodedConcept = null;
                if (lrdto.LabTestResultNameCodedConcept != null)
                {
                    labTestResultNameCodedConcept = new CodedConceptBuilder().WithCodedConceptDto(lrdto.LabTestResultNameCodedConcept);
                }

                lt.AddLabResult(
                    new LabResultBuilder()
                    .WithLabTestResultNameCodedConcept(labTestResultNameCodedConcept)
                    .WithValue(lrdto.Value)
                    .WithUnitOfMeasureCode(lrdto.UnitOfMeasureCode));
            }
                )
                         .MapChangedItem(
                (lrdto, lt, lr) =>
            {
                lt.RemoveLabResult(lr);
                CodedConcept labTestResultNameCodedConcept = null;
                if (lrdto.LabTestResultNameCodedConcept != null)
                {
                    labTestResultNameCodedConcept = new CodedConceptBuilder().WithCodedConceptDto(lrdto.LabTestResultNameCodedConcept);
                }
                lt.AddLabResult(
                    new LabResultBuilder()
                    .WithLabTestResultNameCodedConcept(labTestResultNameCodedConcept)
                    .WithValue(lrdto.Value)
                    .WithUnitOfMeasureCode(lrdto.UnitOfMeasureCode));
            })
                         .MapRemovedItem((lrdto, lt, lr) => lt.RemoveLabResult(lr))
                         .Map();

            return(result);
        }
コード例 #11
0
ファイル: SaveLabRequestHandler.cs プロジェクト: girish66/REM
 /// <summary>
 /// Processes the single aggregate.
 /// </summary>
 /// <param name="dto">The dto to process.</param>
 /// <param name="entity">The entity.</param>
 /// <returns>A <see cref="System.Boolean"/></returns>
 protected override bool ProcessSingleAggregate(LabSpecimenDto dto, LabSpecimen entity)
 {
     _mappingResult &= MapProperties(dto, entity);
     return(_mappingResult);
 }