Skip to content

Commit d1acc21

Browse files
authored
Merge pull request #148 from mcode/dev
Dev
2 parents bafc005 + 4c19e81 commit d1acc21

19 files changed

Lines changed: 1067 additions & 127 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,43 @@ The backend consists of multiple HTTP GET, POST, PATCH, or DELETE routes, most o
1919

2020
The frontend displays pending, approved, and picked up proprietary doctor orders at [http://localhost:5050/DoctorOrders](http://localhost:5050/DoctorOrders). While there is a login page at [http://localhost:5050](http://localhost:5050) for a dummy user, there is no user authentication or authorization system.
2121

22+
## Environment Variables
23+
24+
The PIMS system uses environment variables to configure both the frontend and backend services.
25+
26+
### Frontend Environment Variables
27+
28+
The frontend environment variables are configured in `frontend/.env`:
29+
30+
| Variable Name | Default Value | Description |
31+
| ------------- | ------------- | ----------- |
32+
| PORT | `5050` | The port that the frontend server runs on. Change if there are conflicts with port usage. |
33+
| REACT_APP_PIMS_BACKEND_PORT | `5051` | The port that the backend server runs on. Must match the backend's `BACKEND_PORT` setting. |
34+
35+
To override defaults, either:
36+
- Start the app with environment variables: `PORT=5050 npm start`
37+
- Create a `frontend/.env.local` file with the desired values
38+
39+
### Backend Environment Variables
40+
41+
The backend environment variables are configured in `backend/env.json`:
42+
43+
| Variable Name | Default Value | Description |
44+
| ------------- | ------------- | ----------- |
45+
| BACKEND_PORT | `5051` | The port that the backend server runs on. Change if there are conflicts with port usage. |
46+
| ALLOWED_ORIGIN | `*` | CORS allowed origins. Specify domains that are allowed to access the backend API. |
47+
| MONGO_USERNAME | `pims-user` | Username for MongoDB authentication. Should match the user created during MongoDB setup. |
48+
| MONGO_PASSWORD | `pims-pass` | Password for MongoDB authentication. Should match the password created during MongoDB setup. |
49+
| MONGO_URL | `mongodb://localhost:27017/pims` | MongoDB connection URL. Update if using a different host, port, or database name. |
50+
| AUTH_SOURCE | `pims` | MongoDB authentication source database name. |
51+
| HTTPS_KEY_PATH | `server.key` | Path to the HTTPS private key file. Required only if `USE_HTTPS` is true. |
52+
| HTTPS_CERT_PATH | `server.cert` | Path to the HTTPS certificate file. Required only if `USE_HTTPS` is true. |
53+
| USE_HTTPS | `false` | Set to `true` to enable HTTPS. Ensure valid certificate and key paths are configured. |
54+
| EHR_RXFILL_URL | `http://localhost:8080/test-ehr/ncpdp/script` | URL endpoint for sending RxFill messages to the EHR system. |
55+
| USE_INTERMEDIARY | `true` | Set to `true` to route ETASU checks through the REMS intermediary instead of directly to REMS admin. |
56+
| INTERMEDIARY_FHIR_URL | `http://localhost:3003/4_0_0` | Base URL of the REMS intermediary FHIR server. Used when `USE_INTERMEDIARY` is true. |
57+
| REMS_ADMIN_NCPDP | `http://localhost:8090/ncpdp/script` | URL endpoint for sending NCPDP Script messages directly to REMS admin. |
58+
2259
## Setup
2360

2461
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.

backend/env.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,13 @@
5454
"REMS_ADMIN_NCPDP": {
5555
"type": "string",
5656
"default": "http://localhost:8090/ncpdp/script"
57+
},
58+
"INTERMEDIARY_URL": {
59+
"type": "string",
60+
"default": "http://localhost:8090/ncpdp/script"
61+
},
62+
"EHR_NCPDP_URL": {
63+
"type": "string",
64+
"default": "|| 'http://localhost:8080/ncpdp/script'"
5765
}
5866
}

backend/src/database/schemas/doctorOrderSchemas.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export const orderSchema = new mongoose.Schema({
2525
total: Number,
2626
pickupDate: String,
2727
dispenseStatus: String,
28+
authorizationNumber: String,
29+
authorizationExpiration: String,
30+
denialReasonCode: String,
31+
remsNote: String,
2832
metRequirements: [
2933
{
3034
name: String,
@@ -44,4 +48,4 @@ export const orderSchema = new mongoose.Schema({
4448
// Compound index is used to prevent duplicates based off of the given parameters
4549
orderSchema.index({ simpleDrugName: 1, patientName: 1 }, { unique: true }); // schema level
4650

47-
export const doctorOrder = mongoose.model('doctorOrder', orderSchema);
51+
export const doctorOrder = mongoose.model('doctorOrder', orderSchema);

backend/src/lib/pharmacyConfig.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
// Configuration state
3+
let config = {
4+
useIntermediary: process.env.USE_INTERMEDIARY,
5+
intermediaryUrl: process.env.INTERMEDIARY_URL,
6+
remsAdminUrl: process.env.REMS_ADMIN_NCPDP,
7+
ehrUrl: process.env.EHR_NCPDP_URL
8+
};
9+
10+
11+
12+
export function getConfig() {
13+
return { ...config };
14+
}
15+
16+
17+
export function updateConfig(newConfig) {
18+
config = { ...config, ...newConfig };
19+
console.log('Configuration updated:', config);
20+
return { ...config };
21+
}
22+
23+
/**
24+
* Get the endpoint for NCPDP messages (REMS)
25+
*/
26+
export function getNCPDPEndpoint() {
27+
if (config.useIntermediary) {
28+
return `${config.intermediaryUrl}/ncpdp/script`;
29+
}
30+
return config.remsAdminUrl;
31+
}
32+
33+
/**
34+
* Get the endpoint for ETASU requests
35+
*/
36+
export function getETASUEndpoint() {
37+
if (config.useIntermediary) {
38+
return `${config.intermediaryUrl}/etasu`;
39+
}
40+
// Direct ETASU endpoint to REMS Admin
41+
return config.remsAdminUrl.replace('/ncpdp', '/4_0_0/GuidanceResponse/$rems-etasu');
42+
}
43+
44+
/**
45+
* Get the endpoint for RxFill messages (to EHR)
46+
* RxFill is sent to both EHR and REMS Admin
47+
* If using intermediary, send to intermediary (it forwards to both)
48+
* If not using intermediary, return EHR endpoint (caller must also send to REMS)
49+
*/
50+
export function getRxFillEndpoint() {
51+
if (config.useIntermediary) {
52+
// Intermediary handles forwarding to both EHR and REMS Admin
53+
return `${config.intermediaryUrl}/ncpdp/script`;
54+
}
55+
return config.ehrUrl;
56+
}

0 commit comments

Comments
 (0)