Stream: dotnet
Topic: NHS Transfer of care
Marc Riding (Oct 23 2018 at 13:14):
Marc Riding
12:01 PM
--- Moved from <Implementers>
Hi Guys,
I am really struggling here, any tutorials on using the hl7.fhir .net libs would be greatly appreciated.
Like I said, I am trying to construct something like https://nhsconnect.github.io/ITK-FHIR-Mental-Health-eDischarge/engage_jon_burrows.html
Just really confusing how to go about constructing this xml. Am really disappointed the nhs has just dropped us off at the deep end. Is anyone else going through the same thing ?
Ewout Kramer: Hi @Marc Riding, here is a link to the docs for the C# FHIR API: http://docs.simplifier.net/fhirnetapi/index.html
Martijn Harthoorn: Hi Marc, You probably need something like this:
var eoc = new EpisodeOfCare();
// add fields / data to the resource
var bundle = new Bundle();
bundle.Entry.Add(new Bundle.EntryComponent { Resource = eoc });
Ewout Kramer: If you have more questions on how to use it, join us at the #net stream.
Thanks for the help guys, really appreciate it, I will plod on using trial and error for now, I am making some progress, but very slow. Reminds me of when I first learnt to program, that sort of pace!
Thanks again
Marc Riding (Oct 23 2018 at 13:30):
I have got the following code working:
'' Create patient resource object. Dim myPat As Hl7.Fhir.Model.Patient myPat = New Hl7.Fhir.Model.Patient() myPat.BirthDate = "31/01/2001" '' Create Name resource object. Dim myHumanName = New HumanName() myHumanName.Given = New String() {"Marc"} myHumanName.Family = "Riding" myHumanName.Prefix = New String() {"Mr"} '' Create Address resource object. Dim myAddr = New Address myAddr.Text = "addrText1" '' Add name & addr to patient object myPat.Name.Add(myHumanName) myPat.Address.Add(myAddr) '' Create bundle object, add pat to bundle. Dim myBundle As New Bundle() myBundle.AddResourceEntry(myPat, "url0001") '' Dim myAdmitSection As New Composition.SectionComponent '' myAdmitSection.Title = "Admission Details" '' Dim myComposition As New Composition '' myComposition.Section.Add(myAdmitSection) '' myBundle.AddResourceEntry(myComposition) '' Serialize bundle to xml. Dim serializer As New FhirXmlSerializer() Dim rawxml = New FhirXmlSerializer().SerializeToString(myBundle) TextBox1.Text = rawxml
... This is producing the following XML:
<Bundle xmlns="http://hl7.org/fhir">
<entry>
<fullUrl value="url0001" />
<resource>
<Patient>
<name>
<family value="Riding" />
<given value="Marc" />
<prefix value="Mr" />
</name>
<birthDate value="31/01/2001" />
<address>
<text value="addrText1" />
</address>
</Patient>
</resource>
</entry>
</Bundle>
So I am making some progress, any hints on how to create the Composition and the slice("Admission Details") ? - the section I have that's commented is not working.
Marc
Yunwei Wang (Oct 23 2018 at 14:05):
Dim composition = new Hl7.Fhir.Model.Composition() '' assign composition properties '' add section Dim adSection = new Hl7.Fhir.Model.Composition.SectionComponent() adSection.Title = "Admission Details" '' add other section properties '' add adSection to composition composition.Section.Add(adSection )
Marc Riding (Oct 23 2018 at 14:17):
Hi Yunwei,
thanks for the reply buddy, do you know hew to add the composition to the Bundle ?
Yunwei Wang (Oct 23 2018 at 14:38):
The same as you added patient. Add composition as a resource entry to bundle
myBundle.addResourceEntry(composition, null)
Marc Riding (Oct 23 2018 at 14:58):
Thanks again Yunwei, I was missing the URL param, thought I was getting a type error.
Marc Riding (Oct 26 2018 at 09:42):
Hi guys,
Making good progress with things, got most of the eDischarge sections created and added to the bundle.
Wonder if anyone can advise me on creating a custom (NHS) resource/profile.
Below is what the example xml should come out like , so should I just construct it by hand using xml literals in .net ? or is there a more programmatical method to create these careConnect/NHS-specific entries ?
<entry> <fullUrl value="urn:uuid:f8deaa1e-62ac-41cb-a475-9df3ea737a8e"/> <resource> <AllergyIntolerance> <id value="f8deaa1e-62ac-41cb-a475-9df3ea737a8e"/> <meta> <profile value="https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-ITK-AllergyIntolerance-1"/> </meta> <identifier> <system value="https://tools.ietf.org/html/rfc4122"/> <value value="17faf6c5-2897-458d-9893-3428c755fffb"/> </identifier> <clinicalStatus value="active"/> <verificationStatus value="confirmed"/> <category value="food"/> <code> <coding> <system value="http://snomed.info/sct"/> <code value="256349002"/> <display value="Peanut - dietary"/> </coding> </code> <patient> <reference value="urn:uuid:f919dedc-3c62-462f-a171-8d86c5aaa074"/> </patient> <assertedDate value="2015-03-13"/> <reaction> <manifestation> <coding> <system value="http://snomed.info/sct"/> <code value="247472004"/> <display value="Weal"/> </coding> </manifestation> </reaction> </AllergyIntolerance> </resource> </entry>
Michel Rutten (Oct 26 2018 at 09:49):
Hi @Marc Riding, you can easily create resource instances programmatically using the PoCo classes from the Hl7.Fhir.Core library, for example:
var at = new Hl7.Fhir.Model.AllergyIntolerance() { Id = "1", Identifier = new List<Identifier>() { new Identifier("http://example.org/fhir/mysystem", "abc123") }, // ... };
Marc Riding (Nov 13 2018 at 12:22):
Hi all,
I am now creating these fhir resources, and have created the ones which have ready-made PoCo's from hl7.fhir.core (thanks Michel).
But for instance I would like to create a resource of profile type: https://fhir.nhs.uk/STU3/StructureDefinition/CareConnect-ITK-MedicationStatement-1
This uses http://hl7.org/fhir/StructureDefinition/MedicationStatement as the constrained type (this is like a base/superclass I assume ?)
So I am able to create the Hl7.Fhir.Model.MedicationStatement PoCo, but how do I create the care-connect version of the medication statement resource ?
Marc
Michele Mottini (Nov 13 2018 at 13:46):
You create a Hl7.Fhir.Model.MedictionStatement object filling it based on the profile rules: do not populate elements that are removed in the profile (like basedOn it seems), always fill all required elements etc.
Marc Riding (Nov 13 2018 at 14:11):
Thanks Michele,
That is what I was doing, but what about for elements that are in the custom profile, but NOT in the standard model ? - the one I need to create is the "medicationReference" element (it is 1..1 on the profile). Obviously there is no PoCo field or method/function for this element.
Marc
Michele Mottini (Nov 13 2018 at 14:27):
A profile cannot add new elements to a resource (except as extensions)
Michele Mottini (Nov 13 2018 at 14:28):
medicationReference
is part of MedicationStatament and it is in the class - look for MedicationElement
Michele Mottini (Nov 13 2018 at 14:29):
you have to set it to a ResourceReference so it is rendered as medicationReference
Michele Mottini (Nov 13 2018 at 14:31):
sorry - Medication not MedicationElement
Marc Riding (Nov 14 2018 at 09:50):
Thanks again Michele,
I am still having trouble with the example above. I cannot work out how to use the .net code to add a medication reference to a medication statement. Tbh I can't even seem do this in the standard model, let alone our custom nhs profile.
Also, when googling for custom fhir resources I came across this forums where @Ewout Kramer mentions about using profiles-resources.xml file to add custom resources to the .net/poco library. Is this an option ?
Edit - sorry, might be useful if I actually post the link to the forum ;)
https://github.com/ewoutkramer/fhir-net-api/issues/337
Richard Kavanagh (Nov 14 2018 at 14:39):
@Marc Riding If you send me the details of what you are attempting to do then I'll write you some example code to achieve it. PM me the the details
Michele Mottini (Nov 14 2018 at 16:31):
To set the medication reference: new Hl7.Fhir.Model.MedicationStatement { Medication = new Hl7.Fhir.Model.ResourceReference( "Medication/the-id") . . . }
Michele Mottini (Nov 14 2018 at 16:32):
Don't think trying to re-generate the library with profiles would be the way to go - everything you need is in the standard library
Kevin Mayfield (Nov 18 2018 at 13:07):
MedicationReference is in the standard resource profile. If it's help examples are on the demo CCRI server. This example has the TOC document broken down into sections and then resources within the section https://data.developer.nhs.uk/ccri/ed/patient/1172/document/8
This is based on the documentviewer which NHS TOC should have told you about.
Marc Riding (Nov 19 2018 at 11:46):
Thanks for all the help guys,
I managed to get the medication list and references created. They wouldn't serialize once I got them into the composition & bundle, but luckily enough for now we are relieved of creating these resources as our medications are not snomed-encoded - We are leaving the medications as xhtml at the section level for now.
Marc
Last updated: Apr 12 2022 at 19:14 UTC