Skip to content

Commit 12edb7d

Browse files
BAH-1374 | Add. Display preferred patients under all clinical tabs
Co-authored-by: Soorya Kumaran C <sooryakumaran.c@thoughtworks.com>
1 parent 6e26b3d commit 12edb7d

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

bahmnicore-omod/src/main/resources/V1_99_PatientSearchSql.sql

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,54 @@ UPDATE global_property SET property_value = "select distinct
1414
select visit_attribute_type_id from visit_attribute_type where name=\"Admission Status\"
1515
) and va.voided = 0
1616
where v.date_stopped is null AND v.voided = 0;"
17-
where property = "emrapi.sqlSearch.activePatients";
17+
WHERE property = "emrapi.sqlSearch.activePatients";
1818

19+
UPDATE global_property SET property_value =
20+
"select distinct concat(pn.given_name,' ', pn.family_name) as name,
21+
pi.identifier as identifier,
22+
concat('',p.uuid) as uuid,
23+
IF(va.value_reference = \"Admitted\", \"true\", \"false\") as hasBeenAdmitted
24+
from
25+
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
26+
join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 and pi.preferred = 1
27+
join patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id
28+
join global_property gp on gp.property=\"bahmni.primaryIdentifierType\" and gp.property_value=pit.uuid
29+
join person p on p.person_id = v.patient_id and p.voided=0
30+
join encounter en on en.visit_id = v.visit_id and en.voided=0
31+
join encounter_provider ep on ep.encounter_id = en.encounter_id and ep.voided=0
32+
join provider pr on ep.provider_id=pr.provider_id and pr.retired=0
33+
join person per on pr.person_id=per.person_id and per.voided=0
34+
join location l on l.uuid=${visit_location_uuid} and l.location_id = v.location_id
35+
left outer join visit_attribute va on va.visit_id = v.visit_id and va.voided = 0 and va.attribute_type_id = (
36+
select visit_attribute_type_id from visit_attribute_type where name=\"Admission Status\"
37+
)
38+
where
39+
v.date_stopped is null and
40+
pr.uuid=${provider_uuid}
41+
order by en.encounter_datetime desc"
42+
WHERE property = "emrapi.sqlSearch.activePatientsByProvider";
43+
44+
UPDATE global_property SET property_value =
45+
"select distinct concat(pn.given_name,' ', pn.family_name) as name,
46+
pi.identifier as identifier,
47+
concat('',p.uuid) as uuid,
48+
IF(va.value_reference = \"Admitted\", \"true\", \"false\") as hasBeenAdmitted
49+
from
50+
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
51+
join patient_identifier pi on v.patient_id = pi.patient_id and pi.voided=0 and pi.preferred = 1
52+
join patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id
53+
join global_property gp on gp.property=\"bahmni.primaryIdentifierType\" and gp.property_value=pit.uuid
54+
join person p on p.person_id = v.patient_id and p.voided=0
55+
join encounter en on en.visit_id = v.visit_id and en.voided=0
56+
left outer join location loc on en.location_id = loc.location_id
57+
join encounter_provider ep on ep.encounter_id = en.encounter_id and ep.voided=0
58+
join provider pr on ep.provider_id=pr.provider_id and pr.retired=0
59+
join person per on pr.person_id=per.person_id and per.voided=0
60+
left outer join visit_attribute va on va.visit_id = v.visit_id and va.attribute_type_id = (
61+
select visit_attribute_type_id from visit_attribute_type where name=\"Admission Status\"
62+
)
63+
where
64+
v.date_stopped is null and
65+
loc.uuid=${location_uuid}
66+
order by en.encounter_datetime desc"
67+
WHERE property = "emrapi.sqlSearch.activePatientsByLocation";

bahmnicore-omod/src/main/resources/liquibase.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3874,8 +3874,8 @@
38743874
<sqlFile path="V1_98_WardsListSql.sql"/>
38753875
</changeSet>
38763876

3877-
<changeSet id="bahmni-PatientSearch-Update-202201250930" author="Kavitha S, Soorya Kumaran C">
3878-
<comment>update the property value of emrapi.sqlSearch.activePatients search query to obtain active patients based on preferred and non voided</comment>
3877+
<changeSet id="bahmni-PatientSearch-Update-202201250315" author="Kavitha S, Soorya Kumaran C">
3878+
<comment>Update the property values for searching active patients based on preferred and non voided</comment>
38793879
<sqlFile path="V1_99_PatientSearchSql.sql"/>
38803880
</changeSet>
38813881

0 commit comments

Comments
 (0)