Stream: hapi
Topic: how to implement slice constraint
Dmitri Ilyin (Jan 29 2019 at 14:25):
Hi,
I have to implment a contraint on practitioner Identifier element.
My profile looks like:
<differential>
........
<element id="Practitioner.identifier">
<path value="Practitioner.identifier" />
<slicing>
<discriminator>
<type value="value" />
<path value="system" />
</discriminator>
<rules value="closed" />
</slicing>
<min value="1" />
<max value="1" />
<mustSupport value="true" />
</element>
<element id="Practitioner.identifier:LANR">
<path value="Practitioner.identifier" />
<sliceName value="LANR" />
<min value="1" />
<max value="1" />
<mustSupport value="true" />
</element>
<element id="Practitioner.identifier:LANR.system">
<path value="Practitioner.identifier.system" />
<min value="1" />
<fixedUri value="http://fhir.de/NamingSystem/kbv/lanr" />
<mustSupport value="true" />
</element>
<element id="Practitioner.identifier:LANR.value">
<path value="Practitioner.identifier.value" />
<mustSupport value="true" />
<min value="1" />
</element>
.......
</differential>
I have not realized what HAPI offers here.
I have realized how extentions works with Annotations, but not how constraints could be implemented.
Any suggestions or help are very appreciated.
Using FHIR practitioner resource i could make it just like this:
practitioner.addIdentifier().setSystem("http://fhir.de/NamingSystem/kbv/lanr").setValue("1234567");
But Practitioner without profile allows me to add other Idetifier, since it is a list.
I would like to have a practitioner implementation with only one Identifier.
Actually even with Element of StringType with special name: "LANR" for convinience, since system has fix value and hoping that HAPI deserialize this Element automaticaly.
So, ideally i want to have practitioner.setLanr() and practitioner.getLanr() methods.
I could use the method as simply wrapper and do something like:
setLanr(String value) {
getIdentifierFirstRep().setSystem("http://fhir.de/NamingSystem/kbv/lanr").setValue(value);
}
getLanr() {
getIdentifierFirstRep().getValue();
}
So, this methods were just for convinience here. To prevent the input of next Identifier i could declare addIdentifier() method as private and so on.
But are there any better way to do this with HAPI?
thanks and regards
Dmitri
Last updated: Apr 12 2022 at 19:14 UTC