The mcr_combine_tables Module

This utility combines Medicare Patient Summary or Inpatient Admissions data, that is originally in the form of one table per year into a single view.

It takes care of different types and format of the most common columns, such as: year, state, DO[B/D], zip codes, state and county codes.

The actual schema is defined in ../models/medicare.yaml

This utility uses extended syntax compared with the general data modelling

class MedicareCombinedView(context: DBTableConfig = None)[source]
ps = 'ps'
ip = 'ip'
supported_tables = ['ps', 'ip', 'mbsf_d']
print_sql()[source]
ensure_schema()[source]

Creates the target schema in its own transaction, tolerating a concurrent workflow branch creating it at the same time: CREATE SCHEMA IF NOT EXISTS is not concurrency-safe in PostgreSQL and can fail with a unique constraint violation on pg_namespace.

execute()[source]
execute_sql(cursor, sql: str)[source]
generate_sql()[source]
get_tables(cursor)[source]
table_sql(cursor, qtable: Tuple) → str[source]
get_columns(cursor, table: str) → List[Tuple][source]
classmethod get_column(cursor, table: str, candidates: List[str], ctype: Tuple, macros: Dict) → str | None[source]
classmethod get_simple_column(cursor, table: str, candidates: List[str], ctype: Tuple)[source]
classmethod find_column2arr(cursor, table: str, candidate: str, macros: Dict)[source]