FHIR Chat · Profiling of complex structures · implementers

Stream: implementers

Topic: Profiling of complex structures


view this post on Zulip Lee Surprenant (Mar 27 2017 at 18:16):

Starting work to update my implementation guide for STU3. Does anyone know if there is a way to profile an element that is defined as a reference to another structure?
From http://wiki.hl7.org/?title=FHIR_Spreadsheet_Profile_Authoring :

For complex structures (which includes profiled simple structures with nested elements):

 You can say "@some.complex.element.path" or "@[Element Profile Name]" to say that the type for the element should be a complex structure already defined elsewhere within the resource.

view this post on Zulip Lee Surprenant (Mar 27 2017 at 18:19):

Example: PlanDefinition.action.action (defined as type '@PlanDefinition.action' in plandefinition-spreadsheet.xml of the spec)

view this post on Zulip Grahame Grieve (Mar 27 2017 at 19:09):

are you looking for ElementDefinition.type.targetProfile?

view this post on Zulip Lee Surprenant (Mar 27 2017 at 19:22):

possibly; i'm not familiar with that one and so i'll go look now. in the meantime, i just committed my stripped down sample in case you/anyone interested would like to help crack this nut (sent the same sample to @Bryn Rhodes a while ago but I don't think he's had chance to look into it yet)

view this post on Zulip Lee Surprenant (Mar 27 2017 at 19:22):

https://github.com/lmsurpre/plandefinition-profile-example

view this post on Zulip Lee Surprenant (Mar 27 2017 at 19:33):

so far i've tried a bunch of stuff, but I included in that sample what I felt to be the most promising two ways:
1. as a single structure where i include the subelements of the complex element i'm trying to profile (singleStructure)
2. tried to define a separate structure based on PlanDefinition.action for the profile of PlanDefinition.action.action

#1 is complaining that my differential doesn't match my snapshot (which makes sense since the sub-element isn't repeated in the snapshot)

#2 is giving me this:

view this post on Zulip Lee Surprenant (Mar 27 2017 at 19:33):

java.lang.Exception: exception parsing pack /Users/lmsurpre/svn/fhir/NCCN-simple/resources/plandefinition-order-template-simple-spreadsheet-split: Unhandled case
    at org.hl7.fhir.igtools.spreadsheets.IgSpreadsheetParser.parse(IgSpreadsheetParser.java:204)
    at org.hl7.fhir.igtools.publisher.Publisher.loadSpreadsheet(Publisher.java:1247)
    at org.hl7.fhir.igtools.publisher.Publisher.loadSpreadsheets(Publisher.java:1231)
    at org.hl7.fhir.igtools.publisher.Publisher.load(Publisher.java:1040)
    at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:268)
    at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:3263)
Caused by: java.lang.Exception: Unhandled case
    at org.hl7.fhir.igtools.spreadsheets.TypeParser.parse(TypeParser.java:107)
    at org.hl7.fhir.igtools.spreadsheets.TypeParser.parse(TypeParser.java:46)
    at org.hl7.fhir.igtools.spreadsheets.IgSpreadsheetParser.processLine(IgSpreadsheetParser.java:751)
    at org.hl7.fhir.igtools.spreadsheets.IgSpreadsheetParser.parseProfileSheet(IgSpreadsheetParser.java:268)
    at org.hl7.fhir.igtools.spreadsheets.IgSpreadsheetParser.parse(IgSpreadsheetParser.java:178)

view this post on Zulip Lee Surprenant (Mar 27 2017 at 19:34):

I tried using this syntax in the 'Type' column: "{#subtask}" (based on my reading of http://wiki.hl7.org/index.php?title=FHIR_Spreadsheet_Authoring#Element_Definition_Columns )

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:08):

did some more reading and I don't think ElementDefinition.type.targetProfile is right. That seems to be about elements of type Reference. what I was trying to ask is whether its possible to profile elements that are defined by a 'contentReference'

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:09):

per eld-5, if the element definition has a contentReference, it cannot have type. so i guess the question i have is whether there existing anything like a profile or targetProfile for a contentReference

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:10):

if not, i'm thinking i need to redo all my constraints as invariants which i'd rather not do

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:11):

i want to say things like "PlanDefinition.action must have one or more subaction and those subactions must have codes like x, y, z, etc"

view this post on Zulip Grahame Grieve (Mar 27 2017 at 21:16):

so there's no way to profile a content reference because you should just unroll the content reference and go ahead and make rules about it

view this post on Zulip Grahame Grieve (Mar 27 2017 at 21:17):

.e.g replace the content reference with the content being referred to

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:26):

cool, that is why i tried first. but the spreadsheet tooling doesn't seem to handle that when it generates the snapshot (i.e. the differential lists the extra elements but that doesn't match the snapshot)

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:26):

is this a place where the differential is allowed to differ from the snapshot? or do i need to scrap the tooling and do snapshot by hand?

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:35):

FWIW the only other example of a profiled contentReference i could find was http://build.fhir.org/consentdirective.html and it seems broken there too:
pasted image

view this post on Zulip Lee Surprenant (Mar 27 2017 at 21:37):

I think if 'action' was defined as its own re-usable Type (e.g. like 'Dosage') then I could create a profile for it a lot easier. any advantage to using this 'contentReference' thing over something like that? ...doesn't seem to be very widely used

view this post on Zulip Grahame Grieve (Mar 27 2017 at 21:51):

don't know. let me investigate

view this post on Zulip Grahame Grieve (Mar 28 2017 at 00:48):

I need to debug - can you send me an example?

view this post on Zulip Lee Surprenant (Mar 28 2017 at 02:00):

hi graham, i tried to provide an example at https://github.com/lmsurpre/plandefinition-profile-example

view this post on Zulip Lee Surprenant (Mar 28 2017 at 02:07):

as mentioned above this version currently fails with the following error:

java.lang.Exception: Exception loading http://example.org/fhir/StructureDefinition/order-template: Snapshot for http://example.org/fhir/StructureDefinition/order-template does not contain differential element with id: PlanDefinition:ordertemplate.action.action:subtask.label
    at org.hl7.fhir.igtools.publisher.Publisher.load(Publisher.java:1559)
    at org.hl7.fhir.igtools.publisher.Publisher.loadConformance(Publisher.java:1323)
    at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:272)
    at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:3263)
Caused by: org.hl7.fhir.exceptions.DefinitionException: Snapshot for http://example.org/fhir/StructureDefinition/order-template does not contain differential element with id: PlanDefinition:ordertemplate.action.action:subtask.label
    at org.hl7.fhir.dstu3.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:351)
    at org.hl7.fhir.dstu3.context.SimpleWorkerContext.seeProfile(SimpleWorkerContext.java:263)
    at org.hl7.fhir.dstu3.context.SimpleWorkerContext.seeResource(SimpleWorkerContext.java:213)
    at org.hl7.fhir.igtools.publisher.Publisher.load(Publisher.java:1557)
    ... 3 more

view this post on Zulip Lee Surprenant (Mar 28 2017 at 02:08):

if i remove the offending row from the spreadsheet then it produces a StructureDefinition like this: StructureDefinition-order-template.xml

view this post on Zulip Lee Surprenant (Mar 28 2017 at 02:09):

in this example, I am trying to specify the cardinality of a property (label) of the PlanDefinition.action.action ...any tips/pointers much appreciated

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:24):

can make a gForge task for this please

view this post on Zulip Lee Surprenant (Mar 28 2017 at 03:26):

yes, will do now

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:26):

thanks

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:27):

in single structure?

view this post on Zulip Lee Surprenant (Mar 28 2017 at 03:29):

basically i've tried a bunch of things hoping something would stick. in single structure i tried to just list the extra elements (unwrap the contentReference as you say)

view this post on Zulip Lee Surprenant (Mar 28 2017 at 03:30):

in my other version (which i call the 'split' version), i tried to define a separate structure just to profile PlanDefinition.action -- but I couldn't seem to make that work either (i think it has to be its own standalone resource/datatype to allow that?)

view this post on Zulip Lee Surprenant (Mar 28 2017 at 03:35):

opened http://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_item_id=13139

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:44):

ok, so this one: test-ig-lee.xml

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:45):

that's correct for slicing action at the root level.

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:45):

with a discriminator of label (which is pretty crappy, but valid and sufficient for our purpose now)

view this post on Zulip Grahame Grieve (Mar 28 2017 at 03:45):

can you check that and tell me whether it makes sense, and I'll look at slicing the next level

view this post on Zulip Grahame Grieve (Mar 28 2017 at 06:12):

This one: test-ig-lee.xml - it works now

view this post on Zulip Lee Surprenant (Mar 30 2017 at 18:55):

Sorry, just getting back to this now (I tried it right away but it seemed I needed to wait for the new ig publisher jar and fhir build was broken at that time)

view this post on Zulip Lee Surprenant (Mar 30 2017 at 19:03):

after downloading the latest jar from http://build.fhir.org/downloads, I confirm it builds for me. in my case, I don't even think I need the slicing (because each sub-action at a specific level will be the same), and it worked there as well

view this post on Zulip Lee Surprenant (Mar 30 2017 at 19:04):

one thing i noticed is that when slicing is used, the snapshot still contains this ugly 'Unknown reference to #PlanDefinition.ordertemplate.action' text
pasted image

view this post on Zulip Grahame Grieve (Mar 30 2017 at 19:04):

hmm. I will investigate

view this post on Zulip Lee Surprenant (Mar 30 2017 at 19:05):

in my version without slicing, i don't see that

view this post on Zulip Lee Surprenant (Mar 30 2017 at 19:06):

however, i just tried adding a third level (a sub-sub-action) and this is where things got interesting... the jar seems to be stuck (maybe a endless loop somewhere due to the recursive nature of this)?

view this post on Zulip Lee Surprenant (Mar 30 2017 at 19:06):

i will deliver this updated sample to that github project in case you find some time to look

view this post on Zulip Lee Surprenant (Mar 30 2017 at 19:06):

i havn't tried the 3rd level with slicing yet (i assume it will be the same story)


Last updated: Apr 12 2022 at 19:14 UTC