FHIR Chat · Resource Models & Extensions · dotnet

Stream: dotnet

Topic: Resource Models & Extensions


view this post on Zulip JA (Nov 24 2020 at 05:21):

My organization is unclear on how to properly create a "CoveragePlan" resource.
For reference, the documentation is here: http://hl7.org/fhir/us/Davinci-drug-formulary/StructureDefinition-usdf-CoveragePlan.html

A couple questions we have are:
1) This resource has a number of required "extensions". What exactly does this look like in .NET? Something like the following?

List list = new Hl7.Fhir.Model.List();
list.addExtension(<extension-uri>, <some-value>);

2) How closely should the JSON of our CoveragePlan resource (which is a HL7.Fhir.Model.List) match the the example JSON provided on hl7.org? I ask this because the HL7.Fhir.Model.List model, when serialized, does not seem to match up with the example provided here: http://hl7.org/fhir/us/Davinci-drug-formulary/List-CoveragePlanV3004t.json.html

Any insight into these questions is very much appreciated.

view this post on Zulip Mirjam Baltus (Nov 24 2020 at 08:32):

JA said:

1) This resource has a number of required "extensions". What exactly does this look like in .NET? Something like the following?

The code you mention is correct for adding a simple extension. The CoveragePlan also uses a complex/nested extension, and you will need to build this structure first, before adding it to the List resource:

            var x = new Extension();
            // fill it with the main canonical URL of the definition
            x.Url = "http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierDefinition-extension";
            // add the first sub-extension
            x.AddExtension("drugTierID", new CodeableConcept(<system>,<value>));
            // etc
            list.Extension.Add(x);

2) How closely should the JSON of our CoveragePlan resource (which is a HL7.Fhir.Model.List) match the the example JSON provided on hl7.org? I ask this because the HL7.Fhir.Model.List model, when serialized, does not seem to match up with the example provided here: http://hl7.org/fhir/us/Davinci-drug-formulary/List-CoveragePlanV3004t.json.html

It should at least resemble the example json, and I hope it does after you have constructed the complex extension correctly. If not, please give us some more details on the differences between your json and the example.

view this post on Zulip Brian Postlethwaite (Nov 26 2020 at 02:04):

And by using the fhir NuGet packages, you don't need to worry about the json or xml formatting, as those libs handle all that properly.

view this post on Zulip Ger Vang (Dec 11 2020 at 17:20):

Mirjam Baltus said:

JA said:

1) This resource has a number of required "extensions". What exactly does this look like in .NET? Something like the following?

The code you mention is correct for adding a simple extension. The CoveragePlan also uses a complex/nested extension, and you will need to build this structure first, before adding it to the List resource:

            var x = new Extension();
            // fill it with the main canonical URL of the definition
            x.Url = "http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierDefinition-extension";
            // add the first sub-extension
            x.AddExtension("drugTierID", new CodeableConcept(<system>,<value>));
            // etc
            list.Extension.Add(x);

2) How closely should the JSON of our CoveragePlan resource (which is a HL7.Fhir.Model.List) match the the example JSON provided on hl7.org? I ask this because the HL7.Fhir.Model.List model, when serialized, does not seem to match up with the example provided here: http://hl7.org/fhir/us/Davinci-drug-formulary/List-CoveragePlanV3004t.json.html

It should at least resemble the example json, and I hope it does after you have constructed the complex extension correctly. If not, please give us some more details on the differences between your json and the example.

As JA mentioned, our Extension model when serialized doesn't match up with the example from http://hl7.org/fhir/us/Davinci-drug-formulary/List-CoveragePlanV3004t.json.html. Could it be because we're using Hl7.Fhir.R4 package version 1.9.0 and the example is using STU 1?

Here is an example code extension in a List:

List l = new List();
l.Status = List.ListStatus.Current;
l.Mode = ListMode.Snapshot;
l.Title = "All Coverage Plans";
l.Meta = new Meta() { Profile = new string[] { "http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-CoveragePlan" } };
l.Id = "CoveragePlans";
l.Entry = new List<List.EntryComponent>();

l.AddExtension("DrugTierDefinition", new CodeableConcept("http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierDefinition-extension", "code"));

Our extension output (Hl7.Fhir.R4 (1.9.0)):

"extension": [
          {
            "url": "DrugTierDefinition",
            "value": {
              "coding": [
                {
                  "systemElement": {
                    "value": "http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierDefinition-extension",
                    "elementId": null,
                    "extension": []
                  },
                  "versionElement": null,
                  "codeElement": {
                    "value": "code",
                    "elementId": null,
                    "extension": []
                  },
                  "displayElement": null,
                  "userSelectedElement": null,
                  "elementId": null,
                  "extension": []
                }
              ],
              "textElement": null,
              "elementId": null,
              "extension": []
            },
            "elementId": null,
            "extension": []
          }
        ]

Sample from http://hl7.org/fhir/us/Davinci-drug-formulary/List-CoveragePlanV3004t.json.html:
fhir_stu_extension.png

view this post on Zulip Mirjam Baltus (Dec 11 2020 at 18:53):

The STU1 mentioned in the Implementation Guide is just the version of the IG, not the FHIR version. The IG is based on FHIR R4, so if you use the Hl7.Fhir.R4 library, that should give the correct result.
However, I see in your example output that there are many fields that do not resemble correct FHIR data - it even has empty fields which FHIR does not allow. Question: do you use the Hl7.Fhir.Serialization library and the FhirJsonSerializer? If not, you will not likely end up with correct FHIR json.

view this post on Zulip Ger Vang (Dec 11 2020 at 19:56):

We are not using Hl7.Fhir.Serialization and FhirJsonSerializer. I will install the package and use FhirJsonSerializer to see if we can get it similar to the sample.

Also, thank you for clarifying the STU1.

view this post on Zulip Mirjam Baltus (Dec 11 2020 at 20:18):

The serializer should actually already be in the R4 library, just add a using statement with Hl7.Fhir.Serialization to the code and you should be able to find the serializer plus methods.
And I'm happy to help, those versionings have tripped me up multiple times as well!

view this post on Zulip Ger Vang (Dec 11 2020 at 21:01):

I actually had to install Hl7.Fhir.Serialization separately and upgrade Hl7.Fhir.R4 1.9.0 to 2.0.1 otherwise there will be runtime error since Hl7.Fhir.Serialization is on 2.0.1. The format looks good now.

fhir_npm.png

I'm trying to add these extensions from http://hl7.org/fhir/us/Davinci-drug-formulary/StructureDefinition-usdf-CoveragePlan.html but I'm unable to find "url, system, code and display".

http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierDefinition-extension
http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-Network-extension
http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-SummaryURL-extension
http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-PlanIDType-extension

view this post on Zulip Brian Postlethwaite (Dec 11 2020 at 21:59):

Looking at that profile it has some simple and complex extensions.
I'm assuming that you've got the simple ones working fine with
list.AddExtension(urlX, new FhirString("stuff"));

Complex extensions are made by adding extensions like the above to an extension, and then adding the comolex extension itself in place of the new fhir strng.

view this post on Zulip Ger Vang (Dec 14 2020 at 15:36):

Brian Postlethwaite said:

Looking at that profile it has some simple and complex extensions.
I'm assuming that you've got the simple ones working fine with
list.AddExtension(urlX, new FhirString("stuff"));

Complex extensions are made by adding extensions like the above to an extension, and then adding the comolex extension itself in place of the new fhir strng.

Are there any examples of how to do a complex extension?

view this post on Zulip Ger Vang (Dec 14 2020 at 22:13):

We ended up doing something like this. The serialized data looks similar to the sample output but I do have a few more questions.

What is the identifier value?
What is the Entry Item ResourceReference value?

            List l = new List();
            l.Identifier = new List<Identifier>() { new Identifier() { Value = "" } }; // what is this value?
            l.Entry.Add(new List.EntryComponent() { Item = new ResourceReference("") }); // what is this value?

            Extension drugTier = new Extension();
            drugTier.Url = "http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierDefinition-extension";

            drugTier.Extension.Add(new Extension("drugTierID", new CodeableConcept("http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-DrugTierCS", "generic", "Generic")));
            drugTier.Extension.Add(new Extension("mailOrder", new FhirBoolean(true)));
            l.Extension.Add(drugTier);

            l.Extension.Add(new Extension("http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-Network-extension", new FhirString("PREFERRED")));
            l.Extension.Add(new Extension("http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-SummaryURL-extension", new FhirString("http://url/to/formulary/information")));
            l.Extension.Add(new Extension("http://hl7.org/fhir/us/davinci-drug-formulary/StructureDefinition/usdf-PlanIDType-extension", new FhirString("HIOS-PLAN-ID")));

view this post on Zulip Mirjam Baltus (Dec 15 2020 at 19:38):

The identifier will be your identifier for your CoveragePlan. There does not seem to be an agreed upon system to use for it, so any value you want the plan to be identified by would be good.
The value of the entry should be a reference to a FormularyDrug, which is a profile on the MedicationKnowledge resource.
Check the diagram on the homepage of the IG (http://hl7.org/fhir/us/Davinci-drug-formulary/index.html) for the concepts involved and their links.

view this post on Zulip JA (Dec 18 2020 at 18:00):

Hey Mirjam, I have many questions and appreciate your continued support.

Mirjam Baltus said:

The identifier will be your identifier for your CoveragePlan.
The value of the entry should be a reference to a FormularyDrug, which is a profile on the MedicationKnowledge resource.

The JSON examples for a CoveragePlan seem to have exactly 1 identifier, and 1 entry.. My organization has many (2,000+) CoveragePlans. How does this look in our case? Should we be returning ALL of them as identifiers? Also, will there be an equal number of "entries"?
I assume there would be many entries (FormularyDrugs/MedicationKnowledges) per identifier.. Any insight is very much appreciated.

view this post on Zulip Mirjam Baltus (Dec 21 2020 at 08:17):

JA said:

The JSON examples for a CoveragePlan seem to have exactly 1 identifier, and 1 entry.. My organization has many (2,000+) CoveragePlans. How does this look in our case? Should we be returning ALL of them as identifiers?

I would indeed think that for each CoveragePlan you have in your system, you would have at least one identifier per plan. Depending on what the FHIR request is, you might have 1 or more CoveragePlans in your response.

Also, will there be an equal number of "entries"?
I assume there would be many entries (FormularyDrugs/MedicationKnowledges) per identifier.. Any insight is very much appreciated.

I would assume as well, but I have no knowledge of DaVinci Pdex. These kind of questions are best posed in the DaVinci streams, like #Da Vinci PDex Drug Formulary.


Last updated: Apr 12 2022 at 19:14 UTC