Skip to content

Commit

Permalink
Visit Queues
Browse files Browse the repository at this point in the history
  • Loading branch information
daviemukungi committed Dec 17, 2024
1 parent a5b56a5 commit f59e071
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 1 deletion.
124 changes: 124 additions & 0 deletions configuration/globalproperties/gp_patient_queues.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<config>
<globalProperties>
<globalProperty>
<property>emrapi.sqlSearch.opd</property>
<value>select name, identifier,uuid, activeVisitUuid, hasBeenAdmitted from (
select distinct concat(pn.given_name,' ', ifnull(pn.family_name,'')) as name, pi.identifier as identifier, concat("",p.uuid) as uuid,
concat("",v.uuid) as activeVisitUuid, IF(va.value_reference = "Admitted", "true", "false") as hasBeenAdmitted, vt.visit_type_id as 'visitType',
vt.name as 'visitTypeName'
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0
join patient_identifier pi on v.patient_id = pi.patient_id
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
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
join visit_type vt on v.visit_type_id = vt.visit_type_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
)tMOPDVisits where visitTypeName = 'OPD'</value>
</globalProperty>
<globalProperty>
<property>emrapi.sqlSearch.ipd</property>
<value>select name, identifier,uuid, activeVisitUuid, hasBeenAdmitted from (
select distinct concat(pn.given_name,' ', ifnull(pn.family_name,'')) as name, pi.identifier as identifier, concat("",p.uuid) as uuid,
concat("",v.uuid) as activeVisitUuid, IF(va.value_reference = "Admitted", "true", "false") as hasBeenAdmitted, vt.visit_type_id as 'visitType',
vt.name as 'visitTypeName'
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0
join patient_identifier pi on v.patient_id = pi.patient_id
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
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
join visit_type vt on v.visit_type_id = vt.visit_type_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
)tMOPDVisits where visitTypeName = 'IPD'</value>
</globalProperty>
<globalProperty>
<property>emrapi.sqlSearch.emergency</property>
<value>select name, identifier,uuid, activeVisitUuid, hasBeenAdmitted from (
select distinct concat(pn.given_name,' ', ifnull(pn.family_name,'')) as name, pi.identifier as identifier, concat("",p.uuid) as uuid,
concat("",v.uuid) as activeVisitUuid, IF(va.value_reference = "Admitted", "true", "false") as hasBeenAdmitted, vt.visit_type_id as 'visitType',
vt.name as 'visitTypeName'
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0
join patient_identifier pi on v.patient_id = pi.patient_id
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
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
join visit_type vt on v.visit_type_id = vt.visit_type_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
)tMOPDVisits where visitTypeName = 'EMERGENCY'</value>
</globalProperty>
<globalProperty>
<property>emrapi.sqlSearch.opticalShop</property>
<value>select name, identifier,uuid, activeVisitUuid, hasBeenAdmitted from (
select distinct concat(pn.given_name,' ', ifnull(pn.family_name,'')) as name, pi.identifier as identifier, concat("",p.uuid) as uuid,
concat("",v.uuid) as activeVisitUuid, IF(va.value_reference = "Admitted", "true", "false") as hasBeenAdmitted, vt.visit_type_id as 'visitType',
vt.name as 'visitTypeName'
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0
join patient_identifier pi on v.patient_id = pi.patient_id
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
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
join visit_type vt on v.visit_type_id = vt.visit_type_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
)tMOPDVisits where visitTypeName = 'Optical shop'</value>
</globalProperty>
<globalProperty>
<property>emrapi.sqlSearch.labVisit</property>
<value>select name, identifier,uuid, activeVisitUuid, hasBeenAdmitted from (
select distinct concat(pn.given_name,' ', ifnull(pn.family_name,'')) as name, pi.identifier as identifier, concat("",p.uuid) as uuid,
concat("",v.uuid) as activeVisitUuid, IF(va.value_reference = "Admitted", "true", "false") as hasBeenAdmitted, vt.visit_type_id as 'visitType',
vt.name as 'visitTypeName'
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0
join patient_identifier pi on v.patient_id = pi.patient_id
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
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
join visit_type vt on v.visit_type_id = vt.visit_type_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
)tMOPDVisits where visitTypeName = 'LAB VISIT'</value>
</globalProperty>
<globalProperty>
<property>emrapi.sqlSearch.pharmacy</property>
<value>select name, identifier,uuid, activeVisitUuid, hasBeenAdmitted from (
select distinct concat(pn.given_name,' ', ifnull(pn.family_name,'')) as name, pi.identifier as identifier, concat("",p.uuid) as uuid,
concat("",v.uuid) as activeVisitUuid, IF(va.value_reference = "Admitted", "true", "false") as hasBeenAdmitted, vt.visit_type_id as 'visitType',
vt.name as 'visitTypeName'
from visit v
join person_name pn on v.patient_id = pn.person_id and pn.voided = 0
join patient_identifier pi on v.patient_id = pi.patient_id
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
join location l on l.uuid = ${visit_location_uuid} and v.location_id = l.location_id
join visit_type vt on v.visit_type_id = vt.visit_type_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
)tMOPDVisits where visitTypeName = 'Pharmacy'</value>
</globalProperty>
</globalProperties>
</config>
2 changes: 1 addition & 1 deletion configuration/visittypes/visittypesBdsec.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Uuid,Void/Retire,Name,Description,_version:2
,,OPD,Visit for Out patient,
,True,IPD,Visit for patients being admitted,
,,IPD,Visit for patients being admitted,
,,EMERGENCY,Visit for emergency patients,
,True,Special OPD,Visit for retrospective data entry,
,True,Follow Up,Visit for patients coming for a follow up,
Expand Down

0 comments on commit f59e071

Please sign in to comment.