Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CP to Extension mappings #16767

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions prime-router/docs/design/design/RS-Extention-Registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3418,6 +3418,99 @@
valueType: String
hl7Use: XTN.12

- Resource: Any
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in standup, this pattern is somewhat cobbled together from other extension mapping patterns because of its uniqueness.

CP is somewhat unique in that:

  • It does not exist in the mapping inventory
  • It is a datatype that exists on multiple HL7 segments

With that in mind, the idea here is to create something that is more formalized than simply adding each field to Resource.extension by itself. This allows CP to be noted as such when it shows up, and makes it easier to send CP data if a FHIR sender ever needed to do so.

Still, this is what made sense to me, so if there is a format that better fits existing/future patterns I'm open to it.

FHIR-Type: Extension
HL7-Type:
CP:
Example:
{
"fullUrl": "Coverage/1733795578717198000.8888487d-55f4-4d1d-963d-f8692fc77e9c",
"resource": {
"resourceType": "Coverage",
"id": "1733795578717198000.8888487d-55f4-4d1d-963d-f8692fc77e9c",
"extension": [
{
"url": "https://reportstream.cdc.gov/fhir/StructureDefinition/composite-price",
"extension": [
{
"url": "https://reportstream.cdc.gov/fhir/StructureDefinition/hl7v2Field",
"valueString": "IN1.40"
},
{
"url": "CP.1.1",
"valueDecimal": 33.33
},
{
"url": "CP.1.2",
"valueString": "MXN"
},
{
"url": "CP.2",
"valueString": "P3"
},
{
"url": "CP.3",
"valueDecimal": 3.003
},
{
"url": "CP.4",
"valueDecimal": -3
},
{
"url": "CP.5",
"valueCodeableConcept": {
# CWE to CodeableConcept
}
},
{
"url": "CP.6",
"valueString": "P"
}
]
}
]
}
}
Extension:
- id: composite-price
url: "https://reportstream.cdc.gov/fhir/StructureDefinition/composite-price"
valueType: Extension
hl7Use: NA
extension:
- id: hl7v2Field
url: "https://reportstream.cdc.gov/fhir/StructureDefinition/hl7v2Field"
valueType: String
hl7Use: NA
description: Identifies the HL7 field of the data.
- id: cp-price-quantity
url: "CP.1.1"
valueType: Decimal
hl7use: CP.1.1
- id: cp-price-denomination
url: "CP.1.2"
valueType: String
hl7use: CP.1.2
- id: cp-price-type
url: "CP.2"
valueType: String
hl7use: CP.2
- id: cp-from-value
url: "CP.3"
valueType: Decimal
hl7use: CP.3
- id: cp-to-value
url: "CP.4"
valueType: Decimal
hl7use: CP.4
- id: cp-range-units
url: "CP.5"
valueType: CodeableConcept
hl7use: CP.5
- id: cp-range-type
url: "CP.6"
valueType: String
hl7use: CP.6

- Resource: Any
FHIR-Type: MessageHeader.destination
HL7-Type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
- id: "xon-organization"
url: "https://reportstream.cdc.gov/fhir/StructureDefinition/xon-organization"

# CP -> Extension
- id: "composite-price"
url: "https://reportstream.cdc.gov/fhir/StructureDefinition/composite-price"

# CX -> Identifier
- id: "assigning-facility"
url: "https://reportstream.cdc.gov/fhir/StructureDefinition/assigning-facility"
Expand Down
103 changes: 103 additions & 0 deletions prime-router/metadata/HL7/catchall/hl7/datatypes/CP/CPExtension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# $schema: ./../../../../../json_schema/fhir/hl7-to-fhir-mapping-resource-template.json

url:
type: SYSTEM_URL
value: composite-price

extension:
expressionType: nested
generateList: true
expressions:
- expressionType: nested
expressionsMap:
url:
type: SYSTEM_URL
value: hl7v2Field
valueString:
type: STRING
expressionType: HL7Spec
valueOf: $cpExtensionName
- expressionType: nested
vars:
cp11: STRING, CP.1
condition: $cp11 NOT_NULL
expressionsMap:
url:
type: STRING
value: CP.1.1
valueDecimal:
type: STRING
expressionType: HL7Spec
valueOf: CP.1.1
- expressionType: nested
vars:
cp12: STRING, CP.1.2
condition: $cp12 NOT_NULL
expressionsMap:
url:
type: STRING
value: CP.1.2
valueString:
type: STRING
expressionType: HL7Spec
valueOf: CP.1.2
- expressionType: nested
vars:
cp2: STRING, CP.2
condition: $cp2 NOT_NULL
expressionsMap:
url:
type: STRING
valueOf: CP.2
valueString:
type: STRING
expressionType: HL7Spec
valueOf: CP.2
- expressionType: nested
vars:
cp3: STRING, CP.3
condition: $cp3 NOT_NULL
expressionsMap:
url:
type: STRING
valueOf: CP.3
valueDecimal:
type: STRING
expressionType: HL7Spec
valueOf: CP.3
- expressionType: nested
vars:
cp4: STRING, CP.4
condition: $cp4 NOT_NULL
expressionsMap:
url:
type: STRING
valueOf: CP.4
valueDecimal:
type: STRING
expressionType: HL7Spec
valueOf: CP.4
- expressionType: nested
vars:
cp5: STRING_ALL, CP.5
condition: $cp5 NOT_NULL
expressionsMap:
url:
type: STRING
value: CP.5
valueCodeableConcept:
valueOf: datatypes/CWE/CodeableConcept
specs: CP.5
expressionType: resource
- expressionType: nested
vars:
cp6: STRING, CP.6
condition: $cp6 NOT_NULL
expressionsMap:
url:
type: STRING
valueOf: CP.6
valueString:
type: STRING
expressionType: HL7Spec
valueOf: CP.6
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,36 @@ extension:
expressions:
- expressionType: resource
valueOf: datatypes/AUI/AUIExtension
specs: IN1.14
specs: IN1.14
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these values will move to IN1Extension but that doesn't have to be done now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get to this before the codeowner review was left. In the interest of not making reviewers revise an already approved PR I left a comment to have this be done as part of the main IN1 work. #15500

- expressionType: resource
vars:
in137: STRING, IN1.37
condition: $in137 NOT_NULL
valueOf: datatypes/CP/CPExtension
constants:
cpExtensionName: IN1.37
specs: IN1.37
- expressionType: resource
vars:
in138: STRING, IN1.38
condition: $in138 NOT_NULL
valueOf: datatypes/CP/CPExtension
constants:
cpExtensionName: IN1.38
specs: IN1.38
- expressionType: resource
vars:
in140: STRING, IN1.40
condition: $in140 NOT_NULL
valueOf: datatypes/CP/CPExtension
constants:
cpExtensionName: IN1.40
specs: IN1.40
- expressionType: resource
vars:
in141: STRING, IN1.41
condition: $in141 NOT_NULL
valueOf: datatypes/CP/CPExtension
constants:
cpExtensionName: IN1.41
specs: IN1.41
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ extension:
expressionType: HL7Spec
valueOf: OBR.22
- expressionType: resource
valueOf: datatypes/MOC/Extension
valueOf: datatypes/MOC/MOCExtension
vars:
obr23: STRING_ALL, OBR.23
condition: $obr23 NOT_NULL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# $schema: ./../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

hl7Class: ca.uhn.hl7v2.model.v27.message.OML_O21
hl7Class: fhirengine.translation.hl7.structures.fhirinventory.message.OML_O21
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed to get around some very uncommon edge cases. There is a ticket to update ORU-based mappings with the same change: #16755

This scenario appears to only occur for fields which have been Withdrawn between HL7 2.5.1 and 2.7. This causes the field type to be set to NULLDT by Hapi. This hasn't been an issue with other fields as Hapi will still handle them appropriate when going from a complex fhir type to NULLDT. However, in the case where the withdrawn field has complex subfields (Ex: IN1.38), there will be data modification or loss.


constants:
# Prefix for RS custom extension URLs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# $schema: ./../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

hl7Class: ca.uhn.hl7v2.model.v27.message.OML_O21
hl7Class: fhirengine.translation.hl7.structures.fhirinventory.message.OML_O21

extends: classpath:/metadata/hl7_mapping/OML_O21/OML_O21-base.yml
elements:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# $schema: ./../../../../../../../metadata/json_schema/fhir/fhir-to-hl7-mapping.json

elements:

- name: cp-price-quantity
value: [ '%resource.extension.where(url = "CP.1.1").value' ]
hl7Spec: [ '%{cpField}-1-1' ]

- name: cp-price-denomination
value: [ '%resource.extension.where(url = "CP.1.2").value' ]
hl7Spec: [ '%{cpField}-1-2' ]

- name: cp-price-type
value: [ '%resource.extension.where(url = "CP.2").value' ]
hl7Spec: [ '%{cpField}-2' ]

- name: cp-from-value
value: [ '%resource.extension.where(url = "CP.3").value' ]
hl7Spec: [ '%{cpField}-3' ]

- name: cp-to-value
value: [ '%resource.extension.where(url = "CP.4").value' ]
hl7Spec: [ '%{cpField}-4' ]

- name: cp-range-units
resource: '%resource.extension.where(url = "CP.5").value'
schema: classpath:/metadata/hl7_mapping/datatypes/codeableConcept/CWE.yml
constants:
cweField: '%{cpField}-5'

- name: cp-range-type
value: [ '%resource.extension.where(url = "CP.6").value' ]
hl7Spec: [ '%{cpField}-6' ]
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,32 @@ constants:

elements:

- name: aui-extension
- name: in1-authorization-information
resource: '%resource.extension.where(url = "IN1.14")'
schema: classpath:/metadata/hl7_mapping/datatypes/extensionAUI/AUI.yml
constants:
auiField: '%{hl7IN1Field}-14'
auiField: '%{hl7IN1Field}-14'

- name: in1-policy-deductable
resource: '%resource.extension(%`rsext-composite-price`).where(extension(%`rsext-hl7v2Field`).value = "IN1.37")'
schema: classpath:/metadata/hl7_mapping/datatypes/extensionCP/CP.yml
constants:
cpField: '%{hl7IN1Field}-37'

- name: in1-policy-limit-amount
resource: '%resource.extension(%`rsext-composite-price`).where(extension(%`rsext-hl7v2Field`).value = "IN1.38")'
schema: classpath:/metadata/hl7_mapping/datatypes/extensionCP/CP.yml
constants:
cpField: '%{hl7IN1Field}-38'

- name: in1-room-rate-semi-private
resource: '%resource.extension(%`rsext-composite-price`).where(extension(%`rsext-hl7v2Field`).value = "IN1.40")'
schema: classpath:/metadata/hl7_mapping/datatypes/extensionCP/CP.yml
constants:
cpField: '%{hl7IN1Field}-40'

- name: in1-room-rate-private
resource: '%resource.extension(%`rsext-composite-price`).where(extension(%`rsext-hl7v2Field`).value = "IN1.41")'
schema: classpath:/metadata/hl7_mapping/datatypes/extensionCP/CP.yml
constants:
cpField: '%{hl7IN1Field}-41'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gov.cdc.prime.router.datatests.mappinginventory.cp

import gov.cdc.prime.router.datatests.mappinginventory.verifyHL7ToFHIRToHL7Mapping
import org.junit.jupiter.api.Test

class CPTests {
@Test
fun `test CP mapped to CPExtension`() {
assert(
verifyHL7ToFHIRToHL7Mapping(
"catchall/cp/cp-to-extension",
outputSchema = "classpath:/metadata/hl7_mapping/OML_O21/OML_O21-test.yml"
).passed
)
}
}
Loading
Loading