Skip to content

Commit

Permalink
[PRMT-4832] Added additional logging to sds-fhir-client.js
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-nhs committed May 10, 2024
1 parent bc720c1 commit f0c14fb
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/services/fhir/sds-fhir-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ export const getPracticeAsid = async (odsCode, serviceId) => {
const { sdsFhirUrl, sdsFhirApiKey } = initializeConfig();
logInfo(`Getting ASID via FHIR for ODS code ${odsCode}`);
try {
const response = await axios.get(`${sdsFhirUrl}/Device`, {
params: {
organization: `https://fhir.nhs.uk/Id/ods-organization-code|${odsCode}`,
identifier: `https://fhir.nhs.uk/Id/nhsServiceInteractionId|${serviceId}`
},
headers: {
apiKey: sdsFhirApiKey
}
});

const entries = response.data.entry;
const entries = axios
.get(`${sdsFhirUrl}/Device`, {
params: {
organization: `https://fhir.nhs.uk/Id/ods-organization-code|${odsCode}`,
identifier: `https://fhir.nhs.uk/Id/nhsServiceInteractionId|${serviceId}`
},
headers: {
apiKey: sdsFhirApiKey
}
})
.then(response => response.data.entry)
.catch(error => {
logError(
`Error: Request failed with non-2xx status code\n
Response body: ${error.response.data}\n
HTTP Status code: ${error.response.status}`
);

throw error;
});

if (entries.length === 0) {
throw new Error(`No ASID entries found for ODS code ${odsCode}`);
Expand Down

0 comments on commit f0c14fb

Please sign in to comment.