Skip to content

Commit 0033c1b

Browse files
authored
Merge pull request #270 from answerdigital/feature/lab-observations
Feature/lab observations
2 parents 69590a0 + 04d765a commit 0033c1b

25 files changed

+2909
-2631
lines changed

OmopTransformer/LabTestLookup.cs

Lines changed: 1339 additions & 1446 deletions
Large diffs are not rendered by default.

OmopTransformer/OmopTransformer.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@
260260
<None Update="OxfordLab\Measurements\OxfordLabMeasurement.xml">
261261
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
262262
</None>
263+
<None Update="OxfordLab\Observations\LabReportGeneralComment\OxfordLabGeneralComment.xml">
264+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
265+
</None>
263266
<None Update="OxfordSpineDeath\Death\OxfordSpineDeath.xml">
264267
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
265268
</None>

OmopTransformer/OxfordLab/Measurements/OxfordLabMeasurement.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ select
99
NORMAL_LOW,
1010
NORMAL_HIGH
1111
from ##duckdb_source##
12+
where lower(EVENT) not like '%comment%'
1213
</Sql>
1314
<Explanations>
1415
<Explanation columnName="NHS_NUMBER">
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using OmopTransformer.Annotations;
2+
using OmopTransformer.Omop.Observation;
3+
using OmopTransformer.Transformation;
4+
5+
namespace OmopTransformer.OxfordLab.Observations.LabReportGeneralComment;
6+
7+
internal class OxfordLabGeneralComment : OmopObservation<OxfordLabGeneralCommentRecord>
8+
{
9+
[CopyValue(nameof(Source.NHS_NUMBER))]
10+
public override string? nhs_number { get; set; }
11+
12+
[Transform(typeof(DateConverter), nameof(Source.EVENT_START_DT_TM))]
13+
public override DateTime? observation_date { get; set; }
14+
15+
[Transform(typeof(DateConverter), nameof(Source.EVENT_START_DT_TM))]
16+
public override DateTime? observation_datetime { get; set; }
17+
18+
[ConstantValue(37053687, "Lab report general comments")]
19+
public override int[]? observation_concept_id { get; set; }
20+
21+
[ConstantValue(32828, "EHR episode record")]
22+
public override int? observation_type_concept_id { get; set; }
23+
24+
[CopyValue(nameof(Source.@EVENT))]
25+
public override string? observation_source_value { get; set; }
26+
27+
[CopyValue(nameof(Source.RESULT_VALUE))]
28+
public override string? value_as_string { get; set; }
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<Query>
2+
<Sql type="duckdb">
3+
select
4+
NHS_NUMBER,
5+
EVENT,
6+
EVENT_START_DT_TM,
7+
RESULT_VALUE
8+
from ##duckdb_source##
9+
where lower(EVENT) like '%comment%'
10+
</Sql>
11+
<Explanations>
12+
<Explanation columnName="NHS_NUMBER">
13+
<Description>Patient NHS Number</Description>
14+
<Origin>NHS NUMBER</Origin>
15+
</Explanation>
16+
<Explanation columnName="EVENT">
17+
<Description>Lab test event</Description>
18+
<Origin>EVENT</Origin>
19+
</Explanation>
20+
<Explanation columnName="EVENT_START_DT_TM">
21+
<Description>Lab test event start datetime</Description>
22+
<Origin>EVENT START DT TM</Origin>
23+
</Explanation>
24+
<Explanation columnName="RESULT_VALUE">
25+
<Description>Lab report comment text</Description>
26+
<Origin>RESULT VALUE</Origin>
27+
</Explanation>
28+
</Explanations>
29+
</Query>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using OmopTransformer.Annotations;
2+
3+
namespace OmopTransformer.OxfordLab.Observations.LabReportGeneralComment;
4+
5+
[DataOrigin("OxfordLab")]
6+
[Description("Oxford Lab General Comment Observation")]
7+
[SourceQuery("OxfordLabGeneralComment.xml")]
8+
internal class OxfordLabGeneralCommentRecord
9+
{
10+
public string? NHS_NUMBER { get; set; }
11+
public string? @EVENT { get; set; }
12+
public string? EVENT_START_DT_TM { get; set; }
13+
public string? RESULT_VALUE { get; set; }
14+
}

OmopTransformer/OxfordLab/OxfordLabTransformer.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
using Microsoft.Extensions.Logging;
22
using OmopTransformer.Omop;
3+
using OmopTransformer.Omop.Measurement;
4+
using OmopTransformer.Omop.Observation;
35
using OmopTransformer.OxfordLab.Measurements.OxfordLabMeasurement;
6+
using OmopTransformer.OxfordLab.Observations.LabReportGeneralComment;
47
using OmopTransformer.Transformation;
5-
using OmopTransformer.Omop.Measurement;
68

79
namespace OmopTransformer.OxfordLab;
810

911
internal class OxfordLabTransformer : Transformer
1012
{
1113
private readonly ConceptResolver _conceptResolver;
1214
private readonly IMeasurementRecorder _measurementRecorder;
15+
private readonly IObservationRecorder _observationRecorder;
1316

1417
public OxfordLabTransformer(
1518
IRecordTransformer recordTransformer,
1619
TransformOptions transformOptions,
1720
IRecordProvider recordProvider,
1821
IMeasurementRecorder measurementRecorder,
22+
IObservationRecorder observationRecorder,
1923
ConceptResolver conceptResolver,
2024
IRunAnalysisRecorder runAnalysisRecorder,
2125
ILoggerFactory loggerFactory) : base(recordTransformer,
@@ -26,6 +30,7 @@ public OxfordLabTransformer(
2630
loggerFactory)
2731
{
2832
_measurementRecorder = measurementRecorder;
33+
_observationRecorder = observationRecorder;
2934
_conceptResolver = conceptResolver;
3035
}
3136

@@ -39,6 +44,12 @@ await Transform<OxfordLabMeasurementRecord, OxfordLabMeasurement>(
3944
runId,
4045
cancellationToken);
4146

47+
await Transform<OxfordLabGeneralCommentRecord, OxfordLabGeneralComment>(
48+
_observationRecorder.InsertUpdateObservations,
49+
"Oxford Lab General Comments",
50+
runId,
51+
cancellationToken);
52+
4253
_conceptResolver.PrintErrors();
4354
}
4455
}

docs/transformation-documentation/Measurement_measurement_date.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ select
167167
NORMAL_LOW,
168168
NORMAL_HIGH
169169
from ##duckdb_source##
170+
where lower(EVENT) not like '%comment%'
170171

171172
```
172173

docs/transformation-documentation/Measurement_measurement_datetime.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ select
171171
NORMAL_LOW,
172172
NORMAL_HIGH
173173
from ##duckdb_source##
174+
where lower(EVENT) not like '%comment%'
174175

175176
```
176177

0 commit comments

Comments
 (0)