FHIR Chat · How to constrain datatype · conformance

Stream: conformance

Topic: How to constrain datatype


view this post on Zulip Vadim Peretokin (Jul 08 2019 at 10:55):

How does one constrain a datatype? https://www.hl7.org/fhir/elementdefinition-definitions.html#ElementDefinition.type.profile says it can match any of the profiles, which invalidates it for the purposes of constraining because the datatype will always match the base profile in the specification.

view this post on Zulip Jose Costa Teixeira (Jul 08 2019 at 14:23):

I have a (possibly) related question: Can we say somewhere that for a given element, the max string length is 1K characters, instead of 1M?

view this post on Zulip Jose Costa Teixeira (Jul 08 2019 at 14:25):

is that the goal of ElementDefinition.maxLength ?

view this post on Zulip Eric Haas (Jul 08 2019 at 15:03):

@Jose Costa Teixeira yes

view this post on Zulip Grahame Grieve (Jul 08 2019 at 19:53):

I don't understand this question

view this post on Zulip Vadim Peretokin (Jul 09 2019 at 07:46):

I want to constrain SimpleQuantity to ensure that code is always present for a particular profile of mine

view this post on Zulip Vadim Peretokin (Jul 09 2019 at 07:46):

ElementDefinition.type.profile looks like should do the job is that correct?

view this post on Zulip Richard Townley-O'Neill (Jul 10 2019 at 00:16):

@Vadim Peretokin
Do you want to use an invariant or create a profile of SimpleQuantity?
Hl7 AU has a profile of the data type Address. See http://hl7.org.au/fhir/base/aubase1/StructureDefinition-au-address.html

view this post on Zulip Vadim Peretokin (Jul 10 2019 at 04:41):

@Richard Townley-O'Neill Do you use that extension anywhere?

view this post on Zulip Vadim Peretokin (Jul 10 2019 at 04:41):

The problem I have is with applying it so validation works

view this post on Zulip Richard Townley-O'Neill (Jul 11 2019 at 01:49):

@Vadim Peretokin
We have not used it.
But I got it to work.
Working locally from https://github.com/AuDigitalHealth/ci-fhir-stu3 I used Forge to change a profile of Organization thus:

      <path value="Organization.address" />
      <type>
        <code value="Address" />
        <profile value="http://hl7.org.au/fhir/StructureDefinition/au-address" />
      </type>
      <mustSupport value="true" />

I edited an example which claimed conformance to that profile of Organization to fail the address validation and got the following errors in the IGPublisher qa.html

Organization/084bafa0-866d-11e9-bc42-526af7764f64: Organization.address error   The address shall at least have text or a line [address.text.exists() or address.line.exists()]
Organization/084bafa0-866d-11e9-bc42-526af7764f64: Organization.address.state   warning ValueSet https://healthterminologies.gov.au/fhir/ValueSet/australian-states-territories-2 not found
Organization/084bafa0-866d-11e9-bc42-526af7764f64: Organization.address.country error   Value is 'NZ' but must be 'AU'

view this post on Zulip Vadim Peretokin (Jul 11 2019 at 08:14):

Ah, ok. So the Java validator then replaces the base profile with that one when making the snapshot, and the .NET one will soon too with 1.3... thank you for testing this @Richard Townley-O'Neill

view this post on Zulip Michel Rutten (Jul 18 2019 at 13:51):

Hi @Vadim Peretokin, datatype profiles are similar to resource profiles. A profile can constrain the datatype of an element:

1) By including inline constraints on the specific profile element and/or it's children
2) By specifying a datatype profile on the profile element, as @Richard Townley-O'Neill explains.

Option (2) allows you to re-use the same type constraints across multiple profiles.
Note that the FHIR .NET API and Forge support both approaches, and have done so for quite a while (STU3 & R4).

view this post on Zulip Vadim Peretokin (Jul 18 2019 at 14:03):

Yes that's right, I was unclear on how to actually apply that profile:

https://www.hl7.org/fhir/elementdefinition-definitions.html#ElementDefinition.type.profile says it can match any of the profiles, which invalidates it for the purposes of constraining because the datatype will always match the base profile in the specification.

But it looks like the differential overrides the snapshot (and you fixed that bug in the latest .NET release)

view this post on Zulip Michel Rutten (Jul 18 2019 at 14:21):

Yes, the ElementDefinition.type list property is "special", any type constraints specified in the differential will fully replace/override the original type list, as specified by the base profile. Whereas most other properties inherit omitted information from the base profile. This custom inheritance behavior is necessary to allow constraining polymorphic elements such as Extension.value[x].

view this post on Zulip Jose Costa Teixeira (Oct 01 2019 at 22:14):

any examples of using a contrained data type in a profile?
I have a profile on element - string320 (string with up to 320 characters) and I want to use it in communication.payload, but I can't get it to work.

view this post on Zulip Grahame Grieve (Oct 01 2019 at 22:15):

you should just put it in the profile on the type in the elementdefinition, and everything should work

view this post on Zulip Jose Costa Teixeira (Oct 01 2019 at 22:17):

this?
pasted image

view this post on Zulip Grahame Grieve (Oct 01 2019 at 22:22):

yes but you need a canonical URL

view this post on Zulip Jose Costa Teixeira (Oct 01 2019 at 22:23):

i had that - although the profile is actually not yet stored at that url, i.e. that canonical url does not exist yet - does it make a difference?

view this post on Zulip Grahame Grieve (Oct 01 2019 at 22:24):

no just needs to be in the IG or it's dependencies somewhere

view this post on Zulip Jose Costa Teixeira (Oct 01 2019 at 22:27):

that is what I had first, I think:
canonical = https://www.ehealth.fgov.be/standards/fhir/StructureDefinition/be-string320
and a file "structuredefinition-be-string320.xml" in my profiles folder

view this post on Zulip Jose Costa Teixeira (Oct 01 2019 at 22:27):

could it be my data type profile being incorrectly defined? I can track that tomorrow

view this post on Zulip Jose Costa Teixeira (Oct 26 2019 at 05:57):

I am still unable to successfully publish a constrained datatype - a string wtih <320 characters. I'm sure I'm missing something obvious. Any advice?

view this post on Zulip Jose Costa Teixeira (Oct 26 2019 at 06:00):

I looked at constrained datatypes in the core spec - positiveInt, markdown - and did it the same way, but it doesn't work.

view this post on Zulip Grahame Grieve (Oct 26 2019 at 12:24):

what does 'doesn't work' mean?

view this post on Zulip Jose Costa Teixeira (Oct 26 2019 at 20:09):

Exception generating resource C:\be-core\input\resources\structuredefinition-string320::StructureDefinition/string320: not the right kind of structure to generate schematrons for (02:10.0226)

view this post on Zulip Grahame Grieve (Oct 27 2019 at 00:16):

ah. can I reproduce this?

view this post on Zulip Jose Costa Teixeira (Oct 27 2019 at 06:19):

certainly:
https://github.com/hl7-be/be-core

view this post on Zulip Thomas Tveit Rosenlund (Oct 28 2019 at 10:59):

certainly:
https://github.com/hl7-be/be-core

The profile should still be of type "string" I think.
<type value="string320"/>

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 11:07):

i still get the same issue

view this post on Zulip Thomas Tveit Rosenlund (Oct 28 2019 at 11:22):

Just a quick question. Can you even profile a primitive datatype in FHIR?

Shure, I have profiled both the HumanName and Address datatypes for no-basis profiles, but never the string datatype directly.

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 11:26):

I guess that is my question too

view this post on Zulip Michel Rutten (Oct 28 2019 at 12:01):

Yes, FHIR allows you to profile any datatype, including primitives.

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 12:54):

my question then becomes "how" :)

view this post on Zulip Lloyd McKenzie (Oct 28 2019 at 13:09):

Look at the StructureDefinitions from the core spec to see how the primitives are actually defined

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 13:11):

I looked at the constrained datatypes (positiveInt, Markdown), and did the same (I think) for my string.
these: http://build.fhir.org/structuredefinition-examples.html

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 13:12):

@Lloyd McKenzie Do you mean I should do this not as a profile but as a core definition like I find in the package cache?

view this post on Zulip Grahame Grieve (Oct 28 2019 at 13:57):

you can do it as a profile. I just forgot to cater for this somewhere in the generation code (you can tell how often people have done it...)

view this post on Zulip Grahame Grieve (Oct 28 2019 at 13:58):

it's on my list, but I've been at the snomed conference

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:31):

I can't run this because you are using a template that you haven't released into the system

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:32):

and it should be hl7.be. not hl7be.

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:35):

you have a case error there somewhere - xsd:anyUri not xsd:anyURI

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:36):

Unable to generate snapshot for https://www.ehealth.fgov.be/standards/fhir/StructureDefinition/be-practitioner: Slicing rules on differential (type:item.resolve() (/open)) do not match those on base (type:$this (unordered/closed)) - disciminator @ Extension.value[x] (http://hl7.org/fhir/StructureDefinition/language)

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:40):

in your string profile:

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:40):

<derivation value="constraint"/>

view this post on Zulip Grahame Grieve (Oct 28 2019 at 14:40):

you can't define specializations of primitive data types, only constraints

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 16:39):

<derivation value="constraint"/>

Thank you @Grahame Grieve

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:03):

After I profile one element to use string320 instead of string, the IG Publisher still renders this as string:
pasted image

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:03):

pasted image

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:04):

pasted image

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:04):

is this a IG Publisher issue?

view this post on Zulip Grahame Grieve (Oct 28 2019 at 22:18):

yes looks like it to me

view this post on Zulip Grahame Grieve (Oct 28 2019 at 22:19):

have you committed

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:24):

just did

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:24):

wait not yet

view this post on Zulip Jose Costa Teixeira (Oct 28 2019 at 22:45):

ok just pushed

view this post on Zulip Grahame Grieve (Oct 28 2019 at 23:05):

.. github is blocked on the plane....

view this post on Zulip Rob Hausam (Oct 28 2019 at 23:06):

yeah, I've seen that happen, too

view this post on Zulip Grahame Grieve (Oct 29 2019 at 01:38):

ok fixed and new release is on the way

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 05:10):

still presents this as a string, should be string320..
pasted image
Interesting that in the logical model it correctly shows String320

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 06:29):

.. github is blocked on the plane....

So much for in-flight entertainment.. :)

view this post on Zulip Grahame Grieve (Oct 29 2019 at 06:59):

still presents this as a string

Sounds like you didn't pick up the new IG publisher

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 07:51):

I did.
I looked at the commits to the IG, I could not understand how those changes would resolve this.

view this post on Zulip Grahame Grieve (Oct 29 2019 at 09:11):

changes where in R5.ProfileUtilities

view this post on Zulip Grahame Grieve (Oct 29 2019 at 09:12):

about line 2946

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 09:35):

did you push that? I cannot find it in the recent pushes.

view this post on Zulip Grahame Grieve (Oct 29 2019 at 11:11):

https://github.com/hapifhir/org.hl7.fhir.core/commit/cc496623a6533aa937c25d9baa00082563efafcb

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 13:50):

ok. Sorry, i was looking at fhir-ig-publisher only and thre was something weird on my machine.
It works now, although it is still rendered differently:

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 13:51):

on the profile:
pasted image

view this post on Zulip Jose Costa Teixeira (Oct 29 2019 at 13:52):

pasted image
This is in the logical model

view this post on Zulip Grahame Grieve (Nov 08 2019 at 05:04):

is this sorted now?

view this post on Zulip Jose Costa Teixeira (Nov 08 2019 at 06:45):

I'm checking it with the latest publisher

view this post on Zulip Jose Costa Teixeira (Nov 08 2019 at 06:45):

I will know in 3 mins

view this post on Zulip Jose Costa Teixeira (Nov 08 2019 at 06:49):

it's as before: constraining data types is working fine.

view this post on Zulip Jose Costa Teixeira (Nov 08 2019 at 06:49):

the rendering is still different between the logical model and the profile

view this post on Zulip Jose Costa Teixeira (Nov 08 2019 at 06:49):

I don't know if this is intended. If not, it is just cosmetic so I did not really care about it.

view this post on Zulip Grahame Grieve (Nov 11 2019 at 06:40):

hmm how do I reproduce it?


Last updated: Apr 12 2022 at 19:14 UTC