-
Notifications
You must be signed in to change notification settings - Fork 1
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
Patient infection status #6
Comments
Example query below Alternatively might want to delegate the 'census' step to the API and then the returned MRNs in a WHERE clause? WITH icupts AS (
SELECT
lv.admission_time
--,lo.location_string
,lv.hospital_visit_id
--,bed.hl7string
--,bed.room_id
--,room.hl7string
,room.name
--,room.department_id
--,department.hl7string
,department.name
,department.speciality
FROM star.location_visit lv
LEFT JOIN star.location lo ON lv.location_id = lo.location_id
LEFT JOIN star.bed ON lo.bed_id = bed.bed_id
LEFT JOIN star.room ON lo.room_id = room.room_id
LEFT JOIN star.department ON room.department_id = department.department_id
WHERE SPLIT_PART(lo.location_string,'^',1) ~ '^(WSCC)'
AND lv.discharge_time IS NULL
ORDER BY lv.admission_time DESC
--LIMIT 5
)
SELECT
icupts.*
,vo.mrn_id
,vo.patient_class
,vo.arrival_method
,co.condition_type_id
,ct.name
,co.onset_date
,co.status
FROM icupts
LEFT JOIN hospital_visit vo ON icupts.hospital_visit_id = vo.hospital_visit_id
INNER JOIN patient_condition co ON co.mrn_id = vo.mrn_id
LEFT JOIN condition_type ct ON co.condition_type_id = ct.condition_type_id
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like this could be generated from patient_condition and condition_type tables in star
There will be an many:one relationship so need to think about how to display
But could aggregate to label patient as needing SR?
The text was updated successfully, but these errors were encountered: