Skip to content

Examples of TPMA tasks

ghobro edited this page Jul 29, 2026 · 9 revisions

With actual code or pseudo-code to demo some things you can do with the data.

Load the TPMA explorer data and compare the rates for two providers

We can load the rates data two ways

UDAL Data Bricks

The data which feeds the inputs app is available as a parquet stored on Data Bricks.

We load it using the below

# Load the provider rates data
provider_tpma = spark.read.parquet("/Volumes/udal_lake_mart/newhospitalprogramme/files/inputs_data/dev/provider/rates.parquet")

# view the data
display(provider_tpma)

# there is one row per provider, fyear and strategy / tpma

# if we want to focus on consultant_to_consultant_reduction_adult_surgical in 202425

consultant_to_consultant_reduction_adult_surgical_data = provider_tpma.filter(
    F.col("strategy") == "consultant_to_consultant_reduction_adult_surgical"
    ).filter(
        F.col("fyear") == 202425
    )

# the resultant table is just for this tpma in 202425 and the `crude` and `std_rate` columns give the rate, with one row per provider
display(consultant_to_consultant_reduction_adult_surgical_data)

R Studio

Get a count of beddays for a specific TPMA / provider / baseline year

Determine the proportion of A&E attendances / OP attendances in scope of a TPMA

Get the proportion of inpatient spells in scope of a particular TPMA or any TPMA

Clone this wiki locally