Skip to content

Commit

Permalink
Update OML mappings (#15910)
Browse files Browse the repository at this point in the history
* Update OML FHIR -> HL7 Mappings

* Update OML HL7 -> FHIR mappings

* Add OML mapping integration tests

* Removing unused FHIR -> HL7 mappings

* Adding OML to CWE/CE override

* Adjusting existing tests

* Adding tests for new misc mappings

* Update existing OML integration tests

* Fixing integration tests after rebase

* expected oru changes

* Specimen.collection conditional update

* Updating formatting for cleaner diff

* Missed e2e test updates

* PRT <-> Device mappings will be taken care of in the next PR

* Changed line endings from CRLF to LF

* Removing OML use of HL7v2Name url
  • Loading branch information
JFisk42 authored Oct 8, 2024
1 parent 1bf38e8 commit 9ae7f66
Show file tree
Hide file tree
Showing 64 changed files with 8,200 additions and 2,695 deletions.
68 changes: 55 additions & 13 deletions prime-router/metadata/HL7/catchall/hl7/message/OML_O21.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,48 @@ resources:
repeats: false
isReferenced: false

- resourceName: Provenance
segment: MSH
resourcePath: segments/MSH/Provenance-Source

- resourceName: Provenance
segment: MSH
resourcePath: segments/MSH/Provenance-Transformation

- resourceName: Patient
segment: .PID
group: PATIENT
resourcePath: segments/PID/Patient
isReferenced: true
repeats: false
additionalSegments:
- .PD1
- MSH
- .NTE
- .NK1

- resourceName: ServiceRequest
segment: .ORC
group: ORDER
resourcePath: segments/ORC/ServiceRequest
- resourceName: Provenance
segment: .PID
group: PATIENT
resourcePath: segments/PID/Provenance-Patient

- resourceName: RelatedPerson
segment: .NK1
group: PATIENT
resourcePath: segments/NK1/RelatedPerson
isReferenced: false
repeats: true

- resourceName: Encounter
segment: .PV1
group: PATIENT.PATIENT_VISIT
resourcePath: segments/PV1/Encounter
isReferenced: true
additionalSegments:
- .OBSERVATION_REQUEST.OBR
- .OBSERVATION_REQUEST.NTE
- PATIENT.PATIENT_VISIT.PV1
- .PV2
- MSH
- PATIENT.PID

- resourceName: Observation
- resourceName: OMLObservation
segment: .OBSERVATION_REQUEST.OBSERVATION.OBX
group: ORDER
resourcePath: segments/OBX/Observation
Expand All @@ -40,11 +61,32 @@ resources:
- .OBSERVATION_REQUEST.OBSERVATION.NTE
- MSH

- resourceName: Specimen
segment: SPECIMEN.SPM
group: ORDER.OBSERVATION_REQUEST
- resourceName: OMLSpecimenSource
segment: .OBSERVATION_REQUEST.OBR
group: ORDER
resourcePath: segments/ORC/Specimen
isReferenced: true
repeats: true

- resourceName: OMLSpecimen
segment: .OBSERVATION_REQUEST.SPECIMEN.SPM
group: ORDER
resourcePath: segments/SPM/Specimen
repeats: true
isReferenced: true
additionalSegments:
- MSH
- MSH

- resourceName: ServiceRequest
segment: .ORC
group: ORDER
resourcePath: segments/ORC/ServiceRequest
repeats: true
isReferenced: true
additionalSegments:
- .OBSERVATION_REQUEST.OBR
- .OBSERVATION_REQUEST.NTE
- PATIENT.PATIENT_VISIT.PV1
- MSH
- PATIENT.PID
- .OBSERVATION_REQUEST.OBSERVATION.OBX
4 changes: 2 additions & 2 deletions prime-router/metadata/HL7/catchall/hl7/message/ORU_R01.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ resources:
- .NK1

- resourceName: Provenance
group: PATIENT_RESULT.PATIENT
segment: .PID
group: PATIENT_RESULT.PATIENT
resourcePath: segments/PID/Provenance-Patient

- resourceName: RelatedPerson
Expand All @@ -45,7 +45,7 @@ resources:
resourcePath: segments/PV1/Encounter
isReferenced: true
additionalSegments:
- .PATIENT.VISIT.PV2
- .VISIT.PV2
- MSH

- resourceName: Observation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,27 @@ subject:
expressionType: resource
specs: $Patient

specimen:
generateList: true
expressionType: nested
expressions:
- valueOf: datatype/Reference
generateList: true
expressionType: resource
specs: $OMLSpecimen
useGroup: true
- valueOf: datatype/Reference
expressionType: resource
specs: $OMLSpecimenSource
useGroup: true

supportingInfo:
generateList: true
valueOf: datatype/Reference
expressionType: resource
specs: $OMLObservation
useGroup: true

note:
valueOf: segments/NTE/Annotation
expressionType: resource
Expand Down
30 changes: 27 additions & 3 deletions prime-router/metadata/HL7/catchall/hl7/segments/ORC/Specimen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ container:
expressionType: HL7Spec

collection:
condition: $spm7 NOT_NULL
condition: $obr7 NOT_NULL || $obr8 NOT_NULL || $obr9 NOT_NULL || $obr10 NOT_NULL || $obr15 NOT_NULL
expressionType: nested
generateList: true
vars:
obr7: OBR.7
obr8: OBR.8
obr9: OBR.9
obr10: OBR.10
obr15: OBR.15
expressionsMap:
bodySite:
valueOf: datatypes/CWE/CodeableConcept
Expand Down Expand Up @@ -62,6 +68,24 @@ collection:
type: STRING
valueOf: "GeneralUtils.dateTimeWithZoneId(dateTimeIn,ZONEID)"
expressionType: JEXL
_collectedDateTime:
condition: $dateTimeIn NOT_NULL && $end NULL
expressionType: nested
vars:
dateTimeIn: OBR.7
end: OBR.8
expressionsMap:
extension_1:
generateList: true
expressionType: nested
expressionsMap:
url:
type: SYSTEM_URL
value: hl7v2-date-time
valueString:
type: STRING
valueOf: $dateTimeIn
expressionType: HL7Spec
collector:
condition: $obr10 NOT_NULL
vars:
Expand All @@ -87,10 +111,10 @@ note_specimen-source:
expressionsMap:
url:
type: SYSTEM_URL
value: hl7v2Name
value: hl7v2Component
valueString:
type: STRING
valueOf: specimen-source
valueOf: OBR.15.3

note_collectors-comment:
condition: $obr39 NOT_NULL
Expand Down
12 changes: 9 additions & 3 deletions prime-router/metadata/HL7/catchall/hl7/segments/PID/Patient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ contact:
vars:
nk141: STRING, NK1.41
relationship:
valueOf: datatypes/CWE/CodeableConcept
expressionType: resource
specs: NK1.7
generateList: true
expressionType: nested
expressions:
- valueOf: datatypes/CWE/CodeableConcept
expressionType: resource
specs: NK1.3
- valueOf: datatypes/CWE/CodeableConcept
expressionType: resource
specs: NK1.7
period:
vars:
startDate: NK1.8
Expand Down
8 changes: 8 additions & 0 deletions prime-router/src/main/kotlin/fhirengine/utils/HL7Reader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import java.util.Date
import ca.uhn.hl7v2.model.v251.message.OML_O21 as v251_OML_O21
import ca.uhn.hl7v2.model.v251.message.ORU_R01 as v251_ORU_R01
import ca.uhn.hl7v2.model.v251.segment.MSH as v251_MSH
import ca.uhn.hl7v2.model.v27.message.OML_O21 as v27_OML_O21
import ca.uhn.hl7v2.model.v27.message.ORU_R01 as v27_ORU_R01
import ca.uhn.hl7v2.model.v27.segment.MSH as v27_MSH
import fhirengine.translation.hl7.structures.nistelr251.message.ORU_R01 as NIST_ELR_ORU_R01
Expand Down Expand Up @@ -141,6 +142,7 @@ class HL7Reader(private val actionLogger: ActionLogger) : Logging {
}
"OML" -> {
return listOf(
v27_OML_O21::class.java,
v251_OML_O21::class.java
)
}
Expand Down Expand Up @@ -301,6 +303,12 @@ class HL7Reader(private val actionLogger: ActionLogger) : Logging {
ValidationContextFactory.noValidation(),
ReportStreamCanonicalModelClassFactory(ORU_R01::class.java),
)
} else if (hl7MessageType?.msh93 == "OML_O21") {
DefaultHapiContext(
ParserConfiguration(),
ValidationContextFactory.noValidation(),
ReportStreamCanonicalModelClassFactory(v27_OML_O21::class.java),
)
} else {
DefaultHapiContext(ValidationContextFactory.noValidation())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# $schema: ./../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

hl7Class: ca.uhn.hl7v2.model.v251.message.OML_O21
hl7Class: ca.uhn.hl7v2.model.v27.message.OML_O21

constants:
# Prefix for RS custom extension URLs
rsext: '"https://reportstream.cdc.gov/fhir/StructureDefinition/"'

elements:
- name: message-headers
condition: >
Expand All @@ -15,63 +17,25 @@ elements:
schema: classpath:/metadata/hl7_mapping/resources/MessageHeader/MSH.yml

- name: software-segment
condition: 'Bundle.entry.resource.ofType(MessageHeader).exists()'
resource: 'Bundle.entry.resource.ofType(Provenance).where(entity.exists()).entity.what.resolve()'
schema: classpath:/metadata/hl7_mapping/resources/Device/SFT.yml

- name: software-segment-legacy
condition: >
Bundle.entry.resource.ofType(MessageHeader).exists() and
(Bundle.entry.resource.ofType(MessageHeader).source.extension(%`rsext-software-vendor-org`).exists() or
Bundle.entry.resource.ofType(Provenance).exists().not())
resource: 'Bundle.entry.resource.ofType(MessageHeader)'
schema: classpath:/metadata/hl7_mapping/resources/MessageHeader/SFT.yml

- name: patient-information
resource: 'Bundle.entry.resource.ofType(Patient)'
condition: '%resource.count() = 1'
required: true
constants:
hl7SegmentGroup: '/PATIENT'
schema: classpath:/metadata/hl7_mapping/common/patient.yml

- name: patient-contact
resource: 'Bundle.entry.resource.ofType(Patient).contact'
condition: '%resource.exists()'
constants:
hl7SegmentGroup: '/PATIENT'
schema: classpath:/metadata/hl7_mapping/common/patient-contact.yml

- name: patient-visit
resource: 'Bundle.entry.resource.ofType(Encounter)'
- name: patient-base
condition: '%resource.count() = 1'
constants:
hl7SegmentGroup: '/PATIENT/PATIENT_VISIT'
schema: classpath:/metadata/hl7_mapping/common/patient-visit.yml

- name: order
resource: Bundle.entry.resource.ofType(ServiceRequest)
condition: '%resource.count() > 0'
required: true
schema: classpath:/metadata/hl7_mapping/OML_O21/base/service-request-order.yml
constants:
hl7SegmentGroup: '/ORDER'
resource: 'Bundle.entry.resource.ofType(Patient)'
resourceIndex: patientIndex
schema: classpath:/metadata/hl7_mapping/OML_O21/base/patient/patient-base.yml

- name: order-observation-request
resource: Bundle.entry.resource.ofType(ServiceRequest)
condition: '%resource.count() > 0'
required: true
constants:
hl7SegmentGroup: '/ORDER/OBSERVATION_REQUEST'
schema: classpath:/metadata/hl7_mapping/OML_O21/base/service-request-order-observation.yml
- name: order-base
resource: 'Bundle.entry.resource.ofType(ServiceRequest).where(subject.resolve().id = %resource.entry.resource.ofType(Patient).id)'
resourceIndex: orderIndex

- name: order-observation-result
resource: Bundle.entry.resource.ofType(Observation)
condition: '%resource.count() > 0'
required: true
schema: classpath:/metadata/hl7_mapping/common/observation-result.yml
constants:
hl7SegmentGroup: '/ORDER/OBSERVATION_REQUEST/OBSERVATION(%{resultIndex})'
hl7OBXField: '%{hl7SegmentGroup}/OBX'
resourceIndex: resultIndex

- name: order-specimen
resource: Bundle.entry.resource.ofType(Specimen)
condition: '%resource.count() = 1'
required: true
schema: classpath:/metadata/hl7_mapping/common/specimen.yml
constants:
hl7SpecimenFieldPath: /ORDER/OBSERVATION_REQUEST/SPECIMEN/SPM
schema: classpath:/metadata/hl7_mapping/OML_O21/base/order/order-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# $schema: ./../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

hl7Class: ca.uhn.hl7v2.model.v27.message.OML_O21

extends: classpath:/metadata/hl7_mapping/OML_O21/OML_O21-base.yml
elements:
- name: message-headers
condition: 'true'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# $schema: ./../../../../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

elements:

- name: observation-request
required: true
schema: classpath:/metadata/hl7_mapping/OML_O21/base/order/observation-request/observation-request.yml

- name: observation-request-observation
schema: classpath:/metadata/hl7_mapping/OML_O21/base/order/observation-request/observation/observation.yml

- name: observation-request-specimen
resource: '%resource.specimen.resolve().where(extension(%`rsext-hl7v2Segment`).value = "SPM") | %resource.specimen.resolve().where(extension(%`rsext-hl7v2Segment`).exists().not())'
resourceIndex: specimenIndex
schema: classpath:/metadata/hl7_mapping/OML_O21/base/order/observation-request/specimen/specimen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# $schema: ./../../../../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

elements:

- name: observation-request-service-request
required: true
schema: classpath:/metadata/hl7_mapping/resources/ServiceRequest/OBR.yml
constants:
obrFieldPath: '/ORDER(%{orderIndex})/OBSERVATION_REQUEST/OBR'

# - name: observation-request-note
# todo in second pass, for ORU this is mapped through Observation.note; OML maps through ServiceRequest.note
# this is already mapped into fhir via ORC/ServiceRequest... where is fhir -> hl7?
# todo add scearnio in full oml test for an OBSERVATION_REQUEST.NTE
Loading

0 comments on commit 9ae7f66

Please sign in to comment.