Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ DIRECTORY_SERVICE_URL=http://localhost:3323
DIRECTORY_API_PATH = /drug/ndc.json
DIRECTORY_SPL_PATH = /drugs/spl.zip
SPL_ZIP_FILE_NAME=TESTDATA_rems_document_and_rems_indexing_spl_files.zip
NCPDP_SCRIPT_FORWARD_URL=http://localhost:5051/ncpdp/script

3 changes: 3 additions & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
justify-content: flex-end;
margin: 10px 16px 10px 0;
}
.button-gap {
min-width: 100px;
}

.App h1 {
color: white;
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/views/DataViews/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ const Connections = () => {
await getExistingConnections();
}

const reloadSpl = async () => {
const url = process.env.BACKEND_API_BASE + '/api/reload';
await axios
.post(url)
.then(async function (response: any) {
// after reload is completed, refresh the connections
getExistingConnections();
})
.catch((error: any) => {
setIsLoading(false);
console.log('Error -- > ', error);
});
}

const registerClient = () => {
setConnection({code: '', to: '', toEtasu: '', from: [''], system: '', _id: ''});
setAddNew(true);
Expand Down Expand Up @@ -125,6 +139,17 @@ const Connections = () => {
>
<Card>
<div className="right-btn">
<Button
variant="contained"
sx={{backgroundColor: '#53508E'}}
startIcon={<Refresh />}
onClick={() => {
reloadSpl();
}}
>
Reload
</Button>
<div className='button-gap'>&nbsp;</div>
<Button
variant="contained"
sx={{backgroundColor: '#53508E'}}
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type Config = {
discoveryApiUrl: string | undefined;
discoverySplZipUrl: string | undefined;
splZipFileName: string;
ncpdpScriptForwardUrl: string;
};
database: {
selected: string;
Expand Down Expand Up @@ -88,6 +89,7 @@ const config: Config = {
discoverySplZipUrl: env.get('DIRECTORY_SPL_PATH').asString(),
remsAdminHookPath: env.get('REMS_ADMIN_HOOK_PATH').asString(),
splZipFileName: env.get('SPL_ZIP_FILE_NAME').asString() || 'TESTDATA_rems_document_and_rems_indexing_spl_files.zip',
ncpdpScriptForwardUrl: env.get('NCPDP_SCRIPT_FORWARD_URL').asString() || 'http://localhost:5051/ncpdp/script',
remsAdminFhirEtasuPath:
env.get('REMS_ADMIN_FHIR_PATH').asString() + '/GuidanceResponse/$rems-etasu',
ehrUrl: env.get('EHR_URL').asString(),
Expand Down
28 changes: 26 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { IncomingMessage, ServerResponse } from 'node:http';
import axios from 'axios';
import path from 'path';
import { Connection } from './lib/schemas/Phonebook';
import { EHRWhitelist } from './hooks/hookProxy';
import { EHRWhitelist, loadPhonebook } from './hooks/hookProxy';
import cookieParser from 'cookie-parser';

const logger = container.get('application');
Expand All @@ -33,6 +33,7 @@ const initialize = (config: Config): REMSIntermediary => {
.setProfileRoutes()
.registerEndpoint()
.registerCdsHooks(config.server)
.registerNcpdpScript(config.general)
.setupLogin()
.setErrorRoutes();
};
Expand Down Expand Up @@ -77,7 +78,7 @@ class REMSIntermediary extends Server {
this.app.set('jsonp callback', true);
this.app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
this.app.use(bodyParser.json({ limit: '50mb' }));

this.app.use(bodyParser.text({ limit: '50mb', type: 'application/xml' }));
this.app.use(cookieParser());
this.app.use(cors(corsOptions));
this.app.options('*', cors(corsOptions));
Expand Down Expand Up @@ -128,6 +129,24 @@ class REMSIntermediary extends Server {
return this;
}

registerNcpdpScript({ ncpdpScriptForwardUrl }: Config['general']) {
console.log('Startup... forwarding NCPDP SCRIPT messages to ' + ncpdpScriptForwardUrl);
this.app.post('/script', async (req: any, res: any) => {
console.log('Processing NCPDP SCRIPT message');
console.log(' forwarding message to ' + ncpdpScriptForwardUrl);

// forward the message!
const options = {
method: 'POST',
data: req.body,
headers: req.headers
};
const response = await axios(ncpdpScriptForwardUrl, options);
return response.data;
});
return this;
}

setupLogin() {
this.app.get('/', async (req: any, res: { sendFile: (arg0: string) => void }) => {
res.sendFile(path.join(__dirname, '../public', 'index.html'));
Expand Down Expand Up @@ -246,6 +265,11 @@ class REMSIntermediary extends Server {
res.status(400).send({ message: 'Error updating connection', error });
}
});
this.app.post('/api/reload', async (req: any, res: any) => {
console.log('Processing phonebook reload');
await loadPhonebook();
res.send('Reload completed');
});
return this;
}
/**
Expand Down