FHIR Chat · Message definitions with firely-net-sdk · dotnet

Stream: dotnet

Topic: Message definitions with firely-net-sdk


view this post on Zulip Pash (Mar 11 2021 at 09:26):

Hi everyone.
I need to validate the incoming message and have public message definitions to restrict resources/codes etc by event type. Please advise how to create a message definition (well, probably creation is simple - just use models from the lib but anyway) and validate incoming messages using it with firely-net-sdk?

view this post on Zulip René Spronk (Mar 11 2021 at 09:29):

Defining a message structure (=profiling) isn't easy at all [if you're new to it], see http://build.fhir.org/conformance-module.html .. creating/parsing a message is easy, as is validation, using the ,net SDK, the definition of a profile is not.

view this post on Zulip Pash (Mar 11 2021 at 10:09):

@René Spronk I see. So starting from the easiest: just check if the message contains 1 Patient. Assume this definition is created: https://www.codepile.net/pile/kBLDjWB9 (in memory. By the way, please feel free to add notes there is something looks wrong), how to use it to check the message? I want to investigate how hard is to do it using the best practices and obviously dirty workaround here - validate it manually.

view this post on Zulip René Spronk (Mar 11 2021 at 10:17):

Validation strategies can be found here: http://build.fhir.org/validation.html - what approach you choose depends on your requirements

view this post on Zulip Pash (Mar 11 2021 at 11:06):

@René Spronk hm, I need only validation with MessageDefinition, don't need full profile validation (not sure if it possible, but it is also my question). So just need to check if Bundle with a specific event type (in the MessageHeader) has a set of resources (and additionally validate some properties in that resources, but lets start from an easier example ) and be able to publish that profiles as contracts for third parties. Any advice on how to do it with firely-net-sdk?

view this post on Zulip René Spronk (Mar 11 2021 at 11:08):

I'm not a .net SDK user myself, so I'll leave that to others to respond to.

view this post on Zulip Pash (Mar 11 2021 at 11:13):

@René Spronk np, thank you for help!

@Mirjam Baltus probably you can help with my stupid question?

view this post on Zulip Mirjam Baltus (Mar 11 2021 at 11:57):

@Pash Actually this is not a stupid question at all, but I also have to say that I do not know of a straightforward solution. I think you will have to code the validation by hand.
The MessageHeader of the message could contain a link to the MessageDefinition. With that, I would try to see if the MessageHeader.event[x] matches the one in the definition. Or, if it is not linked, I would try to find the relevant MessageDefinition by using a lookup on the event code in the MessageHeader. After that, I would run through the focus resources in the definition to see if they are listed in the message header, plus also perhaps do a check on the Bundle to see if they're included. But again, this would all be done by coding the important parts of my checks.

view this post on Zulip Pash (Mar 16 2021 at 21:17):

Trying to validate Resource using custom StructureDefinition. In MessageDefinition I have reference to custom StructureDefinition (where specified validation rules valid ONLY in the current context). How to validate resource by only 1 (and every time different) StructureDefinition? I see it is "InMemoryProfileResolver" in FHIR NET lib, but it is private. So I need to create profile resolvers and validators on a fly (not sure if it is a good solution). Any advice?

view this post on Zulip Pash (Mar 16 2021 at 21:46):

Should I create my own custom IResourceResolver?

view this post on Zulip Mirjam Baltus (Mar 23 2021 at 12:43):

@Pash You can point the validator to use a specific profile to validate against. Here's an example:

var source = new CachedResolver(new MultiResolver(new DirectorySource(@"MyProfileFolder",
                    new DirectorySourceSettings() { IncludeSubDirectories = true }),
                    ZipSource.CreateValidationSource()));

var ctx = new ValidationSettings
{
    ResourceResolver = source,
    GenerateSnapshot = true,
};
var validator = new Validator(ctx);

var result = validator.Validate(pat, @"http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");

My example just validates a Patient poco against the US Core Patient profile.
If you put all your custom profiles in the folder, you can expand the last line to validate against a specific profile depending on some determining value.

view this post on Zulip Jeena a (Mar 30 2021 at 15:44):

Hi,
I am using the .net firely library to validate my bundle resource and I get an error on the extenisons - {Text="Unable to resolve reference to profile 'http://XXX/patient-code'"} this is expected in my case as the extensions haven't been published yet. Is there a way to treat these as just warnings. and not error to be able to validate the bundle.

view this post on Zulip Marten Smits (Mar 31 2021 at 14:31):

See my answer here: https://github.com/FirelyTeam/firely-net-sdk/discussions/1675


Last updated: Apr 12 2022 at 19:14 UTC