Returns the the average length in days of all hospitalizations where a certain condition was reported.
Sample query run:
||Condition concept identifier for 'Nausea'
The following is a sample run of the query. The input parameters are highlighted in blue
SELECT avg(hosp_no_days) AS average_hosp_duration_count
SELECT DISTINCT hosp_no_days, person_id, from_visit.visit_occurrence_id
WHERE condition_concept_id = 31967
AND visit_occurrence_id IS NOT NULL) AS from_cond
SELECT DATEDIFF(DAY, visit_start_date, visit_end_date) + 1 AS hosp_no_days,
WHERE place_of_service_concept_id = 9201) AS from_visit
ON from_cond.visit_occurrence_id = from_visit.visit_occurrence_id
Output field list:
||Average length in days of all hospitalization where a certain condition was reported. +1 was added for partial days (e.g. 1.5 days were counted as 2 days).
Sample output record: