@@ -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" ;
0 commit comments