From 7801ae3fa63f8bc2bfa265818557075aa239700f Mon Sep 17 00:00:00 2001 From: Zach Robin Date: Sun, 7 Jan 2024 20:46:18 -0800 Subject: [PATCH 1/4] Added RxStatus --- backend/package.json | 1 + .../buildScript.v2017071.js | 50 +++++++++++++++++++ backend/src/routes/doctorOrders.js | 9 +++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 backend/src/ncpdpScriptBuilder/buildScript.v2017071.js diff --git a/backend/package.json b/backend/package.json index 41007ef..2b4614b 100644 --- a/backend/package.json +++ b/backend/package.json @@ -9,6 +9,7 @@ "body-parser-xml": "^2.0.3", "cors": "^2.8.5", "express": "^4.18.2", + "fast-xml-parser": "^4.3.2", "mongoose": "^6.11.4", "var": "^0.4.0", "web-vitals": "^2.1.4", diff --git a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js new file mode 100644 index 0000000..3c331d7 --- /dev/null +++ b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js @@ -0,0 +1,50 @@ +/* NCPDP SCRIPT v2017071 Support */ +import { XMLBuilder } from 'fast-xml-parser'; + +export default function buildRxStatus(caseNumber, doctorName, drugNames) { + var time = new Date(); + var rxStatus = + { + "RxStatus": [ + { + "Message": [ + { + "Header": [ + { + "To": doctorName + }, + { + "From": "Pharmacy" // Placeholder: This is dependant on individual pharmacy + }, + { + "Message": "NewRx Request Recieved For: " + drugNames + }, + { + "RelatesToMessageID": caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number + }, + { + "Time": time + }, + ] + }, + { + "Body": [ + { + "Status": [ + { + "Code": "200" // Placeholder: This is dependant on individual pharmacy + } + ] + } + ] + } + + ] + } + ] + }; + const builder = new XMLBuilder({ oneListGroup: "true" }); + var RxStatus = builder.build(rxStatus); + + return RxStatus; +} \ No newline at end of file diff --git a/backend/src/routes/doctorOrders.js b/backend/src/routes/doctorOrders.js index 8cb6685..2a33a58 100644 --- a/backend/src/routes/doctorOrders.js +++ b/backend/src/routes/doctorOrders.js @@ -6,6 +6,8 @@ import axios from 'axios'; import bodyParser from 'body-parser'; import bpx from 'body-parser-xml'; import env from 'var'; +import buildRxStatus from '../ncpdpScriptBuilder/buildScript.v2017071.js'; + bpx(bodyParser); router.use( bodyParser.xml({ @@ -47,7 +49,12 @@ router.post('/api/addRx', async (req, res) => { console.log('POST DoctorOrder: '); console.log(newOrder); - res.send(newOrder); + + var RxStatus = buildRxStatus(newOrder.caseNumber, newOrder.doctorName, newOrder.drugNames); + console.log('RxStatus:'); + console.log(RxStatus); + + res.send(RxStatus); }); /** From c13ea23f5d6fdda3d664eae780e37a6c3abde5a1 Mon Sep 17 00:00:00 2001 From: Zach Robin Date: Mon, 8 Jan 2024 01:46:24 -0800 Subject: [PATCH 2/4] removed double quotes --- .../buildScript.v2017071.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js index 3c331d7..f2dbc6c 100644 --- a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js +++ b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js @@ -5,34 +5,34 @@ export default function buildRxStatus(caseNumber, doctorName, drugNames) { var time = new Date(); var rxStatus = { - "RxStatus": [ + 'RxStatus': [ { - "Message": [ + 'Message': [ { - "Header": [ + 'Header': [ { - "To": doctorName + 'To': doctorName }, { - "From": "Pharmacy" // Placeholder: This is dependant on individual pharmacy + 'From': 'Pharmacy' // Placeholder: This is dependant on individual pharmacy }, { - "Message": "NewRx Request Recieved For: " + drugNames + 'Message': 'NewRx Request Recieved For: ' + drugNames }, { - "RelatesToMessageID": caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number + 'RelatesToMessageID': caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number }, { - "Time": time + 'Time': time }, ] }, { - "Body": [ + 'Body': [ { - "Status": [ + 'Status': [ { - "Code": "200" // Placeholder: This is dependant on individual pharmacy + 'Code': '200' // Placeholder: This is dependant on individual pharmacy } ] } @@ -43,7 +43,7 @@ export default function buildRxStatus(caseNumber, doctorName, drugNames) { } ] }; - const builder = new XMLBuilder({ oneListGroup: "true" }); + const builder = new XMLBuilder({ oneListGroup: 'true' }); var RxStatus = builder.build(rxStatus); return RxStatus; From c650c23b64cbab59c749a785f5dba4d5eed7d1a8 Mon Sep 17 00:00:00 2001 From: Zach Robin Date: Mon, 8 Jan 2024 01:55:41 -0800 Subject: [PATCH 3/4] running prettier --- backend/src/ncpdpScriptBuilder/buildScript.v2017071.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js index f2dbc6c..e13fccb 100644 --- a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js +++ b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js @@ -21,7 +21,7 @@ export default function buildRxStatus(caseNumber, doctorName, drugNames) { }, { 'RelatesToMessageID': caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number - }, + }, { 'Time': time }, From 0052e9842cfb1e719e56a0b81a24e8843b8ca1ab Mon Sep 17 00:00:00 2001 From: Zach Robin Date: Tue, 9 Jan 2024 13:12:25 -0800 Subject: [PATCH 4/4] prettier run --- .../buildScript.v2017071.js | 84 +++++++++---------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js index e13fccb..49a5370 100644 --- a/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js +++ b/backend/src/ncpdpScriptBuilder/buildScript.v2017071.js @@ -2,49 +2,47 @@ import { XMLBuilder } from 'fast-xml-parser'; export default function buildRxStatus(caseNumber, doctorName, drugNames) { - var time = new Date(); - var rxStatus = - { - 'RxStatus': [ - { - 'Message': [ - { - 'Header': [ - { - 'To': doctorName - }, - { - 'From': 'Pharmacy' // Placeholder: This is dependant on individual pharmacy - }, - { - 'Message': 'NewRx Request Recieved For: ' + drugNames - }, - { - 'RelatesToMessageID': caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number - }, - { - 'Time': time - }, - ] - }, - { - 'Body': [ - { - 'Status': [ - { - 'Code': '200' // Placeholder: This is dependant on individual pharmacy - } - ] - } - ] - } - + var time = new Date(); + var rxStatus = { + RxStatus: [ + { + Message: [ + { + Header: [ + { + To: doctorName + }, + { + From: 'Pharmacy' // Placeholder: This is dependant on individual pharmacy + }, + { + Message: 'NewRx Request Recieved For: ' + drugNames + }, + { + RelatesToMessageID: caseNumber // Placeholder: This is dependant on individual pharmacy, using Case Number + }, + { + Time: time + } + ] + }, + { + Body: [ + { + Status: [ + { + Code: '200' // Placeholder: This is dependant on individual pharmacy + } ] - } + } + ] + } ] - }; - const builder = new XMLBuilder({ oneListGroup: 'true' }); - var RxStatus = builder.build(rxStatus); + } + ] + }; + const builder = new XMLBuilder({ oneListGroup: 'true' }); + var RxStatus = builder.build(rxStatus); - return RxStatus; -} \ No newline at end of file + return RxStatus; +}