Stream: dotnet
Topic: using us-core-race extension
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?
Michele Mottini (Jul 27 2021 at 19:59):
Yes, the standard .net library will handle that extension just fine
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)
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);
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....
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.
Michele Mottini (Jul 30 2021 at 19:21):
.OfType<Coding>()
Erez Shalom (Aug 05 2021 at 13:30):
Thanks everyone for your useful answers!
Last updated: Apr 12 2022 at 19:14 UTC