Skip to content

Commit

Permalink
Merge pull request #1368 from henrykorir/POC-633
Browse files Browse the repository at this point in the history
POC-633: Display the Total abdominal hysterectomy on the patient dash…
  • Loading branch information
hiqedme authored Feb 14, 2024
2 parents 97bd738 + 54152d7 commit 5e6fc83
Showing 1 changed file with 57 additions and 32 deletions.
89 changes: 57 additions & 32 deletions service/cervical-cancer-screening-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,63 @@ function getPatientCervicalCancerScreeningSummary(patientUuId) {
reject('Patient Uuid is missing');
} else {
const sql = `SELECT
person_id,
DATE_FORMAT(test_datetime,'%d-%m-%Y') as 'test_date',
via_or_via_vili,
pap_smear,
hpv,
uuid,
case
WHEN via_or_via_vili is NOT NULL THEN 'VIA or VIA/VILI'
WHEN pap_smear is NOT NULL THEN 'PAP SMEAR'
WHEN hpv is NOT NULL THEN 'HPV'
ELSE NULL
end as 'test',
case
WHEN via_or_via_vili = 7469 THEN 'ACETOWHITE LESION'
WHEN via_or_via_vili = 1115 THEN 'NORMAL'
WHEN via_or_via_vili = 6497 THEN 'DYSFUNCTIONAL UTERINE BLEEDING'
WHEN via_or_via_vili = 703 THEN 'POSITIVE'
WHEN via_or_via_vili = 7470 THEN 'PUNCTUATED CAPILLARIES'
WHEN via_or_via_vili = 664 THEN 'NEGATIVE'
WHEN via_or_via_vili = 7472 THEN 'ATYPICAL BLOOD VESSELS'
WHEN via_or_via_vili = 7293 THEN 'ULCER'
WHEN via_or_via_vili = 9593 THEN 'FRIABLE TISSUE'
WHEN via_or_via_vili = 6971 THEN 'POSSIBLE'
ELSE NULL
end as 'via_test_result'
FROM
etl.flat_labs_and_imaging
WHERE
(via_or_via_vili IS NOT NULL OR pap_smear IS NOT NULL OR hpv IS NOT NULL)
AND uuid = '${patientUuId}'
ORDER BY test_datetime DESC
LIMIT 10;`;
fli.person_id,
fli.test_date,
fli.via_or_via_vili,
fli.pap_smear,
fli.hpv,
fli.test,
fli.via_test_result,
GROUP_CONCAT(concat_ws('=',concept_id,value_coded,obs_datetime) ORDER BY obs_datetime desc SEPARATOR ' ## ') as reason
FROM
amrs.obs o
LEFT JOIN
(SELECT
person_id,
DATE_FORMAT(test_datetime, '%d-%m-%Y') AS 'test_date',
via_or_via_vili,
pap_smear,
hpv,
uuid,
CASE
WHEN via_or_via_vili IS NOT NULL THEN 'VIA or VIA/VILI'
WHEN pap_smear IS NOT NULL THEN 'PAP SMEAR'
WHEN hpv IS NOT NULL THEN 'HPV'
ELSE NULL
END AS 'test',
CASE
WHEN via_or_via_vili = 7469 THEN 'ACETOWHITE LESION'
WHEN via_or_via_vili = 1115 THEN 'NORMAL'
WHEN via_or_via_vili = 6497 THEN 'DYSFUNCTIONAL UTERINE BLEEDING'
WHEN via_or_via_vili = 703 THEN 'POSITIVE'
WHEN via_or_via_vili = 7470 THEN 'PUNCTUATED CAPILLARIES'
WHEN via_or_via_vili = 664 THEN 'NEGATIVE'
WHEN via_or_via_vili = 7472 THEN 'ATYPICAL BLOOD VESSELS'
WHEN via_or_via_vili = 7293 THEN 'ULCER'
WHEN via_or_via_vili = 9593 THEN 'FRIABLE TISSUE'
WHEN via_or_via_vili = 6971 THEN 'POSSIBLE'
ELSE NULL
END AS 'via_test_result'
FROM
etl.flat_labs_and_imaging
WHERE
(via_or_via_vili IS NOT NULL
OR pap_smear IS NOT NULL
OR hpv IS NOT NULL)
AND uuid = '${patientUuId}'
ORDER BY test_datetime DESC
LIMIT 1) fli ON fli.person_id = o.person_id
WHERE
value_coded IN (5276 , 12109, 1504, 5989)
AND voided = 0
AND o.person_id = (SELECT
person_id
FROM
etl.flat_labs_and_imaging
WHERE
uuid = '${patientUuId}'
LIMIT 1)
ORDER BY o.obs_datetime DESC;`;

const queryParts = {
sql: sql
Expand Down

0 comments on commit 5e6fc83

Please sign in to comment.