Skip to content

Commit

Permalink
Added notion of table level documentation. Added support for callouts…
Browse files Browse the repository at this point in the history
… in documentation for VisitDetail and VisitOccurrence
  • Loading branch information
james-cockayne-ad committed Mar 19, 2024
1 parent 702e299 commit c4740c9
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 11 deletions.
10 changes: 10 additions & 0 deletions OmopTransformer/Annotations/CalloutType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace OmopTransformer.Annotations;

internal enum CalloutType
{
none = 0,
highlight,
important,
note,
warning
}
13 changes: 13 additions & 0 deletions OmopTransformer/Annotations/NotesAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace OmopTransformer.Annotations;

internal class NotesAttribute : Attribute
{
public NotesAttribute(string value, CalloutType calloutType = CalloutType.none)
{
Value = value;
CalloutType = calloutType;
}

public string Value { get; }
public CalloutType CalloutType { get; }
}
11 changes: 11 additions & 0 deletions OmopTransformer/CDS/CdsMappingNotes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace OmopTransformer.CDS;

internal class CdsMappingNotes
{
public const string VisitOccurrenceVisitDetailsNotes =
"### Assumptions\r\n" +
"* `Emergency` covers a visit to A&E within the given Hospital Provider, and hence covers Admission Code 21 and 24 only\r\n" +
"* `Location Class` ID 24 is a Consultant Clinic within the Health Care Provider.\r\n" +
"* `Patient Classification` ID 1 is the only entry that covers 24 hours or more with the use of a bed, and whilst others may be a day/night only, they will be discounted because they are less than 24 hours. Also, maternity is also not taken as an \"\"Inpatient\"\" visit.\r\n" +
"* No calculations to be made between Start and end visit date to try to calculate 24 hours, but instead the \"Patient Classification\" will be sufficient\r\n";
}
1 change: 1 addition & 0 deletions OmopTransformer/CDS/VisitDetails/CdsVisitDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OmopTransformer.CDS.VisitDetails;

[Notes(CdsMappingNotes.VisitOccurrenceVisitDetailsNotes, CalloutType.note)]
internal class CdsVisitDetail : OmopVisitDetail<CdsVisitDetailsRecord>
{
[CopyValue(nameof(Source.NHSNumber))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OmopTransformer.CDS.VisitOccurrenceWithSpell;

[Notes(CdsMappingNotes.VisitOccurrenceVisitDetailsNotes, CalloutType.note)]
internal class CdsVisitOccurrenceWithSpell : OmopVisitOccurrence<CdsVisitOccurrenceWithSpellRecord>
{
[CopyValue(nameof(Source.NHSNumber))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OmopTransformer.CDS.VisitOccurrenceWithoutSpell;

[Notes(CdsMappingNotes.VisitOccurrenceVisitDetailsNotes, CalloutType.note)]
internal class CdsVisitOccurrenceWithoutSpell : OmopVisitOccurrence<CdsVisitOccurrenceWithoutSpellRecord>
{
[CopyValue(nameof(Source.NHSNumber))]
Expand Down
9 changes: 9 additions & 0 deletions OmopTransformer/Documentation/DocumentationRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ public IEnumerable<Document> Render()
omopTable.AppendLine($"## {target.MapperType.Name}");
omopTable.AppendLine($"<a href=\"{target.MapperType.Name}.svg\" target=\"_blank\"><img src=\"{target.MapperType.Name}.svg\" /></a>");
omopTable.AppendLine();

var notes = target.MapperType.GetCustomAttributes(typeof(NotesAttribute)).Cast<NotesAttribute>();

foreach (var note in notes)
{
omopTable.AppendLine($"{{: .{(note.CalloutType == CalloutType.none ? "highlight" : note.CalloutType.ToString())} }}");
omopTable.AppendLine(note.Value);
}

omopTable.AppendLine($"[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title={target.MapperType.Name}%20mapping){{: .btn }}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ where NonPrimaryRecurrenceOriginalDiagnosis is not null;
Source column `NonPrimaryDiagnosisDate`.
Converts text to dates.

* `NonPrimaryDiagnosisDate` DATE OF NON PRIMARY CANCER DIAGNOSIS (CLINICALLY AGREED) is the date where the Non Primary Cancer PATIENT DIAGNOSIS was confirmed or agreed. [DATE OF NON PRIMARY CANCER DIAGNOSIS (CLINICALLY AGREED)](https://www.datadictionary.nhs.uk/data_elements/date_of_non_primary_cancer_diagnosis__clinically_agreed_.html)

```sql
;with
XMLNAMESPACES('http://www.datadictionary.nhs.uk/messages/COSD-v9-0-1' AS COSD901),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@
{
"name": "condition_start_date",
"operation_description": "Converts text to dates.",
"dataSource": [],
"dataSource": [
{
"name": "NonPrimaryDiagnosisDate",
"description": "DATE OF NON PRIMARY CANCER DIAGNOSIS (CLINICALLY AGREED) is the date where the Non Primary Cancer PATIENT DIAGNOSIS was confirmed or agreed.",
"origins": [
{
"origin": "DATE OF NON PRIMARY CANCER DIAGNOSIS (CLINICALLY AGREED)",
"url": "https://www.datadictionary.nhs.uk/data_elements/date_of_non_primary_cancer_diagnosis__clinically_agreed_.html"
}
]
}
],
"query": "\n;with \n XMLNAMESPACES('http://www.datadictionary.nhs.uk/messages/COSD-v9-0-1' AS COSD901),\n CosdRecords as ( \n\n select\n T.staging.value('(Id/@root)[1]', 'uniqueidentifier') as Id,\n T.staging.query('.') as Node\n from omop_staging.cosd_staging\n cross apply content.nodes('COSD901:COSD/*') as T(staging)\n where T.staging.exist('Id/@root') = 1\n and Content.value('namespace-uri((/*:COSD)[1])','nvarchar(max)') = 'http://www.datadictionary.nhs.uk/messages/COSD-v9-0-1'\n and substring (FileName, 15, 2) = 'CO'\n), CO as (\n\tselect\n\t\tId,\n\t\tNode,\n\t\tNode.value('(ColorectalRecord/LinkagePatientId/NhsNumber/@extension)[1]', 'varchar(max)') as NhsNumber,\n\t\tNode.value('(ColorectalRecord/NonPrimaryPathway/DateOfNonPrimaryCancerDiagnosisClinicallyAgreed)[1]', 'varchar(max)') as NonPrimaryDiagnosisDate,\n\t\tNode.value('(ColorectalRecord/NonPrimaryPathway/Progression/ProgressionIcd/@code)[1]', 'varchar(max)') as NonPrimaryProgressionOriginalDiagnosis\n\tfrom CosdRecords\n)\nselect \n\tdistinct \n NhsNumber,\n NonPrimaryDiagnosisDate,\n\t\tNonPrimaryProgressionOriginalDiagnosis\nfrom CO\nwhere NonPrimaryProgressionOriginalDiagnosis is not null;\n\t",
"lookup_table_markdown": null
},
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/transformation-documentation/VisitDetail.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,11 @@ has_toc: false
## CdsVisitDetail
<a href="CdsVisitDetail.svg" target="_blank"><img src="CdsVisitDetail.svg" /></a>

{: .note }
### Assumptions
* `Emergency` covers a visit to A&E within the given Hospital Provider, and hence covers Admission Code 21 and 24 only
* `Location Class` ID 24 is a Consultant Clinic within the Health Care Provider.
* `Patient Classification` ID 1 is the only entry that covers 24 hours or more with the use of a bed, and whilst others may be a day/night only, they will be discounted because they are less than 24 hours. Also, maternity is also not taken as an ""Inpatient"" visit.
* No calculations to be made between Start and end visit date to try to calculate 24 hours, but instead the "Patient Classification" will be sufficient

[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=CdsVisitDetail%20mapping){: .btn }
14 changes: 14 additions & 0 deletions docs/transformation-documentation/VisitOccurrence.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,22 @@ has_toc: false
## CdsVisitOccurrenceWithSpell
<a href="CdsVisitOccurrenceWithSpell.svg" target="_blank"><img src="CdsVisitOccurrenceWithSpell.svg" /></a>

{: .note }
### Assumptions
* `Emergency` covers a visit to A&E within the given Hospital Provider, and hence covers Admission Code 21 and 24 only
* `Location Class` ID 24 is a Consultant Clinic within the Health Care Provider.
* `Patient Classification` ID 1 is the only entry that covers 24 hours or more with the use of a bed, and whilst others may be a day/night only, they will be discounted because they are less than 24 hours. Also, maternity is also not taken as an ""Inpatient"" visit.
* No calculations to be made between Start and end visit date to try to calculate 24 hours, but instead the "Patient Classification" will be sufficient

[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=CdsVisitOccurrenceWithSpell%20mapping){: .btn }
## CdsVisitOccurrenceWithoutSpell
<a href="CdsVisitOccurrenceWithoutSpell.svg" target="_blank"><img src="CdsVisitOccurrenceWithoutSpell.svg" /></a>

{: .note }
### Assumptions
* `Emergency` covers a visit to A&E within the given Hospital Provider, and hence covers Admission Code 21 and 24 only
* `Location Class` ID 24 is a Consultant Clinic within the Health Care Provider.
* `Patient Classification` ID 1 is the only entry that covers 24 hours or more with the use of a bed, and whilst others may be a day/night only, they will be discounted because they are less than 24 hours. Also, maternity is also not taken as an ""Inpatient"" visit.
* No calculations to be made between Start and end visit date to try to calculate 24 hours, but instead the "Patient Classification" will be sufficient

[Comment or raise an issue for this mapping.](https://github.com/answerdigital/oxford-omop-data-mapper/issues/new?title=CdsVisitOccurrenceWithoutSpell%20mapping){: .btn }

0 comments on commit c4740c9

Please sign in to comment.