Skip to content

Commit a415c1e

Browse files
authored
Merge pull request #87 from mcode/add-trial-research-system
Added optional trialResearchSystem column to ClinicalTrialInformationExtractor
2 parents b81d6cb + da0b66b commit a415c1e

9 files changed

+28
-17
lines changed

src/extractors/CSVClinicalTrialInformationExtractor.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class CSVClinicalTrialInformationExtractor extends Extractor {
2727
joinClinicalTrialData(patientId, clinicalTrialData) {
2828
logger.debug('Reformatting clinical trial data from CSV into template format');
2929
const { trialSubjectID, enrollmentStatus, trialResearchID, trialStatus } = clinicalTrialData;
30+
// since trialResearchSystem is optional, check for blank value and replace with default value
31+
const trialResearchSystem = (clinicalTrialData.trialResearchSystem === '') ? 'http://example.com/clinicaltrialids' : clinicalTrialData.trialResearchSystem;
3032
const { clinicalSiteID } = this;
3133

3234
if (!(patientId && clinicalSiteID && trialSubjectID && enrollmentStatus && trialResearchID && trialStatus)) {
@@ -40,11 +42,13 @@ class CSVClinicalTrialInformationExtractor extends Extractor {
4042
trialSubjectID,
4143
trialResearchID,
4244
patientId,
45+
trialResearchSystem,
4346
},
4447
formattedDataStudy: {
4548
trialStatus,
4649
trialResearchID,
4750
clinicalSiteID,
51+
trialResearchSystem,
4852
},
4953
};
5054
}

src/templates/ResearchStudyTemplate.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ function siteTemplate(clinicalSiteID) {
1414
};
1515
}
1616

17-
function researchStudyIdentifierTemplate(trialResearchID) {
17+
function researchStudyIdentifierTemplate(trialResearchID, trialResearchSystem) {
1818
return identifierArr({
19-
system: 'http://example.com/clinicaltrialids',
19+
system: trialResearchSystem,
2020
type: {
2121
text: 'Clinical Trial Research ID',
2222
},
@@ -26,7 +26,9 @@ function researchStudyIdentifierTemplate(trialResearchID) {
2626

2727

2828
// Based on https://www.hl7.org/fhir/researchstudy.html
29-
function researchStudyTemplate({ id, trialStatus, trialResearchID, clinicalSiteID }) {
29+
function researchStudyTemplate({
30+
id, trialStatus, trialResearchID, clinicalSiteID, trialResearchSystem,
31+
}) {
3032
if (!(id && trialStatus && trialResearchID && clinicalSiteID)) {
3133
throw Error('Trying to render a ResearchStudyTemplate, but a required argument is missing; ensure that id, trialStatus, trialResearchID, clinicalSiteID are all present');
3234
}
@@ -36,7 +38,7 @@ function researchStudyTemplate({ id, trialStatus, trialResearchID, clinicalSiteI
3638
id,
3739
status: trialStatus,
3840
...siteTemplate(clinicalSiteID),
39-
...researchStudyIdentifierTemplate(trialResearchID),
41+
...researchStudyIdentifierTemplate(trialResearchID, trialResearchSystem),
4042
};
4143
}
4244

src/templates/ResearchSubjectTemplate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function researchSubjectTemplate({
3737
trialSubjectID,
3838
trialResearchID,
3939
patientId,
40-
trialResearchSystem = 'http://example.com/clinicaltrialids',
40+
trialResearchSystem,
4141
}) {
4242
if (!(id && enrollmentStatus && trialSubjectID && trialResearchID && patientId)) {
4343
throw Error('Trying to render a ResearchStudyTemplate, but a required argument is missing; ensure that id, trialStatus, trialResearchID, clinicalSiteID are all present');

test/extractors/CSVClinicalTrialInformationExtractor.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('CSVClinicalTrialInformationExtractor', () => {
3737
const clonedData = _.cloneDeep(firstClinicalTrialInfoResponse);
3838
expect(csvClinicalTrialInformationExtractor.joinClinicalTrialData(MOCK_PATIENT_MRN, clonedData)).toEqual(expect.anything());
3939
if (key === 'mrn') return; // MRN is not required from CSV
40+
if (key === 'trialResearchSystem') return; // trialResearchSystem is an optional field
4041
delete clonedData[key];
4142
expect(() => csvClinicalTrialInformationExtractor.joinClinicalTrialData(MOCK_PATIENT_MRN, clonedData)).toThrow(new Error(expectedErrorString));
4243
});
@@ -51,11 +52,13 @@ describe('CSVClinicalTrialInformationExtractor', () => {
5152
trialSubjectID: firstClinicalTrialInfoResponse.trialSubjectID,
5253
trialResearchID: firstClinicalTrialInfoResponse.trialResearchID,
5354
patientId: MOCK_PATIENT_MRN,
55+
trialResearchSystem: firstClinicalTrialInfoResponse.trialResearchSystem,
5456
},
5557
formattedDataStudy: {
5658
trialStatus: firstClinicalTrialInfoResponse.trialStatus,
5759
trialResearchID: firstClinicalTrialInfoResponse.trialResearchID,
5860
clinicalSiteID: MOCK_CLINICAL_SITE_ID,
61+
trialResearchSystem: firstClinicalTrialInfoResponse.trialResearchSystem,
5962
},
6063
});
6164
});

test/extractors/fixtures/csv-clinical-trial-information-bundle.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"type": "collection",
44
"entry": [
55
{
6-
"fullUrl": "urn:uuid:d528f1b04f5d3588ef80ca680fbc0f82b93e7c05eb08d293f698c7b075fc0b25",
6+
"fullUrl": "urn:uuid:f8acc19f44696eea31532ac9d3b658f1fea317eba9455eddc78de0857220d362",
77
"resource": {
88
"resourceType": "ResearchSubject",
9-
"id": "d528f1b04f5d3588ef80ca680fbc0f82b93e7c05eb08d293f698c7b075fc0b25",
9+
"id": "f8acc19f44696eea31532ac9d3b658f1fea317eba9455eddc78de0857220d362",
1010
"identifier": [
1111
{
1212
"system": "http://example.com/clinicaltrialsubjectids",
@@ -17,18 +17,18 @@
1717
"status": "example-enrollment-status",
1818
"study": {
1919
"identifier": {
20-
"system": "http://example.com/clinicaltrialids",
20+
"system": "example-system",
2121
"value": "example-researchId"
2222
}
2323
},
2424
"individual": { "reference": "urn:uuid:EXAMPLE-MRN", "type": "Patient" }
2525
}
2626
},
2727
{
28-
"fullUrl": "urn:uuid:1b04fc751b08fd0e0b89293a0ccb61e931e6eeed87d88100fb0c3b15d0cf7fbb",
28+
"fullUrl": "urn:uuid:b245aa8a67b5f67263f5a688813c435ccfb364e0f7865885c512e3a5ca3c9093",
2929
"resource": {
3030
"resourceType": "ResearchStudy",
31-
"id": "1b04fc751b08fd0e0b89293a0ccb61e931e6eeed87d88100fb0c3b15d0cf7fbb",
31+
"id": "b245aa8a67b5f67263f5a688813c435ccfb364e0f7865885c512e3a5ca3c9093",
3232
"status": "example-trialStatus",
3333
"site": [
3434
{
@@ -41,7 +41,7 @@
4141
],
4242
"identifier": [
4343
{
44-
"system": "http://example.com/clinicaltrialids",
44+
"system": "example-system",
4545
"type": { "text": "Clinical Trial Research ID" },
4646
"value": "example-researchId"
4747
}

test/extractors/fixtures/csv-clinical-trial-information-module-response.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"trialSubjectID": "example-subjectId",
55
"enrollmentStatus": "example-enrollment-status",
66
"trialResearchID": "example-researchId",
7-
"trialStatus": "example-trialStatus"
7+
"trialStatus": "example-trialStatus",
8+
"trialResearchSystem":"example-system"
89
}
910
]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mrn,trialSubjectID,enrollmentStatus,trialResearchID,trialStatus
2-
123,subjectId-1,potential-candidate,researchId-1,approved
3-
456,subjectId-2,on-study-intervention,researchId-1,completed
4-
789,subjectId-3,on-study-observation,researchId-2,active
1+
mrn,trialSubjectID,enrollmentStatus,trialResearchID,trialStatus,trialResearchSystem
2+
123,subjectId-1,potential-candidate,researchId-1,approved,system-1
3+
456,subjectId-2,on-study-intervention,researchId-1,completed,system-2
4+
789,subjectId-3,on-study-observation,researchId-2,active,

test/templates/fixtures/research-study-resource.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"identifier": [
1515
{
1616
"value": "AFT1235",
17-
"system": "http://example.com/clinicaltrialids",
17+
"system": "example-system",
1818
"type": {
1919
"text": "Clinical Trial Research ID"
2020
}

test/templates/researchStudy.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const VALID_DATA = {
77
trialStatus: 'active',
88
trialResearchID: 'AFT1235',
99
clinicalSiteID: 'EXAMPLE_SITE_ID',
10+
trialResearchSystem: 'example-system',
1011
};
1112

1213
const INVALID_DATA = {

0 commit comments

Comments
 (0)