Skip to content

Commit ca71c5e

Browse files
committed
formatting changes, fixing some casing errors, adding tests for csvValidator and csvModule
1 parent 9bd3939 commit ca71c5e

File tree

7 files changed

+27
-5
lines changed

7 files changed

+27
-5
lines changed

src/extractors/CSVPatientExtractor.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ function joinAndReformatData(patientData) {
2323
ethnicity,
2424
language,
2525
addressline: addressLine,
26-
city, state, zip,
26+
city,
27+
state,
28+
zip,
2729
} = patientData;
2830

2931
if (!mrn) {

src/extractors/CSVStagingExtractor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ function formatTNMCategoryData(stagingData, patientId) {
1010
const formattedData = [];
1111
const {
1212
conditionid: conditionId,
13-
t, n, m, type,
13+
t,
14+
n,
15+
m,
16+
type,
1417
stagingsystem: stagingSystem,
1518
stagingcodesystem: stagingCodeSystem,
1619
effectivedate: effectiveDate,

test/extractors/CSVCancerDiseaseStatusExtractor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('CSVCancerDiseaseStatusExtractor', () => {
3535
expect(csvCancerDiseaseStatusExtractor.joinAndReformatData(exampleCSVDiseaseStatusModuleResponse, patientId)).toEqual(expect.anything());
3636

3737
localData[0].evidence = ''; // Evidence is not required and will not throw an error
38-
localData[0].observationStatus = ''; // Observation Status is not required and will not throw an error
38+
localData[0].observationstatus = ''; // Observation Status is not required and will not throw an error
3939

4040
// Only including required properties is valid
4141
expect(csvCancerDiseaseStatusExtractor.joinAndReformatData(localData, patientId)).toEqual(expect.anything());

test/extractors/CSVObservationExtractor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('CSVObservationExtractor', () => {
3838
expect(formatData(exampleCSVObservationModuleResponse, patientId)).toEqual(expect.anything());
3939

4040
// Test that deleting an optional value works fine
41-
delete localData[0].bodySite;
41+
delete localData[0].bodysite;
4242
expect(formatData(exampleCSVObservationModuleResponse, patientId)).toEqual(expect.anything());
4343

4444
// Test that deleting a mandatory value throws an error

test/extractors/CSVProcedureExtractor.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('CSVProcedureExtractor', () => {
3737
expect(formatData(localData, patientId)).toEqual(expect.anything());
3838

3939
// Test that removing an optional value works
40-
delete localData[0].bodySite;
40+
delete localData[0].bodysite;
4141
expect(formatData(localData, patientId)).toEqual(expect.anything());
4242

4343
// Test that removing a required value throws

test/helpers/csvValidator.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ const SIMPLE_DATA_MISSING_OPTIONAL_COLUMN = [
6565
},
6666
];
6767

68+
const SIMPLE_DATA_DIFFERENT_CASING = [
69+
{
70+
Header1: '1',
71+
hEaDeR2: '2',
72+
header3: '3',
73+
},
74+
];
75+
6876
const schema = {
6977
headers: [
7078
{ name: 'header1', required: true },
@@ -93,4 +101,8 @@ describe('csvValidator', () => {
93101
test('data missing an optional column should still validate', () => {
94102
expect(validateCSV('', schema, SIMPLE_DATA_MISSING_OPTIONAL_COLUMN)).toBe(true);
95103
});
104+
105+
test('data with different casing in the column header should still validate', () => {
106+
expect(validateCSV('', schema, SIMPLE_DATA_DIFFERENT_CASING)).toBe(true);
107+
});
96108
});

test/modules/CSVModule.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,8 @@ test('Should return an empty array when key-value pair does not exist', async ()
4141
const data = await csvModule.get('mrn', INVALID_MRN);
4242
expect(data).toEqual([]);
4343
});
44+
45+
test('Should return proper value regardless of key casing', async () => {
46+
const data = await csvModule.get('mRN', 'example-mrn-1');
47+
expect(data).toEqual(exampleResponse);
48+
});

0 commit comments

Comments
 (0)