Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dose related fields to medication request extractor #201

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/extractors/CSVCancerRelatedMedicationRequestExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ function formatData(medicationData, patientId) {
intent,
authoredon: authoredOn,
requesterid: requesterId,
dosageroute: dosageRoute,
asneededcode: asNeededCode,
doseratetype: doseRateType,
dosequantityvalue: doseQuantityValue,
dosequantityunit: doseQuantityUnit,
} = medication;

if (!(code && codeSystem && status && intent && requesterId)) {
Expand All @@ -43,6 +48,11 @@ function formatData(medicationData, patientId) {
intent,
authoredOn,
requesterId,
dosageRoute,
asNeededCode,
doseRateType,
doseQuantityValue,
doseQuantityUnit,
};
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/helpers/schemas/csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ const CSVCancerRelatedMedicationRequestSchema = {
{ name: 'intent', required: true },
{ name: 'authoredOn' },
{ name: 'requesterId', required: true },
{ name: 'dosageRoute' },
{ name: 'asNeededCode' },
{ name: 'doseRateType' },
{ name: 'doseQuantityValue' },
{ name: 'doseQuantityUnit' },
],
};

Expand Down
39 changes: 38 additions & 1 deletion src/templates/CancerRelatedMedicationRequestTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const {
medicationTemplate,
subjectTemplate,
treatmentReasonTemplate,
coding,
} = require('./snippets');
const { ifAllArgsObj } = require('../helpers/templateUtils');
const { ifAllArgsObj, ifSomeArgsObj } = require('../helpers/templateUtils');
const { formatDateTime } = require('../helpers/dateUtils');

function procedureIntentTemplate({ procedureIntent }) {
Expand All @@ -22,6 +23,36 @@ function requesterTemplate({ id }) {
};
}

function doseQuantityTemplate({ doseQuantityValue, doseQuantityUnit }) {
return {
doseQuantity: {
value: parseFloat(doseQuantityValue),
unit: doseQuantityUnit,
},
};
}

function doseAndRateTemplate({ doseRateType, doseQuantityValue, doseQuantityUnit }) {
return {
doseAndRate: [{
type: { coding: [coding({ code: doseRateType, system: 'http://terminology.hl7.org/CodeSystem/dose-rate-type' })] },
...ifSomeArgsObj(doseQuantityTemplate)({ doseQuantityValue, doseQuantityUnit }),
}],
};
}

function dosageInstructionTemplate({
dosageRoute, asNeededCode, doseRateType, doseQuantityValue, doseQuantityUnit,
}) {
return {
dosageInstruction: [{
route: { coding: [coding({ code: dosageRoute, system: 'http://snomed.info/sct' })] },
asNeededCodeableConcept: { coding: [coding({ code: asNeededCode, system: 'http://snomed.info/sct' })] },
...ifSomeArgsObj(doseAndRateTemplate)({ doseRateType, doseQuantityValue, doseQuantityUnit }),
}],
};
}

function cancerRelatedMedicationRequestTemplate({
subjectId,
id,
Expand All @@ -36,6 +67,11 @@ function cancerRelatedMedicationRequestTemplate({
intent,
authoredOn,
requesterId,
dosageRoute,
asNeededCode,
doseRateType,
doseQuantityValue,
doseQuantityUnit,
}) {
if (!(subjectId && code && codeSystem && status && intent && requesterId)) {
const e1 = 'Trying to render a CancerRelatedMedicationRequestTemplate, but a required argument is missing; ';
Expand All @@ -55,6 +91,7 @@ function cancerRelatedMedicationRequestTemplate({
status,
intent,
...medicationTemplate({ code, codeSystem, displayText }),
...ifSomeArgsObj(dosageInstructionTemplate)({ dosageRoute, asNeededCode, doseRateType, doseQuantityValue, doseQuantityUnit }),
...ifAllArgsObj(subjectTemplate)({ id: subjectId }),
...(authoredOn && { authoredOn: formatDateTime(authoredOn) }),
...ifAllArgsObj(requesterTemplate)({ id: requesterId }),
Expand Down
36 changes: 36 additions & 0 deletions test/extractors/fixtures/csv-medication-request-bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,42 @@
}
]
},
"dosageInstruction": [
{
"route": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "example-route"
}
]
},
"asNeededCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "example-asneeded"
}
]
},
"doseAndRate": [
{
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/dose-rate-type",
"code": "example-type"
}
]
},
"doseQuantity": {
"value": 111,
"unit": "example-unit"
}
}
]
}
],
"subject": {
"reference": "urn:uuid:mrn-1",
"type": "Patient"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"procedureintent": "example-code",
"status": "example-status",
"requesterid": "example-requester",
"intent": "example-intent"
"intent": "example-intent",
"dosageroute": "example-route",
"asneededcode": "example-asneeded",
"doseratetype": "example-type",
"dosequantityvalue": "111",
"dosequantityunit": "example-unit"
}
]
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mrn,requestId,code,codeSystem,displayText,treatmentReasonCode,treatmentReasonCodeSystem,treatmentReasonDisplayText,procedureIntent,status,intent,authoredOn,requesterId
123,requestId-1,10760,http://www.nlm.nih.gov/research/umls/rxnorm,Triamcinolone Oral Paste,999000,http://snomed.info/sct,Mixed islet cell and exocrine adenocarcinoma,373808002,active,order,2020-01-01,requester-1
456,requestId-2,91318,http://www.nlm.nih.gov/research/umls/rxnorm,Coal Tar Topical Solution,915007,http://snomed.info/sct,Malignant melanoma in junctional nevus,373808002,on-hold,proposal,2019-02-02,requester-2
789,requestId-3,91833,http://www.nlm.nih.gov/research/umls/rxnorm,Vitamin K1 Injectable Solution [Aquamephyton],900006,http://snomed.info/sct,Mucin-producing adenocarcinoma,363676003,cancelled,plan,,requester-3
mrn,requestId,code,codeSystem,displayText,treatmentReasonCode,treatmentReasonCodeSystem,treatmentReasonDisplayText,procedureIntent,status,intent,authoredOn,requesterId,dosageRoute,asNeededCode,doseRateType,doseQuantityValue,doseQuantityUnit
123,requestId-1,10760,http://www.nlm.nih.gov/research/umls/rxnorm,Triamcinolone Oral Paste,999000,http://snomed.info/sct,Mixed islet cell and exocrine adenocarcinoma,373808002,active,order,2020-01-01,requester-1,26643006,1152001,calculated,100,mg
456,requestId-2,91318,http://www.nlm.nih.gov/research/umls/rxnorm,Coal Tar Topical Solution,915007,http://snomed.info/sct,Malignant melanoma in junctional nevus,373808002,on-hold,proposal,2019-02-02,requester-2,46713006,1140008,ordered,50,mg
789,requestId-3,91833,http://www.nlm.nih.gov/research/umls/rxnorm,Vitamin K1 Injectable Solution [Aquamephyton],900006,http://snomed.info/sct,Mucin-producing adenocarcinoma,363676003,cancelled,plan,,requester-3,,,,,
36 changes: 36 additions & 0 deletions test/templates/fixtures/maximal-medication-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,42 @@
}
]
},
"dosageInstruction": [
{
"route": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "example-route"
}
]
},
"asNeededCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "example-asneeded"
}
]
},
"doseAndRate": [
{
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/dose-rate-type",
"code": "example-type"
}
]
},
"doseQuantity": {
"value": 111,
"unit": "example-unit"
}
}
]
}
],
"subject": {
"reference": "urn:uuid:mrn-1",
"type": "Patient"
Expand Down
20 changes: 20 additions & 0 deletions test/templates/medicationRequest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const REQUEST_VALID_DATA = {
status: 'example-status',
requesterId: 'example-requester',
intent: 'example-intent',
dosageRoute: 'example-route',
asNeededCode: 'example-asneeded',
doseRateType: 'example-type',
doseQuantityValue: '111',
doseQuantityUnit: 'example-unit',
};

const REQUEST_MINIMAL_DATA = {
Expand All @@ -33,6 +38,11 @@ const REQUEST_MINIMAL_DATA = {
status: 'example-status',
requesterId: 'example-requester',
intent: 'example-intent',
dosageRoute: null,
asNeededCode: null,
doseRateType: null,
doseQuantityValue: null,
doseQuantityUnit: null,
};


Expand All @@ -50,6 +60,11 @@ const REQUEST_INVALID_DATA = {
status: null,
requesterId: 'example-requester',
intent: 'example-intent',
dosageRoute: 'example-route',
asNeededCode: 'example-asneeded',
doseRateType: 'example-type',
doseQuantityValue: '111',
doseQuantityUnit: 'example-unit',
};

describe('test Medication Request template', () => {
Expand All @@ -76,6 +91,11 @@ describe('test Medication Request template', () => {
treatmentReasonCodeSystem: 'example-code-system',
treatmentReasonDisplayText: 'Example Text',
procedureIntent: 'example-code',
dosageRoute: 'example-route',
asNeededCode: 'example-asneeded',
doseRateType: 'example-type',
doseQuantityValue: '111',
doseQuantityUnit: 'example-unit',
};

const NECESSARY_DATA = {
Expand Down
Loading