diff --git a/OmopTransformer/SUS/Staging/SusAPCParser.cs b/OmopTransformer/SUS/Staging/SusAPCParser.cs index bc3c2f1..a3b3964 100644 --- a/OmopTransformer/SUS/Staging/SusAPCParser.cs +++ b/OmopTransformer/SUS/Staging/SusAPCParser.cs @@ -30,219 +30,219 @@ public IEnumerable ReadFile(string path, CancellationToken cancellati var record = new APC { MessageId = messageId, - GeneratedRecordIdentifier = csv.GetField("Generated Record Identifier"), - PBRSpellID = csv.GetField("PBR Spell ID"), - ReasonForAccess = csv.GetField("Reason for Access"), - CDSType = csv.GetField("CDS type"), - ProtocolIdentifier = csv.GetField("Protocol identifier"), - UniqueCDSIdentifier = csv.GetField("Unique CDS identifier"), - UpdateType = csv.GetField("Update type"), - BulkReplacementCDSGroup = csv.GetField("Bulk replacement CDS group"), - TestIndicator = csv.GetField("Test indicator"), - ApplicableDatetime = csv.GetField("Applicable date/time"), - CensusDate = csv.GetField("Census date"), - ExtractDatetime = csv.GetField("Extract date/time"), - ReportPeriodStartDate = csv.GetField("Report period Start Date"), - ReportPeriodEndDate = csv.GetField("Report period End Date"), - OrganisationCodeSenderOfTransaction = csv.GetField("Organisation code: Sender of transaction"), - OrganisationCodeTypeofSender = csv.GetField("Organisation Code Type of Sender"), - SubmissionDate = csv.GetField("Submission Date"), - CDSInterchangeID = csv.GetField("CDS Interchange ID"), - LocalPatientIdentifier = csv.GetField("Local Patient Identifier"), - OrganisationCodeLocalPatientIdentifier = csv.GetField("Organisation Code (Local Patient Identifier)"), - OrganisationCodeTypeLocalPatientIdentifier = csv.GetField("Organisation Code Type (Local Patient Identifier)"), - NHSNumber = csv.GetField("NHS Number"), - DateofBirth = csv.GetField("Date of Birth"), - BirthWeight = csv.GetField("Birth Weight"), - LiveOrStillBirth = csv.GetField("Live or Still Birth"), - CarerSupportIndicator = csv.GetField("Carer Support Indicator"), - LegalStatusClassificationOnAdmissionPsychiatricCensusOnly = csv.GetField("Legal Status Classification on Admission (Psychiatric Census Only)"), - EthnicGroup = csv.GetField("Ethnic Group"), - MaritalStatusPsychiatricCensusOnly = csv.GetField("Marital Status (Psychiatric Census Only)"), - NHSNumberTraceStatus = csv.GetField("NHS Number Trace Status"), - WithheldIdentityReason = csv.GetField("Withheld Identity Reason"), - Sex = csv.GetField("Sex"), - PregnancyTotalPreviousPregnancies = csv.GetField("Pregnancy Total Previous Pregnancies"), - NameFormatCode = csv.GetField("Name Format Code"), - PatientName = csv.GetField("Patient Name"), - PersonTitle = csv.GetField("Person Title"), - PersonGivenName = csv.GetField("Person Given Name"), - PersonFamilyName = csv.GetField("Person Family Name"), - PersonNameSuffix = csv.GetField("Person Name Suffix"), - PersonInitials = csv.GetField("Person Initials"), - AddressFormatCode = csv.GetField("Address Format Code"), - PatientUsualAddress = csv.GetField("Patient Usual Address"), - Postcode = csv.GetField("Postcode"), - OrganisationCodeResidenceResponsibility = csv.GetField("Organisation Code (Residence Responsibility)"), - PCTofResidence = csv.GetField("PCT of Residence"), - OrganisationCodeTypePCTofResidence = csv.GetField("Organisation Code Type (PCT of Residence)"), - OSVClassificationatCDSActivityDate = csv.GetField("OSV Classification at CDS Activity Date"), - HospitalProviderSpellNumber = csv.GetField("Hospital Provider Spell Number"), - AdministrativeCategory = csv.GetField("Administrative Category"), - PatientClassification = csv.GetField("Patient Classification"), - AdmissionMethodHospitalProviderSpell = csv.GetField("Admission Method (Hospital Provider Spell)"), - DischargeDestinationHospitalProviderSpell = csv.GetField("Discharge Destination (Hospital Provider Spell)"), - DischargeMethodHospitalProviderSpell = csv.GetField("Discharge Method (Hospital Provider Spell)"), - SourceOfAdmissionHospitalProviderSpell = csv.GetField("Source of Admission (Hospital Provider Spell)"), - StartDateHospitalProviderSpell = csv.GetField("Start Date (Hospital Provider Spell)"), - StartTimeHospitalProviderSpell = csv.GetField("Start Time (Hospital Provider Spell)"), - DischargeDateFromHospitalProviderSpell = csv.GetField("Discharge Date (From Hospital Provider Spell)"), - DischargeTimeHospitalProviderSpell = csv.GetField("Discharge Time (Hospital Provider Spell)"), - DischargeToHospitalAtHomeServiceIndicator = csv.GetField("Discharge To Hospital At Home Service Indicator"), - EpisodeNumber = csv.GetField("Episode Number"), - FirstRegularDayNightAdmission = csv.GetField("First Regular Day Night Admission"), - LastEpisodeInSpellIndicator = csv.GetField("Last Episode In Spell Indicator"), - NeonatalLevelOfCare = csv.GetField("Neonatal Level of Care"), - OperationStatus = csv.GetField("Operation Status"), - PsychiatricPatientStatus = csv.GetField("Psychiatric Patient Status"), - StartDateConsultantEpisode = csv.GetField("Start Date (Consultant Episode)"), - StartTimeEpisode = csv.GetField("Start Time (Episode)"), - EndDateConsultantEpisode = csv.GetField("End Date (Consultant Episode)"), - EndTimeEpisode = csv.GetField("End Time (Episode)"), - LengthOfStayAdjustmentRehabilitation = csv.GetField("Length Of Stay Adjustment (Rehabilitation)"), - LengthOfStayAdjustmentSpecialistPalliativeCare = csv.GetField("Length Of Stay Adjustment (Specialist Palliative Care)"), - CommissioningSerialNumber = csv.GetField("Commissioning Serial Number"), - NHSServiceAgreementLineNumber = csv.GetField("NHS Service Agreement Line Number"), - ProviderReferenceNumber = csv.GetField("Provider Reference Number"), - CommissionerReferenceNumber = csv.GetField("Commissioner Reference Number"), - OrganisationCodeCodeOfProvider = csv.GetField("Organisation Code Code of Provider"), - OrganisationCodeTypeOfProvider = csv.GetField("Organisation Code Type of Provider"), - OrganisationCodeCodeOfCommissioner = csv.GetField("Organisation Code Code of Commissioner"), - OrganisationCodeTypeofCommissioner = csv.GetField("Organisation Code Type of Commissioner"), - ConsultantCode = csv.GetField("Consultant Code"), - MainSpecialtyCode = csv.GetField("Main Specialty Code"), - TreatmentFunctionCode = csv.GetField("Treatment Function Code"), - LocalSubSpecialtyCode = csv.GetField("Local Sub Specialty Code"), - MultiProfessionalOrMultidisciplinaryIndCode = csv.GetField("Multi-Professional Or Multidisciplinary Ind Code"), - RehabilitationAssessmentTeamType = csv.GetField("Rehabilitation Assessment Team Type"), - DiagnosisSchemeInUseICD = csv.GetField("Diagnosis Scheme In Use (ICD)"), - DiagnosisSchemeInUseRead = csv.GetField("Diagnosis Scheme In Use (Read)"), - ProcedureSchemeInUseOPCS = csv.GetField("Procedure Scheme In Use (OPCS)"), - ProcedureSchemeInUseREAD = csv.GetField("Procedure Scheme In Use (READ)"), - WardCodeAtEpisodeStartDate = csv.GetField("Ward Code at Episode Start Date"), - WardSecurityLevelAtEpisodeStartDate = csv.GetField("Ward Security Level at Episode Start Date"), - LocationClassAtEpisodeStartDate = csv.GetField("Location Class at Episode Start Date"), - SiteCodeOfTreatmentAtEpisodeStartDate = csv.GetField("Site Code (of Treatment) At Episode Start Date"), - OrganisationCodeTypeSiteCodeOfTreatmentAtStartOfEpisode = csv.GetField("Organisation Code Type (Site Code of Treatment) (At Start of Episode)"), - IntendedClinicalCareIntensityAtStartOfEpisode = csv.GetField("Intended Clinical Care Intensity(At Start of Episode)"), - AgeGroupIntendedAtStartOfEpisode = csv.GetField("Age Group Intended (At Start of Episode)"), - SexOfPatientsAtStartOfEpisode = csv.GetField("Sex of Patients (At Start of Episode)"), - WardDayPeriodAvailability = csv.GetField("Ward Day Period Availability"), - WardNightPeriodAvailability = csv.GetField("Ward Night Period Availability"), - WardCodeAtEpisodeEndDate = csv.GetField("Ward Code at Episode End Date"), - WardSecurityLevelAtEpisodeEndDate = csv.GetField("Ward Security Level at Episode End Date"), - LocationClassAtEpisodeEndDate = csv.GetField("Location Class at Episode End Date"), - SiteCodeOfTreatmentAtEpisodeEndDate = csv.GetField("Site Code (of Treatment) at Episode End Date"), - OrganisationCodeTypeSiteCodeOfTreatmentAtEpisodeEndDate = csv.GetField("Organisation Code Type Site Code (of Treatment) at Episode End Date"), - IntendedClinicalCareIntensityAtEpisodeEndDate = csv.GetField("Intended Clinical Care Intensity at Episode End Date"), - AgeGroupIntendedAtEpisodeEndDate = csv.GetField("Age Group Intended at Episode End Date"), - SexOfPatientsAtEpisodeEndDate = csv.GetField("Sex of Patients at Episode End Date"), - WardDayPeriodAvailabilityAtEpisodeEndDate = csv.GetField("Ward Day Period Availability at Episode End Date"), - WardNightPeriodAvailabilityAtEpisodeEndDate = csv.GetField("Ward Night Period Availability at Episode End Date"), - GeneralMedicalPractitionerCodeofRegisteredGMP = csv.GetField("General Medical Practitioner Code of Registered GMP"), - PracticeCodeOfRegisteredGP = csv.GetField("Practice Code of Registered GP"), - OrganisationCodeTypeofRegisteredGP = csv.GetField("Organisation Code Type of Registered GP"), - ReferrerCode = csv.GetField("Referrer Code"), - ReferringOrganisationCode = csv.GetField("Referring Organisation Code"), - OrganisationCodeTypeofReferrer = csv.GetField("Organisation Code Type of Referrer"), - DirectAccessReferralIndicator = csv.GetField("Direct Access Referral Indicator"), - AmbulanceIncidentNumber = csv.GetField("Ambulance Incident Number"), - OrganisationCodeConveyingAmbulanceTrust = csv.GetField("Organisation Code (Conveying Ambulance Trust)"), - DurationofElectiveWait = csv.GetField("Duration of Elective Wait"), - IntendedManagement = csv.GetField("Intended Management"), - DecidedToAdmitDateForThisProvider = csv.GetField("Decided To Admit Date (For This Provider)"), - WaitingTimeMeasurementType = csv.GetField("Waiting Time Measurement Type"), - LocationTypeCodeAtStartOfEpisode = csv.GetField("Location Type Code at Start of Episode"), - HRGCode = csv.GetField("HRG Code"), - HRGVersionNumber = csv.GetField("HRG Version Number"), - ProcedureSchemeInUse = csv.GetField("Procedure Scheme In Use"), - DominantGroupingVariableProcedure = csv.GetField("Dominant Grouping Variable - Procedure"), - FCEHRG = csv.GetField("FCE HRG"), - EpisodeHRGVersionNumber = csv.GetField("Episode HRG Version Number"), - SpellCoreHRG = csv.GetField("Spell Core HRG"), - SpellHRGVersionNumber = csv.GetField("Spell HRG Version Number"), - NumberOfBabies = csv.GetField("Number of Babies"), - FirstAntenatalAssessmentDate = csv.GetField("First Antenatal Assessment Date"), - GMPCodeofGMPResponsibleforAntenatalCare = csv.GetField("GMP (Code of GMP Responsible for Antenatal Care)"), - CodeofGPPracticeRegisteredGMPAntenatalCare = csv.GetField("Code of GP Practice (Registered GMP- Antenatal Care)"), - OrganisationCodeTypeGPPracticeRegisteredGMPAntenatalCare = csv.GetField("Organisation Code Type GP Practice (Registered GMP- Antenatal Care)"), - LocationClassOfDeliveryPlaceIntended = csv.GetField("Location Class of Delivery Place (Intended)"), - LocationTypeofDeliveryPlaceIntended = csv.GetField("Location Type of Delivery Place (Intended)"), - DeliveryPlaceChangeReason = csv.GetField("Delivery Place Change Reason"), - DeliveryPlaceTypeIntended = csv.GetField("Delivery Place Type (Intended)"), - AnaestheticGivenDuringLabourDelivery = csv.GetField("Anaesthetic Given During Labour/Delivery"), - AnaestheticGivenPostDelivery = csv.GetField("Anaesthetic Given Post Delivery"), - GestationLengthLabourOnset = csv.GetField("Gestation Length (Labour Onset)"), - LabourDeliveryOnsetMethod = csv.GetField("Labour/Delivery Onset Method"), - DeliveryDate = csv.GetField("Delivery Date"), - GestationLengthAssessmentBaby = csv.GetField("Gestation Length (Assessment) Baby"), - LocalPatientIdentifierMother = csv.GetField("Local Patient Identifier (Mother)"), - OrganisationCodeLocalPatientIdentifierMother = csv.GetField("Organisation Code (Local Patient Identifier (Mother))"), - OrganisationCodeTypeMother = csv.GetField("Organisation Code Type (Mother)"), - NHSNumberMother = csv.GetField("NHS Number (Mother)"), - NHSNumberStatusIndicatorMother = csv.GetField("NHS Number Status Indicator (Mother)"), - BirthDateMother = csv.GetField("Birth Date (Mother)"), - AddressFormatCodeMother = csv.GetField("Address Format Code (Mother)"), - PatientUsualAddressMother = csv.GetField("Patient Usual Address (Mother)"), - PostcodeOfUsualAddressMother = csv.GetField("Postcode of Usual Address (Mother)"), - OrganisationCodePCTofResidenceMother = csv.GetField("Organisation Code (PCT of Residence) (Mother)"), - OrganisationCodeTypePCTofResidenceMother = csv.GetField("Organisation Code Type (PCT of Residence) (Mother)"), - UniqueBookingReferenceNumberConverted = csv.GetField("Unique Booking Reference Number Converted"), - PatientPathwayIdentifier = csv.GetField("Patient Pathway Identifier"), - OrganisationCodePatientPathwayIdentifierIssuer = csv.GetField("Organisation Code Patient Pathway Identifier Issuer"), - ReferralToTreatmentPeriodStatus = csv.GetField("Referral To Treatment Period Status"), - ReferralToTreatmentPeriodStartDate = csv.GetField("Referral To Treatment Period Start Date"), - ReferralToTreatmentPeriodEndDate = csv.GetField("Referral To Treatment Period End Date"), - LeadCareActivityIndicator = csv.GetField("Lead Care Activity Indicator"), - AgeatCDSActivityDate = csv.GetField("Age at CDS Activity Date"), - NHSServiceAgreementChangeDate = csv.GetField("NHS Service Agreement Change Date"), - CDSActivityDate = csv.GetField("CDS Activity Date"), - AgeAsOnAdmission = csv.GetField("Age as on Admission"), - AdminCategoryAtStart = csv.GetField("Admin Category at Start"), - HospitalProviderSpellDischargeReadyDate = csv.GetField("Hospital Provider Spell Discharge Ready Date"), - LocationType = csv.GetField("Location Type"), - XMLVersion = csv.GetField("XML Version"), - ConfidentialityCategoryDerived = csv.GetField("Confidentiality Category (Derived)"), - ReferralToTreatmentLengthDerived = csv.GetField("Referral To Treatment Length (Derived)"), - AgeRangePatientdDerivedFromDOB = csv.GetField("Age range patient derived from DOB"), - AgeRangeMotherDerivedFromDOB = csv.GetField("Age range mother derived from DOB"), - AreaCodeDerivedFromPostcode = csv.GetField("Area code derived from postcode."), - CDSGroup = csv.GetField("CDS Group"), - FinishedIndicator = csv.GetField("Finished Indicator"), - PCTDerivedfromGP = csv.GetField("PCT (Derived from GP)"), - PCTTypeDerivedfromGP = csv.GetField("PCT Type (Derived from GP)"), - GPPracticeDerived = csv.GetField("GP Practice (Derived)"), - GPPracticeMotherDerived = csv.GetField("GP Practice Mother (Derived)"), - PCTDerivedfromderivedGPPractice = csv.GetField("PCT (Derived from derived GP Practice)"), - PCTMotherDerivedfromderivedGPPractice = csv.GetField("PCT Mother (Derived from derived GP Practice)"), - SHAfromGPPractice = csv.GetField("SHA from GP Practice"), - SHATypefromGPPractice = csv.GetField("SHA Type from GP Practice"), - HospitalSpellDuration = csv.GetField("Hospital Spell Duration"), - MonthOfBirth = csv.GetField("Month of Birth"), - HomeBirthOrDelivery = csv.GetField("Home Birth or Delivery"), - ElectoralWardFromPostcode = csv.GetField("Electoral Ward from postcode"), - PCTFromPostcode = csv.GetField("PCT from postcode"), - PCTTypefromPostcode = csv.GetField("PCT Type from Postcode"), - SHAfromPostcode = csv.GetField("SHA from Postcode"), - SHATypefromPostcode = csv.GetField("SHA Type from Postcode"), - AreacodeFromProviderPostcode = csv.GetField("Area code from Provider Postcode"), - AgeAtEndOfEpisode = csv.GetField("Age at End of Episode"), - AgeAtStartOfEpisode = csv.GetField("Age at Start of Episode"), - YearOfBirth = csv.GetField("Year of Birth"), - YearOfBirthMother = csv.GetField("Year of Birth Mother"), - MonthOfBirthMother = csv.GetField("Month of Birth Mother"), - CensusArea = csv.GetField("2001 Census Area"), - Country = csv.GetField("Country"), - CountyCode = csv.GetField("County Code"), - CensusED = csv.GetField("1991 Census ED"), - EDDistrictCode = csv.GetField("ED District Code"), - ElectoralWardCode = csv.GetField("Electoral Ward Code"), - GORCode = csv.GetField("GOR Code"), - LocalUnitaryAuthority = csv.GetField("Local Unitary Authority"), - OldSHACode = csv.GetField("Old SHA Code"), - ElectoralArea = csv.GetField("1998 Electoral Area"), - PrimeRecipient = csv.GetField("Prime Recipient"), - CopyRecipients = csv.GetField("Copy Recipients"), + GeneratedRecordIdentifier = csv.GetField("Generated Record Identifier").GetTrimmedValueOrNull(), + PBRSpellID = csv.GetField("PBR Spell ID").GetTrimmedValueOrNull(), + ReasonForAccess = csv.GetField("Reason for Access").GetTrimmedValueOrNull(), + CDSType = csv.GetField("CDS type").GetTrimmedValueOrNull(), + ProtocolIdentifier = csv.GetField("Protocol identifier").GetTrimmedValueOrNull(), + UniqueCDSIdentifier = csv.GetField("Unique CDS identifier").GetTrimmedValueOrNull(), + UpdateType = csv.GetField("Update type").GetTrimmedValueOrNull(), + BulkReplacementCDSGroup = csv.GetField("Bulk replacement CDS group").GetTrimmedValueOrNull(), + TestIndicator = csv.GetField("Test indicator").GetTrimmedValueOrNull(), + ApplicableDatetime = csv.GetField("Applicable date/time").GetTrimmedValueOrNull(), + CensusDate = csv.GetField("Census date").GetTrimmedValueOrNull(), + ExtractDatetime = csv.GetField("Extract date/time").GetTrimmedValueOrNull(), + ReportPeriodStartDate = csv.GetField("Report period Start Date").GetTrimmedValueOrNull(), + ReportPeriodEndDate = csv.GetField("Report period End Date").GetTrimmedValueOrNull(), + OrganisationCodeSenderOfTransaction = csv.GetField("Organisation code: Sender of transaction").GetTrimmedValueOrNull(), + OrganisationCodeTypeofSender = csv.GetField("Organisation Code Type of Sender").GetTrimmedValueOrNull(), + SubmissionDate = csv.GetField("Submission Date").GetTrimmedValueOrNull(), + CDSInterchangeID = csv.GetField("CDS Interchange ID").GetTrimmedValueOrNull(), + LocalPatientIdentifier = csv.GetField("Local Patient Identifier").GetTrimmedValueOrNull(), + OrganisationCodeLocalPatientIdentifier = csv.GetField("Organisation Code (Local Patient Identifier)").GetTrimmedValueOrNull(), + OrganisationCodeTypeLocalPatientIdentifier = csv.GetField("Organisation Code Type (Local Patient Identifier)").GetTrimmedValueOrNull(), + NHSNumber = csv.GetField("NHS Number").GetTrimmedValueOrNull(), + DateofBirth = csv.GetField("Date of Birth").GetTrimmedValueOrNull(), + BirthWeight = csv.GetField("Birth Weight").GetTrimmedValueOrNull(), + LiveOrStillBirth = csv.GetField("Live or Still Birth").GetTrimmedValueOrNull(), + CarerSupportIndicator = csv.GetField("Carer Support Indicator").GetTrimmedValueOrNull(), + LegalStatusClassificationOnAdmissionPsychiatricCensusOnly = csv.GetField("Legal Status Classification on Admission (Psychiatric Census Only)").GetTrimmedValueOrNull(), + EthnicGroup = csv.GetField("Ethnic Group").GetTrimmedValueOrNull(), + MaritalStatusPsychiatricCensusOnly = csv.GetField("Marital Status (Psychiatric Census Only)").GetTrimmedValueOrNull(), + NHSNumberTraceStatus = csv.GetField("NHS Number Trace Status").GetTrimmedValueOrNull(), + WithheldIdentityReason = csv.GetField("Withheld Identity Reason").GetTrimmedValueOrNull(), + Sex = csv.GetField("Sex").GetTrimmedValueOrNull(), + PregnancyTotalPreviousPregnancies = csv.GetField("Pregnancy Total Previous Pregnancies").GetTrimmedValueOrNull(), + NameFormatCode = csv.GetField("Name Format Code").GetTrimmedValueOrNull(), + PatientName = csv.GetField("Patient Name").GetTrimmedValueOrNull(), + PersonTitle = csv.GetField("Person Title").GetTrimmedValueOrNull(), + PersonGivenName = csv.GetField("Person Given Name").GetTrimmedValueOrNull(), + PersonFamilyName = csv.GetField("Person Family Name").GetTrimmedValueOrNull(), + PersonNameSuffix = csv.GetField("Person Name Suffix").GetTrimmedValueOrNull(), + PersonInitials = csv.GetField("Person Initials").GetTrimmedValueOrNull(), + AddressFormatCode = csv.GetField("Address Format Code").GetTrimmedValueOrNull(), + PatientUsualAddress = csv.GetField("Patient Usual Address").GetTrimmedValueOrNull(), + Postcode = csv.GetField("Postcode").GetTrimmedValueOrNull(), + OrganisationCodeResidenceResponsibility = csv.GetField("Organisation Code (Residence Responsibility)").GetTrimmedValueOrNull(), + PCTofResidence = csv.GetField("PCT of Residence").GetTrimmedValueOrNull(), + OrganisationCodeTypePCTofResidence = csv.GetField("Organisation Code Type (PCT of Residence)").GetTrimmedValueOrNull(), + OSVClassificationatCDSActivityDate = csv.GetField("OSV Classification at CDS Activity Date").GetTrimmedValueOrNull(), + HospitalProviderSpellNumber = csv.GetField("Hospital Provider Spell Number").GetTrimmedValueOrNull(), + AdministrativeCategory = csv.GetField("Administrative Category").GetTrimmedValueOrNull(), + PatientClassification = csv.GetField("Patient Classification").GetTrimmedValueOrNull(), + AdmissionMethodHospitalProviderSpell = csv.GetField("Admission Method (Hospital Provider Spell)").GetTrimmedValueOrNull(), + DischargeDestinationHospitalProviderSpell = csv.GetField("Discharge Destination (Hospital Provider Spell)").GetTrimmedValueOrNull(), + DischargeMethodHospitalProviderSpell = csv.GetField("Discharge Method (Hospital Provider Spell)").GetTrimmedValueOrNull(), + SourceOfAdmissionHospitalProviderSpell = csv.GetField("Source of Admission (Hospital Provider Spell)").GetTrimmedValueOrNull(), + StartDateHospitalProviderSpell = csv.GetField("Start Date (Hospital Provider Spell)").GetTrimmedValueOrNull(), + StartTimeHospitalProviderSpell = csv.GetField("Start Time (Hospital Provider Spell)").GetTrimmedValueOrNull(), + DischargeDateFromHospitalProviderSpell = csv.GetField("Discharge Date (From Hospital Provider Spell)").GetTrimmedValueOrNull(), + DischargeTimeHospitalProviderSpell = csv.GetField("Discharge Time (Hospital Provider Spell)").GetTrimmedValueOrNull(), + DischargeToHospitalAtHomeServiceIndicator = csv.GetField("Discharge To Hospital At Home Service Indicator").GetTrimmedValueOrNull(), + EpisodeNumber = csv.GetField("Episode Number").GetTrimmedValueOrNull(), + FirstRegularDayNightAdmission = csv.GetField("First Regular Day Night Admission").GetTrimmedValueOrNull(), + LastEpisodeInSpellIndicator = csv.GetField("Last Episode In Spell Indicator").GetTrimmedValueOrNull(), + NeonatalLevelOfCare = csv.GetField("Neonatal Level of Care").GetTrimmedValueOrNull(), + OperationStatus = csv.GetField("Operation Status").GetTrimmedValueOrNull(), + PsychiatricPatientStatus = csv.GetField("Psychiatric Patient Status").GetTrimmedValueOrNull(), + StartDateConsultantEpisode = csv.GetField("Start Date (Consultant Episode)").GetTrimmedValueOrNull(), + StartTimeEpisode = csv.GetField("Start Time (Episode)").GetTrimmedValueOrNull(), + EndDateConsultantEpisode = csv.GetField("End Date (Consultant Episode)").GetTrimmedValueOrNull(), + EndTimeEpisode = csv.GetField("End Time (Episode)").GetTrimmedValueOrNull(), + LengthOfStayAdjustmentRehabilitation = csv.GetField("Length Of Stay Adjustment (Rehabilitation)").GetTrimmedValueOrNull(), + LengthOfStayAdjustmentSpecialistPalliativeCare = csv.GetField("Length Of Stay Adjustment (Specialist Palliative Care)").GetTrimmedValueOrNull(), + CommissioningSerialNumber = csv.GetField("Commissioning Serial Number").GetTrimmedValueOrNull(), + NHSServiceAgreementLineNumber = csv.GetField("NHS Service Agreement Line Number").GetTrimmedValueOrNull(), + ProviderReferenceNumber = csv.GetField("Provider Reference Number").GetTrimmedValueOrNull(), + CommissionerReferenceNumber = csv.GetField("Commissioner Reference Number").GetTrimmedValueOrNull(), + OrganisationCodeCodeOfProvider = csv.GetField("Organisation Code Code of Provider").GetTrimmedValueOrNull(), + OrganisationCodeTypeOfProvider = csv.GetField("Organisation Code Type of Provider").GetTrimmedValueOrNull(), + OrganisationCodeCodeOfCommissioner = csv.GetField("Organisation Code Code of Commissioner").GetTrimmedValueOrNull(), + OrganisationCodeTypeofCommissioner = csv.GetField("Organisation Code Type of Commissioner").GetTrimmedValueOrNull(), + ConsultantCode = csv.GetField("Consultant Code").GetTrimmedValueOrNull(), + MainSpecialtyCode = csv.GetField("Main Specialty Code").GetTrimmedValueOrNull(), + TreatmentFunctionCode = csv.GetField("Treatment Function Code").GetTrimmedValueOrNull(), + LocalSubSpecialtyCode = csv.GetField("Local Sub Specialty Code").GetTrimmedValueOrNull(), + MultiProfessionalOrMultidisciplinaryIndCode = csv.GetField("Multi-Professional Or Multidisciplinary Ind Code").GetTrimmedValueOrNull(), + RehabilitationAssessmentTeamType = csv.GetField("Rehabilitation Assessment Team Type").GetTrimmedValueOrNull(), + DiagnosisSchemeInUseICD = csv.GetField("Diagnosis Scheme In Use (ICD)").GetTrimmedValueOrNull(), + DiagnosisSchemeInUseRead = csv.GetField("Diagnosis Scheme In Use (Read)").GetTrimmedValueOrNull(), + ProcedureSchemeInUseOPCS = csv.GetField("Procedure Scheme In Use (OPCS)").GetTrimmedValueOrNull(), + ProcedureSchemeInUseREAD = csv.GetField("Procedure Scheme In Use (READ)").GetTrimmedValueOrNull(), + WardCodeAtEpisodeStartDate = csv.GetField("Ward Code at Episode Start Date").GetTrimmedValueOrNull(), + WardSecurityLevelAtEpisodeStartDate = csv.GetField("Ward Security Level at Episode Start Date").GetTrimmedValueOrNull(), + LocationClassAtEpisodeStartDate = csv.GetField("Location Class at Episode Start Date").GetTrimmedValueOrNull(), + SiteCodeOfTreatmentAtEpisodeStartDate = csv.GetField("Site Code (of Treatment) At Episode Start Date").GetTrimmedValueOrNull(), + OrganisationCodeTypeSiteCodeOfTreatmentAtStartOfEpisode = csv.GetField("Organisation Code Type (Site Code of Treatment) (At Start of Episode)").GetTrimmedValueOrNull(), + IntendedClinicalCareIntensityAtStartOfEpisode = csv.GetField("Intended Clinical Care Intensity(At Start of Episode)").GetTrimmedValueOrNull(), + AgeGroupIntendedAtStartOfEpisode = csv.GetField("Age Group Intended (At Start of Episode)").GetTrimmedValueOrNull(), + SexOfPatientsAtStartOfEpisode = csv.GetField("Sex of Patients (At Start of Episode)").GetTrimmedValueOrNull(), + WardDayPeriodAvailability = csv.GetField("Ward Day Period Availability").GetTrimmedValueOrNull(), + WardNightPeriodAvailability = csv.GetField("Ward Night Period Availability").GetTrimmedValueOrNull(), + WardCodeAtEpisodeEndDate = csv.GetField("Ward Code at Episode End Date").GetTrimmedValueOrNull(), + WardSecurityLevelAtEpisodeEndDate = csv.GetField("Ward Security Level at Episode End Date").GetTrimmedValueOrNull(), + LocationClassAtEpisodeEndDate = csv.GetField("Location Class at Episode End Date").GetTrimmedValueOrNull(), + SiteCodeOfTreatmentAtEpisodeEndDate = csv.GetField("Site Code (of Treatment) at Episode End Date").GetTrimmedValueOrNull(), + OrganisationCodeTypeSiteCodeOfTreatmentAtEpisodeEndDate = csv.GetField("Organisation Code Type Site Code (of Treatment) at Episode End Date").GetTrimmedValueOrNull(), + IntendedClinicalCareIntensityAtEpisodeEndDate = csv.GetField("Intended Clinical Care Intensity at Episode End Date").GetTrimmedValueOrNull(), + AgeGroupIntendedAtEpisodeEndDate = csv.GetField("Age Group Intended at Episode End Date").GetTrimmedValueOrNull(), + SexOfPatientsAtEpisodeEndDate = csv.GetField("Sex of Patients at Episode End Date").GetTrimmedValueOrNull(), + WardDayPeriodAvailabilityAtEpisodeEndDate = csv.GetField("Ward Day Period Availability at Episode End Date").GetTrimmedValueOrNull(), + WardNightPeriodAvailabilityAtEpisodeEndDate = csv.GetField("Ward Night Period Availability at Episode End Date").GetTrimmedValueOrNull(), + GeneralMedicalPractitionerCodeofRegisteredGMP = csv.GetField("General Medical Practitioner Code of Registered GMP").GetTrimmedValueOrNull(), + PracticeCodeOfRegisteredGP = csv.GetField("Practice Code of Registered GP").GetTrimmedValueOrNull(), + OrganisationCodeTypeofRegisteredGP = csv.GetField("Organisation Code Type of Registered GP").GetTrimmedValueOrNull(), + ReferrerCode = csv.GetField("Referrer Code").GetTrimmedValueOrNull(), + ReferringOrganisationCode = csv.GetField("Referring Organisation Code").GetTrimmedValueOrNull(), + OrganisationCodeTypeofReferrer = csv.GetField("Organisation Code Type of Referrer").GetTrimmedValueOrNull(), + DirectAccessReferralIndicator = csv.GetField("Direct Access Referral Indicator").GetTrimmedValueOrNull(), + AmbulanceIncidentNumber = csv.GetField("Ambulance Incident Number").GetTrimmedValueOrNull(), + OrganisationCodeConveyingAmbulanceTrust = csv.GetField("Organisation Code (Conveying Ambulance Trust)").GetTrimmedValueOrNull(), + DurationofElectiveWait = csv.GetField("Duration of Elective Wait").GetTrimmedValueOrNull(), + IntendedManagement = csv.GetField("Intended Management").GetTrimmedValueOrNull(), + DecidedToAdmitDateForThisProvider = csv.GetField("Decided To Admit Date (For This Provider)").GetTrimmedValueOrNull(), + WaitingTimeMeasurementType = csv.GetField("Waiting Time Measurement Type").GetTrimmedValueOrNull(), + LocationTypeCodeAtStartOfEpisode = csv.GetField("Location Type Code at Start of Episode").GetTrimmedValueOrNull(), + HRGCode = csv.GetField("HRG Code").GetTrimmedValueOrNull(), + HRGVersionNumber = csv.GetField("HRG Version Number").GetTrimmedValueOrNull(), + ProcedureSchemeInUse = csv.GetField("Procedure Scheme In Use").GetTrimmedValueOrNull(), + DominantGroupingVariableProcedure = csv.GetField("Dominant Grouping Variable - Procedure").GetTrimmedValueOrNull(), + FCEHRG = csv.GetField("FCE HRG").GetTrimmedValueOrNull(), + EpisodeHRGVersionNumber = csv.GetField("Episode HRG Version Number").GetTrimmedValueOrNull(), + SpellCoreHRG = csv.GetField("Spell Core HRG").GetTrimmedValueOrNull(), + SpellHRGVersionNumber = csv.GetField("Spell HRG Version Number").GetTrimmedValueOrNull(), + NumberOfBabies = csv.GetField("Number of Babies").GetTrimmedValueOrNull(), + FirstAntenatalAssessmentDate = csv.GetField("First Antenatal Assessment Date").GetTrimmedValueOrNull(), + GMPCodeofGMPResponsibleforAntenatalCare = csv.GetField("GMP (Code of GMP Responsible for Antenatal Care)").GetTrimmedValueOrNull(), + CodeofGPPracticeRegisteredGMPAntenatalCare = csv.GetField("Code of GP Practice (Registered GMP- Antenatal Care)").GetTrimmedValueOrNull(), + OrganisationCodeTypeGPPracticeRegisteredGMPAntenatalCare = csv.GetField("Organisation Code Type GP Practice (Registered GMP- Antenatal Care)").GetTrimmedValueOrNull(), + LocationClassOfDeliveryPlaceIntended = csv.GetField("Location Class of Delivery Place (Intended)").GetTrimmedValueOrNull(), + LocationTypeofDeliveryPlaceIntended = csv.GetField("Location Type of Delivery Place (Intended)").GetTrimmedValueOrNull(), + DeliveryPlaceChangeReason = csv.GetField("Delivery Place Change Reason").GetTrimmedValueOrNull(), + DeliveryPlaceTypeIntended = csv.GetField("Delivery Place Type (Intended)").GetTrimmedValueOrNull(), + AnaestheticGivenDuringLabourDelivery = csv.GetField("Anaesthetic Given During Labour/Delivery").GetTrimmedValueOrNull(), + AnaestheticGivenPostDelivery = csv.GetField("Anaesthetic Given Post Delivery").GetTrimmedValueOrNull(), + GestationLengthLabourOnset = csv.GetField("Gestation Length (Labour Onset)").GetTrimmedValueOrNull(), + LabourDeliveryOnsetMethod = csv.GetField("Labour/Delivery Onset Method").GetTrimmedValueOrNull(), + DeliveryDate = csv.GetField("Delivery Date").GetTrimmedValueOrNull(), + GestationLengthAssessmentBaby = csv.GetField("Gestation Length (Assessment) Baby").GetTrimmedValueOrNull(), + LocalPatientIdentifierMother = csv.GetField("Local Patient Identifier (Mother)").GetTrimmedValueOrNull(), + OrganisationCodeLocalPatientIdentifierMother = csv.GetField("Organisation Code (Local Patient Identifier (Mother))").GetTrimmedValueOrNull(), + OrganisationCodeTypeMother = csv.GetField("Organisation Code Type (Mother)").GetTrimmedValueOrNull(), + NHSNumberMother = csv.GetField("NHS Number (Mother)").GetTrimmedValueOrNull(), + NHSNumberStatusIndicatorMother = csv.GetField("NHS Number Status Indicator (Mother)").GetTrimmedValueOrNull(), + BirthDateMother = csv.GetField("Birth Date (Mother)").GetTrimmedValueOrNull(), + AddressFormatCodeMother = csv.GetField("Address Format Code (Mother)").GetTrimmedValueOrNull(), + PatientUsualAddressMother = csv.GetField("Patient Usual Address (Mother)").GetTrimmedValueOrNull(), + PostcodeOfUsualAddressMother = csv.GetField("Postcode of Usual Address (Mother)").GetTrimmedValueOrNull(), + OrganisationCodePCTofResidenceMother = csv.GetField("Organisation Code (PCT of Residence) (Mother)").GetTrimmedValueOrNull(), + OrganisationCodeTypePCTofResidenceMother = csv.GetField("Organisation Code Type (PCT of Residence) (Mother)").GetTrimmedValueOrNull(), + UniqueBookingReferenceNumberConverted = csv.GetField("Unique Booking Reference Number Converted").GetTrimmedValueOrNull(), + PatientPathwayIdentifier = csv.GetField("Patient Pathway Identifier").GetTrimmedValueOrNull(), + OrganisationCodePatientPathwayIdentifierIssuer = csv.GetField("Organisation Code Patient Pathway Identifier Issuer").GetTrimmedValueOrNull(), + ReferralToTreatmentPeriodStatus = csv.GetField("Referral To Treatment Period Status").GetTrimmedValueOrNull(), + ReferralToTreatmentPeriodStartDate = csv.GetField("Referral To Treatment Period Start Date").GetTrimmedValueOrNull(), + ReferralToTreatmentPeriodEndDate = csv.GetField("Referral To Treatment Period End Date").GetTrimmedValueOrNull(), + LeadCareActivityIndicator = csv.GetField("Lead Care Activity Indicator").GetTrimmedValueOrNull(), + AgeatCDSActivityDate = csv.GetField("Age at CDS Activity Date").GetTrimmedValueOrNull(), + NHSServiceAgreementChangeDate = csv.GetField("NHS Service Agreement Change Date").GetTrimmedValueOrNull(), + CDSActivityDate = csv.GetField("CDS Activity Date").GetTrimmedValueOrNull(), + AgeAsOnAdmission = csv.GetField("Age as on Admission").GetTrimmedValueOrNull(), + AdminCategoryAtStart = csv.GetField("Admin Category at Start").GetTrimmedValueOrNull(), + HospitalProviderSpellDischargeReadyDate = csv.GetField("Hospital Provider Spell Discharge Ready Date").GetTrimmedValueOrNull(), + LocationType = csv.GetField("Location Type").GetTrimmedValueOrNull(), + XMLVersion = csv.GetField("XML Version").GetTrimmedValueOrNull(), + ConfidentialityCategoryDerived = csv.GetField("Confidentiality Category (Derived)").GetTrimmedValueOrNull(), + ReferralToTreatmentLengthDerived = csv.GetField("Referral To Treatment Length (Derived)").GetTrimmedValueOrNull(), + AgeRangePatientdDerivedFromDOB = csv.GetField("Age range patient derived from DOB").GetTrimmedValueOrNull(), + AgeRangeMotherDerivedFromDOB = csv.GetField("Age range mother derived from DOB").GetTrimmedValueOrNull(), + AreaCodeDerivedFromPostcode = csv.GetField("Area code derived from postcode.").GetTrimmedValueOrNull(), + CDSGroup = csv.GetField("CDS Group").GetTrimmedValueOrNull(), + FinishedIndicator = csv.GetField("Finished Indicator").GetTrimmedValueOrNull(), + PCTDerivedfromGP = csv.GetField("PCT (Derived from GP)").GetTrimmedValueOrNull(), + PCTTypeDerivedfromGP = csv.GetField("PCT Type (Derived from GP)").GetTrimmedValueOrNull(), + GPPracticeDerived = csv.GetField("GP Practice (Derived)").GetTrimmedValueOrNull(), + GPPracticeMotherDerived = csv.GetField("GP Practice Mother (Derived)").GetTrimmedValueOrNull(), + PCTDerivedfromderivedGPPractice = csv.GetField("PCT (Derived from derived GP Practice)").GetTrimmedValueOrNull(), + PCTMotherDerivedfromderivedGPPractice = csv.GetField("PCT Mother (Derived from derived GP Practice)").GetTrimmedValueOrNull(), + SHAfromGPPractice = csv.GetField("SHA from GP Practice").GetTrimmedValueOrNull(), + SHATypefromGPPractice = csv.GetField("SHA Type from GP Practice").GetTrimmedValueOrNull(), + HospitalSpellDuration = csv.GetField("Hospital Spell Duration").GetTrimmedValueOrNull(), + MonthOfBirth = csv.GetField("Month of Birth").GetTrimmedValueOrNull(), + HomeBirthOrDelivery = csv.GetField("Home Birth or Delivery").GetTrimmedValueOrNull(), + ElectoralWardFromPostcode = csv.GetField("Electoral Ward from postcode").GetTrimmedValueOrNull(), + PCTFromPostcode = csv.GetField("PCT from postcode").GetTrimmedValueOrNull(), + PCTTypefromPostcode = csv.GetField("PCT Type from Postcode").GetTrimmedValueOrNull(), + SHAfromPostcode = csv.GetField("SHA from Postcode").GetTrimmedValueOrNull(), + SHATypefromPostcode = csv.GetField("SHA Type from Postcode").GetTrimmedValueOrNull(), + AreacodeFromProviderPostcode = csv.GetField("Area code from Provider Postcode").GetTrimmedValueOrNull(), + AgeAtEndOfEpisode = csv.GetField("Age at End of Episode").GetTrimmedValueOrNull(), + AgeAtStartOfEpisode = csv.GetField("Age at Start of Episode").GetTrimmedValueOrNull(), + YearOfBirth = csv.GetField("Year of Birth").GetTrimmedValueOrNull(), + YearOfBirthMother = csv.GetField("Year of Birth Mother").GetTrimmedValueOrNull(), + MonthOfBirthMother = csv.GetField("Month of Birth Mother").GetTrimmedValueOrNull(), + CensusArea = csv.GetField("2001 Census Area").GetTrimmedValueOrNull(), + Country = csv.GetField("Country").GetTrimmedValueOrNull(), + CountyCode = csv.GetField("County Code").GetTrimmedValueOrNull(), + CensusED = csv.GetField("1991 Census ED").GetTrimmedValueOrNull(), + EDDistrictCode = csv.GetField("ED District Code").GetTrimmedValueOrNull(), + ElectoralWardCode = csv.GetField("Electoral Ward Code").GetTrimmedValueOrNull(), + GORCode = csv.GetField("GOR Code").GetTrimmedValueOrNull(), + LocalUnitaryAuthority = csv.GetField("Local Unitary Authority").GetTrimmedValueOrNull(), + OldSHACode = csv.GetField("Old SHA Code").GetTrimmedValueOrNull(), + ElectoralArea = csv.GetField("1998 Electoral Area").GetTrimmedValueOrNull(), + PrimeRecipient = csv.GetField("Prime Recipient").GetTrimmedValueOrNull(), + CopyRecipients = csv.GetField("Copy Recipients").GetTrimmedValueOrNull(), }; int index = 46; diff --git a/OmopTransformer/StringExtensions.cs b/OmopTransformer/StringExtensions.cs index 9e9705e..f60d6ba 100644 --- a/OmopTransformer/StringExtensions.cs +++ b/OmopTransformer/StringExtensions.cs @@ -35,6 +35,8 @@ public static bool IsEmpty(this string text) { text = text.TrimWhitespace(); + text = text?.TrimEnd(new char[] { '\r', '\n' }) ?? null; + if (string.IsNullOrEmpty(text)) return null; diff --git a/OmopTransformerTests/Transformation/StringExtensionsTest.cs b/OmopTransformerTests/Transformation/StringExtensionsTest.cs new file mode 100644 index 0000000..ed8a0b9 --- /dev/null +++ b/OmopTransformerTests/Transformation/StringExtensionsTest.cs @@ -0,0 +1,61 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using OmopTransformer; + +[TestClass] +public class StringExtensionsTests +{ + [TestMethod] + public void SubstringOrNull_ValidInput_ReturnsCorrectSubstring() + { + string text = "Hello World"; + var result = text.SubstringOrNull(1, 5); + Assert.AreEqual("ello", result); + } + + [TestMethod] + public void SubstringOrNull_WhitespaceOnly_ReturnsNull() + { + string text = " "; + var result = text.SubstringOrNull(1, 2); + Assert.IsNull(result); + } + + [TestMethod] + [ExpectedException(typeof(ArgumentNullException))] + public void SubstringOrNull_NullInput_ThrowsArgumentNullException() + { + string text = null; + text.SubstringOrNull(0, 1); + } + + [DataTestMethod] + [DataRow("", true)] + [DataRow(" ", true)] + [DataRow("hello", false)] + [DataRow(" hello ", false)] + public void IsEmpty_ReturnsExpectedResult(string input, bool expected) + { + Assert.AreEqual(expected, input.IsEmpty()); + } + + [DataTestMethod] + [DataRow(" test ", "test")] + [DataRow(null, null)] + [DataRow("", "")] + public void TrimWhitespace_ReturnsExpectedResult(string input, string expected) + { + Assert.AreEqual(expected, input.TrimWhitespace()); + } + + [DataTestMethod] + [DataRow("hello\r\n", "hello")] + [DataRow("\r\nhello\r\n", "\r\nhello")] + [DataRow("hello\r\nworld", "hello\r\nworld")] + [DataRow(null, null)] + [DataRow("", null)] + [DataRow("\r\n", null)] + public void GetTrimmedValueOrNull_ReturnsExpectedResult(string input, string expected) + { + Assert.AreEqual(expected, input.GetTrimmedValueOrNull()); + } +} \ No newline at end of file