inspectomop.queries.person.patient_counts_by_zip_code

inspectomop.queries.person.patient_counts_by_zip_code(inspector, person_ids=None, return_columns=None)

Returns patient counts grouped by zip code 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’,’zip_code’, ‘count’]
Returns:

results

Return type:

inspectomop.results.Results

Notes

Original SQL

PE08: Number of patients grouped by zip code of residence:

SELECT
    state,
    NVL( zip, '9999999' ) AS zip,
    count(\*) Num_Persons_count
FROM
    person
LEFT OUTER JOIN
    location
USING( location_id )
GROUP BY
    state,
    NVL( zip, '9999999' )
ORDER BY 1, 2;