FHIR Chat · Logical Model Mapping · shorthand

Stream: shorthand

Topic: Logical Model Mapping


view this post on Zulip Matt Rouhana (Oct 12 2021 at 21:10):

Is it possible to define a FSH Mapping from a base resource (e.g., Patient) to a FSH-created logical model?

view this post on Zulip Chris Moesel (Oct 12 2021 at 22:04):

Hi @Matt Rouhana - The FSH Mapping capability is just a friendlier syntax for the existing StructureDefinition.mapping and ElementDefinition.mapping mechanism. Those say they are for mapping to external specifications, but I don't think there is anything that would technically prevent you from adding mappings on your logical models that point to FHIR resources they map to.

I think the more traditional approach to mapping logical models to FHIR resources might be via StructureMap and/or FHIR Mapping Language. But we're starting to reach the limits of my expertise on logical models and mappings, so perhaps @Jose Costa Teixeira can lend more to this conversation than I can.

view this post on Zulip Jose Costa Teixeira (Oct 12 2021 at 22:09):

I can only speak for the utility of it and the generic mechanism:
Mapping a Patient resource to a logical model can be useful to understand what data elements in a profile/resource are mapped to the "abstract" model. For example I'm doing this in Belgium: First define the functional (logical) data model of the data I need (which can be inferred from an previous standard), and then I map this to the FHIR profiles. This mapping is useful to check whether the models are compatible, if there are gaps, etc

view this post on Zulip Jose Costa Teixeira (Oct 12 2021 at 22:13):

The mapping itself in this case can be captured in two places (at least):
a) StructureDefinition.mapping and ElementDefinition.mapping
b) in a StructureMap that links them both (which can expressed also in the form of FHIR mapping as @Chris Moesel says)
From a governance perspective, I am more in favour of using the StructureMap, so option b)

view this post on Zulip Jose Costa Teixeira (Oct 12 2021 at 22:15):

because mapping assertions are meaningful and authors must maintain them, version them, ..
For example someone mapping "gender" in a LM to Patient: do they map to patient.gender or to the gender identity extension? This mapping really does matter, I think

view this post on Zulip Matt Rouhana (Oct 13 2021 at 13:58):

Thanks to both of you for your prompt responses. I was running into the following SUSHI error when trying to compile the Mapping:

error Unable to find source "Patient".

Seems that the Source element of the mapping can't reference a base resource? Creating a stub profile of Patient and referencing that instead seems to work.

As far as using a StructureMap vs. the mapping element of StructureDefinition/ElementDefinition, the former seemed like overkill for my particular use case, at least in my initial review. I'll revisit the documentation and ensure I'm on the right track.

view this post on Zulip Chris Moesel (Oct 13 2021 at 15:07):

@Matt Rouhana - I think you would want to create the mappings on the Logical Model. So your Source: should point to the Logical definition and your destination is the FHIR resource. You need to describe it in terms of how your model maps to the FHIR resource (not how the FHIR resource maps to your model).

That said, it looks like there is a bug in SUSHI that does not properly allow this. When I tried a simple example (FSHOnline link), SUSHI did not recognize the Logical Model as a valid source. We will need to fix this in SUSHI.

view this post on Zulip Matt Rouhana (Oct 13 2021 at 15:44):

@Chris Moesel yeah, I had tried it both ways without any luck. Thanks for looking into it!

view this post on Zulip Chris Moesel (Oct 21 2021 at 11:45):

For those who wish to track this change, this is SUSHI#940.

view this post on Zulip Chris Moesel (Nov 12 2021 at 20:48):

This has been fixed in SUSHI 2.2.0.

view this post on Zulip Mareike Przysucha (Mar 30 2022 at 09:50):

Hi there.
I created several Logical Models and want to map them (a) to other LogicalModels and (b) to existing FHIR Resources. Is it possible to set links?
E.g. for Mappings to RIM, there is a link (http://hl7.org/v3). But for the target of a "self-made" mapping, I don't know how to add a link. Is that possible?
Glad to read your answers.

view this post on Zulip Mareike Przysucha (Mar 30 2022 at 10:02):

Or is this for IG creation?

view this post on Zulip Chris Moesel (Mar 30 2022 at 15:33):

Hi @Mareike Przysucha. I see what you mean. I just did a test project w/ this simple FSH:

Logical: PatientLogical
Parent: Element
* identifier 1..1 SU Identifier "Identifier" "Identifier"

Mapping:  PatientLogicalToFhirR4
Source:   PatientLogical
Target:   "http://hl7.org/fhir/R4"
Id:       fhir-r4
Title:    "FHIR R4"
* -> "Patient"
* identifier -> "Patient.identifier"

The resulting StructureDefinition has these top-level mappings:

"mapping" : [
    {
      "identity" : "rim",
      "uri" : "http://hl7.org/v3",
      "name" : "RIM Mapping"
    },
    {
      "identity" : "fhir-r4",
      "uri" : "http://hl7.org/fhir/R4",
      "name" : "FHIR R4"
    }
  ]

Which get rendered like this:
image.png

view this post on Zulip Chris Moesel (Mar 30 2022 at 15:34):

As you can see, there is no difference in the way the JSON mappings are formatted. The best I can tell is that the IG Publisher must have some special logic that recognizes some mapping URLs (RIM v3) and links them -- but doesn't recognize/link other mapping URLs (FHIR R4?). This probably is a good question for #IG creation.

view this post on Zulip Patrick Ryan (Mar 30 2022 at 22:30):

Hi _ I am trying to refer to a locally defined package, still in dev, and not in the official FHIR package registry. Unless I manually install it into my local .fhir cache, I get an error "could not be loaded locally or from the FHIR package registry". Is there a way to get sushi to load this from package from my own url? I tried special urls, it did not help

parameters:
show-inherited-invariants: false
special-url:

- https://dev.d3ox9vcqia2rpj.amplifyapp.com/site

view this post on Zulip Julia Afeltra (Mar 31 2022 at 15:00):

Hi @Patrick Ryan . Unfortunately, there isn't a way around this - you'll have to manually install the package into your local FHIR cache. SUSHI does not have support built in to download a package from your own URL. SUSHI only looks in your local FHIR cache for packages with version "dev" based on the guidance in the IG Publisher Documentation here.

view this post on Zulip Julia Afeltra (Mar 31 2022 at 16:05):

It may also be worthwhile to mention that if you build the dev package locally using the IG Publisher, the IG Publisher should put the built dev package into your local FHIR cache for you, which hopefully makes the manual process a little bit easier.

view this post on Zulip Mareike Przysucha (Mar 31 2022 at 17:30):

@Chris Moesel Thanks for the reply. Once I am back to office, I will raise the issue there.

view this post on Zulip Al Pivonka (Apr 05 2022 at 18:24):

New to shorthand (JR to FHIR).
I've defined a new logical structure and it complies just fine with no errors.
Yet when I add an example, SUSHI tells me it's not able to find the InstanceOf (the example is being defined within the same fsh file as the logical structure...

thanks

view this post on Zulip Al Pivonka (Apr 05 2022 at 18:41):

I figured it out. I was using logical when I should have been using Resource

HMM thought I resloved this>>

warn
╭─────────────────────────────────────────────────────────────────╮
│ Detected the following non-conformant Resource definitions: │
│ - QuestionnaireItemSettings │
│ │
│ Resources not in the "http://hl7.org/fhir/StructureDefinition" │
│ namespace are not conformant to the FHIR specification. │
│ These resources are incompatible with standard XML/JSON │
│ schemas, public test servers, public registries, standard │
│ validation, and standard publication tooling. These resources │
│ should not be used for inter-organizational data exchange. │
╰─────────────────────────────────────────────────────────────────╯

view this post on Zulip David Pyke (Apr 05 2022 at 19:29):

You can't easily do an instance of a logical model. There are threads about this but the short answer is that it's a pain and has to be a binary inclusion in your IG

view this post on Zulip Chris Moesel (Apr 06 2022 at 13:02):

@Al Pivonka -- @David Pyke is spot on (as usual?). You cannot create instances of logical models using the Instance: FSH mechanism. You must create your example as raw JSON or XML and then include it into the project via a special mechanism. We added support for this workflow in SUSHI 2.2.0. See the SUSHI 2.2.0 Release Notes, and in particular, the section titled Allow Authors to Provide Instances of Logical Models.

view this post on Zulip Al Pivonka (Apr 06 2022 at 13:06):

Thank you.

I'm an ol-java guy.
Should I equate:

  1. "Resource" to a Java Object: able to be instantiated "instanceOf",
  2. "Logical" to a Java interface: not able to be instantiated?

view this post on Zulip Chris Moesel (Apr 06 2022 at 13:47):

I might think of Logical more like UML (maybe?). It's intended more as a design and communication tool; conveying what information is important. But it's not really intended to be the actual implementation.

view this post on Zulip Mareike Przysucha (Apr 06 2022 at 14:33):

Hi @Chris Moesel,
I tried what's written in that part you mentioned before, but I get the following error:
java.lang.Exception: Bad Resource Identity - should have the format [Type]/[id] where Type is a valid resource type:ZIELPatient/MyZIELPatient.

view this post on Zulip Mareike Przysucha (Apr 06 2022 at 14:36):

okay, wait, I'm rerunning with the corrected parameters...

view this post on Zulip Mareike Przysucha (Apr 06 2022 at 14:50):

okay, my fault...

view this post on Zulip Mareike Przysucha (Apr 11 2022 at 07:47):

By the way: for my former issue (Links in Mappings) I started a channel in #IG creation.


Last updated: Apr 12 2022 at 19:14 UTC