Skip to content
This repository has been archived by the owner on Feb 8, 2025. It is now read-only.

Commit

Permalink
NMA-861 FHIR structured response to and from EMR Mediator for NPRS de…
Browse files Browse the repository at this point in the history
…veloped

- EMR Mediator updated to send requests for NPRS validation to NPRS Mediator in FHIR
  • Loading branch information
NgibuiniGikandi committed Apr 20, 2023
1 parent eb55207 commit 4c600c6
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/Controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,32 +98,41 @@ const validatePatient = async(req,res) => {
return;
}

//set content type to fhir
res.setHeader('Content-Type', 'application/fhir+json');

let body = req.body;

urlExists(config.nprsMediatorConfig.apiURL).then((exists) => {
if (exists) {
nprsAPI.POST(generateNPRSResource(body)).then(response => {
if(response.faultCode == 201){
res.status(200).send({response});
}
else{
res.status(200).send(response);
}

res.status(200).send(response);
}).catch(error => {
res.status(400).send(error)
})
}
else {
res.status(400).send({
"message": "No response from NPRS",
"status": "unknown",
"data": {
"idNo":body.identifier[0].value,
"sex": body.gender.charAt(0),
"surname": body.name[0].family,
"auth": "/Y63UYsirfLkT"
}

"resourceType": "Patient",
"identifier": [
{
"system": "http://ohie.org/National_ID",
"value": body.identifier[0].value
}
],
"extension": [
{
"url": "urn:validationproject:nprsStatus",
"valueString": "unknown"
}
],
"name": [
{
"family": body.name[0].family
}
],
"gender": body.gender
});
}
})
Expand Down

0 comments on commit 4c600c6

Please sign in to comment.