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); }
internal Appointment[] toAppointmentsFromDataReader(IDataReader reader) { IList <Appointment> appointments = new List <Appointment>(); try { while (reader.Read()) { string id = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("AppointmentSID")); string sta3n = DbReaderUtil.getInt16Value(reader, reader.GetOrdinal("Sta3n")); string appointmentDateTime = DbReaderUtil.getDateTimeValue(reader, reader.GetOrdinal("AppointmentDateTime")); string purposeOfVisit = DbReaderUtil.getValue(reader, reader.GetOrdinal("PurposeOfVisit")); 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 visitId = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("VisitSID")); string providerName = providerNameIfAvailable(reader); SiteId facility = new SiteId(sta3n, institutionName); HospitalLocation hospitalLocation = new HospitalLocation(); hospitalLocation.Name = locationName; hospitalLocation.StopCode = new KeyValuePair <string, string>("Primary", primaryStopCode); hospitalLocation.Type = medicalService; Appointment appointment = new Appointment() { Id = id, VisitId = visitId, Clinic = hospitalLocation, Timestamp = appointmentDateTime, Purpose = purposeOfVisit, Facility = facility, ProviderName = providerName }; appointments.Add(appointment); } } catch (Exception) { } finally { reader.Close(); } return(appointments.ToArray <Appointment>()); }
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 Problem[] toProblemList(IDataReader reader) { IList <Problem> problemResults = new List <Problem>(); try { while (reader.Read()) { string sta3n = DbReaderUtil.getValue(reader, reader.GetOrdinal("Facility")); SiteId siteId = new SiteId(sta3n); string status = DbReaderUtil.getValue(reader, reader.GetOrdinal("ActiveFlag")); string enteredDate = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("EnteredDate")); string onsetDate = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("OnsetDate")); string modifiedDate = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("LastModifiedDate")); string resolvedDate = DbReaderUtil.getDateValue(reader, reader.GetOrdinal("ResolvedDate")); string priority = DbReaderUtil.getValue(reader, reader.GetOrdinal("Priority")); string icd = DbReaderUtil.getValue(reader, reader.GetOrdinal("ICDDescription")); string icdCode = DbReaderUtil.getValue(reader, reader.GetOrdinal("ICDCode")); string providerNarrative = DbReaderUtil.getValue(reader, reader.GetOrdinal("ProviderNarrative")); string id = DbReaderUtil.getInt64Value(reader, reader.GetOrdinal("ProblemListSID")); string majorDiagnosticCategory = DbReaderUtil.getValue(reader, reader.GetOrdinal("MDC")); Problem problem = new Problem() { Facility = siteId, Status = status, OnsetDate = enteredDate, ModifiedDate = modifiedDate, ResolvedDate = resolvedDate, Priority = priority, NoteNarrative = icd, Id = id, ProviderNarrative = providerNarrative }; problemResults.Add(problem); } } catch (Exception) { } finally { reader.Close(); } return(problemResults.ToArray <Problem>()); }
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>()); }
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); }