Stream: implementers
Topic: Slice using .NET Nuget
Jakob Lindblad (Dec 03 2018 at 13:09):
Hi!
Might be a diffuse question but im stuck so ill give it a try here.
Is it possible to slice attributes using the HL7.Fhir Nuget package in .NET and is there any guides or documentation on how to do this?
I have created a basic 'ActivityDefintion' and want to slice the attribute 'DynamicValue' into "4 slices" and add a 'Code' to every slice.
This is an example of a ActivityDefintion in C# and what i want to slice.
ActivityDefinition activityDefintion = new ActivityDefinition() { Version = "1", Name = "ActivityDefintion", Status = PublicationStatus.Active, Experimental = true, Date = DateTime.UtcNow.ToString(), Publisher = "Jakob", Kind = ResourceType.Task, ApprovalDate = DateTime.UtcNow.ToString(), LastReviewDate = DateTime.UtcNow.ToString(), Library = new List<ResourceReference>() { }, DynamicValue = new List<ActivityDefinition.DynamicValueComponent>() { //I want to slice this } };
Im not expecting anyone to just give med the answer in code but hopefully there is some documentation out there iv missed on how to do this , slicing is a bit fresh for me :-).
Thanks!
Ewout Kramer (Dec 03 2018 at 13:18):
Hi Jakob - "slicing" is something that is defined in "profiles" (https://www.hl7.org/fhir/profiling.html) - basically a FHIR definition mechanism for adding additional constraints and validations on top of the FHIR "core" resources. In the C# implementation, the C# classes are generated from the "core" resources, not from these additional profiles, so there is no reflection of the slicing you might define in a profile in the generated C# classes. Assuming you want to express your slices "statically", that is.
I could also read your question as being about defining a set of criterion ad-hoc (in code here) and then running them "live" on an instance to group the contents of a list into sub-groups. This is not possible yet but I am looking for ways for you to do this in code, instead of having to create a profile. This is however still in the early stages. Ping me if you'd like to know more.
Jakob Lindblad (Dec 03 2018 at 13:36):
@Ewout Kramer Thank you for the clarification and fast reply.
I made a profile in Forge where i sliced like this so basically what i wanted to achive was to create an instance of that profile in code, then cast it to JSON to be able to see a preview on how a valid instance of my profile would look like (the slices more specifically).
Ewout Kramer (Dec 03 2018 at 14:48):
So, you will not see this in the output - the xml/json format does not indicate in which slice the data goes. Also, when you parse the data and use the C# model, you will not see the slices. These slices (for C#) only exist as a concept in a profile, where you can specify additional constraints using slices - so the .NET validator will know while validating using the profile, but there's no trace left of it in either the instance or the POCO model.
Jakob Lindblad (Dec 04 2018 at 07:16):
So, you will not see this in the output - the xml/json format does not indicate in which slice the data goes. Also, when you parse the data and use the C# model, you will not see the slices. These slices (for C#) only exist as a concept in a profile, where you can specify additional constraints using slices - so the .NET validator will know while validating using the profile, but there's no trace left of it in either the instance or the POCO model.
Ok. I misunderstood some basics about the slicing. Thank you for the help!
Last updated: Apr 12 2022 at 19:14 UTC