Stream: shorthand
Topic: example FSH Bundle transaction with Create entries
John Moehrke (Jan 13 2021 at 13:58):
I am struggling with the MHD provide transaction, which is a Bundle transaction with 1 or more create entries. I am sure I am just doing something stupid, so first ask for others examples of FSH specifications of Bundle transactions with creates.
John Moehrke (Jan 13 2021 at 17:02):
I have one Bundle working. but another one keeps throwing the dreaded
error Cannot read property '0' of undefined
Chris Moesel (Jan 13 2021 at 19:52):
I'm afraid that doesn't really give us enough to go on to really debug the issue. The good news, however, is that we hope to release a new version of SUSHI with "soft indexing" today (tomorrow at latest) -- which should make working w/ Bundle instances a lot easier and less error prone.
John Moehrke (Jan 13 2021 at 19:55):
I wish I could give you more to go on. I fully expect that it is my own fat-fingers that are to blame.. but I have tried and have had others look... many eyes might find the problem. Here is the total FSH that causes failure
Instance: ex-dummyProvideDocumentBundle
InstanceOf: Bundle
Title: "Dummy Provide Document Bundle with Minimal metadata"
Description: "Example of a minimal Provide Document Bundle. "
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
* type = #transaction
* timestamp = 2020-11-24T23:50:50-05:00
* entry[0].fullUrl = "http://www.example.org/fhir/List/593cd04e-b696-45c1-bc32-39e55a340a48"
* entry[0].resource = ex-b-list
* entry[0].request.url = "List"
* entry[0].request.method = #POST
* entry[1].fullUrl = "http://www.example.org/fhir/DocumentReference/593cd04e-b696-45c1-bc32-39e55a340a47"
* entry[1].resource = ex-b-documentreference
* entry[1].request.url = "DocumentReference"
* entry[1].request.method = #POST
Instance: ex-b-list
InstanceOf: List
Title: "Dummy List example"
Description: "Dummy List example for completeness sake. No actual use of this resource other than an example target"
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
* status = #current
* mode = #working
* entry.item = Reference(ex-b-documentreference)
Instance: ex-b-documentreference
InstanceOf: DocumentReference
Title: "Dummy DocumentReference example"
Description: "Dummy DocumentReference example for completeness sake. No actual use of this resource other than an example target"
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
* status = #current
* content.attachment.title = "Hello World"
John Moehrke (Jan 13 2021 at 21:34):
is there a problem with that I indicate the Bundle may contain 0..* DocumentReference?
John Moehrke (Jan 13 2021 at 21:37):
is there a problem if I slice on #profile type and use FHIR core Resource as the profile? Overall I have a need to allow unprofiled Binary and Patient, while also requiring specific profiles of List and DocumentReference
John Moehrke (Jan 13 2021 at 21:48):
I have even a more simple one that fails.
Instance: ex-patient2
InstanceOf: Patient
Title: "Dummy Patient example"
Description: "Dummy patient example for completeness sake. No actual use of this resource other than an example target"
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
Instance: ex-dummyPatientBundle
InstanceOf: Bundle
Title: "Dummy Patient feed"
Description: "Example of a patient feed transaction Bundle."
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
* type = #transaction
* timestamp = 2020-11-24T23:50:50-05:00
* entry[0].resource = ex-patient2
* entry[0].fullUrl = "http://www.example.org/fhir/Patient/593cd04e-b696-45c1-bc32-39e55a340a99"
* entry[0].request.url = "Patient"
* entry[0].request.method = #POST
John Moehrke (Jan 13 2021 at 21:48):
surely someone can find where I did something stupid
Jean Duteau (Jan 13 2021 at 21:52):
it has nothing to do with the indexing because I removed the indexes and still get the error
John Moehrke (Jan 13 2021 at 21:52):
so... sushi bug? hope the new one comes along and has this fixed
Jean Duteau (Jan 13 2021 at 21:58):
yep, sushi bug. if you remove the entry[0].resource line or remove the ex-patient2 * meta.security line, it works.
Chris Moesel (Jan 13 2021 at 21:59):
Hmmm... It has something to do with the meta.security
assignment in the ex-patient2
assignment. If I comment out that line, all is well. So, yes, a SUSHI bug. Fixed in the next release? Not sure.
John Moehrke (Jan 13 2021 at 21:59):
what??? hmm.
John Moehrke (Jan 13 2021 at 22:00):
wow.. that is odd
ryan moehrke (Jan 13 2021 at 22:00):
meta tags can't be in contained resources, are you expecting every inline resource to be contained?
John Moehrke (Jan 13 2021 at 22:00):
bundle entry is not contained
John Moehrke (Jan 13 2021 at 22:00):
well, it is inside, but not contained
John Moehrke (Jan 13 2021 at 22:01):
ah... but that is a key to sushi bug root
Chris Moesel (Jan 13 2021 at 22:04):
It looks to me like there is probably some code in SUSHI that is assuming that if meta
exists then meta.profile
also exists -- which is obviously not the case.
Chris Moesel (Jan 13 2021 at 22:05):
OK. It's still broken in the SUSHI version we're about to release, but I suspect this may be a very simple fix. I'll take a quick look to see if I can find the issue and fix it before we release.
Chris Moesel (Jan 13 2021 at 22:08):
Yep. Found it and fixed it.
John Moehrke (Jan 14 2021 at 00:01):
was it related to the meta.security?
John Moehrke (Jan 14 2021 at 00:03):
is the new sushi available?
John Moehrke (Jan 14 2021 at 17:46):
note that resources that are assembled into a Bundle should be marked with "Usage: #inline" so that references within those resources are fixedup to the fullUrl in the Bundle... I did not know this. I did not see mention of this in the sushi documentation. I only understood #inline as for contained, I did not understand it also for Bundle.
John Moehrke (Jan 14 2021 at 17:46):
thanks again to @ryan moehrke -- of MoehrkeResearch
Jean Duteau (Jan 14 2021 at 17:57):
wait what? will SUSHI auto-create the fullUrl if I set each resource to be Usage: #inline and then add it to the Bundle? that would be great and useful if it did that.
John Moehrke (Jan 14 2021 at 17:59):
I am confirming right now... but it did stop the IG builder from crashing
John Moehrke (Jan 14 2021 at 18:00):
nope, it didn't
John Moehrke (Jan 14 2021 at 18:01):
but it did stop the IG build from crashing
John Moehrke (Jan 14 2021 at 18:01):
so, @Jean Duteau how do you handle this problem. I have many resources in the bundle that have interrelationships
Jean Duteau (Jan 14 2021 at 18:05):
if you look at my fhir-spl guide, I just put in references to the various example instances
Instance: NationalPharmaIndia
InstanceOf: LabelerOrganization
Description: "An example of a Labeler Organization."
* id = "a30accef-f437-4136-808c-9ed4ada5fcf8"
* identifier[DUNSNumber].value = "999999999"
* identifier[NDCCode].value = "55555"
* name = "National Pharma of India Inc."
* address.line = "Plot 102 Village Ave"
* address.city = "RangareddyDistrict"
* address.state = "Telangana"
* address.postalCode = "500002"
* address.country = "IND"
* contact.name.text = "Mr. John Doe_1"
* contact.telecom[Phone].value = "+9-140-11112222;ext=3333"
* contact.telecom[Email].value = "jdoe_1@npoiinc.net"
* contact.address.line = "Plot 101 First Street"
* contact.address.city = "RangareddyDistrict"
* contact.address.state = "Telangana"
* contact.address.postalCode = "500001"
* contact.address.country = "IND"
Instance: NationalPharmaIndiaUSAgent
InstanceOf: USAgentOrganization
Description: "An example of a US Agent Organization."
* identifier[DUNSNumber].value = "888888888"
* name = "National Pharma of India Inc. US Agent"
* telecom[Phone].value = "+1-908-999-1212;ext=444"
* telecom[Email].value = "jdoe_2@npoiinc.net"
Instance: NationalPharmaIndiaAffiliation
InstanceOf: USAgentAffiliation
Description: "An example of the linkage between a Labeler and a US Agent"
* organization = Reference(NationalPharmaIndia)
* participatingOrganization = Reference(NationalPharmaIndiaUSAgent)
Instance: NationalPharmaIndiaOperation
InstanceOf: LabelerBusinessOperation
Description: "An example of a Labeler's business operations."
* providedBy = Reference(NationalPharmaIndia)
* type = $NCI-T#C43360 "manufacture"
* serviceProvisionCode = $NCI-T#C106643 "Manufactures human prescription drug products"
Instance: NationalPharmaIndiaRequest
InstanceOf: LabelerCodeRequestBundle
Description: "An example of a Bundle containing a set of Labeler Code Request resources."
* identifier.system = "urn:ietf:rfc:3986"
* identifier.value = "urn:uuid:50606941-3e5d-465c-b4e0-0f5a19eb41d4"
* timestamp = "2002-08-11T01:01:01.111+06:00"
* entry[Labeler].resource = NationalPharmaIndia
* entry[Labeler].fullUrl = "http://example.org/a30accef-f437-4136-808c-9ed4ada5fcf8"
* entry[USAgent].resource = NationalPharmaIndiaUSAgent
* entry[USAgent].fullUrl = "http://example.org/NationalPharmaIndiaUSAgent"
* entry[USAgentAffiliation].resource = NationalPharmaIndiaAffiliation
* entry[USAgentAffiliation].fullUrl = "http://example.org/NationalPharmaIndiaAffiliation"
* entry[BusinessOperation].resource = NationalPharmaIndiaOperation
* entry[BusinessOperation].fullUrl = "http://example.org/NationalPharmaIndiaOperation"
Jean Duteau (Jan 14 2021 at 18:05):
that gets turned into: https://build.fhir.org/ig/HL7/fhir-spl/branches/main/Bundle-NationalPharmaIndiaRequest.json.html
John Moehrke (Jan 14 2021 at 18:10):
in my case my bundle is a transaction to CREATE the resources. so I need to use UUID... but I don't think that matters.
John Moehrke (Jan 14 2021 at 18:10):
but, when I do essentially what you have, I get a NPE in the IG build
John Moehrke (Jan 14 2021 at 18:16):
and isn't your example wrong? meaning the references to your Organization should be using the value of fullUrl of that entry in the bundle?
Jean Duteau (Jan 14 2021 at 18:57):
i don't think so. when I read the Resolving references in Bundles section (http://hl7.org/fhir/bundle.html#references), it says that the reference doesn't have to be an absolute reference , but it gets converted into a URL using the fullURL for that bundle entry
Jean Duteau (Jan 14 2021 at 18:58):
If the reference is not an absolute reference, convert it to an absolute URL:
if the reference has the format [type]/[id], and
if the fullUrl for the bundle entry containing the resource is a RESTful one (see the RESTful URL regex)
extract the [root] from the fullUrl, and append the reference (type/id) to it
then try to resolve within the bundle as for a RESTful URL reference.
John Moehrke (Jan 14 2021 at 19:43):
so in my case (a CREATE) i need to use urn:uuid in my fullUrl... I thus had to covert all of my bundle destine instances to use the UUID as their name, and references to the urn:uuid: of that name. (#inline had no effect on the examples output). But this version makes it thru the IG builder without NPE.
Instance: 593cd04e-b696-45c1-bc32-39e55a340a44
InstanceOf: IHE.MHD.Minimal.SubmissionSet
Title: "SubmissionSet for Minimal metadata in a bundle"
Description: "Example of a minimal submissionSet in List resource used in a bundle."
//Usage: #inline
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
* identifier[0].system = "urn:ietf:rfc:3986"
* identifier[0].value = "urn:oid:1.2.129.6.58.92.88337.5"
* identifier[0].use = #official
* identifier[1].system = "http://example.org/documents"
* identifier[1].value = "23425234-23470-5"
* identifier[1].use = #usual
* status = #current
* mode = #working
* code = MHDlistTypes#submissionset
* date = 2004-12-25T23:50:50-05:00
* entry[0].item = Reference(urn:uuid:593cd04e-b696-45c1-bc32-39e55a340a45)
* entry[1].item = Reference(urn:uuid:593cd04e-b696-45c1-bc32-39e55a340a46)
* extension[sourceId].valueIdentifier.value = "urn:oid:1.2.3.4"
Instance: 593cd04e-b696-45c1-bc32-39e55a340a46
InstanceOf: IHE.MHD.Minimal.DocumentReference
Title: "DocumentReference for Minimal metadata"
Description: "Example of a minimal DocumentReference resource. This is very unlikely to be acceptable anywhere, but it is the minimum required."
//Usage: #inline
* meta.security = http://terminology.hl7.org/CodeSystem/v3-ActReason#HTEST
* masterIdentifier.system = "urn:ietf:rfc:3986"
* masterIdentifier.value = "urn:oid:1.2.840.113556.1.8000.2554.53432.348.12973.17740.34205.4355.50220.62012"
* identifier.system = "urn:ietf:rfc:3986"
* identifier.value = "urn:uuid:7d5bb8ac-68ee-4926-85e7-b8aac8e1f09d"
* status = #current
* content.attachment.contentType = #text/plain
* content.attachment.url = "http://example.com/nowhere.txt"
John Moehrke (Jan 14 2021 at 19:45):
I would like to ask that sushi notice when a instance is being put into a Bundle and handle these fullUrl fixups for us. managing my examples with UUIDs is really not fun.
John Moehrke (Jan 14 2021 at 19:52):
so.. here is my resulting bundle
http://build.fhir.org/ig/IHE/ITI.MHD/branches/master/Bundle-ex-minimalProvideDocumentBundle.json.html
given this FSH input
https://github.com/IHE/ITI.MHD/blob/master/input/fsh/ex-ProvideBundles.fsh
Simone Heckmann (Mar 18 2021 at 09:56):
Yes, I'm struggling hard with a document Bundle right now. I ended up creating Aliases for both the UUID and the urn:uuid:UUID for each example and replaced all the IDs and references in the Bundle manually (because I wanted the individual examples to have "proper" URLs/IDs and only use UUIDs in the Bundle example.)
- entry[+].resource = CompositionExample
- entry[=].fullUrl = $COMPURL
- entry[=].resource.id = $COMPUUID
- entry[=].resource.subject.reference = $PATURL
- entry[=].resource.author.reference = $DEVURL
- entry[=].resource.section[0].entry[0].reference = $OBS1URL
- entry[=].resource.section[0].entry[1].reference = $OBS2URL
But hell, this is painfull!
What's also not helping is that you can't concat Aliases and do something like
- entry[=].fullUrl = urn:uuid:$MyUUID
Does anyone have an idea how to make this smoother...?
Chris Moesel (Mar 18 2021 at 13:09):
OK. Let me restate the use case to ensure I understand. You have Instances that you want to use as standalone examples and in example Bundles (e.g., entry.resource
). Given these instances:
- standalone example representations should have meaningful ids and standard reference URLs
- bundled representations should have UUID ids and urn:uuid reference URLs (so the bundle is self-contained)
Do I have that right? I think the difficulty here is that a truly efficient solution likely requires a Bundle-specific feature in FSH, but we try our best to keep FSH features/syntaxes more generalizable -- because if we get into too many resource-specific syntaxes, FSH becomes a lot harder to learn and master. But... this specific issue truly is "painful" (as you stated), so it would be nice if we could figure something out.
Simone Heckmann (Mar 18 2021 at 13:13):
Yes, the additional challenge is, that all the Bundle.entry.fullUrls need to be populated.
I'm not sure if I'm the only one who would like the individual Resource examples to have "standard" URLs, and only use the uuids when everything comes together in the Bundle. I just feel that looking at an individual Resource with a uuid reference poiting nowhere would be weird...
ryan moehrke (Mar 18 2021 at 15:08):
do aliases work the same way internally that ruleset parameters do? because I figured out that ^url = "prefix{param}" and Ruleset(abc) works
(vs ^url = "prefix" + {param} and Ruleset("abc") or whatever else you might think to try)
Chris Moesel (Mar 18 2021 at 15:43):
Aliases are a lot more rigid than parameters in RuleSets, partly because we don't have the nice {
}
mechanism w/ aliases to signal their use. Part of the issue is that aliases are used in places that arbitrary tokens can also be valid (and passed through as-is). With $
-prefixed aliases, we know that if we run into a place where a URL is expected, and the first character is $
, that must be an alias, because $
isn't a valid first character for a URL. But if the alias starts in the middle of a URL, it's harder to determine if that should be an alias or a literal $
in the middle of the URL -- and if it is an alias in the middle, how do we know where the alias ends and the rest of the literal URL begins? Anyway... that's why we only allow aliases as a full expression of a URL (instead of a partial one).
Elliot Silver (Mar 18 2021 at 17:02):
My two asks in this area are:
- the ability to reference id and/or Canonical of arbitrary resources, not just the limited, special syntax ones that are currently supported
- being able to compose urls. I'd really like to be able to define a "base" url for my project and have all the Canonical urls hang off that.
Chris Moesel (Mar 18 2021 at 17:32):
Elliot Silver said:
My two asks in this area are:
- the ability to reference id and/or Canonical of arbitrary resources, not just the limited, special syntax ones that are currently supported
The Canonical(SomeResource)
mechanism should work for any arbitrary resource as long as its findable in the scope of the IG (which includes IG-defined resources, FHIR core resources, and dependency IG resources). Here's a FSH Online Snippet that demonstrates that. Or am I misunderstanding?
As for id
, we don't currently have a comparable feature to be able to say Id(SomeResource)
. Is that what you're looking for?
- being able to compose urls. I'd really like to be able to define a "base" url for my project and have all the Canonical urls hang off that.
For most FSH definitions, the URL is automatically constructed based on the canonical URL of the IG. Are you talking specifically about Instance
s where you need to set the url
explicitly?
Elliot Silver (Mar 18 2021 at 17:45):
Chris Moesel said:
The
Canonical(SomeResource)
mechanism should work for any arbitrary resource as long as its findable in the scope of the IG (which includes IG-defined resources, FHIR core resources, and dependency IG resources). Here's a FSH Online Snippet that demonstrates that. Or am I misunderstanding?
Is that new? yes, line 6 is what I'm looking for.
As for
id
, we don't currently have a comparable feature to be able to sayId(SomeResource)
. Is that what you're looking for?
Yes, allowing you to wire up more complex examples, cross-referencing, etc.
For most FSH definitions, the URL is automatically constructed based on the canonical URL of the IG. Are you talking specifically about
Instance
s where you need to set theurl
explicitly?
Yes, or constructing the URL of fragments (StructureDefinition elements and Questionnaire items).
Chris Moesel (Mar 18 2021 at 17:56):
Is that new? yes, line 6 is what I'm looking for.
Yup. New in SUSHI 1.3.0, released about two weeks ago:
Support targeting an
Instance
with theCanonical
keyword (#743)
Chris Moesel (Mar 18 2021 at 18:06):
OK. I've just filed three issues related to these conversations:
- Consider new Id(...) mechanism to retrieve the id of a resource
- Investigate approaches to more flexible construction of URLs
- Investigate approaches to more natural (less frustrating) Bundle authoring
Last updated: Apr 12 2022 at 19:14 UTC