From cb94831208f030bf616f4854e2b98c449a020903 Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:48:49 +0300 Subject: [PATCH] POC-781: added HPV payload to etl --- app/lab-integration/utils/lab-client.js | 34 ++++++++++++------- .../utils/poc-eid-payload-helper.js | 11 ++++++ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/lab-integration/utils/lab-client.js b/app/lab-integration/utils/lab-client.js index b8ab204de..a17fc1c94 100644 --- a/app/lab-integration/utils/lab-client.js +++ b/app/lab-integration/utils/lab-client.js @@ -69,6 +69,8 @@ export class LabClient { return this.postViralLoad(payload); case 3: return this.postCD4(payload); + case 5: + return this.postHPV(payload); default: break; } @@ -84,20 +86,26 @@ export class LabClient { postCD4(payload) { return this.getPostRequest(payload, `${this.config.serverUrl}/api/cd4`); } - + postHPV(payload) { + return this.getPostRequest(payload, `${this.config.serverUrl}/api/hpv`); + } getPostRequest(payload, endpoint) { - const options = { - uri: endpoint, - headers: { - apikey: this.config.apiKey, - 'Content-Type': 'application/x-www-form-urlencoded' - }, - method: 'POST', - // json: true, - form: payload, - timeout: 40000 - }; - return rp(options); + try { + const options = { + uri: endpoint, + headers: { + apikey: this.config.apiKey, + 'Content-Type': 'application/x-www-form-urlencoded' + }, + method: 'POST', + // json: true, + form: payload, + timeout: 40000 + }; + return rp(options); + } catch (error) { + console.log('getPostRequestError', error.message); + } } getFetchRequest(filterOptions, offset) { diff --git a/app/lab-integration/utils/poc-eid-payload-helper.js b/app/lab-integration/utils/poc-eid-payload-helper.js index fbfdc89de..1a7d5f996 100644 --- a/app/lab-integration/utils/poc-eid-payload-helper.js +++ b/app/lab-integration/utils/poc-eid-payload-helper.js @@ -34,6 +34,17 @@ amrs_location: getLocation(payload, 'mrsId') }; break; + case 'HPV': + eidPayload = { + test: 5, + mflCode: getLocation(payload, 'mflCode'), + patient_identifier: payload.patientIdentifier, + dob: payload.birthDate, + order_no: payload.orderNumber, + datecollected: payload.dateDrawn, + sex: getGenderCode(payload.sex) + }; + break; case 'DNAPCR': eidPayload = { test: 1,