Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support User Provided Examples of Logical Models #941

Merged
merged 5 commits into from
Oct 22, 2021

Conversation

jafeltra
Copy link
Collaborator

This PR makes a couple minor changes in order to support user provided instances of logical models. Right now, SUSHI does not do any additional processing of these examples and we don't yet support authoring examples of logical models in FSH, but SUSHI will no longer crash if the examples are provided and it properly builds an IG resource with the examples.

In order to provide an example of a logical model, you can author a logical model in FSH like usual, and you can provide either a JSON or XML version of an example of that logical model in either the input/resources or input/examples folder with the name Binary-{id}.json. You also need to provide additional configuration for that resource in the resources property of sushi-config.yaml. You need to specify name for the resource so the IG renders the name when it renders the link to the example, the exampleCanonical should reference the Logical Model that the example is an instance of so the IG publisher knows how to link it, and you need to add an extension to specify the format of the resource. The config entry I've been using to test looks like this:

resources:
  Binary/my-id:
    extension:
      - url: http://hl7.org/fhir/StructureDefinition/implementationguide-resource-format
        valueCode: application/fhir+json
    name: Example of LM
    exampleCanonical: http://example.org/StructureDefinition/MyLM

I've also been testing with a very simple Logical Model and very simple example:

// In any FSH file
Logical: MyLM
Id: MyLM
Title: "My LM"
Description: "This is mine"
* important 1..1 SU boolean "Is this resource important"

and

// In a file called Binary-my-id.json
{
  "resourceType": "MyLM",
  "id": "my-id",
  "important": true
}

If you run SUSHI and the publisher, you should see an Examples tab on the Logical Model page, which should link to the
my-id example. The example's page should should the JSON or XML representation on the Narrative Content tab and should show a Binary with base64 encoding on the JSON/XML tabs.

You should also be able to replace the Binary-my-id.json with the XML version of this file, change the valueCode from application/fhir+json to application/xml and everything should work the same. Most of these steps were from this Zulip thread, and the sample-ig has an example here.

Copy link
Collaborator

@mint-thompson mint-thompson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Could you add a test case showing what happens when there is an example of a logical model that is not properly declared in the configuration's resource list?

src/ig/IGExporter.ts Outdated Show resolved Hide resolved
Co-authored-by: Mint Thompson <[email protected]>
Copy link
Collaborator

@mint-thompson mint-thompson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a little confused when thinking of that test case to add, since what I said is just a fancy way of saying "what if the regular thing happens." So, this looks ready to go!

@julianxcarter julianxcarter self-assigned this Oct 22, 2021
Copy link
Contributor

@julianxcarter julianxcarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just needs a merge from master and this should be ready to merge 👍🏽

@jafeltra jafeltra merged commit 740edc0 into master Oct 22, 2021
@jafeltra jafeltra deleted the cimpl-936-instances-of-lm branch October 22, 2021 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants