From 026d38d9b61f2b8634ec12c3097ee2882235483d Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Mon, 3 Jun 2024 12:49:46 +0300 Subject: [PATCH 1/5] POC-739 created the HEI register templates --- .../registers/hei-register-framework.json | 3 + .../registers/hei-register.json | 436 ++++++++++++++++++ app/routes/hei-register.route.js | 52 +++ .../hei_register/hei-register-service.js | 121 +++++ 4 files changed, 612 insertions(+) create mode 100644 app/reporting-framework/registers/hei-register-framework.json create mode 100644 app/reporting-framework/registers/hei-register.json create mode 100644 app/routes/hei-register.route.js create mode 100644 service/moh-tools/hei_register/hei-register-service.js diff --git a/app/reporting-framework/registers/hei-register-framework.json b/app/reporting-framework/registers/hei-register-framework.json new file mode 100644 index 000000000..1810ce61b --- /dev/null +++ b/app/reporting-framework/registers/hei-register-framework.json @@ -0,0 +1,3 @@ +{ + "reports": ["hei-register-template"] +} diff --git a/app/reporting-framework/registers/hei-register.json b/app/reporting-framework/registers/hei-register.json new file mode 100644 index 000000000..89a199c1e --- /dev/null +++ b/app/reporting-framework/registers/hei-register.json @@ -0,0 +1,436 @@ +{ + "name": "hei-register-template", + "version": "1.0", + "tag": "hei-register-template", + "description": "HIV Exposed Infant Register MOH 408", + "uses": [], + "sources": [ + { + "table": "etl.flat_hei_summary", + "alias": "fhi" + }, + { + "table": "amrs.person_name", + "alias": "p", + "join": { + "type": "LEFT", + "joinCondition": " p.person_id = fhi.person_id" + } + }, + { + "table": "amrs.location", + "alias": "l", + "join": { + "type": "LEFT", + "joinCondition": "l.location_id = fhi.location_id" + } + }, + { + "table": "amrs.patient_identifier", + "alias": "pi1", + "join": { + "type": "LEFT", + "joinCondition": "pi1.patient_id = fhi.person_id AND pi1.identifier_type = 46" + } + }, + { + "table": "amrs.patient_identifier", + "alias": "pi2", + "join": { + "type": "LEFT", + "joinCondition": "pi2.patient_id = fhi.person_id AND pi2.identifier_type = 8" + } + }, + { + "table": "amrs.patient_identifier", + "alias": "pi3", + "join": { + "type": "LEFT", + "joinCondition": "pi3.patient_id = fhi.person_id AND pi3.identifier_type = 38" + } + }, + { + "table": "amrs.patient_identifier", + "alias": "pi4", + "join": { + "type": "LEFT", + "joinCondition": "pi4.patient_id = fhi.person_id AND pi4.identifier_type = 45" + } + }, + { + "table": "amrs.person_attribute", + "alias": "pa", + "join": { + "type": "LEFT", + "joinCondition": "pa.person_id = fhi.person_id AND pa.person_attribute_type_id = 12" + } + }, + { + "table": "amrs.person_attribute", + "alias": "pa", + "join": { + "type": "LEFT", + "joinCondition": "pa.person_id = fhi.person_id AND pa.person_attribute_type_id = 10" + } + } + ], + "columns": [ + { + "type": "simple_column", + "alias": "person_id", + "column": "fhi.person_id" + }, + { + "type": "simple_column", + "alias": "date_enrolled", + "column": "DATE_FORMAT(fhi.date_enrolled,'%Y-%m-%d')" + }, + { + "type": "simple_column", + "alias": "date_of_birth", + "column": "fhi.birth_date" + }, + { + "type": "simple_column", + "alias": "gender", + "column": "fhi.gender" + }, + { + "type": "simple_column", + "alias": "upi_number", + "column": "flat_identifiers.nupi" + }, + { + "type": "simple_column", + "alias": "start_month", + "column": "DATE_FORMAT(hm.endDate,'%Y-%m')" + }, + { + "type": "simple_column", + "alias": "infant_name", + "column": " CONCAT(p.given_name, ' ', p.middle_name, ' ', p.family_name)" + }, + { + "type": "simple_column", + "alias": "location", + "column": "l.name" + }, + { + "type": "simple_column", + "alias": "birth_certificate_number", + "column": "pi1.identifier" + }, + { + "type": "simple_column", + "alias": "amrs_number", + "column": "pi2.identifier" + }, + { + "type": "simple_column", + "alias": "hei_id", + "column": "pi3.identifier" + }, + { + "type": "simple_column", + "alias": "nupi", + "column": "pi4.identifier" + }, + { + "type": "simple_column", + "alias": "parent_name", + "column": "pa.value" + }, + { + "type": "simple_column", + "alias": "Phone_Number", + "column": "pa2.value" + }, + { + "type": "simple_column", + "alias": "initial_hiv_dna_pcr_order_date", + "column": "fhi.initial_hiv_dna_pcr_order_date" + }, + { + "type": "simple_column", + "alias": "first_pcr_date", + "column": "fhi.hiv_dna_pcr_1_date" + }, + { + "type": "simple_column", + "alias": "second_pcr_date", + "column": "fhi.hiv_dna_pcr_2_date" + }, + { + "type": "simple_column", + "alias": "third_pcr_date", + "column": "fhi.hiv_dna_pcr_3_date" + }, + { + "type": "simple_column", + "alias": "confirm_pcr_date", + "column": "fhi.hiv_dna_pcr_4_date" + }, + { + "type": "simple_column", + "alias": "third_pcr_date", + "column": "fhi.hiv_dna_pcr_3_date" + }, + { + "type": "simple_column", + "alias": "first_antibody_date", + "column": "fhi.antibody_screen_1_date" + }, + { + "type": "simple_column", + "alias": "second_antibody_date", + "column": "fhi.antibody_screen_2_date" + }, + { + "type": "derived_column", + "alias": "age_in_weeks_on_first_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "FLOOR(DATEDIFF(fhi.initial_hiv_dna_pcr_order_date, fhi.birth_date) / 7)" + } + }, + { + "type": "derived_column", + "alias": "results_pcr_first_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "COALESCE(fhi.hiv_dna_pcr_resulted, fhi.hiv_dna_pcr_1) = 664", + "value": "N" + }, + { + "condition": "COALESCE(fhi.hiv_dna_pcr_resulted, fhi.hiv_dna_pcr_1) = 703", + "value": "P" + } + ] + } + }, + { + "type": "derived_column", + "alias": "age_in_months_on_second_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "(EXTRACT(YEAR FROM fhi.hiv_dna_pcr_2_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_2_date) - EXTRACT(MONTH FROM fhi.birth_date))" + } + }, + { + "type": "derived_column", + "alias": "age_in_months_on_confirm_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "(EXTRACT(YEAR FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(MONTH FROM fhi.birth_date))" + } + }, + { + "type": "derived_column", + "alias": "age_in_months_on_first_antibody", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "(EXTRACT(YEAR FROM fhi.antibody_screen_1_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.antibody_screen_1_date) - EXTRACT(MONTH FROM fhi.birth_date))" + } + }, + { + "type": "derived_column", + "alias": "age_in_months_on_second_antibody", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "(EXTRACT(YEAR FROM fhi.antibody_screen_2_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.antibody_screen_2_date) - EXTRACT(MONTH FROM fhi.birth_date))" + } + }, + { + "type": "derived_column", + "alias": "results_pcr_second_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "COALESCE(fhi.hiv_dna_pcr_2) = 664", + "value": "N" + }, + { + "condition": "COALESCE(fhi.hiv_dna_pcr_2) = 703", + "value": "P" + } + ] + } + }, + { + "type": "derived_column", + "alias": "age_in_months_on_third_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": " (EXTRACT(YEAR FROM fhi.hiv_dna_pcr_3_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_3_date) - EXTRACT(MONTH FROM fhi.birth_date))" + } + }, + { + "type": "derived_column", + "alias": "results_pcr_third_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "COALESCE(fhi.hiv_dna_pcr_3) = 664", + "value": "N" + }, + { + "condition": "COALESCE(fhi.hiv_dna_pcr_3) = 703", + "value": "P" + } + ] + } + }, + { + "type": "derived_column", + "alias": "results_confirm_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "COALESCE(fhi.hiv_dna_pcr_4) = 664", + "value": "N" + }, + { + "condition": "COALESCE(fhi.hiv_dna_pcr_4) = 703", + "value": "P" + } + ] + } + }, + { + "type": "derived_column", + "alias": "results_first_antibody", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "COALESCE(fhi.antibody_screen_1) = 664", + "value": "N" + }, + { + "condition": "COALESCE(fhi.antibody_screen_1) = 703", + "value": "P" + } + ] + } + }, + { + "type": "derived_column", + "alias": "results_second_antibody", + "expressionType": "simple_expression", + "expressionOptions": { + "caseOptions": [ + { + "condition": "COALESCE(fhi.antibody_screen_2) = 664", + "value": "N" + }, + { + "condition": "COALESCE(fhi.antibody_screen_2) = 703", + "value": "P" + } + ] + } + }, + { + "type": "derived_column", + "alias": "age_in_months_on_confirm_pcr", + "expressionType": "simple_expression", + "expressionOptions": { + "expression": "(EXTRACT(YEAR FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(MONTH FROM fhi.birth_date))" + } + }, + { + "type": "derived_column", + "alias": "infant_feeding", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fhi.infant_feeding_method = 5", + "value": "BF" + }, + { + "condition": "fhi.infant_feeding_method = 17", + "value": "NBF" + }, + { + "condition": "fhi.infant_feeding_method = 15", + "value": "BF" + }, + { + "condition": "fhi.infant_feeding_method = 6", + "value": "BF" + }, + { + "condition": "fhi.infant_feeding_method = 9", + "value": "BF" + }, + { + "condition": "fhi.infant_feeding_method = 8", + "value": "NBF" + }, + { + "condition": "fhi.infant_feeding_method = 3", + "value": "NBF" + } + ] + } + }, + { + "type": "derived_column", + "alias": "hei_outcome", + "expressionType": "case_statement", + "expressionOptions": { + "caseOptions": [ + { + "condition": "fhi.hei_outcome = 1", + "value": "Infected" + }, + { + "condition": "fhi.hei_outcome = 2", + "value": "Uninfected" + }, + { + "condition": "fhi.hei_outcome = 3 ", + "value": "Lost to Follow" + }, + { + "condition": "fhi.hei_outcome = 4", + "value": "Transfer Out" + }, + { + "condition": "fhi.hei_outcome = 5", + "value": "Dead" + }, + { + "condition": "fhi.hei_outcome = 6", + "value": "unknown" + } + ] + } + } + ], + "filters": { + "conditionJoinOperator": "and", + "conditions": [ + { + "filterType": "tableColumns", + "conditionExpression": "DATE_FORMAT(fhi.birth_date, '%Y-%m') = ?", + "parameterName": "cohort" + }, + { + "filterType": "tableColumns", + "conditionExpression": "hm.location_id in ? ", + "parameterName": "locations" + } + ] + }, + "groupBy": { + "groupParam": "groupByParam", + "columns": ["fhi.person_id"] + } +} diff --git a/app/routes/hei-register.route.js b/app/routes/hei-register.route.js new file mode 100644 index 000000000..9c27af34c --- /dev/null +++ b/app/routes/hei-register.route.js @@ -0,0 +1,52 @@ +var authorizer = require('../../authorization/etl-authorizer'); +import { HEIRegisterService } from '../../service/moh-tools/hei_register/hei-register-service'; +var etlHelpers = require('../../etl-helpers'); +var privileges = authorizer.getAllPrivileges(); +var preRequest = require('../../pre-request-processing'); +const routes = [ + { + method: 'GET', + path: '/etl/hei-register', + config: { + plugins: { + hapiAuthorization: { + role: privileges.canViewClinicDashBoard + } + }, + handler: function (request, reply) { + preRequest.resolveLocationIdsToLocationUuids(request, function () { + let requestParams = Object.assign({}, request.query, request.params); + let reportParams = etlHelpers.getReportParams( + 'hei-register', + ['endDate', 'startDate', 'locationUuids'], + requestParams + ); + + reportParams.requestParams.isAggregated = true; + let service = new HEIRegisterService( + 'hei-register', + reportParams.requestParams + ); + service + .generateReport(reportParams.requestParams) + .then((result) => { + reply(result); + }) + .catch((error) => { + reply(error); + }); + }); + }, + description: 'hei reigister', + notes: 'hei register', + tags: ['api'], + validate: { + options: { + allowUnknown: true + }, + params: {} + } + } + } +]; +exports.routes = (server) => server.route(routes); diff --git a/service/moh-tools/hei_register/hei-register-service.js b/service/moh-tools/hei_register/hei-register-service.js new file mode 100644 index 000000000..0f55184e3 --- /dev/null +++ b/service/moh-tools/hei_register/hei-register-service.js @@ -0,0 +1,121 @@ +const _ = require('lodash'); + +import { MultiDatasetPatientlistReport } from '../../app/reporting-framework/multi-dataset-patientlist.report.js'; +import ReportProcessorHelpersService from '../../app/reporting-framework/report-processor-helpers.service'; + +const etlHelpers = require('../../etl-helpers.js'); +const heiregisterSections = require('../../../app/reporting-framework/registers/hei-register-framework.json'); + +export class HeiRegisterService extends MultiDatasetPatientlistReport { + constructor(reportName, params) { + if (params.isAggregated) { + params.excludeParam = ['location_id']; + params.joinColumnParam = 'join_location'; + } + + super(reportName, params); + } + getAggregateReport(reportParams) { + const that = this; + return new Promise((resolve, reject) => { + super + .generateReport(reportParams) + .then((results) => { + if (reportParams && reportParams.type === 'patient-list') { + resolve(results); + } else { + let finalResult = []; + const reportProcessorHelpersService = new ReportProcessorHelpersService(); + for (let result of results) { + if ( + result.report && + result.report.reportSchemas && + result.report.reportSchemas.main && + result.report.reportSchemas.main.transFormDirectives.joinColumn + ) { + finalResult = reportProcessorHelpersService.joinDataSets( + that.params[ + result.report.reportSchemas.main.transFormDirectives + .joinColumnParam + ] || + result.report.reportSchemas.main.transFormDirectives + .joinColumn, + finalResult, + result?.results?.results?.results + ); + } + } + resolve({ + queriesAndSchemas: results, + result: finalResult, + sectionDefinitions: prepMonthlyReportSections, + indicatorDefinitions: [] + }); + } + }) + .catch((error) => { + console.error('hei register generation error: ', error); + reject(error); + }); + }); + } + + generatePatientList(indicators) { + let self = this; + return new Promise((resolve, reject) => { + super + .generatePatientListReport(indicators) + .then((results) => { + let indicatorLabels = self.getIndicatorSectionDefinitions( + results.indicators, + prepMonthlyReportSections + ); + + results.indicators = indicatorLabels; + + if (results.result.length > 0) { + _.each(results.result, (item) => { + item.cur_prep_meds_names = etlHelpers.getARVNames( + item.cur_prep_meds_names + ); + }); + } + + self + .resolveLocationUuidsToName(self.params.locationUuids) + .then((locations) => { + results.locations = locations; + resolve(results); + }) + .catch((err) => { + resolve(results); + }); + }) + .catch((err) => { + reject(results); + }); + }); + } + + getIndicatorSectionDefinitions(requestIndicators, sectionDefinitions) { + let results = []; + _.each(requestIndicators, function (requestIndicator) { + _.each(sectionDefinitions, function (sectionDefinition) { + _.each(sectionDefinition.indicators, function (indicator) { + if (indicator.indicator === requestIndicator) { + results.push(indicator); + } + }); + }); + }); + return results; + } + + resolveLocationUuidsToName(uuids) { + return new Promise((resolve, reject) => { + dao.resolveLocationUuidsToName(uuids.split(','), (loc) => { + resolve(loc); + }); + }); + } +} From a8c83e9e7c6978f19ebf9c7f282209fc8c0322f2 Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Wed, 5 Jun 2024 00:03:20 +0300 Subject: [PATCH 2/5] POC-739 created dataset for HEI and Care and treatment registers --- app/registers-framework/registers-db.js | 163 +++++++ .../registers/hei-register-framework.json | 3 - .../registers/hei-register.json | 436 ------------------ app/routes/hei-register.route.js | 52 --- app/routes/register.route.js | 60 +++ .../hei_register/hei-register-service.js | 121 ----- 6 files changed, 223 insertions(+), 612 deletions(-) create mode 100644 app/registers-framework/registers-db.js delete mode 100644 app/reporting-framework/registers/hei-register-framework.json delete mode 100644 app/reporting-framework/registers/hei-register.json delete mode 100644 app/routes/hei-register.route.js create mode 100644 app/routes/register.route.js delete mode 100644 service/moh-tools/hei_register/hei-register-service.js diff --git a/app/registers-framework/registers-db.js b/app/registers-framework/registers-db.js new file mode 100644 index 000000000..dcdc89cf1 --- /dev/null +++ b/app/registers-framework/registers-db.js @@ -0,0 +1,163 @@ +var db = require('../../etl-db'); + +var defs = { + getHeiDetails: (params) => { + return new Promise((resolve, reject) => { + let queryParts = {}; + let sql = ` + SELECT + fhi.person_id, + fhi.date_enrolled, + fhi.birth_date, + fhi.gender, + CONCAT(p.given_name, ' ', p.middle_name, ' ', p.family_name) AS Infant_name, + l.name AS Location, + pi1.identifier AS Birth_Certificate_number, + pi2.identifier AS AMRS_Number, + pi3.identifier AS HEI_ID, + pi4.identifier AS NUPI, + pa.value AS parent_name, + pa2.value AS Phone_Number, + fhi.initial_hiv_dna_pcr_order_date, + FLOOR(DATEDIFF(fhi.initial_hiv_dna_pcr_order_date, fhi.birth_date) / 7) AS age_in_weeks_on_first_pcr, + fhi.hiv_dna_pcr_1_date AS first_pcr_date, + CASE + WHEN COALESCE(fhi.hiv_dna_pcr_resulted, fhi.hiv_dna_pcr_1) = 664 THEN 'N' + WHEN COALESCE(fhi.hiv_dna_pcr_resulted, fhi.hiv_dna_pcr_1) = 703 THEN 'P' + END AS results_pcr_first_pcr, + (EXTRACT(YEAR FROM fhi.hiv_dna_pcr_2_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_2_date) - EXTRACT(MONTH FROM fhi.birth_date)) AS age_in_months_on_second_pcr, + fhi.hiv_dna_pcr_2_date AS second_pcr_date, + CASE + WHEN COALESCE(fhi.hiv_dna_pcr_2) = 664 THEN 'N' + WHEN COALESCE(fhi.hiv_dna_pcr_2) = 703 THEN 'P' + END AS results_pcr_second_pcr, + (EXTRACT(YEAR FROM fhi.hiv_dna_pcr_3_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_3_date) - EXTRACT(MONTH FROM fhi.birth_date)) AS age_in_months_on_third_pcr, + fhi.hiv_dna_pcr_3_date AS third_pcr_date, + CASE + WHEN COALESCE(fhi.hiv_dna_pcr_3) = 664 THEN 'N' + WHEN COALESCE(fhi.hiv_dna_pcr_3) = 703 THEN 'P' + END AS results_pcr_third_pcr, + (EXTRACT(YEAR FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(MONTH FROM fhi.birth_date)) AS age_in_months_on_confirm_pcr, + fhi.hiv_dna_pcr_4_date AS confirm_pcr_date, + CASE + WHEN COALESCE(fhi.hiv_dna_pcr_4) = 664 THEN 'N' + WHEN COALESCE(fhi.hiv_dna_pcr_4) = 703 THEN 'P' + END AS results_confirm_pcr, + (EXTRACT(YEAR FROM fhi.antibody_screen_1_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + + (EXTRACT(MONTH FROM fhi.antibody_screen_1_date) - EXTRACT(MONTH FROM fhi.birth_date)) AS age_in_months_on_first_antibody, + fhi.antibody_screen_1_date AS first_antibody_date, + CASE + WHEN COALESCE(fhi.antibody_screen_1) = 664 THEN 'N' + WHEN COALESCE(fhi.antibody_screen_1) = 703 THEN 'P' + END AS results_first_antibody, + (EXTRACT(YEAR FROM fhi.antibody_screen_2_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + + (EXTRACT(MONTH FROM fhi.antibody_screen_2_date) - EXTRACT(MONTH FROM fhi.birth_date)) AS age_in_months_on_second_antibody, + fhi.antibody_screen_2_date AS second_antibody_date, + CASE + WHEN fhi.antibody_screen_2 = 664 THEN 'N' + WHEN fhi.antibody_screen_2 = 703 THEN 'P' + END AS results_second_antibody, + CASE + WHEN fhi.infant_feeding_method IN (5, 15, 6, 9) THEN 'BF' + WHEN fhi.infant_feeding_method IN (17, 8, 3) THEN 'NBF' + END AS infant_feeding, + CASE + WHEN fhi.hei_outcome = 1 THEN 'Infected' + WHEN fhi.hei_outcome = 2 THEN 'Uninfected' + WHEN fhi.hei_outcome = 3 THEN 'Lost to Follow' + WHEN fhi.hei_outcome = 4 THEN 'Transfer Out' + WHEN fhi.hei_outcome = 5 THEN 'Dead' + WHEN fhi.hei_outcome = 6 THEN 'f' + END AS hei_outcome + FROM + etl.flat_hei_summary fhi + LEFT JOIN amrs.person_name p ON p.person_id = fhi.person_id + LEFT JOIN amrs.location l ON l.location_id = fhi.location_id + LEFT JOIN amrs.patient_identifier pi1 ON pi1.patient_id = fhi.person_id AND pi1.identifier_type = 46 + LEFT JOIN amrs.patient_identifier pi2 ON pi2.patient_id = fhi.person_id AND pi2.identifier_type = 8 + LEFT JOIN amrs.patient_identifier pi3 ON pi3.patient_id = fhi.person_id AND pi3.identifier_type = 38 + LEFT JOIN amrs.patient_identifier pi4 ON pi4.patient_id = fhi.person_id AND pi4.identifier_type = 45 + LEFT JOIN amrs.person_attribute pa ON pa.person_id = fhi.person_id AND pa.person_attribute_type_id = 12 + LEFT JOIN amrs.person_attribute pa2 ON pa2.person_id = fhi.person_id AND pa2.person_attribute_type_id = 10 + WHERE + DATE_FORMAT(fhi.birth_date, '%Y-%m') = '2023-04' + AND fhi.location_id IN (315) + GROUP BY + fhi.person_id +`; + + queryParts = { + sql: sql + }; + return db.queryServer(queryParts, function (result) { + result.sql = sql; + resolve(result.result); + }); + }); + }, + getCareTreatmentDetails: (params) => { + return new Promise((resolve, reject) => { + let queryParts = {}; + let sql = ` + SELECT + fhs.encounter_datetime AS DATE, + pi.identifier AS National_ID, + pi3.identifier AS NUPI, + pi2.identifier AS CCC_Number, + EXTRACT(YEAR FROM fhs.encounter_datetime) - EXTRACT(YEAR FROM p.birthdate) - CASE + WHEN + (EXTRACT(MONTH FROM fhs.encounter_datetime) < EXTRACT(MONTH FROM p.birthdate)) + OR (EXTRACT(MONTH FROM fhs.encounter_datetime) = EXTRACT(MONTH FROM p.birthdate) + AND EXTRACT(DAY FROM fhs.encounter_datetime) < EXTRACT(DAY FROM p.birthdate)) + THEN + 1 + ELSE 0 + END AS Age, + CASE + WHEN DATE(fhs.encounter_datetime) = DATE(fhs.hiv_start_date) THEN 1 + ELSE 0 + END AS started_on_art, + fhs.tb_screen as screened_for_tb, + CASE + WHEN DATE(fhs.encounter_datetime) = DATE(fhs.ipt_start_date) THEN 1 + ELSE 0 + END AS started_on_tpt, + null as Dsd_status, + null as Dsd_type, + null as remarks + FROM + etl.flat_hiv_summary_v15b fhs + INNER JOIN + amrs.person p ON p.person_id = fhs.person_id + left join + amrs.location l on l.location_id and fhs.location_id + LEFT JOIN + amrs.patient_identifier pi ON pi.patient_id = fhs.person_id + AND pi.identifier_type = 5 + LEFT JOIN + amrs.patient_identifier pi2 ON fhs.person_id = pi2.patient_id + AND pi2.identifier_type = 28 + LEFT JOIN + amrs.patient_identifier pi3 ON fhs.person_id = pi3.patient_id + AND pi3.identifier_type = 45 + WHERE + fhs.is_clinical_encounter=1 + and DATE(fhs.encounter_datetime) = '2024-04-02' + and fhs.location_id in (315); +`; + + queryParts = { + sql: sql + }; + return db.queryServer(queryParts, function (result) { + result.sql = sql; + resolve(result.result); + }); + }); + } +}; + +module.exports = defs; diff --git a/app/reporting-framework/registers/hei-register-framework.json b/app/reporting-framework/registers/hei-register-framework.json deleted file mode 100644 index 1810ce61b..000000000 --- a/app/reporting-framework/registers/hei-register-framework.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "reports": ["hei-register-template"] -} diff --git a/app/reporting-framework/registers/hei-register.json b/app/reporting-framework/registers/hei-register.json deleted file mode 100644 index 89a199c1e..000000000 --- a/app/reporting-framework/registers/hei-register.json +++ /dev/null @@ -1,436 +0,0 @@ -{ - "name": "hei-register-template", - "version": "1.0", - "tag": "hei-register-template", - "description": "HIV Exposed Infant Register MOH 408", - "uses": [], - "sources": [ - { - "table": "etl.flat_hei_summary", - "alias": "fhi" - }, - { - "table": "amrs.person_name", - "alias": "p", - "join": { - "type": "LEFT", - "joinCondition": " p.person_id = fhi.person_id" - } - }, - { - "table": "amrs.location", - "alias": "l", - "join": { - "type": "LEFT", - "joinCondition": "l.location_id = fhi.location_id" - } - }, - { - "table": "amrs.patient_identifier", - "alias": "pi1", - "join": { - "type": "LEFT", - "joinCondition": "pi1.patient_id = fhi.person_id AND pi1.identifier_type = 46" - } - }, - { - "table": "amrs.patient_identifier", - "alias": "pi2", - "join": { - "type": "LEFT", - "joinCondition": "pi2.patient_id = fhi.person_id AND pi2.identifier_type = 8" - } - }, - { - "table": "amrs.patient_identifier", - "alias": "pi3", - "join": { - "type": "LEFT", - "joinCondition": "pi3.patient_id = fhi.person_id AND pi3.identifier_type = 38" - } - }, - { - "table": "amrs.patient_identifier", - "alias": "pi4", - "join": { - "type": "LEFT", - "joinCondition": "pi4.patient_id = fhi.person_id AND pi4.identifier_type = 45" - } - }, - { - "table": "amrs.person_attribute", - "alias": "pa", - "join": { - "type": "LEFT", - "joinCondition": "pa.person_id = fhi.person_id AND pa.person_attribute_type_id = 12" - } - }, - { - "table": "amrs.person_attribute", - "alias": "pa", - "join": { - "type": "LEFT", - "joinCondition": "pa.person_id = fhi.person_id AND pa.person_attribute_type_id = 10" - } - } - ], - "columns": [ - { - "type": "simple_column", - "alias": "person_id", - "column": "fhi.person_id" - }, - { - "type": "simple_column", - "alias": "date_enrolled", - "column": "DATE_FORMAT(fhi.date_enrolled,'%Y-%m-%d')" - }, - { - "type": "simple_column", - "alias": "date_of_birth", - "column": "fhi.birth_date" - }, - { - "type": "simple_column", - "alias": "gender", - "column": "fhi.gender" - }, - { - "type": "simple_column", - "alias": "upi_number", - "column": "flat_identifiers.nupi" - }, - { - "type": "simple_column", - "alias": "start_month", - "column": "DATE_FORMAT(hm.endDate,'%Y-%m')" - }, - { - "type": "simple_column", - "alias": "infant_name", - "column": " CONCAT(p.given_name, ' ', p.middle_name, ' ', p.family_name)" - }, - { - "type": "simple_column", - "alias": "location", - "column": "l.name" - }, - { - "type": "simple_column", - "alias": "birth_certificate_number", - "column": "pi1.identifier" - }, - { - "type": "simple_column", - "alias": "amrs_number", - "column": "pi2.identifier" - }, - { - "type": "simple_column", - "alias": "hei_id", - "column": "pi3.identifier" - }, - { - "type": "simple_column", - "alias": "nupi", - "column": "pi4.identifier" - }, - { - "type": "simple_column", - "alias": "parent_name", - "column": "pa.value" - }, - { - "type": "simple_column", - "alias": "Phone_Number", - "column": "pa2.value" - }, - { - "type": "simple_column", - "alias": "initial_hiv_dna_pcr_order_date", - "column": "fhi.initial_hiv_dna_pcr_order_date" - }, - { - "type": "simple_column", - "alias": "first_pcr_date", - "column": "fhi.hiv_dna_pcr_1_date" - }, - { - "type": "simple_column", - "alias": "second_pcr_date", - "column": "fhi.hiv_dna_pcr_2_date" - }, - { - "type": "simple_column", - "alias": "third_pcr_date", - "column": "fhi.hiv_dna_pcr_3_date" - }, - { - "type": "simple_column", - "alias": "confirm_pcr_date", - "column": "fhi.hiv_dna_pcr_4_date" - }, - { - "type": "simple_column", - "alias": "third_pcr_date", - "column": "fhi.hiv_dna_pcr_3_date" - }, - { - "type": "simple_column", - "alias": "first_antibody_date", - "column": "fhi.antibody_screen_1_date" - }, - { - "type": "simple_column", - "alias": "second_antibody_date", - "column": "fhi.antibody_screen_2_date" - }, - { - "type": "derived_column", - "alias": "age_in_weeks_on_first_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": "FLOOR(DATEDIFF(fhi.initial_hiv_dna_pcr_order_date, fhi.birth_date) / 7)" - } - }, - { - "type": "derived_column", - "alias": "results_pcr_first_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "caseOptions": [ - { - "condition": "COALESCE(fhi.hiv_dna_pcr_resulted, fhi.hiv_dna_pcr_1) = 664", - "value": "N" - }, - { - "condition": "COALESCE(fhi.hiv_dna_pcr_resulted, fhi.hiv_dna_pcr_1) = 703", - "value": "P" - } - ] - } - }, - { - "type": "derived_column", - "alias": "age_in_months_on_second_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": "(EXTRACT(YEAR FROM fhi.hiv_dna_pcr_2_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_2_date) - EXTRACT(MONTH FROM fhi.birth_date))" - } - }, - { - "type": "derived_column", - "alias": "age_in_months_on_confirm_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": "(EXTRACT(YEAR FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(MONTH FROM fhi.birth_date))" - } - }, - { - "type": "derived_column", - "alias": "age_in_months_on_first_antibody", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": "(EXTRACT(YEAR FROM fhi.antibody_screen_1_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.antibody_screen_1_date) - EXTRACT(MONTH FROM fhi.birth_date))" - } - }, - { - "type": "derived_column", - "alias": "age_in_months_on_second_antibody", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": "(EXTRACT(YEAR FROM fhi.antibody_screen_2_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.antibody_screen_2_date) - EXTRACT(MONTH FROM fhi.birth_date))" - } - }, - { - "type": "derived_column", - "alias": "results_pcr_second_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "caseOptions": [ - { - "condition": "COALESCE(fhi.hiv_dna_pcr_2) = 664", - "value": "N" - }, - { - "condition": "COALESCE(fhi.hiv_dna_pcr_2) = 703", - "value": "P" - } - ] - } - }, - { - "type": "derived_column", - "alias": "age_in_months_on_third_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": " (EXTRACT(YEAR FROM fhi.hiv_dna_pcr_3_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_3_date) - EXTRACT(MONTH FROM fhi.birth_date))" - } - }, - { - "type": "derived_column", - "alias": "results_pcr_third_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "caseOptions": [ - { - "condition": "COALESCE(fhi.hiv_dna_pcr_3) = 664", - "value": "N" - }, - { - "condition": "COALESCE(fhi.hiv_dna_pcr_3) = 703", - "value": "P" - } - ] - } - }, - { - "type": "derived_column", - "alias": "results_confirm_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "caseOptions": [ - { - "condition": "COALESCE(fhi.hiv_dna_pcr_4) = 664", - "value": "N" - }, - { - "condition": "COALESCE(fhi.hiv_dna_pcr_4) = 703", - "value": "P" - } - ] - } - }, - { - "type": "derived_column", - "alias": "results_first_antibody", - "expressionType": "simple_expression", - "expressionOptions": { - "caseOptions": [ - { - "condition": "COALESCE(fhi.antibody_screen_1) = 664", - "value": "N" - }, - { - "condition": "COALESCE(fhi.antibody_screen_1) = 703", - "value": "P" - } - ] - } - }, - { - "type": "derived_column", - "alias": "results_second_antibody", - "expressionType": "simple_expression", - "expressionOptions": { - "caseOptions": [ - { - "condition": "COALESCE(fhi.antibody_screen_2) = 664", - "value": "N" - }, - { - "condition": "COALESCE(fhi.antibody_screen_2) = 703", - "value": "P" - } - ] - } - }, - { - "type": "derived_column", - "alias": "age_in_months_on_confirm_pcr", - "expressionType": "simple_expression", - "expressionOptions": { - "expression": "(EXTRACT(YEAR FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(YEAR FROM fhi.birth_date)) * 12 + (EXTRACT(MONTH FROM fhi.hiv_dna_pcr_4_date) - EXTRACT(MONTH FROM fhi.birth_date))" - } - }, - { - "type": "derived_column", - "alias": "infant_feeding", - "expressionType": "case_statement", - "expressionOptions": { - "caseOptions": [ - { - "condition": "fhi.infant_feeding_method = 5", - "value": "BF" - }, - { - "condition": "fhi.infant_feeding_method = 17", - "value": "NBF" - }, - { - "condition": "fhi.infant_feeding_method = 15", - "value": "BF" - }, - { - "condition": "fhi.infant_feeding_method = 6", - "value": "BF" - }, - { - "condition": "fhi.infant_feeding_method = 9", - "value": "BF" - }, - { - "condition": "fhi.infant_feeding_method = 8", - "value": "NBF" - }, - { - "condition": "fhi.infant_feeding_method = 3", - "value": "NBF" - } - ] - } - }, - { - "type": "derived_column", - "alias": "hei_outcome", - "expressionType": "case_statement", - "expressionOptions": { - "caseOptions": [ - { - "condition": "fhi.hei_outcome = 1", - "value": "Infected" - }, - { - "condition": "fhi.hei_outcome = 2", - "value": "Uninfected" - }, - { - "condition": "fhi.hei_outcome = 3 ", - "value": "Lost to Follow" - }, - { - "condition": "fhi.hei_outcome = 4", - "value": "Transfer Out" - }, - { - "condition": "fhi.hei_outcome = 5", - "value": "Dead" - }, - { - "condition": "fhi.hei_outcome = 6", - "value": "unknown" - } - ] - } - } - ], - "filters": { - "conditionJoinOperator": "and", - "conditions": [ - { - "filterType": "tableColumns", - "conditionExpression": "DATE_FORMAT(fhi.birth_date, '%Y-%m') = ?", - "parameterName": "cohort" - }, - { - "filterType": "tableColumns", - "conditionExpression": "hm.location_id in ? ", - "parameterName": "locations" - } - ] - }, - "groupBy": { - "groupParam": "groupByParam", - "columns": ["fhi.person_id"] - } -} diff --git a/app/routes/hei-register.route.js b/app/routes/hei-register.route.js deleted file mode 100644 index 9c27af34c..000000000 --- a/app/routes/hei-register.route.js +++ /dev/null @@ -1,52 +0,0 @@ -var authorizer = require('../../authorization/etl-authorizer'); -import { HEIRegisterService } from '../../service/moh-tools/hei_register/hei-register-service'; -var etlHelpers = require('../../etl-helpers'); -var privileges = authorizer.getAllPrivileges(); -var preRequest = require('../../pre-request-processing'); -const routes = [ - { - method: 'GET', - path: '/etl/hei-register', - config: { - plugins: { - hapiAuthorization: { - role: privileges.canViewClinicDashBoard - } - }, - handler: function (request, reply) { - preRequest.resolveLocationIdsToLocationUuids(request, function () { - let requestParams = Object.assign({}, request.query, request.params); - let reportParams = etlHelpers.getReportParams( - 'hei-register', - ['endDate', 'startDate', 'locationUuids'], - requestParams - ); - - reportParams.requestParams.isAggregated = true; - let service = new HEIRegisterService( - 'hei-register', - reportParams.requestParams - ); - service - .generateReport(reportParams.requestParams) - .then((result) => { - reply(result); - }) - .catch((error) => { - reply(error); - }); - }); - }, - description: 'hei reigister', - notes: 'hei register', - tags: ['api'], - validate: { - options: { - allowUnknown: true - }, - params: {} - } - } - } -]; -exports.routes = (server) => server.route(routes); diff --git a/app/routes/register.route.js b/app/routes/register.route.js new file mode 100644 index 000000000..92bacc6fc --- /dev/null +++ b/app/routes/register.route.js @@ -0,0 +1,60 @@ +var authorizer = require('../../authorization/etl-authorizer'); +var privileges = authorizer.getAllPrivileges(); +var dbRegister = require('../registers-framework/registers-db'); + +const routes = [ + { + method: 'GET', + path: '/etl/hei-register', + config: { + plugins: {}, + handler: function (request, reply) { + dbRegister + .getHeiDetails(request.query.p) + .then((result) => { + reply(result); + }) + .catch((error) => { + reply(error); + }); + }, + description: 'List of facilities with MFL code', + notes: 'Returns facilities list', + tags: ['api'], + validate: { + options: { + allowUnknown: true + }, + params: {} + } + } + }, + { + method: 'GET', + path: '/etl/care-and-treatment-register', + config: { + plugins: {}, + handler: function (request, reply) { + dbRegister + .getCareTreatmentDetails(request.query.p) + .then((result) => { + reply(result); + }) + .catch((error) => { + reply(error); + }); + }, + description: 'List of facilities with MFL code', + notes: 'Returns facilities list', + tags: ['api'], + validate: { + options: { + allowUnknown: true + }, + params: {} + } + } + } +]; + +exports.routes = (server) => server.route(routes); diff --git a/service/moh-tools/hei_register/hei-register-service.js b/service/moh-tools/hei_register/hei-register-service.js deleted file mode 100644 index 0f55184e3..000000000 --- a/service/moh-tools/hei_register/hei-register-service.js +++ /dev/null @@ -1,121 +0,0 @@ -const _ = require('lodash'); - -import { MultiDatasetPatientlistReport } from '../../app/reporting-framework/multi-dataset-patientlist.report.js'; -import ReportProcessorHelpersService from '../../app/reporting-framework/report-processor-helpers.service'; - -const etlHelpers = require('../../etl-helpers.js'); -const heiregisterSections = require('../../../app/reporting-framework/registers/hei-register-framework.json'); - -export class HeiRegisterService extends MultiDatasetPatientlistReport { - constructor(reportName, params) { - if (params.isAggregated) { - params.excludeParam = ['location_id']; - params.joinColumnParam = 'join_location'; - } - - super(reportName, params); - } - getAggregateReport(reportParams) { - const that = this; - return new Promise((resolve, reject) => { - super - .generateReport(reportParams) - .then((results) => { - if (reportParams && reportParams.type === 'patient-list') { - resolve(results); - } else { - let finalResult = []; - const reportProcessorHelpersService = new ReportProcessorHelpersService(); - for (let result of results) { - if ( - result.report && - result.report.reportSchemas && - result.report.reportSchemas.main && - result.report.reportSchemas.main.transFormDirectives.joinColumn - ) { - finalResult = reportProcessorHelpersService.joinDataSets( - that.params[ - result.report.reportSchemas.main.transFormDirectives - .joinColumnParam - ] || - result.report.reportSchemas.main.transFormDirectives - .joinColumn, - finalResult, - result?.results?.results?.results - ); - } - } - resolve({ - queriesAndSchemas: results, - result: finalResult, - sectionDefinitions: prepMonthlyReportSections, - indicatorDefinitions: [] - }); - } - }) - .catch((error) => { - console.error('hei register generation error: ', error); - reject(error); - }); - }); - } - - generatePatientList(indicators) { - let self = this; - return new Promise((resolve, reject) => { - super - .generatePatientListReport(indicators) - .then((results) => { - let indicatorLabels = self.getIndicatorSectionDefinitions( - results.indicators, - prepMonthlyReportSections - ); - - results.indicators = indicatorLabels; - - if (results.result.length > 0) { - _.each(results.result, (item) => { - item.cur_prep_meds_names = etlHelpers.getARVNames( - item.cur_prep_meds_names - ); - }); - } - - self - .resolveLocationUuidsToName(self.params.locationUuids) - .then((locations) => { - results.locations = locations; - resolve(results); - }) - .catch((err) => { - resolve(results); - }); - }) - .catch((err) => { - reject(results); - }); - }); - } - - getIndicatorSectionDefinitions(requestIndicators, sectionDefinitions) { - let results = []; - _.each(requestIndicators, function (requestIndicator) { - _.each(sectionDefinitions, function (sectionDefinition) { - _.each(sectionDefinition.indicators, function (indicator) { - if (indicator.indicator === requestIndicator) { - results.push(indicator); - } - }); - }); - }); - return results; - } - - resolveLocationUuidsToName(uuids) { - return new Promise((resolve, reject) => { - dao.resolveLocationUuidsToName(uuids.split(','), (loc) => { - resolve(loc); - }); - }); - } -} From 43cea834bf36656b830e6f0c8d8da23f0da34c25 Mon Sep 17 00:00:00 2001 From: Alfred-Mutai Date: Thu, 6 Jun 2024 11:11:41 +0300 Subject: [PATCH 3/5] POC-745: --- app/facility-mappings/registers.js | 20 ++++++++++++++++++ app/routes/registers.route.js | 34 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 app/facility-mappings/registers.js create mode 100644 app/routes/registers.route.js diff --git a/app/facility-mappings/registers.js b/app/facility-mappings/registers.js new file mode 100644 index 000000000..f4cd52ebd --- /dev/null +++ b/app/facility-mappings/registers.js @@ -0,0 +1,20 @@ +var db = require('../../etl-db'); + +var defs = { + getPrEPRegisterData: (params) => { + return new Promise((resolve, reject) => { + let queryParts = {}; + let sql = + 'SELECT l.name as location_name, fps.encounter_id, pi.identifier AS PrEP_Number, pi2.identifier AS National_ID, pi3.identifier AS NUPI, fps.encounter_datetime AS Date_Of_Visit, EXTRACT(YEAR FROM fps.encounter_datetime) - EXTRACT(YEAR FROM fps.birthdate) - CASE WHEN (EXTRACT(MONTH FROM fps.encounter_datetime) < EXTRACT(MONTH FROM fps.birthdate)) OR (EXTRACT(MONTH FROM fps.encounter_datetime) = EXTRACT(MONTH FROM fps.birthdate) AND EXTRACT(DAY FROM fps.encounter_datetime) < EXTRACT(DAY FROM fps.birthdate)) THEN 1 ELSE 0 END Age, fps.gender AS Sex, fps.population_type, NULL AS client_prep_status, NULL AS prep_method, CASE WHEN COALESCE(fps.hiv_rapid_test_result) = 664 THEN "N" WHEN COALESCE(fps.hiv_rapid_test_result) = 703 THEN "P" END AS HIV_result, NULL AS with_STI, COALESCE(fps.initiation_reason, fps.discontinued_reason) AS remarks FROM etl.flat_prep_summary_v1_1 fps LEFT JOIN amrs.location l ON l.location_id = fps.location_id LEFT JOIN amrs.patient_identifier pi ON fps.person_id = pi.patient_id AND pi.identifier_type = 44 LEFT JOIN amrs.patient_identifier pi2 ON fps.person_id = pi2.patient_id AND pi2.identifier_type = 5 LEFT JOIN amrs.patient_identifier pi3 ON fps.person_id = pi3.patient_id AND pi3.identifier_type = 45 WHERE DATE(fps.encounter_datetime)= "2024-01-02" AND fps.location_id in (1,13,14)'; + queryParts = { + sql: sql + }; + return db.queryServer(queryParts, function (result) { + result.sql = sql; + resolve(result.result); + }); + }); + } +}; + +module.exports = defs; diff --git a/app/routes/registers.route.js b/app/routes/registers.route.js new file mode 100644 index 000000000..1b90f2b06 --- /dev/null +++ b/app/routes/registers.route.js @@ -0,0 +1,34 @@ +var authorizer = require('../../authorization/etl-authorizer'); +var privileges = authorizer.getAllPrivileges(); +var facilitymappings = require('../facility-mappings/registers'); + +const routes = [ + { + method: 'GET', + path: '/etl/prepregisterdata', + config: { + plugins: {}, + handler: function (request, reply) { + facilitymappings + .getPrEPRegisterData(request.query) + .then((result) => { + reply(result); + }) + .catch((error) => { + reply(error); + }); + }, + description: 'List of facilities with MFL code', + notes: 'Returns facilities list', + tags: ['api'], + validate: { + options: { + allowUnknown: true + }, + params: {} + } + } + } +]; + +exports.routes = (server) => server.route(routes); From 8ed64575aa3fcc994cb2c47ea6ff13d1cda500a2 Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Thu, 6 Jun 2024 11:12:47 +0300 Subject: [PATCH 4/5] POC-746 added data for HEI --- app/registers-framework/registers-db.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/registers-framework/registers-db.js b/app/registers-framework/registers-db.js index dcdc89cf1..84ebd7a19 100644 --- a/app/registers-framework/registers-db.js +++ b/app/registers-framework/registers-db.js @@ -99,6 +99,7 @@ var defs = { }); }, getCareTreatmentDetails: (params) => { + console.log('CareNATreatment: ', params); return new Promise((resolve, reject) => { let queryParts = {}; let sql = ` @@ -146,7 +147,7 @@ var defs = { WHERE fhs.is_clinical_encounter=1 and DATE(fhs.encounter_datetime) = '2024-04-02' - and fhs.location_id in (315); + and fhs.location_id in (315) group by fhs.person_id; `; queryParts = { From 1cd9f1dcf9b2c0e529b4a96fe2b89fc13316834a Mon Sep 17 00:00:00 2001 From: Faith Kamau <121166087+hiqedme@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:18:15 +0300 Subject: [PATCH 5/5] POC-739: added hpv payload 2 --- app/lab-integration/utils/poc-eid-payload-helper.js | 1 + app/registers-framework/registers-db.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lab-integration/utils/poc-eid-payload-helper.js b/app/lab-integration/utils/poc-eid-payload-helper.js index fbfdc89de..a74e62844 100644 --- a/app/lab-integration/utils/poc-eid-payload-helper.js +++ b/app/lab-integration/utils/poc-eid-payload-helper.js @@ -55,6 +55,7 @@ lab: '', amrs_location: getLocation(payload, 'mrsId') }; + console.log('DNAPCR PAYLOAD: ', eidPayload); break; case 'CD4': eidPayload = { diff --git a/app/registers-framework/registers-db.js b/app/registers-framework/registers-db.js index 84ebd7a19..ff3100803 100644 --- a/app/registers-framework/registers-db.js +++ b/app/registers-framework/registers-db.js @@ -147,7 +147,7 @@ var defs = { WHERE fhs.is_clinical_encounter=1 and DATE(fhs.encounter_datetime) = '2024-04-02' - and fhs.location_id in (315) group by fhs.person_id; + and fhs.location_id in (315) group by fhs.person_id `; queryParts = {