Skip to content

Commit a23f9a8

Browse files
committed
POC-130: End point to expose Patients with validation issues
1 parent bd1c883 commit a23f9a8

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

app/routes/client-validation-issues.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const routes = [
1414
reply(err);
1515
});
1616
},
17-
description: 'Get all verification aggregates ',
18-
notes: 'Returns all verification aggregates',
17+
description: 'Get all Clients with validation issues',
18+
notes: 'Returns all clients with validation issues',
1919
tags: ['api'],
2020
validate: {
2121
options: {

app/routes/patient-medication-history.route.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var authorizer = require('../../authorization/etl-authorizer');
22
var privileges = authorizer.getAllPrivileges();
3+
// imports
34
import {
45
generateMedsDataSet,
56
getOncMeds

service/client-validation-service.js

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ export class ClientValidationIssues {
55
generateVerificationClients(params) {
66
const that = this;
77
return new Promise(function (resolve, reject) {
8-
const sql = that.verificationClientsQuery(params.locationUuid);
8+
const sql = that.verificationClientsQuery(
9+
params.locationUuid,
10+
params.limit,
11+
params.offset
12+
);
13+
914
const queryParts = {
1015
sql: sql
1116
};
@@ -15,62 +20,69 @@ export class ClientValidationIssues {
1520
});
1621
}
1722

18-
verificationClientsQuery(location) {
19-
return `SELECT
20-
County,
21-
l.name AS 'Health Facility',
22-
mfl_code AS 'MFL Code',
23-
cc.identifier AS 'CCC NO',fh.person_id,
24-
nv.clientNumber as 'NUPI',
25-
nv.errorDescription as "Error description",
23+
verificationClientsQuery(location, limit, offset) {
24+
return (
25+
`SELECT
26+
county,
27+
l.name AS 'health_facility',
28+
mfl_code,
29+
CONCAT(COALESCE(nv.clientNumber, ''),',',COALESCE(cc.identifier,'')) as 'identifiers',
30+
fh.person_id,
31+
fh.uuid as patient_uuid,
32+
nv.errorDescription as "error_description",
2633
CONCAT(COALESCE(person_name.given_name, ''),
2734
' ',
2835
COALESCE(person_name.middle_name, ''),
2936
' ',
3037
COALESCE(person_name.family_name, '')) AS 'person_name',
3138
GROUP_CONCAT(DISTINCT contacts.value
3239
SEPARATOR ',') AS 'phone_number',
33-
DATE_FORMAT(pf.birthdate, '%Y-%m-%d') AS 'Date of Birth',
40+
DATE_FORMAT(pf.birthdate, '%Y-%m-%d') AS 'date_of_birth',
3441
EXTRACT(YEAR FROM (FROM_DAYS(DATEDIFF(NOW(), pf.birthdate)))) AS age,
3542
pf.gender
3643
3744
FROM
3845
etl.flat_hiv_summary_v15b fh
3946
LEFT JOIN
40-
amrs_migration.patient_identifier cc ON (fh.person_id = cc.patient_id
47+
amrs.patient_identifier cc ON (fh.person_id = cc.patient_id
4148
AND cc.identifier_type = 28
4249
AND cc.voided = 0)
4350
LEFT JOIN
44-
amrs_migration.person pf ON (fh.person_id = pf.person_id AND dead = 0
51+
amrs.person pf ON (fh.person_id = pf.person_id AND dead = 0
4552
AND pf.voided = 0)
4653
LEFT JOIN
47-
amrs_migration.location l ON (l.location_id = fh.last_non_transit_location_id)
54+
amrs.location l ON (l.location_id = fh.last_non_transit_location_id)
4855
LEFT JOIN
4956
ndwr.mfl_codes lx ON (l.location_id = lx.location_id)
5057
LEFT JOIN
51-
amrs_migration.person_name person_name ON (fh.person_id = person_name.person_id
58+
amrs.person_name person_name ON (fh.person_id = person_name.person_id
5259
AND (person_name.voided IS NULL
5360
|| person_name.voided = 0)
5461
AND person_name.preferred = 1)
5562
LEFT JOIN
56-
amrs_migration.person_attribute contacts ON (fh.person_id = contacts.person_id
63+
amrs.person_attribute contacts ON (fh.person_id = contacts.person_id
5764
AND (contacts.voided IS NULL
5865
|| contacts.voided = 0)
5966
AND contacts.person_attribute_type_id IN (10 , 48))
6067
LEFT JOIN
61-
amrs_migration.patient_identifier id ON (id.patient_id = fh.person_id
68+
amrs.patient_identifier id ON (id.patient_id = fh.person_id
6269
AND id.identifier_type = 45
6370
AND id.voided = 0)
6471
LEFT JOIN
6572
etl.hiv_monthly_report_dataset_v1_2 dd ON (dd.person_id = fh.person_id)
6673
inner join etl.nupi_verification nv on nv.clientNumber=id.identifier
6774
WHERE
68-
fh.location_id != 195
69-
AND fh.location_id = '${location}'
75+
fh.location_id != 195
76+
AND l.uuid = '${location}'
7077
AND fh.next_clinical_datetime_hiv IS NULL
7178
AND fh.is_clinical_encounter = 1
7279
AND (TIMESTAMPDIFF(DAY, fh.rtc_date, CURDATE()) < 30)
7380
AND fh.cur_arv_meds IS NOT NULL
74-
GROUP BY fh.person_id limit 10;`;
81+
GROUP BY fh.person_id limit ` +
82+
limit +
83+
` offset ` +
84+
offset +
85+
`;`
86+
);
7587
}
7688
}

0 commit comments

Comments
 (0)