FHIR Chat · Custom StructureDefinition using fhir-net-api · dotnet

Stream: dotnet

Topic: Custom StructureDefinition using fhir-net-api


view this post on Zulip Muhammad Abubakar Ikram (Apr 10 2017 at 10:51):

Hello everyone,

If I want to have custom StructureDefinition for my resource how to have it? using fhir-net-api?
more generally I want to implement profiling and I want constraints on my resources according to my healthcare ecosystem.

view this post on Zulip Brian Postlethwaite (Apr 10 2017 at 10:55):

Are you asking how to validate your resource using the fhir-net-api?

view this post on Zulip Muhammad Abubakar Ikram (Apr 10 2017 at 11:13):

Yes, I need to know how to validate a resource using fhir-net-api?

view this post on Zulip Muhammad Abubakar Ikram (Apr 11 2017 at 07:19):

I am validating resource like this but it is always giving error on all the servers I have tested.
FhirClient obj2 = new FhirClient("http://sqlonfhir-stu3.azurewebsites.net/fhir");
CapabilityStatement res = obj2.CapabilityStatement();
Validator obj = new Validator();
var a = obj.Validate(res);

view this post on Zulip Ewout Kramer (Apr 11 2017 at 08:22):

Hi Muhammad, although the validator is present in the STU3 distribution, most of its code is still DSTU2 - we just made it compile. We are updating that part of the code over the coming weeks, and it will be ready before may this year.

view this post on Zulip Muhammad Abubakar Ikram (Apr 12 2017 at 06:16):

Can I fairly bind my object models (of the resources that are compliant to my custom profiles) to the object models in the fhir-net-api?

view this post on Zulip Muhammad Abubakar Ikram (Apr 17 2017 at 09:13):

@Brian Postlethwaite Could you please help me? "Can I fairly bind my object models (of the resources that are compliant to my custom profiles) to the object models in the fhir-net-api?"

view this post on Zulip Brian Postlethwaite (Apr 21 2017 at 01:22):

Not sure what you're asking there

view this post on Zulip Muhammad Abubakar Ikram (Apr 26 2018 at 11:12):

@Brian Postlethwaite Sir I want to extend some of the default resources in FHIR such as Patient. I am using fhir-net-api stu3 that contains all the default models for all the resources in the FHIR. If I want to extend patient, for example, I want to add a new field to the patient resource how can I achieve that? How can I have customized model in fhir-net-api?

view this post on Zulip Grahame Grieve (Apr 26 2018 at 11:52):

you should use extensions

view this post on Zulip Muhammad Abubakar Ikram (Apr 26 2018 at 13:53):

@Grahame Grieve okay Sir, one thing more Let's say I have created StructureDefinition ExtendedPatient with some extensions then my FHIR server will also have the standard Patient resource? or my ExtendedPatient will overwrite the standard Patient?

view this post on Zulip Michel Rutten (Apr 30 2018 at 08:35):

Hi @Muhammad Abubakar, you could configure your server to reject patient resources that do not conform to your ExtendedPatient profile. The server can advertise this behavior to clients via it's CapabilityStatement:
http://hl7.org/fhir/capabilitystatement-definitions.html#CapabilityStatement.rest.resource.profile
BTW Vonk, the .NET FHIR Server, allows you to upload your profiles to a special Administration endpoint. Vonk will then automatically use those profiles for instance validation, and update the CapabilityStatement accordingly, at runtime and without restarting the server.

view this post on Zulip Muhammad Abubakar Ikram (May 02 2018 at 13:59):

I am trying to create a profile based on Patient with forge and trying to use it in fhir-net-api.

But, I am facing some issues.

I am just adding a custom email extension in Patient profile
Extension: https://simplifier.net/chs/EmailExtension
Profile: https://simplifier.net/chs/CHSPatient

Issues:
1. When I am validating patient profile on simplifier it gives error
Invalid : Instance failed constraint sdf-20 "No slicing on the root element"
StructureDefinition.differential[0]

2. When I am adding the structure definition of the patient profile in profiles-resources.xml in fhir-net-api, after updating templates it gives me a new class against CHSPatient, but when I make an object of CHSPatient it is missing email extension and also all other patient properties.

view this post on Zulip Michel Rutten (May 02 2018 at 14:41):

Hi @Muhammad Abubakar, concerning your questions:
Ad 1) This is caused by an invalid invariant fhirpath expression in the STU3 FHIR specification.
The current expression tests the first element in the differential component, however as the differential is sparse, the first element in the list is not guaranteed to be the root element.
See:
https://github.com/ewoutkramer/fhir-net-api/issues/424
https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_item_id=13768&start=0
This issue has already been reported and will be fixed in FHIR R4.
For now, you can safely ignore this validation message.
Ad 2) Please be aware that the T4 templates in the FHIR .NET API are specifically designed to generate the PoCo classes for the core resources and datatypes. However the templates were never designed to provide generic profile-based code generation. Also, the T4 template logic resembles spaghetti code and is not very maintainable. We may update the templates to another technology in the future.

view this post on Zulip Brian Postlethwaite (May 02 2018 at 23:20):

(Not by me though ;) - however I could clean them up a bit, but not much return on that)

view this post on Zulip Muhammad Abubakar Ikram (May 03 2018 at 04:52):

@Michel Rutten So, is there any other way that I can get my custom resource classes in fhir-net-api?

I am getting an another issue with forge that when I used to import the patient profile in forge from simplifier (profile link I have shared in previous message) it gives error on extension url refrence and it cannot resolve the url.

Another enhancement you can do with forge is that while importing the profile when we connect to the simplifier account it automatically selects the first entry it should not select first entry by default and the select button should be disabled that time

view this post on Zulip Brian Postlethwaite (May 03 2018 at 10:05):

Thought I'd share some more detailed comments on the how I personally use the fhir-net API with extentions, without doing the whole, lets create a new Patient that has my properties in it and try and shoe-horn it into the fhir serializers.
https://brianpos.com/2018/05/03/code-generation-fhir-custom-resources/
@James Agnew , interested if this would also apply to the HAPI java client too?

view this post on Zulip Muhammad Abubakar Ikram (May 04 2018 at 10:07):

@Brian Postlethwaite Sir, it is a very good approach that solves the problem of having custom properties in a predefined resource.

Sir, I have another requirement of also having a totally custom resource in FHIR. Sir can you please also guide me how I can achieve that?

view this post on Zulip Michael van der Zel (May 04 2018 at 11:41):

@Alexander Henket Would be great to have a extension package on top of the fhir-net-api based on the NL Profiles!? I know at least 1 PGO implementer that will use that :-)

view this post on Zulip Grahame Grieve (May 05 2018 at 03:56):

I don't think Java has helper methods. I certainly use them extensively in pascal

view this post on Zulip Grahame Grieve (May 05 2018 at 03:56):

I think in Java it has to be a wrapper class instead. generating these from profiles is on my list.

view this post on Zulip Grahame Grieve (May 05 2018 at 03:58):

btw, one thing to point out: you don't always know what profile a resource conforms to, nor will you know when reading a bundle. Nor will the profiles conform to a strict heirarchy. So trying to define subclasses doesn't match reality, but it's the hammer OO programmers are trained to know about ...

view this post on Zulip Brian Postlethwaite (May 05 2018 at 05:55):

Thanks, that was the other point I forgot to include in the post, will add an update to it.

view this post on Zulip Muhammad Abubakar Ikram (May 07 2018 at 09:37):

@Brian Postlethwaite if we use extensions like this in resources using fhir-net-api then how we can accommodate custom profiles? because the patient will have custom fields as well. Will we have their respective custom profiles on the StructureDefinition endpoint? or we will not have their respective custom profiles on the StructureDefinition?
because we have to validate the resources against the profiles

static class UsCorePatient
{
public static Code BirthSex(this Hl7.Fhir.Model.Patient me)
{
return me.GetExtensionValue<Code>("[URL birthsex extension]");
}
public static void BirthSex(this Hl7.Fhir.Model.Patient me,
Code value)
{
me.SetExtension("[URL birthsex extension]", value);
}
}

view this post on Zulip Brian Postlethwaite (May 07 2018 at 11:06):

A resource can conform to multiple profiles at the same time, and this IS how profiles are implemented in the fhir net api, and if you want to declare that your instance conforms to a specific profile, add that to the patient.meta.profile.Add("http://profile etc,...");
A structure definition will define exactly what those URLs that I have included above are for the custom patient profile.

view this post on Zulip Ewout Kramer (May 07 2018 at 16:21):

This is going to be even more (lexically) clean with the introduction of mixin extension properties in C# 8. (https://www.infoq.com/news/2017/08/CSharp-8). We'll have to see whether this makes it into C# 8 though.......


Last updated: Apr 12 2022 at 19:14 UTC