Skip to content

Commit

Permalink
Do not refer to database names in queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
james-cockayne-ad committed Jan 10, 2025
1 parent 53dba9a commit c9942ea
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
op.NHSNumber,
op.CDSActivityDate
from omop_staging.sus_OP_ICDDiagnosis d
inner join [OMOP_SUS].[omop_staging].[sus_OP] op
inner join [omop_staging].[sus_OP] op
on d.MessageId = op.MessageId
where op.NHSNumber is not null
</Sql>
Expand Down
2 changes: 1 addition & 1 deletion OmopTransformer/SUS/OP/Death/SusOPDeath.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
select
NHSNumber as nhs_number,
max(ReferralToTreatmentPeriodEndDate) as death_date
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where ReferralToTreatmentPeriodStatus = 36
and ReferralToTreatmentPeriodEndDate is not null
and NHSNumber is not null
Expand Down
2 changes: 1 addition & 1 deletion OmopTransformer/SUS/OP/Location/SusOPLocation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Postcode,
Country,
NHSNumber
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
and Postcode is not null
</Sql>
Expand Down
2 changes: 1 addition & 1 deletion OmopTransformer/SUS/OP/Person/SusOPPerson.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber
</Sql>
Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/CdsPerson.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
],
"query": "\nselect\n\tNHSNumber,\n\tmax(DateofBirth) as DateOfBirth,\n\tmax(EthnicCategory) as EthnicCategory,\n\tmax(PersonCurrentGenderCode) as PersonCurrentGenderCode\nfrom omop_staging.cds_line01\nwhere NHSNumber is not null\ngroup by NHSNumber\n\t",
"lookup_table_markdown": "\r\n\r\n|PersonCurrentGenderCode|gender_concept_id|notes|\r\n|------|-----|-----|\r\n|1|8507|Male|\r\n|2|8532|Female|\r\n|9|8551|Indeterminate (unable to be classified as either male or female)|\r\n|X|8551|Not known|\r\n\r\nNotes\r\n* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)\r\n* [OMOP Gender](https://athena.ohdsi.org/search-terms/terms?conceptClass=Gender&invalidReason=Valid&vocabulary=Gender&page=1&pageSize=50&query=)\r\n"
"lookup_table_markdown": "\r\n\r\n|PersonCurrentGenderCode|gender_concept_id|notes|\r\n|------|-----|-----|\r\n|1|8507|Male|\r\n|2|8532|Female|\r\n|9|0|Indeterminate (unable to be classified as either male or female)|\r\n|X|0|Not known|\r\n\r\nNotes\r\n* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)\r\n* [OMOP Gender](https://athena.ohdsi.org/search-terms/terms?conceptClass=Gender&invalidReason=Valid&vocabulary=Gender&page=1&pageSize=50&query=)\r\n"
},
{
"name": "year_of_birth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Resolve ICD10 codes to OMOP concepts. If code cannot be mapped, map using the pa
op.NHSNumber,
op.CDSActivityDate
from omop_staging.sus_OP_ICDDiagnosis d
inner join [OMOP_SUS].[omop_staging].[sus_OP] op
inner join [omop_staging].[sus_OP] op
on d.MessageId = op.MessageId
where op.NHSNumber is not null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ has_toc: false
op.NHSNumber,
op.CDSActivityDate
from omop_staging.sus_OP_ICDDiagnosis d
inner join [OMOP_SUS].[omop_staging].[sus_OP] op
inner join [omop_staging].[sus_OP] op
on d.MessageId = op.MessageId
where op.NHSNumber is not null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Converts text to dates.
op.NHSNumber,
op.CDSActivityDate
from omop_staging.sus_OP_ICDDiagnosis d
inner join [OMOP_SUS].[omop_staging].[sus_OP] op
inner join [omop_staging].[sus_OP] op
on d.MessageId = op.MessageId
where op.NHSNumber is not null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ has_toc: false
op.NHSNumber,
op.CDSActivityDate
from omop_staging.sus_OP_ICDDiagnosis d
inner join [OMOP_SUS].[omop_staging].[sus_OP] op
inner join [omop_staging].[sus_OP] op
on d.MessageId = op.MessageId
where op.NHSNumber is not null

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Death_NhsNumber.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ has_toc: false
select
NHSNumber as nhs_number,
max(ReferralToTreatmentPeriodEndDate) as death_date
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where ReferralToTreatmentPeriodStatus = 36
and ReferralToTreatmentPeriodEndDate is not null
and NHSNumber is not null
Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Death_death_date.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Converts text to dates.
select
NHSNumber as nhs_number,
max(ReferralToTreatmentPeriodEndDate) as death_date
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where ReferralToTreatmentPeriodStatus = 36
and ReferralToTreatmentPeriodEndDate is not null
and NHSNumber is not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ has_toc: false
Postcode,
Country,
NHSNumber
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
and Postcode is not null

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Location_nhs_number.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ has_toc: false
Postcode,
Country,
NHSNumber
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
and Postcode is not null

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Location_zip.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Uppercase the postcode then insert the space in the correct location, if needed.
Postcode,
Country,
NHSNumber
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
and Postcode is not null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ group by
* `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]
select
NHSNumber,
GeneratedRecordIdentifier,
StartDateHospitalProviderSpell,
StartTimeHospitalProviderSpell,
ReferrerCode -- Referrer code is the code of the person making the referral request
FROM [omop_staging].[sus_APC]
where NHSNumber is not null

```

Expand Down
14 changes: 8 additions & 6 deletions docs/transformation-documentation/Observation_nhs_number.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ group by
* `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]
select
NHSNumber,
GeneratedRecordIdentifier,
StartDateHospitalProviderSpell,
StartTimeHospitalProviderSpell,
ReferrerCode -- Referrer code is the code of the person making the referral request
FROM [omop_staging].[sus_APC]
where NHSNumber is not null

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ 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]
select
NHSNumber,
GeneratedRecordIdentifier,
StartDateHospitalProviderSpell,
StartTimeHospitalProviderSpell,
ReferrerCode -- Referrer code is the code of the person making the referral request
FROM [omop_staging].[sus_APC]
where NHSNumber is not null

```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ 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]
select
NHSNumber,
GeneratedRecordIdentifier,
StartDateHospitalProviderSpell,
StartTimeHospitalProviderSpell,
ReferrerCode -- Referrer code is the code of the person making the referral request
FROM [omop_staging].[sus_APC]
where NHSNumber is not null

```

Expand Down
14 changes: 8 additions & 6 deletions docs/transformation-documentation/Observation_value_as_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ group by
* `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]
select
NHSNumber,
GeneratedRecordIdentifier,
StartDateHospitalProviderSpell,
StartTimeHospitalProviderSpell,
ReferrerCode -- Referrer code is the code of the person making the referral request
FROM [omop_staging].[sus_APC]
where NHSNumber is not null

```

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Person_birth_datetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Converts text to dates.
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Person_day_of_birth.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Selects the day of the month or null if the date is null.
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
18 changes: 9 additions & 9 deletions docs/transformation-documentation/Person_gender_concept_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Lookup gender concept.
|------|-----|-----|
|1|8507|Male|
|2|8532|Female|
|9|8551|Indeterminate (unable to be classified as either male or female)|
|X|8551|Not known|
|9|0|Indeterminate (unable to be classified as either male or female)|
|X|0|Not known|

Notes
* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)
Expand All @@ -30,7 +30,7 @@ Notes
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand All @@ -47,8 +47,8 @@ Lookup gender concept.
|------|-----|-----|
|1|8507|Male|
|2|8532|Female|
|9|8551|Indeterminate (unable to be classified as either male or female)|
|X|8551|Not known|
|9|0|Indeterminate (unable to be classified as either male or female)|
|X|0|Not known|

Notes
* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)
Expand Down Expand Up @@ -79,8 +79,8 @@ Lookup gender concept.
|------|-----|-----|
|1|8507|Male|
|2|8532|Female|
|9|8551|Indeterminate (unable to be classified as either male or female)|
|X|8551|Not known|
|9|0|Indeterminate (unable to be classified as either male or female)|
|X|0|Not known|

Notes
* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)
Expand Down Expand Up @@ -140,8 +140,8 @@ Lookup gender concept.
|------|-----|-----|
|1|8507|Male|
|2|8532|Female|
|9|8551|Indeterminate (unable to be classified as either male or female)|
|X|8551|Not known|
|9|0|Indeterminate (unable to be classified as either male or female)|
|X|0|Not known|

Notes
* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ has_toc: false
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Person_month_of_birth.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Selects the month of the year or null if the date is null.
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ has_toc: false
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Notes
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Notes
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ has_toc: false
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/Person_year_of_birth.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Selects the year from a date or null of the date is null.
max(DateofBirth) as DateOfBirth,
max(EthnicCategory) as EthnicCategory,
max(Sex) as PersonCurrentGenderCode
from [OMOP_SUS].[omop_staging].[sus_OP]
from [omop_staging].[sus_OP]
where NHSNumber is not null
group by NHSNumber

Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/SactPerson.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
],
"query": "\nselect\n\tNHS_Number,\n\tmax (Patient_Postcode) as Patient_Postcode,\n\tmax (Date_Of_Birth) as Date_Of_Birth,\n\tmax (Person_Stated_Gender_Code) as Person_Stated_Gender_Code\nfrom omop_staging.sact_staging\ngroup by NHS_Number\n\t",
"lookup_table_markdown": "\r\n\r\n|Person_Stated_Gender_Code|gender_concept_id|notes|\r\n|------|-----|-----|\r\n|1|8507|Male|\r\n|2|8532|Female|\r\n|9|8551|Indeterminate (unable to be classified as either male or female)|\r\n|X|8551|Not known|\r\n\r\nNotes\r\n* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)\r\n* [OMOP Gender](https://athena.ohdsi.org/search-terms/terms?conceptClass=Gender&invalidReason=Valid&vocabulary=Gender&page=1&pageSize=50&query=)\r\n"
"lookup_table_markdown": "\r\n\r\n|Person_Stated_Gender_Code|gender_concept_id|notes|\r\n|------|-----|-----|\r\n|1|8507|Male|\r\n|2|8532|Female|\r\n|9|0|Indeterminate (unable to be classified as either male or female)|\r\n|X|0|Not known|\r\n\r\nNotes\r\n* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)\r\n* [OMOP Gender](https://athena.ohdsi.org/search-terms/terms?conceptClass=Gender&invalidReason=Valid&vocabulary=Gender&page=1&pageSize=50&query=)\r\n"
},
{
"name": "year_of_birth",
Expand Down
2 changes: 1 addition & 1 deletion docs/transformation-documentation/SusAPCPerson.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
],
"query": "\n\tselect\n\t\tNHSNumber,\n\t\tmax(DateofBirth) as DateOfBirth,\n\t\tmax(EthnicGroup) as EthnicCategory,\n\t\tmax(Sex) as PersonCurrentGenderCode\n\tfrom omop_staging.sus_APC\n\twhere NHSNumber is not null\n\tgroup by NHSNumber\n\t",
"lookup_table_markdown": "\r\n\r\n|PersonCurrentGenderCode|gender_concept_id|notes|\r\n|------|-----|-----|\r\n|1|8507|Male|\r\n|2|8532|Female|\r\n|9|8551|Indeterminate (unable to be classified as either male or female)|\r\n|X|8551|Not known|\r\n\r\nNotes\r\n* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)\r\n* [OMOP Gender](https://athena.ohdsi.org/search-terms/terms?conceptClass=Gender&invalidReason=Valid&vocabulary=Gender&page=1&pageSize=50&query=)\r\n"
"lookup_table_markdown": "\r\n\r\n|PersonCurrentGenderCode|gender_concept_id|notes|\r\n|------|-----|-----|\r\n|1|8507|Male|\r\n|2|8532|Female|\r\n|9|0|Indeterminate (unable to be classified as either male or female)|\r\n|X|0|Not known|\r\n\r\nNotes\r\n* [NHS Gender](https://www.datadictionary.nhs.uk/data_elements/person_stated_gender_code.html)\r\n* [OMOP Gender](https://athena.ohdsi.org/search-terms/terms?conceptClass=Gender&invalidReason=Valid&vocabulary=Gender&page=1&pageSize=50&query=)\r\n"
},
{
"name": "year_of_birth",
Expand Down
Loading

0 comments on commit c9942ea

Please sign in to comment.