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

BAH-1236 | Bug fix. Modified query to display only preferred patients… #110

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
67 changes: 67 additions & 0 deletions bahmnicore-omod/src/main/resources/V1_99_PatientSearchSql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
UPDATE global_property SET property_value = "select distinct
concat(pn.given_name,' ', pn.family_name) as name,
pi.identifier as identifier,
concat('',p.uuid) as uuid,
IF(va.value_reference = \"Admitted\", \"true\", \"false\") as hasBeenAdmitted
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0 and pn.preferred = 1
join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 and pi.preferred = 1
join patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id
join global_property gp on gp.property=\"bahmni.primaryIdentifierType\" and gp.property_value=pit.uuid
join person p on p.person_id = v.patient_id and p.voided = 0
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
left outer join visit_attribute va on va.visit_id = v.visit_id and va.attribute_type_id = (
select visit_attribute_type_id from visit_attribute_type where name=\"Admission Status\"
) and va.voided = 0
where v.date_stopped is null AND v.voided = 0;"
WHERE property = "emrapi.sqlSearch.activePatients";

UPDATE global_property SET property_value =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we please break the SQL file into 3 different ones please and also create liquibase changesets that are specific to a specific property?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, sure.

"select distinct concat(pn.given_name,' ', pn.family_name) as name,
pi.identifier as identifier,
concat('',p.uuid) as uuid,
IF(va.value_reference = \"Admitted\", \"true\", \"false\") as hasBeenAdmitted
from
visit v join person_name pn on v.patient_id = pn.person_id and pn.voided = 0 and v.voided=0 and pn.preferred = 1
join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 and pi.preferred = 1
join patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id
join global_property gp on gp.property=\"bahmni.primaryIdentifierType\" and gp.property_value=pit.uuid
join person p on p.person_id = v.patient_id and p.voided=0
join encounter en on en.visit_id = v.visit_id and en.voided=0
join encounter_provider ep on ep.encounter_id = en.encounter_id and ep.voided=0
join provider pr on ep.provider_id=pr.provider_id and pr.retired=0
join person per on pr.person_id=per.person_id and per.voided=0
join location l on l.uuid=${visit_location_uuid} and l.location_id = v.location_id
left outer join visit_attribute va on va.visit_id = v.visit_id and va.voided = 0 and va.attribute_type_id = (
select visit_attribute_type_id from visit_attribute_type where name=\"Admission Status\"
)
where
v.date_stopped is null and
pr.uuid=${provider_uuid}
order by en.encounter_datetime desc"
WHERE property = "emrapi.sqlSearch.activePatientsByProvider";

UPDATE global_property SET property_value =
"select distinct concat(pn.given_name,' ', pn.family_name) as name,
pi.identifier as identifier,
concat('',p.uuid) as uuid,
IF(va.value_reference = \"Admitted\", \"true\", \"false\") as hasBeenAdmitted
from
visit v join person_name pn on v.patient_id = pn.person_id and pn.voided = 0 and v.voided=0 and pn.preferred = 1
join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 and pi.preferred = 1
join patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id
join global_property gp on gp.property=\"bahmni.primaryIdentifierType\" and gp.property_value=pit.uuid
join person p on p.person_id = v.patient_id and p.voided=0
join encounter en on en.visit_id = v.visit_id and en.voided=0
left outer join location loc on en.location_id = loc.location_id
join encounter_provider ep on ep.encounter_id = en.encounter_id and ep.voided=0
join provider pr on ep.provider_id=pr.provider_id and pr.retired=0
join person per on pr.person_id=per.person_id and per.voided=0
left outer join visit_attribute va on va.visit_id = v.visit_id and va.attribute_type_id = (
select visit_attribute_type_id from visit_attribute_type where name=\"Admission Status\"
)
where
v.date_stopped is null and
loc.uuid=${location_uuid}
order by en.encounter_datetime desc"
WHERE property = "emrapi.sqlSearch.activePatientsByLocation";
5 changes: 5 additions & 0 deletions bahmnicore-omod/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3874,6 +3874,11 @@
<sqlFile path="V1_98_WardsListSql.sql"/>
</changeSet>

<changeSet id="bahmni-PatientSearch-Update-202201250315" author="Kavitha S, Soorya Kumaran C">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please use 3 different changesets as suggested above? also please make sure that the changeset clearly says which is for which property

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

<comment>Update the property values for searching active patients based on preferred and non voided</comment>
<sqlFile path="V1_99_PatientSearchSql.sql"/>
</changeSet>

<changeSet id="bahmni-201703061748" author="Shruthi P, Pushpa">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
Expand Down