Stream: mapping-framework
Topic: Simple form example
Brian Kaney (Aug 07 2019 at 13:25):
I am trying to wrap my head around https://www.hl7.org/fhir/mapping-language.html#simple and the long form equivalent and could use some help...
In the long example, I see that the create
transform takes a type
parameter, which is a string of a type that is known (somehow). This example uses the string 'type'. Then the dependent invocation of the rule is spelled defaultMappingGroup
. Is this a special kind of invocation? Most of the examples I've seen the spelling of the invocation corresponds to the spelling of the type parameter in the transform of the rule target. Or refer to some other group.
Jean Duteau (Aug 07 2019 at 13:30):
Let's say that src.element is of type CodeableConcept and tgt.element is of type v3CE. Further, let's assume you've defined a group called mapCodeableConceptTov3CE that maps CodeableConcept to v3CE and is declared with (types) which means that its the default mapping for those two types. Then the short form becomes equivalent to:
src.element as vvs -> tgt.element = create('v3CE') as vvt then mapCodeableConceptTov3CE(vvs, vvt)
Brian Kaney (Aug 07 2019 at 13:51):
Okay. So this example assumes a group called defaultMappingGroup
to exist? I guess I am trying to understand how we go from the shorthand to the long form here...
Jean Duteau (Aug 07 2019 at 13:53):
No, it does not need to be called "defaultMappingGroup". That part is just saying that what ever group has been defined as the default mapping group for the src.element and the tgt.element types will be called. That is what it states that right after the long form:
Where the name of the type given as a parameter to 'create' and the group invoked by the 'then' are determined by the context of src.element and tgt.element and the selected default mapping group, as documented in the next section.
Jean Duteau (Aug 07 2019 at 13:56):
As I said earlier, if this group was present in your set of mappings:
group mapCodeableConceptToV3CE(source src:CodeableConcept, target tgt:v3CE) <<types>> { mapping stuff goes here}
then the long form equivalent becomes:
src.element as vvs -> tgt.element = create('v3CE') as vvt then mapCodeableConceptTov3CE(vvs, vvt)
Brian Kaney (Aug 07 2019 at 14:03):
Thanks @Jean Duteau for bearing with me -- just so I am clear, what would the long form of the first rule of the R3->R4 of the Basic resource (https://www.hl7.org/fhir/basic-version-maps.html#2.34.13.1) be, e.g.src.identifier -> tgt.identifier
?
Jean Duteau (Aug 07 2019 at 14:04):
src.identifier as vvs -> tgt.identifier = create('Identifier' as vvt then whateverTheNameOfTheDefaultIdentifierToIdentiferMappingIs(vvs, vvt);
Jean Duteau (Aug 07 2019 at 14:06):
src.identifier as vvs -> tgt.identifier = create('Identifier') as vvt then Identifier(vvs, vvt); (I looked and saw that was the name of the default mapping of IdentifierR3 to Identifier) (https://www.hl7.org/fhir/datatypes-version-maps.html#identifier)
Brian Kaney (Aug 22 2019 at 03:16):
And as I dig deeper, I am trying to understand the implication of <<types>>
vs <<type+>>
for default groups.
Why was it decided that group string2id
should have <<types>>
while group id2string
a group type of <<type+>>
(see https://github.com/HL7/fhir/blob/master/implementations/r3maps/R4toR3/primitives.map)?
Jean Duteau (Aug 22 2019 at 04:47):
The section on default mappings talks about the difference: http://hl7.org/implement/standards/fhir/mapping-language.html#7.7.0.9
<<types>> is used when you want the source and the target to match exactly.
<<type+>> is used when you only need the source to match and the target will just get cast/converted to the target type.
So string2id is marked as <<types>> because we only want this transform to be called when the source is a string and the target is an idR3. It won't get called in any situtation.
OTOH id2string is marked as <<type+>> because it is sort of the fallback for when the source is an id and the target isn't something more specific (id2oid for instance) and the target can be converted to a string. so it will handle id2code, id2markdown, and id2string. NOTE: it won't handle id2id even though id is a type of string, because we have a group that matches id, id already specified.
Last updated: Apr 12 2022 at 19:14 UTC