Definition
Overview
Section titled “Overview”mart_prescribing_scotland combines Scottish SETP prescriptions and items with PMR prescription-item context, claim episodes, and eligible dispensing activity. Its grain is one SETP prescription item per extended claim, or one row with null claim fields when no claim is linked; the surrogate identifier preserves separate claim episodes.
Key Data Fields
Section titled “Key Data Fields”| Field | Description |
|---|---|
| prescribing_scotland_id | Surrogate identifier for the organisation, SETP prescription/item, and optional extended claim. |
| prescription_item_guid | GUID for the prescription item, used in message exchanges. |
| prescription_item_extended_claim_guid | Canonical extended claim identity. |
| service_type | Human-readable Scottish service name, such as AMS, CMS, or MAS. |
| is_fully_dispensed | True when the parent PMR item and prescription are active, current quantity is positive, and eligible supply fulfills it. |
| claim_is_fully_dispensed | True when the claim-linked PMR item and prescription are active, its current quantity is positive, and eligible supply fulfills it. |
| eligible_dispensing_count | Count of distinct eligible dispensing records for the parent PMR item. |
| episode | Repeat episode label, such as 3 of 12. |
Source
Section titled “Source”The model starts from ProScript Connect SETP prescription and prescription-item
data, with extended claim records joined at claim grain. It adds PMR item and
prescription context, aggregated eligible dispensing from
prescription_item_supply, patient and pharmacy details, service/status/request
lookups, and preparation data from dim_preparation. The dbt lineage is the
related stg_setp_* and stg_* models plus prescription_item_supply,
active_pharmacy, and dim_preparation -> prescribing_scotland ->
mart_prescribing_scotland.
mart_prescribing_scotland is incremental with merge strategy and unique key
(organisation, prescribing_scotland_id). Refreshes are triggered by ingestion
dates for SETP prescriptions and items, PMR items and prescriptions, patients,
extended claims, parent and claim-linked dispensing, and pharmacy updates.
Duplicate rows are reduced to one per key and routed to the quarantine model.