wierdly-looking
wierdly-looking

Reputation: 7

Understanding the difference between FHIR String_ vs String

I'm trying to understand the different between the uses of setText()/setLabel Vs. setTextSimple / setLabelSimple in the FHIR Reference implementation.

What use cases would require the use of the String_ primitive type instead of the plain old setLabelSimple() approach? I've tried looking at several examples of use, and I cant really see why i'd favor one over the other. As far as I can see, both perform exactly the same, and the String_ object's value gets assigned to a plain old Java String object anyway...

Is there a preferred mode of use that anyone would recommend ? and if so, why ?

Upvotes: 0

Views: 277

Answers (1)

Grahame Grieve
Grahame Grieve

Reputation: 3586

The FHIR string type has extensions and an xml id:

 <text value="[text value]" id="[id]">
   <extension url="[url]">
     <value[x] ... />
   </extension>
 </text>

The String_ getText() returns a type that has a getValue(), and a getXmlId(), and a getExtension() which returns a list of the extensions.

The java.lang.String getTextSimple() ignores the id and the extension, and returns the @value - it's a convenience short cut.

When would you use getText() instead of getTextSimple()? - when you want to deal with extensions or internal cross references. Otherwise, just use ...Simple().

(In fact, it's on my list of todos to flip them over, and have java.lang.String getText(), and String_ getTextObject() or something, as the .Net reference implementation does)

Upvotes: 1

Related Questions