Skip to content

Commit

Permalink
Merge pull request #1363 from henrykorir/POC-607
Browse files Browse the repository at this point in the history
POC-607: Remove cancer screening reminder for clients done hysterectomy
  • Loading branch information
Alfred-Mutai authored Jan 26, 2024
2 parents b7869c3 + 4e667b1 commit 89bd74e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
41 changes: 26 additions & 15 deletions service/cervical-cancer-screening-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@ const defs = {

function getPatientLatestCericalScreeningResult(personId) {
return new Promise((resolve, reject) => {
const sql = `SELECT
person_id,
test_datetime,
via_or_via_vili,
TIMESTAMPDIFF(YEAR,test_datetime,now()) AS 'years_since_last_via_or_via_vili_test',
CASE
WHEN TIMESTAMPDIFF(YEAR,test_datetime,now()) >= 1 THEN 1
ELSE NULL
END AS 'qualifies_for_via_or_via_vili_retest'
FROM
etl.flat_labs_and_imaging
WHERE
via_or_via_vili IS NOT NULL AND person_id = ${personId}
ORDER BY test_datetime DESC LIMIT 1;`;

const sql = `SELECT fli.person_id,
test_datetime,
via_or_via_vili,
TIMESTAMPDIFF(YEAR, test_datetime, NOW()) AS 'years_since_last_via_or_via_vili_test',
CASE
WHEN TIMESTAMPDIFF(YEAR, test_datetime, NOW()) >= 1 THEN 1
ELSE NULL
END AS 'qualifies_for_via_or_via_vili_retest',
CASE
WHEN value_coded = 5276 THEN 1
ELSE NULL
END AS 'has_hysterectomy_done'
FROM etl.flat_labs_and_imaging fli
LEFT JOIN
(SELECT person_id,
value_coded,
max(obs_datetime) latest_steralization_dt
FROM amrs.obs
WHERE value_coded = 5276
AND person_id = ${personId}
AND voided = 0
LIMIT 1) fs ON (fli.person_id = fs.person_id)
WHERE via_or_via_vili IS NOT NULL
AND fli.person_id = ${personId}
ORDER BY test_datetime DESC
LIMIT 1;`;
const queryParts = {
sql: sql
};
Expand Down
5 changes: 4 additions & 1 deletion service/patient-reminder.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,10 @@ function getCerivalScreeningReminder(personId) {

function generateCervicalScreeningReminder(data) {
let reminders = [];
if (data.qualifies_for_via_or_via_vili_retest === 1) {
if (
data.has_hysterectomy_done !== 1 &&
data.qualifies_for_via_or_via_vili_retest === 1
) {
reminders.push({
message:
'Patient is due for a repeat cervical cancer screening test. Last test result was Normal on ' +
Expand Down

0 comments on commit 89bd74e

Please sign in to comment.