Skip to content

Commit

Permalink
Perform case-insensitive comparisons for header columns (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-thompson committed Jun 29, 2024
1 parent 833fa39 commit f48cabb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/versions/2.0/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,14 @@ export function validateHeaderRow(
errors.push(
csvErr(rowIndex, index, header, ERRORS.HEADER_COLUMN_BLANK(header))
)
} else if (header === "last_updated_on" && !isValidDate(value)) {
} else if (
sepColumnsEqual(header, "last_updated_on") &&
!isValidDate(value)
) {
errors.push(
csvErr(rowIndex, index, header, ERRORS.INVALID_DATE(header, value))
)
} else if (header === AFFIRMATION) {
} else if (sepColumnsEqual(header, AFFIRMATION)) {
errors.push(
...validateRequiredEnumField(
objectFromKeysValues(headers, row),
Expand Down
4 changes: 3 additions & 1 deletion src/versions/common/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export function objectFromKeysValues(
keys: string[],
values: string[]
): { [key: string]: string } {
return Object.fromEntries(keys.map((key, index) => [key, values[index]]))
return Object.fromEntries(
keys.map((key, index) => [key, values[index]]).filter((entry) => entry)
)
}

export function rowIsEmpty(row: string[]): boolean {
Expand Down
7 changes: 7 additions & 0 deletions test/2.0/csv.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ test("validateCsvWideHeaderError", async (t) => {
message:
'Header column "hospital_location" is miscoded or missing. You must include this header and confirm that it is encoded as specified in the data dictionary.',
},
{
path: "G2",
field:
"to the best of its knowledge and belief, the hospital has included all applicable standard charge information in accordance with the requirements of 45 cfr 180.50, and the information encoded is true, accurate, and complete as of the date indicated.",
message:
'"to the best of its knowledge and belief, the hospital has included all applicable standard charge information in accordance with the requirements of 45 cfr 180.50, and the information encoded is true, accurate, and complete as of the date indicated." value "yes" is not one of the allowed valid values. You must encode one of these valid values: true, false',
},
{
path: "A1",
message:
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/2.0/sample-wide-error-header.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
hospital_name,last_updated_on,version,hospital_ location,hospital_address,license_number|AL,"To the best of its knowledge and belief, the hospital has included all applicable standard charge information in accordance with the requirements of 45 CFR 180.50, and the information encoded is true, accurate, and complete as of the date indicated.",,,,,,,,,,,,,,,,,,,
West Mercy Hospital,2024-07-01,2.0.0,West Mercy Hospital|West Mercy Surgical Center,"12 Main Street, Fullerton, CA 92832|23 Ocean Ave, San Jose, CA 94088",50056,true,,,,,,,,,,,,,,,,,,,
West Mercy Hospital,2024-07-01,2.0.0,West Mercy Hospital|West Mercy Surgical Center,"12 Main Street, Fullerton, CA 92832|23 Ocean Ave, San Jose, CA 94088",50056,yes,,,,,,,,,,,,,,,,,,,
description,code|1,code|1|type,code|2,code|2|type,modifiers,setting,drug_unit_of_measurement,drug_type_of_measurement,standard_charge|gross,standard_charge|discounted_cash,standard_charge|Platform_Health_Insurance|PPO|negotiated_dollar,standard_charge|Platform_Health_Insurance|PPO|negotiated_percentage,standard_charge|Platform_Health_Insurance|PPO|negotiated_algorithm,estimated_amount|Platform_Health_Insurance|PPO,standard_charge|Platform_Health_Insurance|PPO|methodology,additional_payer_notes|Platform_Health_Insurance|PPO,standard_charge|Region_Health_Insurance|HMO|negotiated_dollar,standard_charge|Region_Health_Insurance|HMO|negotiated_percentage,standard_charge|Region_Health_Insurance|HMO|negotiated_algorithm,estimated_amount|Region_Health_Insurance|HMO,standard_charge|Region_Health_Insurance|HMO|methodology,additional_payer_notes|Region_Health_Insurance|HMO,standard_charge|min,standard_charge|max,additional_generic_notes
Major hip and knee joint replacement or reattachment of lower extremity without mcc,470,MS-DRG,175869,LOCAL,,inpatient,,,,,20000,,MS-DRG,22243.34,case rate,,,50,,23145.98,percent of total billed charges,,20000,20000,
Major hip and knee joint replacement or reattachment of lower extremity without mcc,470,MS-DRG,175869,LOCAL,,inpatient,,,,,20000,,https://www.cms.gov/Outreach-and-Education/Medicare-Learning-Network-MLN/MLNProducts/html/images/OP.jpg,22243.34,case rate,,,50,,23145.98,percent of total billed charges,,20000,20000,
Expand Down

0 comments on commit f48cabb

Please sign in to comment.