From 66b2b13b4202d6b57e8afda3d73b3a6eeeed1f18 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Thu, 21 Dec 2023 14:03:35 -0500 Subject: [PATCH 01/11] Run Prettier --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5e341bb..4b9b276 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,21 @@ # Pharmacy Information Management System -### Setup +### Setup +The application is divided into a frontend and backend service. For an initial setup you will need to `run npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services. -The application is divided into a frontend and backend service. For an initial setup you will need to `run npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services. +### Running -### Running +Running the individual services can be done by either launching both of them independently or using pm2. To run them individually you will need to open a terminal window in each of the frontend and backend subdirectories. From there you will need to run `npm start` in each of the terminal windows. -Running the individual services can be done by either launching both of them independently or using pm2. To run them individually you will need to open a terminal window in each of the frontend and backend subdirectories. From there you will need to run `npm start` in each of the terminal windows. +To run both the systems under pm2 you will first need to install it: `npm install pm2 -g` After it is installed you can run both the systems with a single command `pm2 start pm2.config.json`. This will start both the frontend and the backend services. -To run both the systems under pm2 you will first need to install it: `npm install pm2 -g` After it is installed you can run both the systems with a single command `pm2 start pm2.config.json`. This will start both the frontend and the backend services. +By default, the frontend will start on port 3000 and the backend will start on port 5051. To configure the frontend to start on different port set the PORT environment variable to the port you would like it to start on. ex. `PORT 5050 npm start` To configure the backend to start on a different port set the BACKEND_PORT environment variable to the port you would like it to run on. -By default, the frontend will start on port 3000 and the backend will start on port 5051. To configure the frontend to start on different port set the PORT environment variable to the port you would like it to start on. ex. `PORT 5050 npm start` To configure the backend to start on a different port set the BACKEND_PORT environment variable to the port you would like it to run on. +These environment variables, and others , can also be set in the pm2 configuration file for the individula service entries. -These environment variables, and others , can also be set in the pm2 configuration file for the individula service entries. - -Once running both the frontend and backend systems open [http://localhost:5050](http://localhost:5050) in your browser to view the application. +Once running both the frontend and backend systems open [http://localhost:5050](http://localhost:5050) in your browser to view the application. ## Version + This application requires node v20.0 or greater. From b64dc78490f44d4db63e1e07b8c45e447c9c0953 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Fri, 22 Dec 2023 15:02:52 -0500 Subject: [PATCH 02/11] Move .github workflow files and delete unused workflow --- .github/auto_assign.yml | 16 ---------------- .../pull_request_template.md | 0 2 files changed, 16 deletions(-) delete mode 100644 .github/auto_assign.yml rename pull_request_template.md => .github/pull_request_template.md (100%) diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml deleted file mode 100644 index 407ed6d..0000000 --- a/.github/auto_assign.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Set to true to add reviewers to pull requests -addReviewers: true - -# Set to true to add assignees to pull requests -addAssignees: false - -# A list of reviewers to be added to pull requests (GitHub user name) -reviewers: - - zacharyrobin - - KeeyanGhoreshi - - smalho01 - - plarocque4 - - kennyEung - -# A number of reviewers added to the pull request, Set to 0 to add all reviewers -numberOfReviewers: 0 diff --git a/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from pull_request_template.md rename to .github/pull_request_template.md From 7ab1f9e57d05878d30a8932a42d609971be37303 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Fri, 22 Dec 2023 16:52:33 -0500 Subject: [PATCH 03/11] Update README.md and remove development-mode pm2-related Dockerfile build step and config file --- Dockerfile.dev | 2 -- README.md | 27 +++++++++++++++++++-------- pm2.config.dev.js | 22 ---------------------- pm2.config.js | 30 +++++++++++++++--------------- 4 files changed, 34 insertions(+), 47 deletions(-) delete mode 100644 pm2.config.dev.js diff --git a/Dockerfile.dev b/Dockerfile.dev index 436f2df..a575c3a 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -8,8 +8,6 @@ WORKDIR /home/node/app/frontend RUN npm install WORKDIR /home/node/app -RUN npm install pm2 -g - EXPOSE 5050 EXPOSE 5051 diff --git a/README.md b/README.md index 4b9b276..60e98ca 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,31 @@ # Pharmacy Information Management System -### Setup +## Setup -The application is divided into a frontend and backend service. For an initial setup you will need to `run npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services. +The application is divided into a frontend and backend service. For an initial setup you will need to run `npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services. -### Running +## Running backend and frontend -Running the individual services can be done by either launching both of them independently or using pm2. To run them individually you will need to open a terminal window in each of the frontend and backend subdirectories. From there you will need to run `npm start` in each of the terminal windows. +Running the individual services can be done by either launching both of them independently or using pm2. -To run both the systems under pm2 you will first need to install it: `npm install pm2 -g` After it is installed you can run both the systems with a single command `pm2 start pm2.config.json`. This will start both the frontend and the backend services. +### Running independently -By default, the frontend will start on port 3000 and the backend will start on port 5051. To configure the frontend to start on different port set the PORT environment variable to the port you would like it to start on. ex. `PORT 5050 npm start` To configure the backend to start on a different port set the BACKEND_PORT environment variable to the port you would like it to run on. +To run them individually you will need to open a terminal window in each of the frontend and backend subdirectories. From there you will need to run `npm start` in each of the terminal windows. -These environment variables, and others , can also be set in the pm2 configuration file for the individula service entries. +By default, the frontend will start on port 5050 (defined in `frontend/.env`) and the backend will start on port 5051 (defined in `backend/env.json`). -Once running both the frontend and backend systems open [http://localhost:5050](http://localhost:5050) in your browser to view the application. +To configure the frontend to start on different port, set the `PORT` environment variable to the desired port; e.g. `PORT=5050 npm start`, or create a `frontend/.env.local` to override `PORT`. + +To configure the backend to start on a different port, set the `BACKEND_PORT` environment variable to the desired port; e.g. +`BACKEND_PORT=5051 npm start`. + +These environment variables, and others, can also be set in the pm2 configuration file for the individual service entries. + +Once running both the frontend and backend systems, open [http://localhost:5050](http://localhost:5050) in your browser to view the application. + +### Using pm2 + +`pm2` is used in our [Dockerized REMS Integration Prototype setup](https://github.com/mcode/rems-setup/blob/main/DeveloperSetupGuide.md) for production to start both the frontend and the backend services. It is not used in development due to a bug with hot-reloading code changes in the two services. ## Version diff --git a/pm2.config.dev.js b/pm2.config.dev.js deleted file mode 100644 index de6fb45..0000000 --- a/pm2.config.dev.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file serves as configuration for the PM2 process manager. - * For more info, see: http://pm2.keymetrics.io/docs/usage/application-declaration/ - * - * This is mainly used in our Docker image. - */ - module.exports = { - apps: [ - // API Server - { - name: 'API', - script: 'npm start', - cwd: 'backend' - }, - // Fronted Server - { - name: 'FrontEnd', - script: 'npm start', - cwd: 'frontend' - } - ] -}; \ No newline at end of file diff --git a/pm2.config.js b/pm2.config.js index 25649bc..a4dc8e2 100644 --- a/pm2.config.js +++ b/pm2.config.js @@ -4,25 +4,25 @@ * * This is mainly used in our Docker image. */ - module.exports = { +module.exports = { apps: [ // API Server { - name: 'API', - script: 'npm start', - cwd: 'backend', + name: "API", + script: "npm start", + cwd: "backend", env_production: { - NODE_ENV: 'production' - } + NODE_ENV: "production", + }, }, - // Fronted Server + // Frontend Server { - name: 'FrontEnd', - script: 'npm start', - cwd: 'frontend', + name: "FrontEnd", + script: "npm start", + cwd: "frontend", env_production: { - NODE_ENV: 'production' - } - } - ] -}; \ No newline at end of file + NODE_ENV: "production", + }, + }, + ], +}; From 972415b619522e2431b9bf725046ba32ca02b31f Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Fri, 22 Dec 2023 17:00:54 -0500 Subject: [PATCH 04/11] Update README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 60e98ca..d9a904b 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,7 @@ Once running both the frontend and backend systems, open [http://localhost:5050] ## Version -This application requires node v20.0 or greater. +This application requires node.js v20.0 or greater. Using [`nvm`](https://github.com/nvm-sh/nvm) is optional, but easier when managing different node.js versions. + +- `nvm install 20` +- `nvm use 20` or `nvm use default 20`, as most of the REMS Integration Prototype repositories use node.js v20.0. From 28c54dc704bacf8585fbb9a5d272a2fd0179fe71 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Tue, 2 Jan 2024 14:40:18 -0500 Subject: [PATCH 05/11] Update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d9a904b..c07a75f 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ## Setup -The application is divided into a frontend and backend service. For an initial setup you will need to run `npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services. +The application is divided into a frontend and backend service. For an initial setup run `npm install` in both the frontend and backend subdirectories. This will install the dependencies required for each of the services. ## Running backend and frontend -Running the individual services can be done by either launching both of them independently or using pm2. +Run the individual services by either launching both of them independently or using pm2 innately through Docker. ### Running independently @@ -32,4 +32,4 @@ Once running both the frontend and backend systems, open [http://localhost:5050] This application requires node.js v20.0 or greater. Using [`nvm`](https://github.com/nvm-sh/nvm) is optional, but easier when managing different node.js versions. - `nvm install 20` -- `nvm use 20` or `nvm use default 20`, as most of the REMS Integration Prototype repositories use node.js v20.0. +- `nvm use 20` or `nvm use default 20`, as most of the REMS Integration Prototype repositories are compatible with node v20.0. From 28a410be5b03633a5cc0c06f43972bc2c4fd1dd5 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Thu, 4 Jan 2024 19:21:13 -0500 Subject: [PATCH 06/11] Fix typo --- backend/src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/server.ts b/backend/src/server.ts index 118dcce..c9289f4 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -27,7 +27,7 @@ async function main() { let server: any = app; if (env.USE_HTTPS) { - console.log('Enabling HTTPS HTTPS'); + console.log('Enabling HTTPS'); const credentials = { key: fs.readFileSync(env.HTTPS_KEY_PATH), cert: fs.readFileSync(env.HTTPS_CERT_PATH) From 7801ae3fa63f8bc2bfa265818557075aa239700f Mon Sep 17 00:00:00 2001 From: Zach Robin Date: Sun, 7 Jan 2024 20:46:18 -0800 Subject: [PATCH 07/11] 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 08/11] 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 09/11] 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 10/11] 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; +} From 9cacc9583ebafe23f92ad54c00ae62cbdb80cb5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:19:28 +0000 Subject: [PATCH 11/11] Bump follow-redirects from 1.15.2 to 1.15.4 in /backend Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.4. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.2...v1.15.4) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- backend/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/package-lock.json b/backend/package-lock.json index 7b6a8bc..9d93004 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -3381,9 +3381,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.4", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", + "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", "funding": [ { "type": "individual",