From 5b01da6bc3e03af297ad617264ba7f0df34852a1 Mon Sep 17 00:00:00 2001 From: James Cockayne Date: Wed, 8 Jan 2025 15:50:09 +0000 Subject: [PATCH 1/3] Fix bug where some mapped ICD10/ICDO3/OPCS4 codes were not standard once resolved. --- .../VersionedMigrations/V60__code_map_primary_key.sql | 6 ++++++ OmopTransformer/Icd10Resolver.cs | 9 ++++++++- OmopTransformer/Icdo3Resolver.cs | 11 ++++++++++- OmopTransformer/OPCS4Resolver.cs | 11 ++++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 Database/Migrations/sql/VersionedMigrations/V60__code_map_primary_key.sql diff --git a/Database/Migrations/sql/VersionedMigrations/V60__code_map_primary_key.sql b/Database/Migrations/sql/VersionedMigrations/V60__code_map_primary_key.sql new file mode 100644 index 0000000..e4206b1 --- /dev/null +++ b/Database/Migrations/sql/VersionedMigrations/V60__code_map_primary_key.sql @@ -0,0 +1,6 @@ +alter table omop_staging.concept_code_map + add constraint PK_omop_staging_concept_code_map_source_concept_id_target_concept_id + primary key ( + source_concept_id, + target_concept_id + ); \ No newline at end of file diff --git a/OmopTransformer/Icd10Resolver.cs b/OmopTransformer/Icd10Resolver.cs index ed226fe..451068d 100644 --- a/OmopTransformer/Icd10Resolver.cs +++ b/OmopTransformer/Icd10Resolver.cs @@ -27,9 +27,16 @@ private Dictionary GetIcd10Codes() connection.Open(); + string query = "select " + + " ccm.target_concept_id as concept_id, " + + " replace(ccm.source_concept_code, '.', '') as Code " + + "from omop_staging.concept_code_map ccm " + + " inner join cdm.concept c " + + " on ccm.source_concept_id = c.concept_id " + + "where c.vocabulary_id = 'ICD10' "; return connection - .Query(sql: "select concept_id, replace(concept_code, '.', '') as Code from cdm.concept where vocabulary_id = 'ICD10'") + .Query(sql: query) .ToDictionary( row => row.Code!, row => row.concept_id); diff --git a/OmopTransformer/Icdo3Resolver.cs b/OmopTransformer/Icdo3Resolver.cs index 7163738..c1ed1f4 100644 --- a/OmopTransformer/Icdo3Resolver.cs +++ b/OmopTransformer/Icdo3Resolver.cs @@ -27,9 +27,18 @@ private Dictionary GetIcdo3Codes() connection.Open(); + string query = + "select " + + " ccm.target_concept_id as concept_id, " + + " ccm.source_concept_code as concept_code " + + "from omop_staging.concept_code_map ccm " + + " inner join cdm.concept c " + + " on ccm.source_concept_id = c.concept_id " + + "where c.vocabulary_id = 'ICDO3' "; + return connection - .Query(sql: "select concept_id, concept_code as Code from cdm.concept where vocabulary_id = 'ICDO3'") + .Query(query) .ToDictionary( row => row.Code!, row => row.concept_id); diff --git a/OmopTransformer/OPCS4Resolver.cs b/OmopTransformer/OPCS4Resolver.cs index 304dfe8..aad3381 100644 --- a/OmopTransformer/OPCS4Resolver.cs +++ b/OmopTransformer/OPCS4Resolver.cs @@ -27,9 +27,18 @@ private Dictionary GetOpcs4Codes() connection.Open(); + string query = + "select " + + " ccm.target_concept_id as concept_id, " + + " replace(ccm.source_concept_code, '.', '') as Code " + + "from omop_staging.concept_code_map ccm " + + " inner join cdm.concept c " + + " on ccm.source_concept_id = c.concept_id " + + "where c.vocabulary_id = 'OPCS4' "; + return connection - .Query(sql: "select replace (concept_code, '.', '') as Code, concept_id from cdm.concept where vocabulary_id = 'OPCS4'") + .Query(sql: query) .ToDictionary( row => row.Code!, row => row.concept_id); From 81f9489f1c5214d95fe06cf7a66a35153328b18f Mon Sep 17 00:00:00 2001 From: James Cockayne Date: Wed, 8 Jan 2025 15:51:58 +0000 Subject: [PATCH 2/3] Remove rule exception field_isstandardvalidconcept_death_cause_concept_id --- DataQualityDashboard/known_errors.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/DataQualityDashboard/known_errors.txt b/DataQualityDashboard/known_errors.txt index 695d562..095d292 100644 --- a/DataQualityDashboard/known_errors.txt +++ b/DataQualityDashboard/known_errors.txt @@ -1,5 +1,4 @@ table_measurepersoncompleteness_observation -field_isstandardvalidconcept_death_cause_concept_id field_isstandardvalidconcept_person_gender_concept_id field_plausiblevaluelow_cdm_source_source_release_date field_withinvisitdates_visit_detail_visit_detail_start_date \ No newline at end of file From 9dbd08434a44e36600525a6a8417cf9eac65c772 Mon Sep 17 00:00:00 2001 From: James Cockayne Date: Thu, 9 Jan 2025 11:09:17 +0000 Subject: [PATCH 3/3] Re render documentation --- .../CdsAnaestheticDuringLabourDelivery.json | 2 +- ...CdsAnaestheticGivenPostLabourDelivery.json | 2 +- .../CdsCarerSupportIndicator.json | 2 +- .../CdsSourceOfReferralForOutpatients.json | 2 +- .../CdsTotalPreviousPregnancies.json | 2 +- .../Death_NhsNumber.md | 46 ++++---- .../Death_cause_concept_id.md | 46 ++++---- .../Death_cause_source_value.md | 46 ++++---- .../Death_death_date.md | 46 ++++---- .../Death_death_datetime.md | 46 ++++---- .../Observation.md | 14 +++ .../Observation_RecordConnectionIdentifier.md | 17 +++ .../Observation_nhs_number.md | 17 +++ .../Observation_observation_concept_id.md | 4 + .../Observation_observation_date.md | 18 +++ .../Observation_observation_datetime.md | 18 +++ ...Observation_observation_type_concept_id.md | 22 ++-- .../Observation_value_as_string.md | 17 +++ .../Provider_provider_source_value.md | 14 +-- .../Provider_specialty_concept_id.md | 14 +-- .../Provider_specialty_source_value.md | 14 +-- ...SusAPCAnaestheticDuringLabourDelivery.json | 2 +- ...APCAnaestheticGivenPostLabourDelivery.json | 2 +- .../SusAPCCarerSupportIndicator.json | 2 +- .../SusAPCDeath.json | 10 +- .../SusAPCProvider.json | 6 +- .../SusAPCSourceOfReferralForOutpatients.json | 110 ++++++++++++++++++ .../SusAPCSourceOfReferralForOutpatients.svg | 75 ++++++++++++ .../SusAPCTotalPreviousPregnancies.json | 2 +- 29 files changed, 456 insertions(+), 162 deletions(-) create mode 100644 docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.json create mode 100644 docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.svg diff --git a/docs/transformation-documentation/CdsAnaestheticDuringLabourDelivery.json b/docs/transformation-documentation/CdsAnaestheticDuringLabourDelivery.json index 7d20f76..8ea1591 100644 --- a/docs/transformation-documentation/CdsAnaestheticDuringLabourDelivery.json +++ b/docs/transformation-documentation/CdsAnaestheticDuringLabourDelivery.json @@ -109,7 +109,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/CdsAnaestheticGivenPostLabourDelivery.json b/docs/transformation-documentation/CdsAnaestheticGivenPostLabourDelivery.json index 395b64b..261f783 100644 --- a/docs/transformation-documentation/CdsAnaestheticGivenPostLabourDelivery.json +++ b/docs/transformation-documentation/CdsAnaestheticGivenPostLabourDelivery.json @@ -101,7 +101,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/CdsCarerSupportIndicator.json b/docs/transformation-documentation/CdsCarerSupportIndicator.json index 91ca25e..182efee 100644 --- a/docs/transformation-documentation/CdsCarerSupportIndicator.json +++ b/docs/transformation-documentation/CdsCarerSupportIndicator.json @@ -101,7 +101,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/CdsSourceOfReferralForOutpatients.json b/docs/transformation-documentation/CdsSourceOfReferralForOutpatients.json index b65bac4..34f0dc7 100644 --- a/docs/transformation-documentation/CdsSourceOfReferralForOutpatients.json +++ b/docs/transformation-documentation/CdsSourceOfReferralForOutpatients.json @@ -109,7 +109,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/CdsTotalPreviousPregnancies.json b/docs/transformation-documentation/CdsTotalPreviousPregnancies.json index 29cf233..7334f63 100644 --- a/docs/transformation-documentation/CdsTotalPreviousPregnancies.json +++ b/docs/transformation-documentation/CdsTotalPreviousPregnancies.json @@ -101,7 +101,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/Death_NhsNumber.md b/docs/transformation-documentation/Death_NhsNumber.md index a772bac..436589d 100644 --- a/docs/transformation-documentation/Death_NhsNumber.md +++ b/docs/transformation-documentation/Death_NhsNumber.md @@ -31,33 +31,33 @@ has_toc: false * `nhs_number` Patient NHS Number [NHS NUMBER](https://www.datadictionary.nhs.uk/data_elements/nhs_number.html) ```sql - ;with primarydiagnosis as ( - select * - from omop_staging.sus_ICDDiagnosis - where IsPrimaryDiagnosis = 1 - ) +;with primarydiagnosis as ( + select * + from omop_staging.sus_ICDDiagnosis + where IsPrimaryDiagnosis = 1 +) - select - apc.NHSNumber as nhs_number, - max(apc.DischargeDateFromHospitalProviderSpell) as death_date, - max(apc.DischargeTimeHospitalProviderSpell) as death_time, - max(d.DiagnosisICD) as DiagnosisICD - from - omop_staging.sus_APC apc - left join primarydiagnosis d +select + apc.NHSNumber as nhs_number, + max(apc.DischargeDateFromHospitalProviderSpell) as death_date, + max(apc.DischargeTimeHospitalProviderSpell) as death_time, + max(d.DiagnosisICD) as DiagnosisICD +from omop_staging.sus_APC apc + left join primarydiagnosis d on apc.MessageId = d.MessageId - where - apc.NHSNumber is not null and - apc.DischargeDateFromHospitalProviderSpell is not null and +where + apc.NHSNumber is not null and + apc.DischargeDateFromHospitalProviderSpell is not null and + ( + apc.DischargeMethodHospitalProviderSpell = '4' -- "Patient died" + or ( - apc.DischargeMethodHospitalProviderSpell = '4' - or ( - apc.DischargeDestinationHospitalProviderSpell = '79' - and - apc.DischargeMethodHospitalProviderSpell != '5' - ) + apc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth + and + apc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth ) - group by apc.NHSNumber +) +group by apc.NHSNumber ``` diff --git a/docs/transformation-documentation/Death_cause_concept_id.md b/docs/transformation-documentation/Death_cause_concept_id.md index 372cd01..ecf2e1c 100644 --- a/docs/transformation-documentation/Death_cause_concept_id.md +++ b/docs/transformation-documentation/Death_cause_concept_id.md @@ -13,33 +13,33 @@ Resolve ICD10 codes to OMOP concepts. If code cannot be mapped, map using the pa * `DiagnosisICD` Primary Diagnosis [PRIMARY DIAGNOSIS]() ```sql - ;with primarydiagnosis as ( - select * - from omop_staging.sus_ICDDiagnosis - where IsPrimaryDiagnosis = 1 - ) +;with primarydiagnosis as ( + select * + from omop_staging.sus_ICDDiagnosis + where IsPrimaryDiagnosis = 1 +) - select - apc.NHSNumber as nhs_number, - max(apc.DischargeDateFromHospitalProviderSpell) as death_date, - max(apc.DischargeTimeHospitalProviderSpell) as death_time, - max(d.DiagnosisICD) as DiagnosisICD - from - omop_staging.sus_APC apc - left join primarydiagnosis d +select + apc.NHSNumber as nhs_number, + max(apc.DischargeDateFromHospitalProviderSpell) as death_date, + max(apc.DischargeTimeHospitalProviderSpell) as death_time, + max(d.DiagnosisICD) as DiagnosisICD +from omop_staging.sus_APC apc + left join primarydiagnosis d on apc.MessageId = d.MessageId - where - apc.NHSNumber is not null and - apc.DischargeDateFromHospitalProviderSpell is not null and +where + apc.NHSNumber is not null and + apc.DischargeDateFromHospitalProviderSpell is not null and + ( + apc.DischargeMethodHospitalProviderSpell = '4' -- "Patient died" + or ( - apc.DischargeMethodHospitalProviderSpell = '4' - or ( - apc.DischargeDestinationHospitalProviderSpell = '79' - and - apc.DischargeMethodHospitalProviderSpell != '5' - ) + apc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth + and + apc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth ) - group by apc.NHSNumber +) +group by apc.NHSNumber ``` diff --git a/docs/transformation-documentation/Death_cause_source_value.md b/docs/transformation-documentation/Death_cause_source_value.md index edbcf75..cc3deef 100644 --- a/docs/transformation-documentation/Death_cause_source_value.md +++ b/docs/transformation-documentation/Death_cause_source_value.md @@ -12,33 +12,33 @@ has_toc: false * `DiagnosisICD` Primary Diagnosis [PRIMARY DIAGNOSIS]() ```sql - ;with primarydiagnosis as ( - select * - from omop_staging.sus_ICDDiagnosis - where IsPrimaryDiagnosis = 1 - ) +;with primarydiagnosis as ( + select * + from omop_staging.sus_ICDDiagnosis + where IsPrimaryDiagnosis = 1 +) - select - apc.NHSNumber as nhs_number, - max(apc.DischargeDateFromHospitalProviderSpell) as death_date, - max(apc.DischargeTimeHospitalProviderSpell) as death_time, - max(d.DiagnosisICD) as DiagnosisICD - from - omop_staging.sus_APC apc - left join primarydiagnosis d +select + apc.NHSNumber as nhs_number, + max(apc.DischargeDateFromHospitalProviderSpell) as death_date, + max(apc.DischargeTimeHospitalProviderSpell) as death_time, + max(d.DiagnosisICD) as DiagnosisICD +from omop_staging.sus_APC apc + left join primarydiagnosis d on apc.MessageId = d.MessageId - where - apc.NHSNumber is not null and - apc.DischargeDateFromHospitalProviderSpell is not null and +where + apc.NHSNumber is not null and + apc.DischargeDateFromHospitalProviderSpell is not null and + ( + apc.DischargeMethodHospitalProviderSpell = '4' -- "Patient died" + or ( - apc.DischargeMethodHospitalProviderSpell = '4' - or ( - apc.DischargeDestinationHospitalProviderSpell = '79' - and - apc.DischargeMethodHospitalProviderSpell != '5' - ) + apc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth + and + apc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth ) - group by apc.NHSNumber +) +group by apc.NHSNumber ``` diff --git a/docs/transformation-documentation/Death_death_date.md b/docs/transformation-documentation/Death_death_date.md index 10cc8c8..348dbe6 100644 --- a/docs/transformation-documentation/Death_death_date.md +++ b/docs/transformation-documentation/Death_death_date.md @@ -33,33 +33,33 @@ Converts text to dates. * `death_date` Discharge date of the patient's spell. [DISCHARGE DATE (HOSPITAL PROVIDER SPELL)](https://www.datadictionary.nhs.uk/data_elements/discharge_date__hospital_provider_spell_.html) ```sql - ;with primarydiagnosis as ( - select * - from omop_staging.sus_ICDDiagnosis - where IsPrimaryDiagnosis = 1 - ) +;with primarydiagnosis as ( + select * + from omop_staging.sus_ICDDiagnosis + where IsPrimaryDiagnosis = 1 +) - select - apc.NHSNumber as nhs_number, - max(apc.DischargeDateFromHospitalProviderSpell) as death_date, - max(apc.DischargeTimeHospitalProviderSpell) as death_time, - max(d.DiagnosisICD) as DiagnosisICD - from - omop_staging.sus_APC apc - left join primarydiagnosis d +select + apc.NHSNumber as nhs_number, + max(apc.DischargeDateFromHospitalProviderSpell) as death_date, + max(apc.DischargeTimeHospitalProviderSpell) as death_time, + max(d.DiagnosisICD) as DiagnosisICD +from omop_staging.sus_APC apc + left join primarydiagnosis d on apc.MessageId = d.MessageId - where - apc.NHSNumber is not null and - apc.DischargeDateFromHospitalProviderSpell is not null and +where + apc.NHSNumber is not null and + apc.DischargeDateFromHospitalProviderSpell is not null and + ( + apc.DischargeMethodHospitalProviderSpell = '4' -- "Patient died" + or ( - apc.DischargeMethodHospitalProviderSpell = '4' - or ( - apc.DischargeDestinationHospitalProviderSpell = '79' - and - apc.DischargeMethodHospitalProviderSpell != '5' - ) + apc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth + and + apc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth ) - group by apc.NHSNumber +) +group by apc.NHSNumber ``` diff --git a/docs/transformation-documentation/Death_death_datetime.md b/docs/transformation-documentation/Death_death_datetime.md index e8b181f..da6da7c 100644 --- a/docs/transformation-documentation/Death_death_datetime.md +++ b/docs/transformation-documentation/Death_death_datetime.md @@ -15,33 +15,33 @@ Combines a date with a time of day. * `death_time` Discharge time of the patient's spell. [DISCHARGE TIME (HOSPITAL PROVIDER SPELL)](https://www.datadictionary.nhs.uk/data_elements/discharge_time__hospital_provider_spell_.html) ```sql - ;with primarydiagnosis as ( - select * - from omop_staging.sus_ICDDiagnosis - where IsPrimaryDiagnosis = 1 - ) +;with primarydiagnosis as ( + select * + from omop_staging.sus_ICDDiagnosis + where IsPrimaryDiagnosis = 1 +) - select - apc.NHSNumber as nhs_number, - max(apc.DischargeDateFromHospitalProviderSpell) as death_date, - max(apc.DischargeTimeHospitalProviderSpell) as death_time, - max(d.DiagnosisICD) as DiagnosisICD - from - omop_staging.sus_APC apc - left join primarydiagnosis d +select + apc.NHSNumber as nhs_number, + max(apc.DischargeDateFromHospitalProviderSpell) as death_date, + max(apc.DischargeTimeHospitalProviderSpell) as death_time, + max(d.DiagnosisICD) as DiagnosisICD +from omop_staging.sus_APC apc + left join primarydiagnosis d on apc.MessageId = d.MessageId - where - apc.NHSNumber is not null and - apc.DischargeDateFromHospitalProviderSpell is not null and +where + apc.NHSNumber is not null and + apc.DischargeDateFromHospitalProviderSpell is not null and + ( + apc.DischargeMethodHospitalProviderSpell = '4' -- "Patient died" + or ( - apc.DischargeMethodHospitalProviderSpell = '4' - or ( - apc.DischargeDestinationHospitalProviderSpell = '79' - and - apc.DischargeMethodHospitalProviderSpell != '5' - ) + apc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth + and + apc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth ) - group by apc.NHSNumber +) +group by apc.NHSNumber ``` diff --git a/docs/transformation-documentation/Observation.md b/docs/transformation-documentation/Observation.md index 16ec5c5..fca4c45 100644 --- a/docs/transformation-documentation/Observation.md +++ b/docs/transformation-documentation/Observation.md @@ -33,6 +33,20 @@ has_toc: false > [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=SusAPCTotalPreviousPregnancies%20mapping){: .btn } +## SusAPCSourceOfReferralForOutpatients + + +{: .important-title } +> Notes +> +> Observations do not require a standardized test or other activity to generate clinical fact. Typical observations are medical history, family history, lifestyle choices, healthcare utilization patterns, social circumstances etc +> +> Valid Observation Concepts are not enforced to be from any domain. They should still be standard concepts and typically belong to the Observation or Measurement domain. +> +> Observations can be stored as attribute value pairs, with the attribute as the Observation Concept and the value representing the clinical fact. This fact can be stored as a Concept (value_as_concept), a numerical value (value_as_number) or a verbatim string (value_as_string) +> + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=SusAPCSourceOfReferralForOutpatients%20mapping){: .btn } ## SusAPCNumberOfBabies diff --git a/docs/transformation-documentation/Observation_RecordConnectionIdentifier.md b/docs/transformation-documentation/Observation_RecordConnectionIdentifier.md index f14f046..005832e 100644 --- a/docs/transformation-documentation/Observation_RecordConnectionIdentifier.md +++ b/docs/transformation-documentation/Observation_RecordConnectionIdentifier.md @@ -33,6 +33,23 @@ group by [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20RecordConnectionIdentifier%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +* Value copied from `GeneratedRecordIdentifier` + +* `GeneratedRecordIdentifier` CDS specific identifier that binds multiple CDS messages together. [CDS RECORD IDENTIFIER](https://www.datadictionary.nhs.uk/data_elements/cds_record_identifier.html) + +```sql +select NHSNumber, + GeneratedRecordIdentifier, + StartDateHospitalProviderSpell, + StartTimeHospitalProviderSpell, + ReferrerCode -- Referrer code is the code of the person making the referral request +FROM [OMOP_SUS].[omop_staging].[sus_APC] + +``` + + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20RecordConnectionIdentifier%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient NumberofBabies Observation * Value copied from `GeneratedRecordIdentifier` diff --git a/docs/transformation-documentation/Observation_nhs_number.md b/docs/transformation-documentation/Observation_nhs_number.md index 1d41031..16a769c 100644 --- a/docs/transformation-documentation/Observation_nhs_number.md +++ b/docs/transformation-documentation/Observation_nhs_number.md @@ -33,6 +33,23 @@ group by [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20nhs_number%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +* Value copied from `NHSNumber` + +* `NHSNumber` Patient NHS Number [NHS NUMBER](https://www.datadictionary.nhs.uk/data_elements/nhs_number.html) + +```sql +select NHSNumber, + GeneratedRecordIdentifier, + StartDateHospitalProviderSpell, + StartTimeHospitalProviderSpell, + ReferrerCode -- Referrer code is the code of the person making the referral request +FROM [OMOP_SUS].[omop_staging].[sus_APC] + +``` + + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20nhs_number%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient NumberofBabies Observation * Value copied from `NHSNumber` diff --git a/docs/transformation-documentation/Observation_observation_concept_id.md b/docs/transformation-documentation/Observation_observation_concept_id.md index 72d198b..6c02541 100644 --- a/docs/transformation-documentation/Observation_observation_concept_id.md +++ b/docs/transformation-documentation/Observation_observation_concept_id.md @@ -10,6 +10,10 @@ has_toc: false * Constant value set to `4078008`. Number of previous pregnancies [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_concept_id%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +* Constant value set to `4258129`. Referral by + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_concept_id%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient NumberofBabies Observation * Constant value set to `4209211`. Number of births at term diff --git a/docs/transformation-documentation/Observation_observation_date.md b/docs/transformation-documentation/Observation_observation_date.md index 1e521d7..bf5a169 100644 --- a/docs/transformation-documentation/Observation_observation_date.md +++ b/docs/transformation-documentation/Observation_observation_date.md @@ -34,6 +34,24 @@ group by [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_date%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +Source column `StartDateHospitalProviderSpell`. +Converts text to dates. + +* `StartDateHospitalProviderSpell` Event date [START DATE (HOSPITAL PROVIDER SPELL)](https://www.datadictionary.nhs.uk/data_elements/start_date__hospital_provider_spell_.html) + +```sql +select NHSNumber, + GeneratedRecordIdentifier, + StartDateHospitalProviderSpell, + StartTimeHospitalProviderSpell, + ReferrerCode -- Referrer code is the code of the person making the referral request +FROM [OMOP_SUS].[omop_staging].[sus_APC] + +``` + + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_date%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient NumberofBabies Observation Source column `observation_date`. Converts text to dates. diff --git a/docs/transformation-documentation/Observation_observation_datetime.md b/docs/transformation-documentation/Observation_observation_datetime.md index 3ceeda9..95892cd 100644 --- a/docs/transformation-documentation/Observation_observation_datetime.md +++ b/docs/transformation-documentation/Observation_observation_datetime.md @@ -34,6 +34,24 @@ group by [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_datetime%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +Source column `StartTimeHospitalProviderSpell`. +Converts text to dates. + +* `StartTimeHospitalProviderSpell` Records whether anaesthetic was given during Labour/ Delivery, and the type used. [START TIME (HOSPITAL PROVIDER SPELL)](https://www.datadictionary.nhs.uk/data_elements/start_time__hospital_provider_spell_.html) + +```sql +select NHSNumber, + GeneratedRecordIdentifier, + StartDateHospitalProviderSpell, + StartTimeHospitalProviderSpell, + ReferrerCode -- Referrer code is the code of the person making the referral request +FROM [OMOP_SUS].[omop_staging].[sus_APC] + +``` + + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_datetime%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient NumberofBabies Observation Source column `observation_date`. Converts text to dates. diff --git a/docs/transformation-documentation/Observation_observation_type_concept_id.md b/docs/transformation-documentation/Observation_observation_type_concept_id.md index a4281a5..d4ac0cc 100644 --- a/docs/transformation-documentation/Observation_observation_type_concept_id.md +++ b/docs/transformation-documentation/Observation_observation_type_concept_id.md @@ -7,9 +7,13 @@ has_toc: false --- # observation_type_concept_id ### SUS Inpatient Total Previous Pregnancies Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +* Constant value set to `32818`. EHR administration record + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient NumberofBabies Observation * Constant value set to `38000280`. Observation recorded from EHR @@ -19,7 +23,7 @@ has_toc: false [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20SUS%20Inpatient%20Gestation%20Length%20Labour%20Onset%20Observation%20mapping){: .btn } ### SUS Inpatient Carer Support Indicator Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20SUS%20Inpatient%20Carer%20Support%20Indicator%20Observation%20mapping){: .btn } ### Sus APC Birth Weight Observation @@ -27,11 +31,11 @@ has_toc: false [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Sus%20APC%20Birth%20Weight%20Observation%20mapping){: .btn } ### SUS APC Anaesthetic Given Post Labour Delivery Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20SUS%20APC%20Anaesthetic%20Given%20Post%20Labour%20Delivery%20Observation%20mapping){: .btn } ### SUS APC Anaesthetic During Labour Delivery Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20SUS%20APC%20Anaesthetic%20During%20Labour%20Delivery%20Observation%20mapping){: .btn } ### CosdV9TobaccoSmokingStatus @@ -123,11 +127,11 @@ has_toc: false [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20CosdV8AdultComorbidityEvaluation%20mapping){: .btn } ### Cds Total Previous Pregnancies Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } ### Cds Source Of Referral For Outpatients Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Source%20Of%20Referral%20For%20Outpatients%20Observation%20mapping){: .btn } ### Cds Person Weight Observation @@ -143,7 +147,7 @@ has_toc: false [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Gestation%20Length%20Labour%20Onset%20Observation%20mapping){: .btn } ### Cds Carer Support Indicator Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Carer%20Support%20Indicator%20Observation%20mapping){: .btn } ### Cds Birth Weight Observation @@ -151,10 +155,10 @@ has_toc: false [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Birth%20Weight%20Observation%20mapping){: .btn } ### Cds Anaesthetic Given Post Labour Delivery Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Anaesthetic%20Given%20Post%20Labour%20Delivery%20Observation%20mapping){: .btn } ### Cds Anaesthetic During Labour Delivery Observation -* Constant value set to `38000281`. Observation recorded from EHR with text result +* Constant value set to `32818`. EHR administration record [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20observation_type_concept_id%20field%20Cds%20Anaesthetic%20During%20Labour%20Delivery%20Observation%20mapping){: .btn } diff --git a/docs/transformation-documentation/Observation_value_as_string.md b/docs/transformation-documentation/Observation_value_as_string.md index 1a07ff2..c1488d3 100644 --- a/docs/transformation-documentation/Observation_value_as_string.md +++ b/docs/transformation-documentation/Observation_value_as_string.md @@ -33,6 +33,23 @@ group by [Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20value_as_string%20field%20SUS%20Inpatient%20Total%20Previous%20Pregnancies%20Observation%20mapping){: .btn } +### SUS APC Source Of Referral For Outpatients +* Value copied from `ReferrerCode` + +* `ReferrerCode` Referrer code is the code of the person making the referral request. [REFERRER CODE](https://www.datadictionary.nhs.uk/data_elements/referrer_code.html) + +```sql +select NHSNumber, + GeneratedRecordIdentifier, + StartDateHospitalProviderSpell, + StartTimeHospitalProviderSpell, + ReferrerCode -- Referrer code is the code of the person making the referral request +FROM [OMOP_SUS].[omop_staging].[sus_APC] + +``` + + +[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=OMOP%20Observation%20table%20value_as_string%20field%20SUS%20APC%20Source%20Of%20Referral%20For%20Outpatients%20mapping){: .btn } ### SUS Inpatient Carer Support Indicator Observation * Value copied from `CarerSupportIndicator` diff --git a/docs/transformation-documentation/Provider_provider_source_value.md b/docs/transformation-documentation/Provider_provider_source_value.md index 68db07a..364e50a 100644 --- a/docs/transformation-documentation/Provider_provider_source_value.md +++ b/docs/transformation-documentation/Provider_provider_source_value.md @@ -12,7 +12,7 @@ has_toc: false * `ConsultantCode` A unique code identifying a care professional [CONSULTANT CODE](https://www.datadictionary.nhs.uk/data_elements/consultant_code.html) ```sql - with counts as ( +with counts as ( select ConsultantCode, MainSpecialtyCode, @@ -20,18 +20,18 @@ has_toc: false row_number() over ( partition by ConsultantCode order by count(*) desc, MainSpecialtyCode - ) rnk - from ( - select distinct +) rnk +from ( + select ConsultantCode, MainSpecialtyCode from [OMOP_QA].[omop_staging].[sus_APC] where MainSpecialtyCode is not null and ConsultantCode is not null - ) grouped +) grouped group by ConsultantCode, MainSpecialtyCode - ) - select +) +select ConsultantCode, MainSpecialtyCode from counts diff --git a/docs/transformation-documentation/Provider_specialty_concept_id.md b/docs/transformation-documentation/Provider_specialty_concept_id.md index 4071007..9852b0e 100644 --- a/docs/transformation-documentation/Provider_specialty_concept_id.md +++ b/docs/transformation-documentation/Provider_specialty_concept_id.md @@ -107,7 +107,7 @@ Notes * `MainSpecialtyCode` A unique code identifying each MAIN SPECIALTY designated by Royal Colleges. [MAIN SPECIALTY CODE]() ```sql - with counts as ( +with counts as ( select ConsultantCode, MainSpecialtyCode, @@ -115,18 +115,18 @@ Notes row_number() over ( partition by ConsultantCode order by count(*) desc, MainSpecialtyCode - ) rnk - from ( - select distinct +) rnk +from ( + select ConsultantCode, MainSpecialtyCode from [OMOP_QA].[omop_staging].[sus_APC] where MainSpecialtyCode is not null and ConsultantCode is not null - ) grouped +) grouped group by ConsultantCode, MainSpecialtyCode - ) - select +) +select ConsultantCode, MainSpecialtyCode from counts diff --git a/docs/transformation-documentation/Provider_specialty_source_value.md b/docs/transformation-documentation/Provider_specialty_source_value.md index 9462544..65a8802 100644 --- a/docs/transformation-documentation/Provider_specialty_source_value.md +++ b/docs/transformation-documentation/Provider_specialty_source_value.md @@ -12,7 +12,7 @@ has_toc: false * `MainSpecialtyCode` A unique code identifying each MAIN SPECIALTY designated by Royal Colleges. [MAIN SPECIALTY CODE]() ```sql - with counts as ( +with counts as ( select ConsultantCode, MainSpecialtyCode, @@ -20,18 +20,18 @@ has_toc: false row_number() over ( partition by ConsultantCode order by count(*) desc, MainSpecialtyCode - ) rnk - from ( - select distinct +) rnk +from ( + select ConsultantCode, MainSpecialtyCode from [OMOP_QA].[omop_staging].[sus_APC] where MainSpecialtyCode is not null and ConsultantCode is not null - ) grouped +) grouped group by ConsultantCode, MainSpecialtyCode - ) - select +) +select ConsultantCode, MainSpecialtyCode from counts diff --git a/docs/transformation-documentation/SusAPCAnaestheticDuringLabourDelivery.json b/docs/transformation-documentation/SusAPCAnaestheticDuringLabourDelivery.json index 239af92..4a20ae3 100644 --- a/docs/transformation-documentation/SusAPCAnaestheticDuringLabourDelivery.json +++ b/docs/transformation-documentation/SusAPCAnaestheticDuringLabourDelivery.json @@ -109,7 +109,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/SusAPCAnaestheticGivenPostLabourDelivery.json b/docs/transformation-documentation/SusAPCAnaestheticGivenPostLabourDelivery.json index 1168d37..06e8e0e 100644 --- a/docs/transformation-documentation/SusAPCAnaestheticGivenPostLabourDelivery.json +++ b/docs/transformation-documentation/SusAPCAnaestheticGivenPostLabourDelivery.json @@ -101,7 +101,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/SusAPCCarerSupportIndicator.json b/docs/transformation-documentation/SusAPCCarerSupportIndicator.json index e6adb4d..780f98a 100644 --- a/docs/transformation-documentation/SusAPCCarerSupportIndicator.json +++ b/docs/transformation-documentation/SusAPCCarerSupportIndicator.json @@ -101,7 +101,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null diff --git a/docs/transformation-documentation/SusAPCDeath.json b/docs/transformation-documentation/SusAPCDeath.json index 348fe0c..0152de5 100644 --- a/docs/transformation-documentation/SusAPCDeath.json +++ b/docs/transformation-documentation/SusAPCDeath.json @@ -17,7 +17,7 @@ ] } ], - "query": "\n\t\t;with primarydiagnosis as (\n\t\tselect *\n\t\tfrom omop_staging.sus_ICDDiagnosis\n\t\twhere IsPrimaryDiagnosis = 1\n\t\t)\n\n\t\tselect\n\t\tapc.NHSNumber as nhs_number,\n\t\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\t\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\t\tmax(d.DiagnosisICD) as DiagnosisICD\n\t\tfrom\n\t\tomop_staging.sus_APC apc\n\t\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\n\t\twhere\n\t\tapc.NHSNumber is not null and\n\t\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4'\n\t\tor (\n\t\tapc.DischargeDestinationHospitalProviderSpell = '79'\n\t\tand\n\t\tapc.DischargeMethodHospitalProviderSpell != '5'\n\t\t)\n\t\t)\n\t\tgroup by apc.NHSNumber\n\t", + "query": "\n;with primarydiagnosis as (\n\tselect *\n\tfrom omop_staging.sus_ICDDiagnosis\n\twhere IsPrimaryDiagnosis = 1\n)\n\nselect\n\tapc.NHSNumber as nhs_number,\n\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\tmax(d.DiagnosisICD) as DiagnosisICD\nfrom omop_staging.sus_APC apc\n\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\nwhere\n\tapc.NHSNumber is not null and\n\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4' -- \"Patient died\"\n\t\tor\n\t\t(\n\t\t\tapc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth\n\t\t\tand\n\t\t\tapc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth\n\t\t)\n)\ngroup by apc.NHSNumber\n\t", "lookup_table_markdown": null }, { @@ -35,7 +35,7 @@ ] } ], - "query": "\n\t\t;with primarydiagnosis as (\n\t\tselect *\n\t\tfrom omop_staging.sus_ICDDiagnosis\n\t\twhere IsPrimaryDiagnosis = 1\n\t\t)\n\n\t\tselect\n\t\tapc.NHSNumber as nhs_number,\n\t\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\t\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\t\tmax(d.DiagnosisICD) as DiagnosisICD\n\t\tfrom\n\t\tomop_staging.sus_APC apc\n\t\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\n\t\twhere\n\t\tapc.NHSNumber is not null and\n\t\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4'\n\t\tor (\n\t\tapc.DischargeDestinationHospitalProviderSpell = '79'\n\t\tand\n\t\tapc.DischargeMethodHospitalProviderSpell != '5'\n\t\t)\n\t\t)\n\t\tgroup by apc.NHSNumber\n\t", + "query": "\n;with primarydiagnosis as (\n\tselect *\n\tfrom omop_staging.sus_ICDDiagnosis\n\twhere IsPrimaryDiagnosis = 1\n)\n\nselect\n\tapc.NHSNumber as nhs_number,\n\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\tmax(d.DiagnosisICD) as DiagnosisICD\nfrom omop_staging.sus_APC apc\n\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\nwhere\n\tapc.NHSNumber is not null and\n\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4' -- \"Patient died\"\n\t\tor\n\t\t(\n\t\t\tapc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth\n\t\t\tand\n\t\t\tapc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth\n\t\t)\n)\ngroup by apc.NHSNumber\n\t", "lookup_table_markdown": null }, { @@ -63,7 +63,7 @@ ] } ], - "query": "\n\t\t;with primarydiagnosis as (\n\t\tselect *\n\t\tfrom omop_staging.sus_ICDDiagnosis\n\t\twhere IsPrimaryDiagnosis = 1\n\t\t)\n\n\t\tselect\n\t\tapc.NHSNumber as nhs_number,\n\t\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\t\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\t\tmax(d.DiagnosisICD) as DiagnosisICD\n\t\tfrom\n\t\tomop_staging.sus_APC apc\n\t\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\n\t\twhere\n\t\tapc.NHSNumber is not null and\n\t\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4'\n\t\tor (\n\t\tapc.DischargeDestinationHospitalProviderSpell = '79'\n\t\tand\n\t\tapc.DischargeMethodHospitalProviderSpell != '5'\n\t\t)\n\t\t)\n\t\tgroup by apc.NHSNumber\n\t", + "query": "\n;with primarydiagnosis as (\n\tselect *\n\tfrom omop_staging.sus_ICDDiagnosis\n\twhere IsPrimaryDiagnosis = 1\n)\n\nselect\n\tapc.NHSNumber as nhs_number,\n\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\tmax(d.DiagnosisICD) as DiagnosisICD\nfrom omop_staging.sus_APC apc\n\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\nwhere\n\tapc.NHSNumber is not null and\n\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4' -- \"Patient died\"\n\t\tor\n\t\t(\n\t\t\tapc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth\n\t\t\tand\n\t\t\tapc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth\n\t\t)\n)\ngroup by apc.NHSNumber\n\t", "lookup_table_markdown": null }, { @@ -81,7 +81,7 @@ ] } ], - "query": "\n\t\t;with primarydiagnosis as (\n\t\tselect *\n\t\tfrom omop_staging.sus_ICDDiagnosis\n\t\twhere IsPrimaryDiagnosis = 1\n\t\t)\n\n\t\tselect\n\t\tapc.NHSNumber as nhs_number,\n\t\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\t\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\t\tmax(d.DiagnosisICD) as DiagnosisICD\n\t\tfrom\n\t\tomop_staging.sus_APC apc\n\t\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\n\t\twhere\n\t\tapc.NHSNumber is not null and\n\t\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4'\n\t\tor (\n\t\tapc.DischargeDestinationHospitalProviderSpell = '79'\n\t\tand\n\t\tapc.DischargeMethodHospitalProviderSpell != '5'\n\t\t)\n\t\t)\n\t\tgroup by apc.NHSNumber\n\t", + "query": "\n;with primarydiagnosis as (\n\tselect *\n\tfrom omop_staging.sus_ICDDiagnosis\n\twhere IsPrimaryDiagnosis = 1\n)\n\nselect\n\tapc.NHSNumber as nhs_number,\n\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\tmax(d.DiagnosisICD) as DiagnosisICD\nfrom omop_staging.sus_APC apc\n\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\nwhere\n\tapc.NHSNumber is not null and\n\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4' -- \"Patient died\"\n\t\tor\n\t\t(\n\t\t\tapc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth\n\t\t\tand\n\t\t\tapc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth\n\t\t)\n)\ngroup by apc.NHSNumber\n\t", "lookup_table_markdown": null }, { @@ -99,7 +99,7 @@ ] } ], - "query": "\n\t\t;with primarydiagnosis as (\n\t\tselect *\n\t\tfrom omop_staging.sus_ICDDiagnosis\n\t\twhere IsPrimaryDiagnosis = 1\n\t\t)\n\n\t\tselect\n\t\tapc.NHSNumber as nhs_number,\n\t\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\t\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\t\tmax(d.DiagnosisICD) as DiagnosisICD\n\t\tfrom\n\t\tomop_staging.sus_APC apc\n\t\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\n\t\twhere\n\t\tapc.NHSNumber is not null and\n\t\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4'\n\t\tor (\n\t\tapc.DischargeDestinationHospitalProviderSpell = '79'\n\t\tand\n\t\tapc.DischargeMethodHospitalProviderSpell != '5'\n\t\t)\n\t\t)\n\t\tgroup by apc.NHSNumber\n\t", + "query": "\n;with primarydiagnosis as (\n\tselect *\n\tfrom omop_staging.sus_ICDDiagnosis\n\twhere IsPrimaryDiagnosis = 1\n)\n\nselect\n\tapc.NHSNumber as nhs_number,\n\tmax(apc.DischargeDateFromHospitalProviderSpell) as death_date,\n\tmax(apc.DischargeTimeHospitalProviderSpell) as death_time,\n\tmax(d.DiagnosisICD) as DiagnosisICD\nfrom omop_staging.sus_APC apc\n\tleft join primarydiagnosis d\n\t\ton apc.MessageId = d.MessageId\nwhere\n\tapc.NHSNumber is not null and\n\tapc.DischargeDateFromHospitalProviderSpell is not null and\n\t(\n\t\tapc.DischargeMethodHospitalProviderSpell = '4' -- \"Patient died\"\n\t\tor\n\t\t(\n\t\t\tapc.DischargeDestinationHospitalProviderSpell = '79' -- Not applicable - PATIENT died or stillbirth\n\t\t\tand\n\t\t\tapc.DischargeMethodHospitalProviderSpell != '5' -- not stillbirth\n\t\t)\n)\ngroup by apc.NHSNumber\n\t", "lookup_table_markdown": null } ] diff --git a/docs/transformation-documentation/SusAPCProvider.json b/docs/transformation-documentation/SusAPCProvider.json index 9a0ce76..59b47e7 100644 --- a/docs/transformation-documentation/SusAPCProvider.json +++ b/docs/transformation-documentation/SusAPCProvider.json @@ -17,7 +17,7 @@ ] } ], - "query": "\n\twith counts as (\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode,\n\tcount(*) as SpecialtyFrequency,\n\trow_number() over (\n\tpartition by ConsultantCode \n\torder by count(*) desc, MainSpecialtyCode\n\t) rnk\n\tfrom (\n\tselect distinct\n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom [OMOP_QA].[omop_staging].[sus_APC]\n\twhere MainSpecialtyCode is not null\n\tand ConsultantCode is not null\n\t) grouped\n\tgroup by ConsultantCode, MainSpecialtyCode\n\t)\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom counts\n\twhere rnk = 1;\n\t", + "query": "\nwith counts as (\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode,\n\tcount(*) as SpecialtyFrequency,\n\trow_number() over (\n\tpartition by ConsultantCode \n\torder by count(*) desc, MainSpecialtyCode\n) rnk\nfrom (\n\tselect\n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom [OMOP_QA].[omop_staging].[sus_APC]\n\twhere MainSpecialtyCode is not null\n\tand ConsultantCode is not null\n) grouped\n\tgroup by ConsultantCode, MainSpecialtyCode\n)\nselect \n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom counts\n\twhere rnk = 1;\n\t", "lookup_table_markdown": null }, { @@ -35,7 +35,7 @@ ] } ], - "query": "\n\twith counts as (\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode,\n\tcount(*) as SpecialtyFrequency,\n\trow_number() over (\n\tpartition by ConsultantCode \n\torder by count(*) desc, MainSpecialtyCode\n\t) rnk\n\tfrom (\n\tselect distinct\n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom [OMOP_QA].[omop_staging].[sus_APC]\n\twhere MainSpecialtyCode is not null\n\tand ConsultantCode is not null\n\t) grouped\n\tgroup by ConsultantCode, MainSpecialtyCode\n\t)\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom counts\n\twhere rnk = 1;\n\t", + "query": "\nwith counts as (\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode,\n\tcount(*) as SpecialtyFrequency,\n\trow_number() over (\n\tpartition by ConsultantCode \n\torder by count(*) desc, MainSpecialtyCode\n) rnk\nfrom (\n\tselect\n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom [OMOP_QA].[omop_staging].[sus_APC]\n\twhere MainSpecialtyCode is not null\n\tand ConsultantCode is not null\n) grouped\n\tgroup by ConsultantCode, MainSpecialtyCode\n)\nselect \n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom counts\n\twhere rnk = 1;\n\t", "lookup_table_markdown": null }, { @@ -53,7 +53,7 @@ ] } ], - "query": "\n\twith counts as (\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode,\n\tcount(*) as SpecialtyFrequency,\n\trow_number() over (\n\tpartition by ConsultantCode \n\torder by count(*) desc, MainSpecialtyCode\n\t) rnk\n\tfrom (\n\tselect distinct\n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom [OMOP_QA].[omop_staging].[sus_APC]\n\twhere MainSpecialtyCode is not null\n\tand ConsultantCode is not null\n\t) grouped\n\tgroup by ConsultantCode, MainSpecialtyCode\n\t)\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom counts\n\twhere rnk = 1;\n\t", + "query": "\nwith counts as (\n\tselect \n\tConsultantCode,\n\tMainSpecialtyCode,\n\tcount(*) as SpecialtyFrequency,\n\trow_number() over (\n\tpartition by ConsultantCode \n\torder by count(*) desc, MainSpecialtyCode\n) rnk\nfrom (\n\tselect\n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom [OMOP_QA].[omop_staging].[sus_APC]\n\twhere MainSpecialtyCode is not null\n\tand ConsultantCode is not null\n) grouped\n\tgroup by ConsultantCode, MainSpecialtyCode\n)\nselect \n\tConsultantCode,\n\tMainSpecialtyCode\n\tfrom counts\n\twhere rnk = 1;\n\t", "lookup_table_markdown": "\r\n\r\n|MainSpecialtyCode|specialty_concept_id|notes|\r\n|------|-----|-----|\r\n|100|38004447|General Surgery|\r\n|101|38004474|Urology|\r\n|107|38004496|Vascular Surgery|\r\n|110|38003915|Trauma and Orthopedics|\r\n|120||Ear Nose and Throat|\r\n|130|38004463|Ophthalmology|\r\n|140|38004464|Oral Surgery|\r\n|141|44777671|Restorative Dentistry|\r\n|142|38003677|Pediatric Dentistry|\r\n|143|44777673|Orthodontics|\r\n|145|38003826|Oral and Maxillofacial Surgery|\r\n|146|38003674|Endodontics|\r\n|147|38003678|Periodontics|\r\n|148|38003679|Prosthodontics|\r\n|149|903261|Surgical Dentistry|\r\n|150|38004459|Neurosurgery|\r\n|160|38004467|Plastic Surgery|\r\n|170||Cardiothoracic Surgery|\r\n|171|45756819|Pediatric Surgery|\r\n|180|38004510|Emergency Medicine|\r\n|190||Anesthetics|\r\n|192||Intensive Care Medicine|\r\n|200||Aviation and Space Medicine|\r\n|300|38004456|General Internal Medicine|\r\n|301|38004455|Gastroenterology|\r\n|302|45756771|Endocrinology and Diabetes|\r\n|303|38004501|Clinical Hematology|\r\n|304||Clinical Physiology|\r\n|305|38004025|Clinical Pharmacology|\r\n|310||Audio Vestibular Medicine|\r\n|311|45756760|Clinical Genetics|\r\n|313|44777719|Clinical Immunology|\r\n|314|38003967|Rehabilitation Medicine|\r\n|315||Palliative Medicine|\r\n|317|38003830|Allergy|\r\n|320|38004451|Cardiology|\r\n|321|45756805|Pediatric Cardiology|\r\n|325|903263|Sport and Exercise Medicine|\r\n|326|903264|Acute Internal Medicine|\r\n|330|38004452|Dermatology|\r\n|340||Respiratory Medicine|\r\n|350|38004484|Infectious Diseases|\r\n|352|44777687|Tropical Medicine|\r\n|360||Genitourinary Medicine|\r\n|361||Renal Medicine|\r\n|370|38004507|Medical Oncology|\r\n|371|38004476|Nuclear Medicine|\r\n|400|38004458|Neurology|\r\n|401|45756763|Clinical Neurophysiology|\r\n|410|38004491|Rheumatology|\r\n|420|38004477|Pediatrics|\r\n|421|44777781|Pediatric Neurology|\r\n|430|38004478|Geriatric Medicine|\r\n|450||Dental Medicine|\r\n|451|903265|Special Care Dentistry|\r\n|460|38004463|Medical Ophthalmology|\r\n|501|38003905|Obstetrics|\r\n|502|38003902|Gynecology|\r\n|504|903266|Community Sexual and Reproductive Health|\r\n|560|44777784|Midwifery|\r\n|600|38004446|General Medical Practice|\r\n|601|38003675|General Dental Practice|\r\n|700||Learning Disability|\r\n|710||Adult Mental Illness|\r\n|711|45756756|Child and Adolescent Psychiatry|\r\n|712|45756775|Forensic Psychiatry|\r\n|713||Medical Psychotherapy|\r\n|715|38004470|Old Age Psychiatry|\r\n|800|38004507|Clinical Oncology|\r\n|810|45756825|Radiology|\r\n|820|38004466|General Pathology|\r\n|821|44777706|Blood Transfusion|\r\n|822|45756796|Chemical Pathology|\r\n|823|38004501|Hematology|\r\n|824|44777708|Histopathology|\r\n|830|38003930|Immunopathology|\r\n|831|903269|Medical Microbiology and Virology|\r\n|833|44777684|Medical Microbiology|\r\n|834|903269|Medical Virology|\r\n|900|44777712|Community Medicine|\r\n|901|44777713|Occupational Medicine|\r\n|902||Community Health Services Dental|\r\n|903|903271|Public Health Medicine|\r\n|904|38003673|Public Health Dental|\r\n|950||Nursing|\r\n|960||Allied Health Professional|\r\n\r\nNotes\r\n* [NHS MainSpecialtyCode](https://www.datadictionary.nhs.uk/attributes/main_specialty_code.html#attribute_main_specialty_code.data_elements)\r\n* [OMOP Providers](https://athena.ohdsi.org/search-terms/terms?domain=Provider&standardConcept=Standard&conceptClass=Physician+Specialty&page=1&pageSize=15&query=General+Dental+Practice&boosts)\r\n" } ] diff --git a/docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.json b/docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.json new file mode 100644 index 0000000..01dd2b8 --- /dev/null +++ b/docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.json @@ -0,0 +1,110 @@ +{ + "omopTable": "Observation", + "origin": "SUS", + "omopColumns": [ + { + "name": "nhs_number", + "operation_description": "Value copied from `NHSNumber`", + "dataSource": [ + { + "name": "NHSNumber", + "description": "Patient NHS Number", + "origins": [ + { + "origin": "NHS NUMBER", + "url": "https://www.datadictionary.nhs.uk/data_elements/nhs_number.html" + } + ] + } + ], + "query": "\nselect\tNHSNumber,\n\t\tGeneratedRecordIdentifier,\n\t\tStartDateHospitalProviderSpell,\n\t\tStartTimeHospitalProviderSpell,\n\t\tReferrerCode -- Referrer code is the code of the person making the referral request\nFROM [OMOP_SUS].[omop_staging].[sus_APC]\n\t", + "lookup_table_markdown": null + }, + { + "name": "RecordConnectionIdentifier", + "operation_description": "Value copied from `GeneratedRecordIdentifier`", + "dataSource": [ + { + "name": "GeneratedRecordIdentifier", + "description": "CDS specific identifier that binds multiple CDS messages together.", + "origins": [ + { + "origin": "CDS RECORD IDENTIFIER", + "url": "https://www.datadictionary.nhs.uk/data_elements/cds_record_identifier.html" + } + ] + } + ], + "query": "\nselect\tNHSNumber,\n\t\tGeneratedRecordIdentifier,\n\t\tStartDateHospitalProviderSpell,\n\t\tStartTimeHospitalProviderSpell,\n\t\tReferrerCode -- Referrer code is the code of the person making the referral request\nFROM [OMOP_SUS].[omop_staging].[sus_APC]\n\t", + "lookup_table_markdown": null + }, + { + "name": "observation_concept_id", + "operation_description": "Constant value set to `4258129`. Referral by", + "dataSource": null, + "query": null, + "lookup_table_markdown": null + }, + { + "name": "observation_date", + "operation_description": "Converts text to dates.", + "dataSource": [ + { + "name": "StartDateHospitalProviderSpell", + "description": "Event date", + "origins": [ + { + "origin": "START DATE (HOSPITAL PROVIDER SPELL)", + "url": "https://www.datadictionary.nhs.uk/data_elements/start_date__hospital_provider_spell_.html" + } + ] + } + ], + "query": "\nselect\tNHSNumber,\n\t\tGeneratedRecordIdentifier,\n\t\tStartDateHospitalProviderSpell,\n\t\tStartTimeHospitalProviderSpell,\n\t\tReferrerCode -- Referrer code is the code of the person making the referral request\nFROM [OMOP_SUS].[omop_staging].[sus_APC]\n\t", + "lookup_table_markdown": null + }, + { + "name": "observation_datetime", + "operation_description": "Converts text to dates.", + "dataSource": [ + { + "name": "StartTimeHospitalProviderSpell", + "description": "Records whether anaesthetic was given during Labour/ Delivery, and the type used.", + "origins": [ + { + "origin": "START TIME (HOSPITAL PROVIDER SPELL)", + "url": "https://www.datadictionary.nhs.uk/data_elements/start_time__hospital_provider_spell_.html" + } + ] + } + ], + "query": "\nselect\tNHSNumber,\n\t\tGeneratedRecordIdentifier,\n\t\tStartDateHospitalProviderSpell,\n\t\tStartTimeHospitalProviderSpell,\n\t\tReferrerCode -- Referrer code is the code of the person making the referral request\nFROM [OMOP_SUS].[omop_staging].[sus_APC]\n\t", + "lookup_table_markdown": null + }, + { + "name": "observation_type_concept_id", + "operation_description": "Constant value set to `32818`. EHR administration record", + "dataSource": null, + "query": null, + "lookup_table_markdown": null + }, + { + "name": "value_as_string", + "operation_description": "Value copied from `ReferrerCode`", + "dataSource": [ + { + "name": "ReferrerCode", + "description": "Referrer code is the code of the person making the referral request.", + "origins": [ + { + "origin": "REFERRER CODE", + "url": "https://www.datadictionary.nhs.uk/data_elements/referrer_code.html" + } + ] + } + ], + "query": "\nselect\tNHSNumber,\n\t\tGeneratedRecordIdentifier,\n\t\tStartDateHospitalProviderSpell,\n\t\tStartTimeHospitalProviderSpell,\n\t\tReferrerCode -- Referrer code is the code of the person making the referral request\nFROM [OMOP_SUS].[omop_staging].[sus_APC]\n\t", + "lookup_table_markdown": null + } + ] +} \ No newline at end of file diff --git a/docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.svg b/docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.svg new file mode 100644 index 0000000..5ff73e7 --- /dev/null +++ b/docs/transformation-documentation/SusAPCSourceOfReferralForOutpatients.svg @@ -0,0 +1,75 @@ + + + + + NHS NUMBER + + + + + + Copy value + + + + nhs_number + + + + CDS RECORD IDENTIFIER + + + + + + Copy value + + + + RecordConnectionIdentifier + + + + START DATE (HOSPITAL + PROVIDER SPELL) + + + + + + Converts text to dates. + + + + observation_date + + + + START TIME (HOSPITAL + PROVIDER SPELL) + + + + + + Converts text to dates. + + + + observation_datetime + + + + REFERRER CODE + + + + + + Copy value + + + + value_as_string + + \ No newline at end of file diff --git a/docs/transformation-documentation/SusAPCTotalPreviousPregnancies.json b/docs/transformation-documentation/SusAPCTotalPreviousPregnancies.json index bbfacd8..6059b12 100644 --- a/docs/transformation-documentation/SusAPCTotalPreviousPregnancies.json +++ b/docs/transformation-documentation/SusAPCTotalPreviousPregnancies.json @@ -101,7 +101,7 @@ }, { "name": "observation_type_concept_id", - "operation_description": "Constant value set to `38000281`. Observation recorded from EHR with text result", + "operation_description": "Constant value set to `32818`. EHR administration record", "dataSource": null, "query": null, "lookup_table_markdown": null