Skip to content

Commit bd8adec

Browse files
authored
Merge pull request #99 from mcode/add-clinical-site-system
Support specifying clinicalSiteSystem in configuration file
2 parents 45af086 + 4dd0208 commit bd8adec

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

src/extractors/CSVClinicalTrialInformationExtractor.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ function getPatientId(context) {
1616
}
1717

1818
class CSVClinicalTrialInformationExtractor extends BaseCSVExtractor {
19-
constructor({ filePath, clinicalSiteID }) {
19+
constructor({ filePath, clinicalSiteID, clinicalSiteSystem }) {
2020
super({ filePath, csvSchema: CSVClinicalTrialInformationSchema });
2121
if (!clinicalSiteID) logger.warn(`${this.constructor.name} expects a value for clinicalSiteID but got ${clinicalSiteID}`);
2222
this.clinicalSiteID = clinicalSiteID;
23+
this.clinicalSiteSystem = clinicalSiteSystem;
2324
}
2425

2526
joinClinicalTrialData(patientId, clinicalTrialData) {
2627
logger.debug('Reformatting clinical trial data from CSV into template format');
2728
const {
2829
trialSubjectID, enrollmentStatus, trialResearchID, trialStatus, trialResearchSystem,
2930
} = clinicalTrialData;
30-
const { clinicalSiteID } = this;
31+
const { clinicalSiteID, clinicalSiteSystem } = this;
3132

3233
if (!(patientId && clinicalSiteID && trialSubjectID && enrollmentStatus && trialResearchID && trialStatus)) {
3334
throw new Error('Clinical trial missing an expected property: patientId, clinicalSiteID, trialSubjectID, enrollmentStatus, trialResearchID, and trialStatus are required.');
@@ -46,6 +47,7 @@ class CSVClinicalTrialInformationExtractor extends BaseCSVExtractor {
4647
trialStatus,
4748
trialResearchID,
4849
clinicalSiteID,
50+
clinicalSiteSystem,
4951
trialResearchSystem,
5052
},
5153
};

src/templates/ResearchStudyTemplate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const { identifierArr, identifier } = require('./snippets');
22

3-
function siteTemplate(clinicalSiteID) {
3+
function siteTemplate(clinicalSiteID, clinicalSiteSystem) {
44
return {
55
site: [
66
{
77
display: 'ID associated with Clinical Trial',
88
...identifier({
9-
system: 'http://example.com/clinicalSiteIds',
9+
system: clinicalSiteSystem,
1010
value: clinicalSiteID,
1111
}),
1212
},
@@ -27,7 +27,7 @@ function researchStudyIdentifierTemplate(trialResearchID, trialResearchSystem) {
2727

2828
// Based on https://www.hl7.org/fhir/researchstudy.html
2929
function researchStudyTemplate({
30-
id, trialStatus, trialResearchID, clinicalSiteID, trialResearchSystem,
30+
id, trialStatus, trialResearchID, clinicalSiteID, clinicalSiteSystem, trialResearchSystem,
3131
}) {
3232
if (!(id && trialStatus && trialResearchID && clinicalSiteID)) {
3333
throw Error('Trying to render a ResearchStudyTemplate, but a required argument is missing; ensure that id, trialStatus, trialResearchID, clinicalSiteID are all present');
@@ -37,7 +37,7 @@ function researchStudyTemplate({
3737
resourceType: 'ResearchStudy',
3838
id,
3939
status: trialStatus,
40-
...siteTemplate(clinicalSiteID),
40+
...siteTemplate(clinicalSiteID, clinicalSiteSystem),
4141
...researchStudyIdentifierTemplate(trialResearchID, trialResearchSystem),
4242
};
4343
}

test/extractors/CSVClinicalTrialInformationExtractor.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ const exampleClinicalTrialInformationBundle = require('./fixtures/csv-clinical-t
88
// Constants for mock tests
99
const MOCK_CSV_PATH = path.join(__dirname, 'fixtures/example.csv'); // need a valid path/csv here to avoid parse error
1010
const MOCK_CLINICAL_SITE_ID = 'EXAMPLE-CLINICAL-SITE-ID';
11+
const MOCK_CLINICAL_SITE_SYSTEM = 'EXAMPLE-CLINICAL-SITE-SYSTEM';
1112
const MOCK_PATIENT_MRN = 'EXAMPLE-MRN';
1213

1314
// Instantiate module with mock parameters
1415
const csvClinicalTrialInformationExtractor = new CSVClinicalTrialInformationExtractor({
1516
filePath: MOCK_CSV_PATH,
1617
clinicalSiteID: MOCK_CLINICAL_SITE_ID,
18+
clinicalSiteSystem: MOCK_CLINICAL_SITE_SYSTEM,
1719
});
1820

1921
// Destructure all modules
@@ -58,6 +60,7 @@ describe('CSVClinicalTrialInformationExtractor', () => {
5860
trialStatus: firstClinicalTrialInfoResponse.trialStatus,
5961
trialResearchID: firstClinicalTrialInfoResponse.trialResearchID,
6062
clinicalSiteID: MOCK_CLINICAL_SITE_ID,
63+
clinicalSiteSystem: MOCK_CLINICAL_SITE_SYSTEM,
6164
trialResearchSystem: firstClinicalTrialInfoResponse.trialResearchSystem,
6265
},
6366
});

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@
2525
}
2626
},
2727
{
28-
"fullUrl": "urn:uuid:b245aa8a67b5f67263f5a688813c435ccfb364e0f7865885c512e3a5ca3c9093",
28+
"fullUrl": "urn:uuid:28bd7a4890539dc60998a1b2d423e631a6d4373eb05001c45bd9f2bab3166506",
2929
"resource": {
3030
"resourceType": "ResearchStudy",
31-
"id": "b245aa8a67b5f67263f5a688813c435ccfb364e0f7865885c512e3a5ca3c9093",
31+
"id": "28bd7a4890539dc60998a1b2d423e631a6d4373eb05001c45bd9f2bab3166506",
3232
"status": "example-trialStatus",
3333
"site": [
3434
{
3535
"display": "ID associated with Clinical Trial",
3636
"identifier": {
37-
"system": "http://example.com/clinicalSiteIds",
37+
"system": "EXAMPLE-CLINICAL-SITE-SYSTEM",
3838
"value": "EXAMPLE-CLINICAL-SITE-ID"
3939
}
4040
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"display": "ID associated with Clinical Trial",
88
"identifier": {
9-
"system": "http://example.com/clinicalSiteIds",
9+
"system": "EXAMPLE_SITE_SYSTEM",
1010
"value": "EXAMPLE_SITE_ID"
1111
}
1212
}

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+
clinicalSiteSystem: 'EXAMPLE_SITE_SYSTEM',
1011
trialResearchSystem: 'example-system',
1112
};
1213

0 commit comments

Comments
 (0)