FHIR Chat · spec examples of StructureMap · mapping-framework

Stream: mapping-framework

Topic: spec examples of StructureMap


view this post on Zulip Brian Postlethwaite (Sep 05 2021 at 23:46):

Checking this page here, is it just me, or is the rendering for the Raw StructureMap format not correct here?
http://build.fhir.org/structuremap-supplyrequest-transform.html
It's all run together (not as a pre block)
there are no brackets around parameters
there are no {} brackets around the rules in the group
the name for the rule is at the start and not the end...

view this post on Zulip Brian Postlethwaite (Sep 05 2021 at 23:51):

and the grammar for the targetlistmode is only singular in cardinality, however the FHIR resource definition permits multiple

view this post on Zulip Brian Postlethwaite (Sep 06 2021 at 00:25):

grammar has dependent as singular cardinality, structuremap has multiple

view this post on Zulip Brian Postlethwaite (Sep 06 2021 at 01:30):

Is this rule in the grammar intended to mean that you must have at least 2 parameters? (or should the + be a * here)
'(' parameter (',' parameter)+ ')'

view this post on Zulip Brian Postlethwaite (Sep 06 2021 at 05:56):

I'm putting together a serialization to convert StructureMap resources into the FHIR Mapping Language format in c#
https://gist.github.com/brianpos/2f2d33a0f22ef566947bc4a5b7dc1eb8#file-structuremap_serializer-cs-L310
Anyone else done anything similar?
The section highlighted is where I'm struggling a bit...

view this post on Zulip Brian Postlethwaite (Sep 07 2021 at 12:35):

And the conversion the other way around (FML -> StructureMap) is coming along nicely too, maybe that will answer more questions as I compelete that.
https://gist.github.com/brianpos/e4fd4575a6d39290c8cc258f3100a2ac
This particular code will probably end up in the HL7 FHIR Nuget Packages

view this post on Zulip Alexander Zautke (Sep 07 2021 at 21:15):

@Brian Postlethwaite The example still uses the STU3 syntax. Written using the current spec it would look something like this:

map "http://hl7.org/fhir/StructureMap/supplyrequest-transform" = supplyRequestTransform

uses "http://hl7.org/fhir/StructureDefinition/ActivityDefinition" as source
uses "http://hl7.org/fhir/StructureDefinition/SupplyRequest" as target

group main(source `source`: ActivityDefinition, target `target`: SupplyRequest)
{
    `source`.id -> target.status = 'draft' "status";
    `source`.id -> target.category = 'non-stock' "category";
    `source`.id -> target.priority = 'routine' "priority";
    `source`.quantity as quantity -> target.orderedItem as orderedItem, orderedItem.quantity = quantity "quantity";
    `source`.code as code -> target.orderedItem as orderedItem, orderedItem.itemCodeableConcept = code "item";
    `source`.id -> target.occurrence = ('now()') "when";
    `source`.id -> target.authoredOn = ('now()') "authoredOn";
}

view this post on Zulip Alexander Zautke (Sep 07 2021 at 21:17):

To make things a bit less confusing, you can skip the ".id" part of the source selection and simply use

`source` -> tgt [...]

I'm still have the wish that we allow a wildcard token here, e.g. "_ -> tgt.element"

view this post on Zulip Brian Postlethwaite (Sep 07 2021 at 21:19):

Is there a good collection of samples, or just grab the entire spec 3-4 conversions file?

view this post on Zulip Alexander Zautke (Sep 07 2021 at 21:19):

Brian Postlethwaite said:

and the grammar for the targetlistmode is only singular in cardinality, however the FHIR resource definition permits multiple

Not sure how multiple target list modes would work. Might be a simple mistake in the spec.

view this post on Zulip Alexander Zautke (Sep 07 2021 at 21:23):

Mapping files for the tutorial can be found here: https://github.com/ahdis/fhir-mapping-tutorial. Those maps have been tested over the last connectathons. It's a good starting point.

view this post on Zulip Alexander Zautke (Sep 07 2021 at 21:24):

I personally used the following map as part of the DevDays tutorials: https://github.com/FirelyTeam/Firely.FhirMapper.Examples/tree/FakeInpatientDrugChart-STU3

view this post on Zulip Brian Postlethwaite (Sep 09 2021 at 00:35):

@Alexander Zautke is there a fhir mapping session at the fhir connectathon next week?
Would like to go over these issues,

view this post on Zulip Alexander Zautke (Sep 09 2021 at 07:00):

I wouldn't be aware of any scheduled sessions. If you like we could schedule a break-out session and go over it. Maybe we can get a few people to join.

view this post on Zulip Oliver Egger (Sep 09 2021 at 07:39):

count me in for the break-out session

view this post on Zulip Brian Postlethwaite (Sep 09 2021 at 09:20):

Come in over to the questionnaires track and we'll give it a whirl.

view this post on Zulip Brian Postlethwaite (Sep 09 2021 at 22:31):

My parser is now basically working, however loading in some of the samples that I've found, there are some issues around the fhirpath type and string.
The hunger vital signs map
http://hl7.org/fhir/us/sdoh-clinicalcare/STU1/mapping_instructions.html
has a rule

src.item as answerItem1 where "linkId = '/88122-7'" -> bundle.entry as entry

the fml grammar states that the where clause is a fhirpath element

whereClause
    : 'where' fhirPath
    ;

and fhirpath is declared as a literal which includes STRING which is defined as single quoted content.
However as seen in this example, it is declared using " (double quotes) which are used for DELIMITEDIDENTIFIER elements
Which is wrong?
http://hl7.org/fhir/mapping.g4

view this post on Zulip Brian Postlethwaite (Sep 09 2021 at 22:52):

@Grahame Grieve what does the Java fml engine do here?

view this post on Zulip Brian Postlethwaite (Sep 09 2021 at 23:25):

@Alexander Zautke what does your fhirpath engine do with this?

view this post on Zulip Alexander Zautke (Sep 10 2021 at 05:21):

I think both engines only except double quotes here

view this post on Zulip Alexander Zautke (Sep 10 2021 at 05:24):

Thers’s also an unapplied change request to change it the double quotes to parentheses due to some grammar ambiguity

view this post on Zulip Oliver Egger (Sep 10 2021 at 06:18):

double quotes are not accepted by the java fml engine (see example), the examples are using fhirPath not quoted eg:

  src.a21 as a where a21.matches('[0-9]+') -> tgt.a21 = a "rule_a21b";

view this post on Zulip Brian Postlethwaite (Sep 10 2021 at 06:54):

So is this more or less implying that " and ' mean the same thing in the FML then?
(and bactic ` is used for delimiting identifiers?)

view this post on Zulip Alexander Zautke (Sep 10 2021 at 07:55):

Yes, bactics are used for delimited identifiers. The current spec still states that you can also use double quotes for delimited identifiers (https://www.hl7.org/fhir/mapping-language.html#syntax). But we got rid of this as well, but the ticket has not yet been applied.

view this post on Zulip Alexander Zautke (Sep 10 2021 at 07:57):

Single quotes would then only be used within FHIRPath statements for strings, no?

view this post on Zulip Brian Postlethwaite (Sep 10 2021 at 08:48):

I'll check with that assumption in mind to see what comes out.

view this post on Zulip Brian Postlethwaite (Sep 10 2021 at 13:34):

Is the \ still used for delimiting the backtics, or double back tic ``

view this post on Zulip Brian Postlethwaite (Sep 11 2021 at 08:03):

How about this rule from the example... @Alexander Zautke

  //for each answer item in the questionnareResponse, create an Observation and add it to the groupObservation
  src.item as answerItem1 where "linkId = '/88122-7'" -> bundle.entry as entry, entry.resource = create('sdohccObservation') as observation1 then
    TransformObservation(src, answerItem1, observation1, entry), TransformObservation1(src, answerItem1, observation1, entry);

According to the grammar, dependent invocations can't repeat (only rules can)

dependent
    : 'then' (invocation | rules)
    ;

Is there intended to be an invocations node in the grammar?

view this post on Zulip Brian Postlethwaite (Sep 11 2021 at 21:52):

My first FHL => StructureMap resource conversion
https://sqlonfhir-r4.azurewebsites.net/fhir/StructureMap/Hunger-Vital-Sign
(ignore the narrative shown in it, that part is in progress still, and yet to do the QA checks on the mapping to ensure that I've correctly mapped it)
http://hl7.org/fhir/us/sdoh-clinicalcare/STU1/mapping_instructions.html#hvs

view this post on Zulip Alexander Zautke (Sep 14 2021 at 18:53):

@Brian Postlethwaite I have some free time over the next hours, would now be a good time to take a look at these issues?

view this post on Zulip Alexander Zautke (Sep 14 2021 at 18:54):

@Oliver Egger would this work for you, too?

view this post on Zulip Brian Postlethwaite (Sep 14 2021 at 18:54):

Come on over to the questionnaire track if you like

view this post on Zulip Alexander Zautke (Sep 14 2021 at 19:02):

I don't see any active sessions in Whova for the Questionnaire track, which one are you using?

view this post on Zulip Alexander Zautke (Sep 14 2021 at 20:28):

FHIR-20841 - Rule source 'default' should be of type string
FHIR-20844 - Add date, time and dateTime to StructureMap.group.rule.target.parameter.value[x]
FHIR-20842 - Dependent variables should be of type “id” - StructureMap Change
FHIR-25286 - Harmonize delimitedIdentifiers in FHIRPath and Mapping Language - Documentation Change
FHIR-28465 - Replace isInteger with convertsToInteger() in Mapping Language Tutorial - Tutorial Change
FHIR-20840 - Document that repeating dependent rules are allowed - Documentation Change
FHIR-20848 - Can dependent rules and nested rules be combined?
FHIR-25266 - StructureMap does not account for escaped identifiers in id fields - StructureMap change
FHIR-21642 - Add "const" keyword to the mapping language - Syntax change
FHIR-22110 - Add "doccomments" facility to the mapping language - Syntax change
FHIR-22622 - Is the Mapping "map" statement followed by a string or an identifier? - Syntax change
FHIR-27915 - Replace "map" statement with shorthand synatx - Syntax change
FHIR-20577 - Add Media Type for FHIR Mapping Language - Documentation Change
FHIR-20845 - Can 'type' and 'min'/'max' be used independently? - Documentation Change
FHIR-20846 - Should we align transforms and FhirPath? - Documentation Change
FHIR-20905 - How to hande an element with a choice of types as the target in a mapping rule - Documentation Change
FHIR-21641 - Allow for a source statement to walk deeper into the children - Documentation Change
FHIR-21643 - Document listmode and update ANTLR grammar - Documentation Change
FHIR-22774 - Document support for implicit casts in mapping language - Documentation change
FHIR-23007 - In mapping language, talk about trees instead of DAGs - Documentation change
FHIR-23010 - In mapping language, state that rule application order is implementation-dependent - Documentation change
FHIR-25220 - Clarify language around invoking multiple groups - Documentation change
FHIR-25376 - Clarify behaviour for matching multiple source statements - Documentation Change
FHIR-27140 - Mapping Language - type parameter of cast function should contain model info - Documentation Change
FHIR-20847 - What's the purpose of target.contextType?
FHIR-20849 - Make name optional for mapping rules
FHIR-20849 - Make name optional for mapping rules
FHIR-20843 - Consider removing 'none' from StructureMapGroupTypeMode
FHIR-20839 - Allow mapping groups with 0 rules
FHIR-23937 - Document parameters of dateOp

view this post on Zulip Grahame Grieve (Sep 20 2021 at 18:46):

I'm not sure. is there open issues from this thread?

view this post on Zulip Brian Postlethwaite (Sep 20 2021 at 19:13):

The inconsistencies I noted were in this list, but hadn't been applied to the R5 spec yet.
(and I'm working with R4 not R5, which didn't help me either)


Last updated: Apr 12 2022 at 19:14 UTC