Add Full Medication Information Call - Fix Vulns #29
15 changed files with 109 additions and 5228 deletions
2
.github/workflows/api-deploy-nonprod.yml
vendored
2
.github/workflows/api-deploy-nonprod.yml
vendored
|
|
@ -90,5 +90,5 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy to Coolify
|
- name: Deploy to Coolify
|
||||||
run: |
|
run: |
|
||||||
curl -X --request GET '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
curl '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
||||||
|
|
||||||
|
|
|
||||||
2
.github/workflows/api-deploy-prod.yml
vendored
2
.github/workflows/api-deploy-prod.yml
vendored
|
|
@ -90,5 +90,5 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy to Coolify
|
- name: Deploy to Coolify
|
||||||
run: |
|
run: |
|
||||||
curl --request GET '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
curl '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
||||||
|
|
||||||
|
|
|
||||||
2
.github/workflows/web-deploy-nonprod.yml
vendored
2
.github/workflows/web-deploy-nonprod.yml
vendored
|
|
@ -90,5 +90,5 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy to Coolify
|
- name: Deploy to Coolify
|
||||||
run: |
|
run: |
|
||||||
curl --request GET '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
curl '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
||||||
|
|
||||||
|
|
|
||||||
2
.github/workflows/web-deploy-prod.yml
vendored
2
.github/workflows/web-deploy-prod.yml
vendored
|
|
@ -90,5 +90,5 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy to Coolify
|
- name: Deploy to Coolify
|
||||||
run: |
|
run: |
|
||||||
curl --request GET '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
curl '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
|
||||||
|
|
||||||
|
|
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -23,4 +23,7 @@ dist-ssr
|
||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
|
api/package-lock.json
|
||||||
|
web/package-lock.json
|
||||||
|
|
@ -4,7 +4,7 @@ WORKDIR /app
|
||||||
|
|
||||||
COPY ./package*.json ./
|
COPY ./package*.json ./
|
||||||
|
|
||||||
RUN npm ci
|
RUN npm cache clean --force && npm install --no-audit --no-fund
|
||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
|
|
|
||||||
1363
api/package-lock.json
generated
1363
api/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -12,7 +12,8 @@
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.5.0",
|
"dotenv": "^16.5.0",
|
||||||
"express": "^5.2.0",
|
"express": "^5.2.0",
|
||||||
"pg": "^8.17.1"
|
"pg": "^8.17.1",
|
||||||
|
"yup": "^1.7.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^3.1.10"
|
"nodemon": "^3.1.10"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { databaseServices } from '../index.js';
|
import { databaseServices } from '../index.js';
|
||||||
|
import { fullMedicationInformationSchema } from '../validations/medications.js';
|
||||||
|
|
||||||
export const medicationRouter = express.Router();
|
export const medicationRouter = express.Router();
|
||||||
|
|
||||||
|
|
@ -27,4 +28,19 @@ medicationRouter.get('/base/', async (req, res) => {
|
||||||
} finally {
|
} finally {
|
||||||
res.send(data);
|
res.send(data);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
medicationRouter.post('/full/', async (req, res) => {
|
||||||
|
let data;
|
||||||
|
const body = req?.body;
|
||||||
|
try {
|
||||||
|
await fullMedicationInformationSchema.validate(body);
|
||||||
|
data = await databaseServices.getFullMedicationInformation(body?.drugId);
|
||||||
|
res.status(200);
|
||||||
|
} catch (err) {
|
||||||
|
data = { Error: err?.message };
|
||||||
|
res.status(500);
|
||||||
|
} finally {
|
||||||
|
res.send(data);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -64,5 +64,66 @@ export const medicationHelpers = {
|
||||||
const fullMedList = Object.values(medMap);
|
const fullMedList = Object.values(medMap);
|
||||||
|
|
||||||
return fullMedList;
|
return fullMedList;
|
||||||
|
},
|
||||||
|
getFullMedicationInformation: async (drugId) => {
|
||||||
|
const [medInformation, medRoutes] = await Promise.all([
|
||||||
|
paramyxRunQuery(
|
||||||
|
`select
|
||||||
|
m.id,
|
||||||
|
m.generic,
|
||||||
|
m.trade,
|
||||||
|
m.system,
|
||||||
|
mi.class,
|
||||||
|
mi.indications,
|
||||||
|
mi.contraindications,
|
||||||
|
mi.precautions,
|
||||||
|
mi.adverse,
|
||||||
|
mi.onset,
|
||||||
|
mi.duration,
|
||||||
|
mi.tip,
|
||||||
|
mi.action
|
||||||
|
from medications m inner join medication_information mi on m.id = mi.id where m.id = $1;`,
|
||||||
|
[drugId]
|
||||||
|
),
|
||||||
|
paramyxRunQuery(`select * from medication_routes mr where medication_id = $1;`, [drugId])
|
||||||
|
]);
|
||||||
|
|
||||||
|
const fullMedicationInformation = {
|
||||||
|
...medInformation
|
||||||
|
};
|
||||||
|
|
||||||
|
medRoutes?.forEach((row) => {
|
||||||
|
if (row?.is_adult) {
|
||||||
|
fullMedicationInformation.adult = {
|
||||||
|
totalMax: row.total_max,
|
||||||
|
iv: row.intravenous,
|
||||||
|
io: row.intraosseous,
|
||||||
|
im: row.intramuscular,
|
||||||
|
in: row.intranasal,
|
||||||
|
po: row.oral,
|
||||||
|
sl: row.sublingual,
|
||||||
|
pr: row.rectal,
|
||||||
|
neb: row.nebulizer,
|
||||||
|
et: row.endotracheal,
|
||||||
|
sga: row.supraglottic
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fullMedicationInformation.pediatric = {
|
||||||
|
totalMax: row.total_max,
|
||||||
|
iv: row.intravenous,
|
||||||
|
io: row.intraosseous,
|
||||||
|
im: row.intramuscular,
|
||||||
|
in: row.intranasal,
|
||||||
|
po: row.oral,
|
||||||
|
sl: row.sublingual,
|
||||||
|
pr: row.rectal,
|
||||||
|
neb: row.nebulizer,
|
||||||
|
et: row.endotracheal,
|
||||||
|
sga: row.supraglottic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return fullMedicationInformation;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -21,7 +21,18 @@ const getBaseMedications = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getFullMedicationInformation = async (drugId) => {
|
||||||
|
try {
|
||||||
|
const dataResp = medicationHelpers.getFullMedicationInformation(drugId);
|
||||||
|
return dataResp;
|
||||||
|
} catch (err) {
|
||||||
|
console.log('GET FULL MEDICATION INFORMATION ERROR: ', err);
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const medicationOperations = {
|
export const medicationOperations = {
|
||||||
getMedications,
|
getMedications,
|
||||||
getBaseMedications
|
getBaseMedications,
|
||||||
|
getFullMedicationInformation
|
||||||
}
|
}
|
||||||
5
api/services/validations/medications.js
Normal file
5
api/services/validations/medications.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import * as Yup from 'yup';
|
||||||
|
|
||||||
|
export const fullMedicationInformationSchema = Yup.object().shape({
|
||||||
|
drugId: Yup.string().required("drugId is required"),
|
||||||
|
});
|
||||||
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -809,9 +809,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.23",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
||||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ WORKDIR /app
|
||||||
|
|
||||||
COPY ./package*.json ./
|
COPY ./package*.json ./
|
||||||
|
|
||||||
RUN npm ci
|
RUN npm cache clean --force && npm install --no-audit --no-fund
|
||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
|
|
||||||
|
|
|
||||||
3853
web/package-lock.json
generated
3853
web/package-lock.json
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue