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

Visit Queues #58

Merged
merged 1 commit into from
Dec 17, 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
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