This SQL query retrieves the number of patients who were discharged and readmitted within a certain timeframe for each organization, along with the total number of patients discharged for each organization and month.

The first subquery retrieves the total number of patients discharged from each organization in each month. The second subquery retrieves the number of patients who were readmitted within 31 days of their previous discharge. The third subquery retrieves the number of patients who were readmitted on the same day as their previous discharge. The fourth and fifth subqueries retrieve the number of patients who were readmitted within 2-15 days and 16-30 days of their previous discharge, respectively.

The subqueries are then joined on the yearmonth and org_code columns to produce a table with all of the relevant information. The columns returned are yearmonth, org_code, org_name, num_cyrs (total number of patients discharged), num_zryrs (number of patients readmitted within 31 days), num_dtzry (number of patients readmitted on the same day), num_lzzry (number of patients readmitted within 2-15 days), and num_yyzry (number of patients readmitted within 16-30 days)

SELECT	aYEARMONTH	aORG_CODE	aORG_NAME	anum_cyrs	bnum_zryrs	cnum_dtzry	dnum_lzzry	enum_yyzry	FROMSELECT 	SUBSTRtYW_TS 1 7 yearmonth	pCODE ORG_CODE	pNAME ORG_NAME	COUNTDISTINCT tPATIENT_LOCAL_ID num_cyr

原文地址: https://www.cveoy.top/t/topic/ht5W 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录