Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC-607: Remove cancer screening reminder for clients done hysterectomy #1363

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading