|
| 1 | +# SCAFFOLD [Data Ingestion Model](https://docs.google.com/spreadsheets/d/1qDjS2-a7F1El53jUx0fippL3m28pQilLcYNAv4pQkxI/edit?gid=1258033503#gid=1258033503) |
| 2 | +We adopted several [FHIR standard](https://hl7.org/fhir/index.html)'s resources to model data ingestion for SCAFFOLD. The input data include: |
| 3 | +- Provider information |
| 4 | +- Performance data |
| 5 | +- Comparator data |
| 6 | +- Message history |
| 7 | +- Preference |
| 8 | + |
| 9 | +The data was structured using FHIR resources to the extent possible. Since no suitable resources exist for history and preferences, those were represented using our own format. |
| 10 | + |
| 11 | +## Data Structure |
| 12 | +### Provider information (`PractitionerRole`) |
| 13 | +The [`PractitionerRole`](https://build.fhir.org/practitionerrole.html) resource is used to represent message recipients(individuals or organizations), their relationships and their roles. The input data include a table (PractitionerRole.csv) with the following columns: |
| 14 | +- **[PractitionerRole.identifier](https://build.fhir.org/practitionerrole-definitions.html#PractitionerRole.identifier)**: Unique identifier for each row in the Practitiner table. This identifier links performance data, history and preferences to each recipient. In those datasets, PractitionerRole.identifier is refered to as subject. |
| 15 | +- **[PractitionerRole.practitioner](https://build.fhir.org/practitionerrole-definitions.html#PractitionerRole.practitioner)**: Contains the practitioner identifier. If this column has a value, the row represents an individual practitioner otherwise it is aggregate data for a group for example a hospital. |
| 16 | +- **[PractitionerRole.organization](https://build.fhir.org/practitionerrole-definitions.html#PractitionerRole.organization)**: Contains the identifier of the institution where the recipient serves. This field, together with `PractitionerRole.code` is used to identify the comparator data associated with each recipient. |
| 17 | + |
| 18 | +- **[PractitionerRole.code](https://build.fhir.org/practitionerrole-definitions.html#PractitionerRole.code)**: Contains the role of the recipient in the institution. Example values for this field could be `Resident`, `Attending` or `CRNA`. |
| 19 | +- **type**: Indicates whether the performance data belong to an individual provider or to a group of providers. Accordingly, a `PractitionerRole` may represent either a single provider or a group. This field is not part of the FHIR `PractitionerRole` resource; in our model, it is introduced to classify `PractitionerRole` as either individual or group, allowing us to distinguish between the two types of performance data. Example values include `Practitioner` and `Organization`. |
| 20 | + |
| 21 | +### Performance data (`MeasureReport`) |
| 22 | +Performance data are modeled using the [`MeasureReport`](https://build.fhir.org/measurereport.html) resource, which represents the results of a measure evaluation. In SCAFFOLD, each row of performance data is modled as a measure report. Accordingly, the input data include a table (PerformanceMeasureReport.csv) with the following columns: |
| 23 | +- **[identifier](https://build.fhir.org/measurereport-definitions.html#MeasureReport.identifier)**: Uniquely identifies a specific performance data record. |
| 24 | +- **[measure](https://build.fhir.org/measurereport-definitions.html#MeasureReport.measure)**: |
| 25 | +A reference to the measure with which the performance record is associated. |
| 26 | +- **[subject](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.subject)**: Contains the recipient's unique identifier. |
| 27 | +- **[period.start](https://hl7.org/fhir/datatypes-definitions.html#Period.start)**: The start date of the period for which the performance record was collected. |
| 28 | +- **[period.end](https://hl7.org/fhir/datatypes-definitions.html#Period.end)**: The end date of the period for which the performance record was collected. |
| 29 | +- **[measureScore](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.group.measureScore_x_).rate**: The calculated success rate for the performance record. |
| 30 | +- **[measureScore](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.group.measureScore_x_).denominator**: The total number of cases on which the performance record is based. |
| 31 | +- **[measureScore](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.group.measureScore_x_).range**: Used for categorical values. |
| 32 | + |
| 33 | +### Comparator data (`MeasureReport`): |
| 34 | +Comparator data , which represent aggregated performance for a selected group of recipients, are modeled using the [`MeasureReport`](https://build.fhir.org/measurereport.html) resource. In SCAFFOLD, each row of comparator data is modeled as a measure report. Accordingly, the input data include a table (ComparatorMeasureReport.csv) with the following columns: |
| 35 | +- **[identifier](https://build.fhir.org/measurereport-definitions.html#MeasureReport.identifier)**: Uniquely identifies a specific comparator data record. |
| 36 | +- **[measure](https://build.fhir.org/measurereport-definitions.html#MeasureReport.measure)**: A reference to the measure with which the comparator record is associated. |
| 37 | +- **[group.subject](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.subject)**: The identifier of the organization for which the comparator record is calculated. This column is equivalent to the `PractitionerRole.organization` column in the Provider Information data set. |
| 38 | +- **[period.start](https://hl7.org/fhir/datatypes-definitions.html#Period.start)**: The start date of the period for which the comparator record was collected. |
| 39 | +- **[period.end](https://hl7.org/fhir/datatypes-definitions.html#Period.end)**: The end date of the period for which the comparator record was collected. |
| 40 | +- **[measureScore](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.group.measureScore_x_).rate**: The average calculated success rate for the performance records of the selected group of providers. |
| 41 | +- **[measureScore](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.group.measureScore_x_).denominator**: The total number of cases on which the comparator record is based. |
| 42 | +- **[group.code](https://hl7.org/fhir/measurereport-definitions.html#MeasureReport.group.code)**: Specifies the type of comparator represented in each comparator record. Example values for this field include `peer average`, `Peer Top 10%` or `Goal Value`. |
| 43 | +- **[PractitionerRole.code](https://build.fhir.org/practitionerrole-definitions.html#PractitionerRole.code)**: Indicates the role of the providers for whom the comparator record is calculated. Example values for this field include `Resident`, `Attending` or `CRNA`. |
| 44 | + |
| 45 | +### Message history |
| 46 | +Message history captures previously generated messages over defined time periods. SCAFFOLD's input data include a table (MessageHistory.csv) with the following columns: |
| 47 | +- **subject**: The provider (practitioner) identifier, to whom the message history record belongs. |
| 48 | +- **period.start**: The start date of the period for which the message was created. |
| 49 | +- **period.end**: The end date of the period for which the message was created. |
| 50 | +- **history.json**: A JSON dictionary summarizing the generated message, with the following keys: |
| 51 | + - **message_template**: The identifier of the message template used to generate the message. |
| 52 | + - **message_template_name**: The name of the message template used to generate the message. |
| 53 | + - **message_generated_datetime**: The date and time the message was generated. |
| 54 | + - **measure**: The measure associated with the generated message. |
| 55 | + - **acceptable_by**: The causal pathway associated with the generated message. |
| 56 | + |
| 57 | +### Preference |
| 58 | +Preferences captures providers' choices, priorities, and settings for messages that are generated for them. SCAFFOLD's input data include a table (Preferences.csv) with the following columns: |
| 59 | +- **subject**: The provider (practitioner) identifier, to whom the preferences record belongs. |
| 60 | +- **preferences.json**: A JSON dictionary with preferences detail. Here is an example of preferences JSON which SCAFFOLD can currently use |
| 61 | + ```json |
| 62 | + { |
| 63 | + "Utilities": { |
| 64 | + "Message_Format": { |
| 65 | + "Social gain": "0.04", |
| 66 | + "Social stayed better":"-0.08", |
| 67 | + "Worsening": "-0.1", |
| 68 | + "Improving": "-0.11", |
| 69 | + "Social loss": "0.69", |
| 70 | + "Social stayed worse": "-0.54", |
| 71 | + "Social better": "-1.23", |
| 72 | + "Social worse": "0.54", |
| 73 | + "Social approach": "1.0", |
| 74 | + "Goal gain": "0.07", |
| 75 | + "Goal approach": "1.1" |
| 76 | + }, |
| 77 | + "Display_Format": { |
| 78 | + "Bar chart": 1, |
| 79 | + "Line chart": 0, |
| 80 | + "Text-only": 0, |
| 81 | + "System-generated": 0 |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + ``` |
| 86 | +## Data Generator |
| 87 | +First, create a folder for new data (i.e. `new_data`). |
| 88 | +If the data is going to be generated for individual recipients, create a config.json inside the new data folder containing |
| 89 | +```json |
| 90 | +{ |
| 91 | + "ComparatorMergeColumns":["group.subject", "PractitionerRole.code"] |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +for hospital level data use |
| 96 | +```json |
| 97 | +{ |
| 98 | + "ComparatorMergeColumns":["PractitionerRole.code"] |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +Now you can run the scripts sequentially to generate data. |
| 103 | + |
| 104 | +For example to generate hospital level data for 100 hospitals run the following commands: |
| 105 | + |
| 106 | +```zsh |
| 107 | +python data\ ingestion\ model/sandbox\ generator/PractitionerRole_hospital_level.py --num_orgs 100 --path new_data |
| 108 | + |
| 109 | +python data\ ingestion\ model/sandbox\ generator/PerformanceMeasureReport.py --path new_data |
| 110 | + |
| 111 | +python data\ ingestion\ model/sandbox\ generator/ComparatorMeasureReport.py --path new_data |
| 112 | + |
| 113 | +python data\ ingestion\ model/sandbox\ generator/Preference.py --path new_data |
| 114 | + |
| 115 | +ENV_PATH=/Path/to/your/environment/file/dev.env python data\ ingestion\ model/sandbox\ generator/MessageHistory.py --path new_data |
| 116 | +``` |
| 117 | + |
| 118 | +This will start by creatig the list of hospitals in PractitionerRole.csv file. Then will generate performance data in PerformanceMeasureReports.csv. Next step will create the comparator data in ComparatorMeasureReport.csv. Then the preferences will be added to preferences.csv. Finall step will use SCAFFOLD to generate the history of messages generated by pipeline for the months before the performance month. |
| 119 | + |
| 120 | +## Example Data |
| 121 | +Sandbox hospital level example data is generated for 100 hospitals and included at 'sandbox examples' folder. This folder includes |
| 122 | +- PractitionerRole.csv, which contains hospital definitions |
| 123 | +- PerformanceMeaasureReport, which contains performance data for each hospital on 12 defined measures in sandbox knowledge base for 12 month. |
| 124 | +- config.json, which is required to find the right comparator for each recipient |
| 125 | +- ComparatorMeasureReport.csv, which contains the comparator data for based on the entire network for each measure, for each month. |
| 126 | +- Preferences.csv, which includes preferences for a small subgroup of recipients. |
| 127 | +- MessageHistory.csv, which includes history of generated messages for 11 month before the performance month. |
| 128 | + |
| 129 | +# Run SCAFFOLD |
| 130 | +To run SCAFFOLD on sandbox data you need to prepare the environment and install SCAFFOLD. For more detail, follow the `Quick start` section of the [main SCAFFOLD documentation page](../README.md). Skip `Run SCAFFOLD API` and `Run SCAFFOLD CLI with JSON inputs` sections and continue with `Run SCAFFOLD CLI with CSV inputs`. |
| 131 | + |
| 132 | + |
0 commit comments