Exemple #1
0
        internal VitalSign buildVitalSign(IDataReader reader)
        {
            SiteId facility = new SiteId()
            {
                Id   = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n")),
                Name = DbReaderUtil.getValue(reader, reader.GetOrdinal("Location"))
            };

            string          id        = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("VitalSignSID"));
            string          dateTaken = DbReaderUtil.getDateTimeValue(reader, reader.GetOrdinal("VitalSignTakenDateTime"));
            string          vitalType = DbReaderUtil.getValue(reader, reader.GetOrdinal("VitalType"));
            string          typeId    = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("VitalTypeSID"));
            ObservationType type      = new ObservationType(typeId, VitalSign.VITAL_SIGN, vitalType);

            VitalSign vitalSign = new VitalSign()
            {
                Id        = id,
                Facility  = facility,
                Type      = type,
                Value1    = DbReaderUtil.getValue(reader, reader.GetOrdinal("Result")),
                Timestamp = dateTaken
            };

            return(vitalSign);
        }
Exemple #2
0
        public Site createSiteFromAllInstitutionsReader(IDataReader reader)
        {
            string id             = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("InstitutionSID"));
            string code           = DbReaderUtil.getValue(reader, reader.GetOrdinal("InstitutionCode"));
            string name           = DbReaderUtil.getValue(reader, reader.GetOrdinal("InstitutionName"));
            string type           = DbReaderUtil.getValue(reader, reader.GetOrdinal("FacilityType"));
            string sta3n          = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n"));
            string streetAddress1 = DbReaderUtil.getValue(reader, reader.GetOrdinal("StreetAddress1"));
            string streetAddress2 = DbReaderUtil.getValue(reader, reader.GetOrdinal("StreetAddress2"));
            string city           = DbReaderUtil.getValue(reader, reader.GetOrdinal("City"));
            string state          = DbReaderUtil.getValue(reader, reader.GetOrdinal("StateAbbrev"));
            string zipCode        = DbReaderUtil.getValue(reader, reader.GetOrdinal("Zip"));

            string address = formatAddress(streetAddress1, streetAddress2, city, state, zipCode);

            Site site = new Site()
            {
                Id           = id,
                Name         = name,
                SystemName   = code,
                ParentSiteId = sta3n,
                SiteType     = type,
                Address      = address,
                City         = city,
                State        = state,
            };

            return(site);
        }
        internal User[] toUsers(IDataReader reader)
        {
            List <User> users = new List <User>();

            while (reader.Read())
            {
                string id              = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("StaffSID"));
                string sta3n           = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n"));
                string networkUsername = DbReaderUtil.getValue(reader, reader.GetOrdinal("NetworkUsername"));
                string positionTitle   = DbReaderUtil.getValue(reader, reader.GetOrdinal("PositionTitle"));
                string firstName       = DbReaderUtil.getValue(reader, reader.GetOrdinal("FirstName"));
                string lastName        = DbReaderUtil.getValue(reader, reader.GetOrdinal("LastName"));
                string prefix          = DbReaderUtil.getValue(reader, reader.GetOrdinal("StaffNamePrefix"));
                string suffix          = DbReaderUtil.getValue(reader, reader.GetOrdinal("StaffNameSuffix"));
                string officePhone     = DbReaderUtil.getValue(reader, reader.GetOrdinal("OfficePhone"));
                string phone3          = DbReaderUtil.getValue(reader, reader.GetOrdinal("Phone3"));
                string phone4          = DbReaderUtil.getValue(reader, reader.GetOrdinal("Phone4"));
                string voicePager      = DbReaderUtil.getValue(reader, reader.GetOrdinal("VoicePager"));
                string digitalPager    = DbReaderUtil.getValue(reader, reader.GetOrdinal("DigitalPager"));
                string emailAddress    = DbReaderUtil.getValue(reader, reader.GetOrdinal("EmailAddress"));
                //string signatureBlockTitle = DbReaderUtil.getValue(reader, reader.GetOrdinal("SignatureBlockTitle"));
                //string faxNumber = DbReaderUtil.getValue(reader, reader.GetOrdinal("FaxNumber"));

                SiteId siteId = new SiteId()
                {
                    Id = sta3n
                };

                PersonName personName = new PersonName()
                {
                    Firstname = firstName,
                    Lastname  = lastName,
                    Prefix    = prefix,
                    Suffix    = suffix
                };

                User user = new User()
                {
                    Name         = personName,
                    UserName     = networkUsername,
                    EmailAddress = emailAddress,
                    VoicePager   = voicePager,
                    DigitalPager = digitalPager,
                    Phone        = officePhone,
                    Title        = positionTitle,
                    LogonSiteId  = siteId
                };
                users.Add(user);
            }

            return(users.ToArray <User>());
        }
        internal Medication[] toMeds(IDataReader reader)
        {
            IList <Medication> results = new List <Medication>();

            while (reader.Read())
            {
                string facility         = DbReaderUtil.getValue(reader, reader.GetOrdinal("Facility"));
                string sta3n            = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n"));
                string id               = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("RxOutpatSID"));
                string status           = DbReaderUtil.getValue(reader, reader.GetOrdinal("RxStatus"));
                string drugNameWithDose = DbReaderUtil.getValue(reader, reader.GetOrdinal("LocalDrugNameWithDose"));
                string issueDate        = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("IssueDate"));
                string rxNumber         = DbReaderUtil.getValue(reader, reader.GetOrdinal("RxNumber"));
                string refills          = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("MaxRefills"));
                string patientIcn       = DbReaderUtil.getValue(reader, reader.GetOrdinal("PatientICN"));
                string sig              = DbReaderUtil.getValue(reader, reader.GetOrdinal("Sig"));
                string daysSupply       = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("DaysSupply"));
                string quantity         = DbReaderUtil.getValue(reader, reader.GetOrdinal("Qty"));
                string lastFilledDate   = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("LastFillDate"));
                string expriationDate   = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("ExpirationDate"));

                SiteId site = new SiteId()
                {
                    Name = facility,
                    Id   = sta3n
                };

                Medication med = new Medication()
                {
                    Facility       = site,
                    Id             = id,
                    Drug           = new KeyValuePair <string, string>(id, drugNameWithDose),
                    Name           = drugNameWithDose,
                    RxNumber       = rxNumber,
                    IssueDate      = issueDate,
                    LastFillDate   = lastFilledDate,
                    Refills        = refills,
                    Status         = status,
                    Sig            = sig,
                    ExpirationDate = expriationDate,
                    Quantity       = quantity,
                    DaysSupply     = daysSupply
                };

                results.Add(med);
            }
            return(results.ToArray <Medication>());
        }
        internal MentalHealthInstrumentResultSet toMentalHealthInstrumentResultSet(IDataReader reader)
        {
            MentalHealthInstrumentResultSet result = new MentalHealthInstrumentResultSet()
            {
                Scale               = new KeyValuePair <string, string>("Scale", DbReaderUtil.getValue(reader, reader.GetOrdinal("SurveyScale"))),
                RawScore            = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("RawScore")),
                Id                  = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("SurveyResultSID")),
                Instrument          = new KeyValuePair <string, string>("Instrument", DbReaderUtil.getValue(reader, reader.GetOrdinal("SurveyName"))),
                AdministrationId    = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("SurveyAdministrationSID")),
                SurveyGivenDateTime = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("SurveyGivenDateTime")),
                SurveySavedDateTime = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("SurveySavedDateTime"))
            };

            result.TransformedScores.Add("1", DbReaderUtil.getValue(reader, reader.GetOrdinal("TransformedScore1")));
            result.TransformedScores.Add("2", DbReaderUtil.getValue(reader, reader.GetOrdinal("TransformedScore2")));
            result.TransformedScores.Add("3", DbReaderUtil.getValue(reader, reader.GetOrdinal("TransformedScore3")));

            return(result);
        }
        internal MentalHealthInstrumentAdministration toMentalHealthInstrumentAdministration(IDataReader reader)
        {
            MentalHealthInstrumentAdministration instrumentAdministration = new MentalHealthInstrumentAdministration()
            {
                Id                        = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("SurveyAdministrationSID")),
                Patient                   = new KeyValuePair <string, string>("", DbReaderUtil.getValue(reader, reader.GetOrdinal("PatientICN"))),
                Instrument                = new KeyValuePair <string, string>("", DbReaderUtil.getValue(reader, reader.GetOrdinal("SurveyName"))),
                DateAdministered          = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("SurveyGivenDateTime")),
                DateSaved                 = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("SurveySavedDateTime")),
                OrderedBy                 = new KeyValuePair <string, string>("", DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("OrderedBySID"))),
                AdministeredBy            = new KeyValuePair <string, string>("", DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("AdministeredBySID"))),
                IsSigned                  = DbReaderUtil.getBooleanFromYNValue(reader, reader.GetOrdinal("IsSignedFlag")),
                IsComplete                = DbReaderUtil.getBooleanFromYNValue(reader, reader.GetOrdinal("IsCompleteFlag")),
                NumberOfQuestionsAnswered = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("NumberOfQuestionsAnswered")),
                TransmissionStatus        = DbReaderUtil.getValue(reader, reader.GetOrdinal("TransmissionStatus")),
                TransmissionTime          = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("TransmisionTime")),
                HospitalLocation          = new KeyValuePair <string, string>("", DbReaderUtil.getValue(reader, reader.GetOrdinal("Facility")))
            };

            return(instrumentAdministration);
        }
Exemple #7
0
        internal Visit[] toVisitsFromDataReader(IDataReader reader)
        {
            IList <Visit> visits = new List <Visit>();

            try
            {
                while (reader.Read())
                {
                    string providerSid = DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("ProviderSID"));
                    //ignore record if we don't have valid provider
                    if (!String.IsNullOrEmpty(providerSid))
                    {
                        string id                = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("VisitSID"));
                        string sta3n             = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n"));
                        string visitDateTime     = DbReaderUtil.getDateTimeValue(reader, reader.GetOrdinal("VisitDateTime"));
                        string locationName      = DbReaderUtil.getValue(reader, reader.GetOrdinal("LocationName"));
                        string primaryStopCode   = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("PrimaryStopCode"));
                        string secondaryStopCode = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("SecondaryStopCode"));
                        string institutionName   = DbReaderUtil.getValue(reader, reader.GetOrdinal("InstitutionName"));
                        string locationType      = DbReaderUtil.getValue(reader, reader.GetOrdinal("LocationType"));
                        string medicalService    = DbReaderUtil.getValue(reader, reader.GetOrdinal("MedicalService"));
                        string firstName         = getStringValue(reader, "FirstName");
                        string lastName          = getStringValue(reader, "LastName");
                        string prefix            = getStringValue(reader, "StaffNamePrefix");
                        string suffix            = getStringValue(reader, "StaffNameSuffix");
                        string providerClass     = getStringValue(reader, "ProviderClass");

                        SiteId facility = new SiteId(sta3n, institutionName);

                        HospitalLocation hospitalLocation = new HospitalLocation()
                        {
                            Name     = locationName,
                            StopCode = new KeyValuePair <string, string>("Primary", primaryStopCode),
                            Type     = locationType
                        };

                        PersonName name = new PersonName()
                        {
                            Firstname = firstName,
                            Lastname  = lastName,
                            Prefix    = prefix,
                            Suffix    = suffix
                        };

                        User provider = new User()
                        {
                            Name          = name,
                            ProviderClass = providerClass,
                            UserClass     = providerClass
                        };

                        Visit visit = new Visit()
                        {
                            Id        = id,
                            Location  = hospitalLocation,
                            Timestamp = visitDateTime,
                            Facility  = facility,
                            Provider  = provider,
                            Service   = medicalService
                        };

                        visits.Add(visit);
                    }
                }
            }
            catch (Exception) { }
            finally
            {
                reader.Close();
            }
            return(visits.ToArray <Visit>());
        }
Exemple #8
0
        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);
        }