inspectomop.queries.person.patient_counts_by_year_of_birth_and_gender¶
- inspectomop.queries.person.patient_counts_by_year_of_birth_and_gender(inspector, person_ids=None, return_columns=None)¶
Returns patient counts stratified by year of birth and gender 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 : [‘gender_concept_id’,’gender’,’year_of_birth’, ‘count’]
- Returns:
results
- Return type:
Notes
Original SQL
PE09: Number of patients by gender, stratified by year of birth:
SELECT gender_concept_id, c.concept_name AS gender_name, year_of_birth, COUNT(p.person_id) AS num_persons FROM person p INNER JOIN concept c ON p.gender_concept_id = c.concept_id GROUP BY gender_concept_id, c.concept_name, year_of_birth ORDER BY concept_name, year_of_birth;