inspectomop.queries.person.patient_counts_by_residence_state¶
- inspectomop.queries.person.patient_counts_by_residence_state(inspector, person_ids=None, return_columns=None)¶
Returns patient counts grouped by state for the database or alternativily, for a supplied list of person_ids.
- Parameters:
person_ids (list of int, optional) – list of person_ids [int]. If None (default), get the gender distribution for all individuals in the person table
inspector (inspectomop.inspector.Inspector)
return_columns (list of str, optional) –
optional subset of columns to return from the query
columns : [‘state’, ‘count’]
- Returns:
results
- Return type:
Notes
Original SQL
PE07: Number of patients grouped by residence state location:
SELECT NVL( state, 'XX' ) AS state_abbr, count(\*) as Num_Persons_count FROM person LEFT OUTER JOIN location USING( location_id ) GROUP BY NVL( state, 'XX' ) ORDER BY 1;