FHIR Chat · using us-core-race extension · dotnet

Stream: dotnet

Topic: using us-core-race extension


view this post on Zulip Erez Shalom (Jul 27 2021 at 19:13):

Hello everyone,
One of the business cases of my clients is delivering patient's "race". I was thinking to tell him to use the US Core patient profile because it has the "us-core-race" extension. This data will be transmitted as FHIR JSON to our side.
We use the dot.net library to parse this JSON (which is not aimed to support specific profiles), thus I have a doubt if this library can parse the "us-core-race" extension. will I be able to parse it with the dotnet library? if not, what are my options?

view this post on Zulip Michele Mottini (Jul 27 2021 at 19:59):

Yes, the standard .net library will handle that extension just fine

view this post on Zulip Gino Canessa (Jul 27 2021 at 19:59):

Hi Erez, I assume you are referring to the Firely Net SDK (e.g., NuGet package Hl7.Fhir.R4)? If so, you can use the US Core Race extension with the library.

There is a documentation page on extensions that has the basic syntax you will need. For that particular extension (by coincidence), I have some example code as well. UsCoreRace.cs has an extension class for Patient, which allows for code like:

Patient patient = new Patient();
patient.UsCoreRaceSet(
    "Race default text",
    new UsCoreRace.UsCoreOmbRaceCategoryValues[] { UsCoreRace.UsCoreOmbRaceCategoryValues.Unknown });

patient.UsCoreRaceTextSet("Updated text");

patient.UsCoreRaceOmbCategoryAdd(UsCoreRace.UsCoreOmbRaceCategoryValues.AmericanIndianOrAlaskaNative);
patient.UsCoreRaceOmbCategoryAdd(UsCoreRace.UsCoreOmbRaceCategoryValues.AmericanIndianOrAlaskaNative);
patient.UsCoreRaceOmbCategoryAdd(UsCoreRace.UsCoreOmbRaceCategoryValues.Asian);
patient.UsCoreRaceOmbCategoryAdd(UsCoreRace.UsCoreOmbRaceCategoryValues.Unknown);

That repo has links to some videos walking through how that code was written. (edit: which can serve as a more detailed walkthrough of using extensions with C# code)

view this post on Zulip Matthew Dugal (Jul 30 2021 at 15:25):

This is what I used to parse US Core Race. Any one see any issues with this?

var raceValues = castResource.Extension
    .Where(x => x.Url == "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race")
    .SelectMany(x => x.Extension)
    .Where(x => x.Value is Coding)
    .Select(x => x.Value as Coding);

view this post on Zulip Ewout Kramer (Jul 30 2021 at 15:41):

Looks ok. It doesn't work for you? Debugging Linq is not too easy, but you can take the full statement apart in single Where/Select/ etc and then debug....

view this post on Zulip Matthew Dugal (Jul 30 2021 at 15:57):

No it works fine. Just wanted a second set of eyes before making it a suggestion to Erez for parsing. Thank you BTW.

view this post on Zulip Michele Mottini (Jul 30 2021 at 19:21):

.OfType<Coding>()

view this post on Zulip Erez Shalom (Aug 05 2021 at 13:30):

Thanks everyone for your useful answers!


Last updated: Apr 12 2022 at 19:14 UTC