Skip to content

Commit a185987

Browse files
authored
Merge pull request #130 from mcode/ndc-rxnorm-mapping
Ndc-rxnorm-mapping
2 parents cab52f2 + 4a58825 commit a185987

File tree

2 files changed

+65
-15
lines changed

2 files changed

+65
-15
lines changed

backend/src/database/data.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
export const medicationRequestToRemsAdmins = Object.freeze([
22
{
33
rxnorm: 2183126,
4+
ndc: '65597-407-20',
45
display: 'Turalio 200 MG Oral Capsule',
56
remsAdminFhirUrl: process.env.REMS_ADMIN_FHIR_URL || 'http://localhost:8090/4_0_0'
67
},
78
{
89
rxnorm: 6064,
10+
ndc: '0245-0571-01',
911
display: 'Isotretinoin 20 MG Oral Capsule',
1012
remsAdminFhirUrl: process.env.REMS_ADMIN_FHIR_URL || 'http://localhost:8090/4_0_0'
1113
},
1214
{
1315
rxnorm: 1237051,
16+
ndc: '63459-502-30',
1417
display: 'TIRF 200 UG Oral Transmucosal Lozenge',
1518
remsAdminFhirUrl: process.env.REMS_ADMIN_FHIR_URL || 'http://localhost:8090/4_0_0'
1619
},
1720
{
1821
rxnorm: 1666386,
22+
ndc: '58604-214-30',
1923
display: 'Addyi 100 MG Oral Tablet',
2024
remsAdminFhirUrl: process.env.REMS_ADMIN_FHIR_URL || 'http://localhost:8090/4_0_0'
2125
}

backend/src/routes/doctorOrders.js

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,17 @@ router.delete('/api/deleteAll', async (req, res) => {
249249
});
250250

251251
const isRemsDrug = order => {
252-
return medicationRequestToRemsAdmins.some(
253-
entry => Number(order.drugRxnormCode) === Number(entry.rxnorm)
254-
);
252+
return medicationRequestToRemsAdmins.some(entry => {
253+
if (order.drugNdcCode && entry.ndc) {
254+
return order.drugNdcCode === entry.ndc;
255+
}
256+
257+
if (order.drugRxnormCode && entry.rxnorm) {
258+
return Number(order.drugRxnormCode) === Number(entry.rxnorm);
259+
}
260+
261+
return false;
262+
});
255263
};
256264

257265
const getEtasuUrl = order => {
@@ -260,9 +268,16 @@ const getEtasuUrl = order => {
260268
if (env.USE_INTERMEDIARY) {
261269
baseUrl = env.INTERMEDIARY_FHIR_URL;
262270
} else {
263-
const rxnorm = order.drugRxnormCode;
264271
const remsDrug = medicationRequestToRemsAdmins.find(entry => {
265-
return Number(rxnorm) === Number(entry.rxnorm);
272+
if (order.drugNdcCode && entry.ndc) {
273+
return order.drugNdcCode === entry.ndc;
274+
}
275+
276+
if (order.drugRxnormCode && entry.rxnorm) {
277+
return Number(order.drugRxnormCode) === Number(entry.rxnorm);
278+
}
279+
280+
return false;
266281
});
267282
baseUrl = remsDrug?.remsAdminFhirUrl;
268283
}
@@ -291,6 +306,36 @@ const getGuidanceResponse = async order => {
291306
]
292307
};
293308
} else {
309+
let medicationCoding = [];
310+
311+
if (order.drugNdcCode) {
312+
medicationCoding.push({
313+
system: 'http://hl7.org/fhir/sid/ndc',
314+
code: order.drugNdcCode,
315+
display: order.drugNames
316+
});
317+
}
318+
319+
if (order.drugRxnormCode) {
320+
medicationCoding.push({
321+
system: 'http://www.nlm.nih.gov/research/umls/rxnorm',
322+
code: order.drugRxnormCode,
323+
display: order.drugNames
324+
});
325+
} else {
326+
const remsDrug = medicationRequestToRemsAdmins.find(entry => {
327+
return order.drugNdcCode && entry.ndc && order.drugNdcCode === entry.ndc;
328+
});
329+
330+
if (remsDrug && remsDrug.rxnorm) {
331+
medicationCoding.push({
332+
system: 'http://www.nlm.nih.gov/research/umls/rxnorm',
333+
code: remsDrug.rxnorm.toString(),
334+
display: order.drugNames
335+
});
336+
}
337+
}
338+
294339
body = {
295340
resourceType: 'Parameters',
296341
parameter: [
@@ -315,13 +360,7 @@ const getGuidanceResponse = async order => {
315360
resourceType: 'Medication',
316361
id: order.prescriberOrderNumber,
317362
code: {
318-
coding: [
319-
{
320-
system: 'http://www.nlm.nih.gov/research/umls/rxnorm',
321-
code: order.drugRxnormCode,
322-
display: order.drugNames
323-
}
324-
]
363+
coding: medicationCoding
325364
}
326365
}
327366
}
@@ -356,7 +395,7 @@ const getDispenseStatus = (order, guidanceResponse) => {
356395
* Return : Mongoose schema of a newOrder
357396
*/
358397
async function parseNCPDPScript(newRx) {
359-
// Parsing XML NCPDP SCRIPT from EHR
398+
// Parsing XML NCPDP SCRIPT from EHR
360399
const incompleteOrder = {
361400
orderId: newRx.Message.Header.MessageID.toString(), // Will need to return to this and use actual pt identifier or uuid
362401
caseNumber: newRx.Message.Header.AuthorizationNumber,
@@ -385,8 +424,15 @@ async function parseNCPDPScript(newRx) {
385424
newRx.Message.Body.NewRx.Prescriber.NonVeterinarian.CommunicationNumbers.ElectronicMail,
386425
drugNames: newRx.Message.Body.NewRx.MedicationPrescribed.DrugDescription,
387426
simpleDrugName: newRx.Message.Body.NewRx.MedicationPrescribed.DrugDescription.split(' ')[0],
388-
drugNdcCode: newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.ProductCode.Code,
389-
drugRxnormCode: newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.DrugDBCode.Code,
427+
428+
drugNdcCode:
429+
newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.ProductCode?.Code ||
430+
newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.NDC ||
431+
null,
432+
433+
drugRxnormCode:
434+
newRx.Message.Body.NewRx.MedicationPrescribed.DrugCoded.DrugDBCode?.Code || null,
435+
390436
rxDate: newRx.Message.Body.NewRx.MedicationPrescribed.WrittenDate.Date,
391437
drugPrice: 200, // Add later?
392438
quantities: newRx.Message.Body.NewRx.MedicationPrescribed.Quantity.Value,

0 commit comments

Comments
 (0)