* Add Full Medication Information Call - Fix Vulns * Update .gitignore * Delete api/package-lock.json * Delete web/package-lock.json * Push package-locks * Update * Update * Update api-deploy-nonprod.yml * Missed a ' * Update pipelines
46 lines
No EOL
1.1 KiB
JavaScript
46 lines
No EOL
1.1 KiB
JavaScript
import express from 'express';
|
|
import { databaseServices } from '../index.js';
|
|
import { fullMedicationInformationSchema } from '../validations/medications.js';
|
|
|
|
export const medicationRouter = express.Router();
|
|
|
|
medicationRouter.get('/', async (req, res) => {
|
|
let data;
|
|
try {
|
|
data = await databaseServices.getMedications();
|
|
res.status(200);
|
|
} catch (err) {
|
|
data = { Error: err?.message };
|
|
res.status(500);
|
|
} finally {
|
|
res.send(data);
|
|
}
|
|
});
|
|
|
|
medicationRouter.get('/base/', async (req, res) => {
|
|
let data;
|
|
try {
|
|
data = await databaseServices.getBaseMedications();
|
|
res.status(200);
|
|
} catch (err) {
|
|
data = { Error: err?.message };
|
|
res.status(500);
|
|
} finally {
|
|
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);
|
|
}
|
|
}); |