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 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 String providerNameIfAvailable(IDataReader reader) { string providerName = ""; try { providerName = DbReaderUtil.getValue(reader, reader.GetOrdinal("StaffName")); } catch (Exception) { } // ignore return(providerName); }
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 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 SurgeryReport toSurgeryReport(IDataReader reader) { SiteId facility = new SiteId() { Id = DbReaderUtil.getValue(reader, reader.GetOrdinal("station__no")) }; SurgeryReport report = new SurgeryReport() { Id = DbReaderUtil.getValue(reader, reader.GetOrdinal("id")), Title = DbReaderUtil.getValue(reader, reader.GetOrdinal("principal_procedure")), Timestamp = DbReaderUtil.getValue(reader, reader.GetOrdinal("dt")), Facility = facility }; return(report); }
internal IList <Immunization> toImmunizations(IDataReader reader) { IList <Immunization> immunizations = new List <Immunization>(); while (reader.Read()) { //Int32 immSid = (string)DbReaderUtil.getInt32Value(reader, reader.GetOrdinal("ImmunizationSID")); string immIen = reader.GetString(reader.GetOrdinal("ImmunizationIEN")); Int16 sitecode = reader.GetInt16(reader.GetOrdinal("Sta3n")); string patientIen = DbReaderUtil.getValue(reader, reader.GetOrdinal("PatientIEN")); //string patientSid = getValue(reader, reader.GetOrdinal("PatientSID")); string immunizationName = DbReaderUtil.getValue(reader, reader.GetOrdinal("ImmunizationName")); string immunizationShortName = DbReaderUtil.getValue(reader, reader.GetOrdinal("ImmunizationShortName")); string inactive = DbReaderUtil.getValue(reader, reader.GetOrdinal("ImmunizationInactiveFlag")); string series = DbReaderUtil.getValue(reader, reader.GetOrdinal("Series")); string reaction = DbReaderUtil.getValue(reader, reader.GetOrdinal("Reaction")); string contraindicated = DbReaderUtil.getValue(reader, reader.GetOrdinal("ContraindicatedFlag")); DateTime eventDateTime = reader.IsDBNull(reader.GetOrdinal("EventDateTime")) ? new DateTime() : reader.GetDateTime(reader.GetOrdinal("EventDateTime")); DateTime visitDateTime = reader.IsDBNull(reader.GetOrdinal("VisitDateTime")) ? new DateTime() : reader.GetDateTime(reader.GetOrdinal("VisitDateTime")); DateTime immunizationDateTime = reader.IsDBNull(reader.GetOrdinal("ImmunizationDateTime")) ? new DateTime() : reader.GetDateTime(reader.GetOrdinal("ImmunizationDateTime")); string orderedBy = DbReaderUtil.getValue(reader, reader.GetOrdinal("OrderingStaffIEN")); string comments = DbReaderUtil.getValue(reader, reader.GetOrdinal("Comments")); Immunization imm = new Immunization() { AdministeredDate = eventDateTime.ToString(), Comments = comments, Contraindicated = contraindicated, Encounter = new Visit() { Timestamp = visitDateTime.ToString(), Facility = new SiteId(sitecode.ToString()) }, Id = immIen, Name = immunizationName, OrderedBy = new User() { Uid = orderedBy }, Reaction = reaction, Series = series, ShortName = immunizationShortName }; } return(immunizations); }
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 RadiologyReport buildRadiologyReport(IDataReader reader) { SiteId facility = new SiteId() { Id = DbReaderUtil.getValue(reader, reader.GetOrdinal("station__no")) }; RadiologyReport report = new RadiologyReport() { Facility = facility, Id = DbReaderUtil.getValue(reader, reader.GetOrdinal("id")), Impression = DbReaderUtil.getValue(reader, reader.GetOrdinal("impressiontextwp")), Status = DbReaderUtil.getValue(reader, reader.GetOrdinal("report_status")), Text = DbReaderUtil.getValue(reader, reader.GetOrdinal("reporttextwp")), Title = DbReaderUtil.getValue(reader, reader.GetOrdinal("procedure102")), Timestamp = DbReaderUtil.getDateTimeValue(reader, reader.GetOrdinal("dt")), CaseNumber = DbReaderUtil.getValue(reader, reader.GetOrdinal("caseNumber")) }; return(report); }
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); }
internal Allergy toAllergy(IDataReader reader) { string facilityId = DbReaderUtil.getValue(reader, reader.GetOrdinal("station__no")); string id = DbReaderUtil.getValue(reader, reader.GetOrdinal("id")); string name = DbReaderUtil.getValue(reader, reader.GetOrdinal("reactant")); string timestamp = DbReaderUtil.getValue(reader, reader.GetOrdinal("dt")); string type = DbReaderUtil.getValue(reader, reader.GetOrdinal("allergy_type")); string reaction = DbReaderUtil.getValue(reader, reader.GetOrdinal("reaction")); string facilityName = DbReaderUtil.getValue(reader, reader.GetOrdinal("facility")); SiteId facility = new SiteId() { Id = facilityId, Name = facilityName }; Symptom symptom = new Symptom() { Name = reaction, Facility = facility, Timestamp = timestamp }; List <Symptom> symptoms = new List <Symptom>() { symptom }; Allergy allergy = new Allergy() { AllergenId = id, AllergenName = name, Timestamp = timestamp, AllergenType = type, Facility = facility, Reactions = symptoms }; return(allergy); }
internal string toNoteText(IDataReader reader) { string report = ""; try { while (reader.Read()) { string text = DbReaderUtil.getValue(reader, reader.GetOrdinal("ReportText")); string title = DbReaderUtil.getValue(reader, reader.GetOrdinal("TIUStandardTitle")); string date = DbReaderUtil.getDateTimeValue(reader, reader.GetOrdinal("EntryDateTime")); report = concatenateNote(report, text, title, date); } } catch (Exception) { } finally { reader.Close(); } return(report); }
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); }