001package org.hl7.fhir.dstu2016may.utils;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009    
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030 */
031
032
033
034import java.net.URISyntaxException;
035
036/*
037Copyright (c) 2011+, HL7, Inc
038All rights reserved.
039
040Redistribution and use in source and binary forms, with or without modification, 
041are permitted provided that the following conditions are met:
042
043 * Redistributions of source code must retain the above copyright notice, this 
044   list of conditions and the following disclaimer.
045 * Redistributions in binary form must reproduce the above copyright notice, 
046   this list of conditions and the following disclaimer in the documentation 
047   and/or other materials provided with the distribution.
048 * Neither the name of HL7 nor the names of its contributors may be used to 
049   endorse or promote products derived from this software without specific 
050   prior written permission.
051
052THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
053ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
054WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
055IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
056INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
057NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
058PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
059WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
060ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
061POSSIBILITY OF SUCH DAMAGE.
062
063 */
064
065import java.util.ArrayList;
066import java.util.Iterator;
067import java.util.List;
068
069import org.apache.commons.lang3.StringUtils;
070import org.hl7.fhir.dstu2016may.model.BooleanType;
071import org.hl7.fhir.dstu2016may.model.CodeSystem;
072import org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent;
073import org.hl7.fhir.dstu2016may.model.CodeType;
074import org.hl7.fhir.dstu2016may.model.CodeableConcept;
075import org.hl7.fhir.dstu2016may.model.Coding;
076import org.hl7.fhir.dstu2016may.model.DataElement;
077import org.hl7.fhir.dstu2016may.model.DomainResource;
078import org.hl7.fhir.dstu2016may.model.Element;
079import org.hl7.fhir.dstu2016may.model.ElementDefinition;
080import org.hl7.fhir.dstu2016may.model.Extension;
081import org.hl7.fhir.dstu2016may.model.ExtensionHelper;
082import org.hl7.fhir.dstu2016may.model.Factory;
083import org.hl7.fhir.dstu2016may.model.Identifier;
084import org.hl7.fhir.dstu2016may.model.IntegerType;
085import org.hl7.fhir.dstu2016may.model.MarkdownType;
086import org.hl7.fhir.dstu2016may.model.PrimitiveType;
087import org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemComponent;
088import org.hl7.fhir.dstu2016may.model.Questionnaire.QuestionnaireItemType;
089import org.hl7.fhir.dstu2016may.model.StringType;
090import org.hl7.fhir.dstu2016may.model.Type;
091import org.hl7.fhir.dstu2016may.model.UriType;
092import org.hl7.fhir.dstu2016may.model.ValueSet;
093import org.hl7.fhir.exceptions.FHIRFormatError;
094import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
095
096
097public class ToolingExtensions {
098
099  // validated
100  public static final String EXT_SUBSUMES = "http://hl7.org/fhir/StructureDefinition/codesystem-subsumes"; 
101  private static final String EXT_OID = "http://hl7.org/fhir/StructureDefinition/valueset-oid";
102//  public static final String EXT_DEPRECATED = "http://hl7.org/fhir/StructureDefinition/codesystem-deprecated";
103  public static final String EXT_DEFINITION = "http://hl7.org/fhir/StructureDefinition/valueset-definition";
104  public static final String EXT_COMMENT = "http://hl7.org/fhir/StructureDefinition/valueset-comments";
105  private static final String EXT_IDENTIFIER = "http://hl7.org/fhir/StructureDefinition/identifier";
106  private static final String EXT_TRANSLATION = "http://hl7.org/fhir/StructureDefinition/translation";
107  public static final String EXT_ISSUE_SOURCE = "http://hl7.org/fhir/StructureDefinition/operationoutcome-issue-source";
108  public static final String EXT_DISPLAY_HINT = "http://hl7.org/fhir/StructureDefinition/structuredefinition-display-hint"; 
109  public static final String EXT_REPLACED_BY = "http://hl7.org/fhir/StructureDefinition/valueset-replacedby";
110  public static final String EXT_JSON_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type"; 
111  public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type"; 
112  public static final String EXT_REGEX = "http://hl7.org/fhir/StructureDefinition/structuredefinition-regex"; 
113  public static final String EXT_CONTROL = "http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl"; 
114  public static final String EXT_MINOCCURS = "http://hl7.org/fhir/StructureDefinition/questionnaire-minOccurs"; 
115  public static final String EXT_MAXOCCURS = "http://hl7.org/fhir/StructureDefinition/questionnaire-maxOccurs";
116  public static final String EXT_ALLOWEDRESOURCE = "http://hl7.org/fhir/StructureDefinition/questionnaire-allowedResource";
117  public static final String EXT_REFERENCEFILTER = "http://hl7.org/fhir/StructureDefinition/questionnaire-referenceFilter";
118
119  // unregistered?
120
121//  public static final String EXT_FLYOVER = "http://hl7.org/fhir/Profile/questionnaire-extensions#flyover";
122//  private static final String EXT_QTYPE = "http://www.healthintersections.com.au/fhir/Profile/metadata#type";
123//  private static final String EXT_QREF = "http://www.healthintersections.com.au/fhir/Profile/metadata#reference";
124//  private static final String EXTENSION_FILTER_ONLY = "http://www.healthintersections.com.au/fhir/Profile/metadata#expandNeedsFilter";
125//  private static final String EXT_TYPE = "http://www.healthintersections.com.au/fhir/Profile/metadata#type";
126//  private static final String EXT_REFERENCE = "http://www.healthintersections.com.au/fhir/Profile/metadata#reference";
127  private static final String EXT_FHIRTYPE = "http://hl7.org/fhir/StructureDefinition/questionnaire-fhirType";
128  private static final String EXT_ALLOWABLE_UNITS = "http://hl7.org/fhir/StructureDefinition/elementdefinition-allowedUnits";
129  public static final String EXT_CIMI_REFERENCE = "http://hl7.org/fhir/StructureDefinition/cimi-reference";
130  public static final String EXT_UNCLOSED = "http://hl7.org/fhir/StructureDefinition/valueset-unclosed";
131  public static final String EXT_FMM_LEVEL = "http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm";
132  
133
134  // specific extension helpers
135
136  public static Extension makeIssueSource(Source source) {
137    Extension ex = new Extension();
138    // todo: write this up and get it published with the pack (and handle the redirect?)
139    ex.setUrl(ToolingExtensions.EXT_ISSUE_SOURCE);
140    CodeType c = new CodeType();
141    c.setValue(source.toString());
142    ex.setValue(c);
143    return ex;
144  }
145
146  public static boolean hasExtension(DomainResource de, String url) {
147    return getExtension(de, url) != null;
148  }
149
150  public static boolean hasExtension(Element e, String url) {
151    return getExtension(e, url) != null;
152  }
153
154  public static void addStringExtension(DomainResource dr, String url, String content) {
155    if (!StringUtils.isBlank(content)) {
156      Extension ex = getExtension(dr, url);
157      if (ex != null)
158        ex.setValue(new StringType(content));
159      else
160        dr.getExtension().add(Factory.newExtension(url, new StringType(content), true));   
161    }
162  }
163
164  public static void addMarkdownExtension(DomainResource dr, String url, String content) {
165    if (!StringUtils.isBlank(content)) {
166      Extension ex = getExtension(dr, url);
167      if (ex != null)
168        ex.setValue(new StringType(content));
169      else
170        dr.getExtension().add(Factory.newExtension(url, new MarkdownType(content), true));   
171    }
172  }
173
174  public static void addStringExtension(Element e, String url, String content) {
175    if (!StringUtils.isBlank(content)) {
176      Extension ex = getExtension(e, url);
177      if (ex != null)
178        ex.setValue(new StringType(content));
179      else
180        e.getExtension().add(Factory.newExtension(url, new StringType(content), true));   
181    }
182  }
183
184  public static void addIntegerExtension(DomainResource dr, String url, int value) {
185    Extension ex = getExtension(dr, url);
186    if (ex != null)
187      ex.setValue(new IntegerType(value));
188    else
189      dr.getExtension().add(Factory.newExtension(url, new IntegerType(value), true));   
190  }
191
192  public static void addComment(Element nc, String comment) {
193    if (!StringUtils.isBlank(comment))
194      nc.getExtension().add(Factory.newExtension(EXT_COMMENT, Factory.newString_(comment), true));   
195  }
196
197//  public static void markDeprecated(Element nc) {
198//    setDeprecated(nc);   
199//  }
200//
201  public static void addSubsumes(ConceptDefinitionComponent nc, String code) {
202    nc.getModifierExtension().add(Factory.newExtension(EXT_SUBSUMES, Factory.newCode(code), true));   
203  }
204
205  public static void addDefinition(Element nc, String definition) {
206    if (!StringUtils.isBlank(definition))
207      nc.getExtension().add(Factory.newExtension(EXT_DEFINITION, Factory.newString_(definition), true));   
208  }
209
210  public static void addDisplayHint(Element def, String hint) {
211    if (!StringUtils.isBlank(hint))
212      def.getExtension().add(Factory.newExtension(EXT_DISPLAY_HINT, Factory.newString_(hint), true));   
213  }
214
215  public static String getDisplayHint(Element def) {
216    return readStringExtension(def, EXT_DISPLAY_HINT);    
217  }
218
219  public static String readStringExtension(Element c, String uri) {
220    Extension ex = ExtensionHelper.getExtension(c, uri);
221    if (ex == null)
222      return null;
223    if (ex.getValue() instanceof UriType)
224      return ((UriType) ex.getValue()).getValue();
225    if (!(ex.getValue() instanceof StringType))
226      return null;
227    return ((StringType) ex.getValue()).getValue();
228  }
229
230  public static String readStringExtension(DomainResource c, String uri) {
231    Extension ex = getExtension(c, uri);
232    if (ex == null)
233      return null;
234    if ((ex.getValue() instanceof StringType))
235      return ((StringType) ex.getValue()).getValue();
236    if ((ex.getValue() instanceof UriType))
237      return ((UriType) ex.getValue()).getValue();
238    if ((ex.getValue() instanceof MarkdownType))
239      return ((MarkdownType) ex.getValue()).getValue();
240    return null;
241  }
242
243  @SuppressWarnings("unchecked")
244  public static PrimitiveType<Type> readPrimitiveExtension(DomainResource c, String uri) {
245    Extension ex = getExtension(c, uri);
246    if (ex == null)
247      return null;
248    return (PrimitiveType<Type>) ex.getValue();
249  }
250
251  public static boolean findStringExtension(Element c, String uri) {
252    Extension ex = ExtensionHelper.getExtension(c, uri);
253    if (ex == null)
254      return false;
255    if (!(ex.getValue() instanceof StringType))
256      return false;
257    return !StringUtils.isBlank(((StringType) ex.getValue()).getValue());
258  }
259
260  public static Boolean readBooleanExtension(Element c, String uri) {
261    Extension ex = ExtensionHelper.getExtension(c, uri);
262    if (ex == null)
263      return null;
264    if (!(ex.getValue() instanceof BooleanType))
265      return null;
266    return ((BooleanType) ex.getValue()).getValue();
267  }
268
269  public static boolean findBooleanExtension(Element c, String uri) {
270    Extension ex = ExtensionHelper.getExtension(c, uri);
271    if (ex == null)
272      return false;
273    if (!(ex.getValue() instanceof BooleanType))
274      return false;
275    return true;
276  }
277
278  public static String getComment(ConceptDefinitionComponent c) {
279    return readStringExtension(c, EXT_COMMENT);    
280  }
281//
282//  public static Boolean getDeprecated(Element c) {
283//    return readBooleanExtension(c, EXT_DEPRECATED);    
284//  }
285
286  public static boolean hasComment(ConceptDefinitionComponent c) {
287    return findStringExtension(c, EXT_COMMENT);    
288  }
289
290//  public static boolean hasDeprecated(Element c) {
291//    return findBooleanExtension(c, EXT_DEPRECATED);    
292//  }
293
294  public static List<CodeType> getSubsumes(ConceptDefinitionComponent c) {
295    List<CodeType> res = new ArrayList<CodeType>();
296
297    for (Extension e : c.getExtension()) {
298      if (EXT_SUBSUMES.equals(e.getUrl()))
299        res.add((CodeType) e.getValue());
300    }
301    return res;
302  }
303
304  public static void addFlyOver(QuestionnaireItemComponent item, String text){
305    if (!StringUtils.isBlank(text)) {
306        QuestionnaireItemComponent display = item.addItem();
307        display.setType(QuestionnaireItemType.DISPLAY);
308        display.setText(text);
309        display.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept("flyover", "http://hl7.org/fhir/questionnaire-item-control", "Fly-over"), true));
310    }
311  }
312
313  public static void addMin(QuestionnaireItemComponent item, int min) {
314    item.getExtension().add(Factory.newExtension(EXT_MINOCCURS, Factory.newInteger(min), true));
315  }
316  
317  public static void addMax(QuestionnaireItemComponent item, int max) {
318    item.getExtension().add(Factory.newExtension(EXT_MAXOCCURS, Factory.newInteger(max), true));
319  }
320  
321  public static void addFhirType(QuestionnaireItemComponent group, String value) {
322    group.getExtension().add(Factory.newExtension(EXT_FHIRTYPE, Factory.newString_(value), true));       
323  }
324
325  public static void addControl(QuestionnaireItemComponent group, String value) {
326    group.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept(value, "http://hl7.org/fhir/questionnaire-item-control", value), true));
327  }
328
329  public static void addAllowedResource(QuestionnaireItemComponent group, String value) {
330    group.getExtension().add(Factory.newExtension(EXT_ALLOWEDRESOURCE, Factory.newCode(value), true));       
331  }
332
333  public static void addReferenceFilter(QuestionnaireItemComponent group, String value) {
334    group.getExtension().add(Factory.newExtension(EXT_REFERENCEFILTER, Factory.newString_(value), true));       
335  }
336
337  public static void addIdentifier(Element element, Identifier value) {
338    element.getExtension().add(Factory.newExtension(EXT_IDENTIFIER, value, true));       
339  }
340
341  /**
342   * @param name the identity of the extension of interest
343   * @return The extension, if on this element, else null
344   */
345  public static Extension getExtension(DomainResource resource, String name) {
346    if (name == null)
347      return null;
348    if (!resource.hasExtension())
349      return null;
350    for (Extension e : resource.getExtension()) {
351      if (name.equals(e.getUrl()))
352        return e;
353    }
354    return null;
355  }
356
357  public static Extension getExtension(Element el, String name) {
358    if (name == null)
359      return null;
360    if (!el.hasExtension())
361      return null;
362    for (Extension e : el.getExtension()) {
363      if (name.equals(e.getUrl()))
364        return e;
365    }
366    return null;
367  }
368
369  public static void setStringExtension(DomainResource resource, String uri, String value) {
370    Extension ext = getExtension(resource, uri);
371    if (ext != null)
372      ext.setValue(new StringType(value));
373    else
374      resource.getExtension().add(new Extension(new UriType(uri)).setValue(new StringType(value)));
375  }
376
377  public static String getOID(CodeSystem define) {
378    return readStringExtension(define, EXT_OID);    
379  }
380
381  public static String getOID(ValueSet vs) {
382    return readStringExtension(vs, EXT_OID);    
383  }
384
385  public static void setOID(CodeSystem define, String oid) throws FHIRFormatError, URISyntaxException {
386    if (!oid.startsWith("urn:oid:"))
387      throw new FHIRFormatError("Error in OID format");
388    if (oid.startsWith("urn:oid:urn:oid:"))
389      throw new FHIRFormatError("Error in OID format");
390    if (!hasExtension(define, EXT_OID))
391    define.getExtension().add(Factory.newExtension(EXT_OID, Factory.newUri(oid), false));       
392    else if (!oid.equals(readStringExtension(define, EXT_OID)))
393      throw new Error("Attempt to assign multiple OIDs to a code system");
394  }
395  public static void setOID(ValueSet vs, String oid) throws FHIRFormatError, URISyntaxException {
396    if (!oid.startsWith("urn:oid:"))
397      throw new FHIRFormatError("Error in OID format");
398    if (oid.startsWith("urn:oid:urn:oid:"))
399      throw new FHIRFormatError("Error in OID format");
400    if (!hasExtension(vs, EXT_OID))
401    vs.getExtension().add(Factory.newExtension(EXT_OID, Factory.newUri(oid), false));       
402    else if (!oid.equals(readStringExtension(vs, EXT_OID)))
403      throw new Error("Attempt to assign multiple OIDs to value set "+vs.getName()+" ("+vs.getUrl()+"). Has "+readStringExtension(vs, EXT_OID)+", trying to add "+oid);
404  }
405
406  public static boolean hasLanguageTranslation(Element element, String lang) {
407    for (Extension e : element.getExtension()) {
408      if (e.getUrl().equals(EXT_TRANSLATION)) {
409        Extension e1 = ExtensionHelper.getExtension(e, "lang");
410
411        if (e1 != null && e1.getValue() instanceof CodeType && ((CodeType) e.getValue()).getValue().equals(lang))
412          return true;
413      }
414    }
415    return false;
416  }
417
418  public static String getLanguageTranslation(Element element, String lang) {
419    for (Extension e : element.getExtension()) {
420      if (e.getUrl().equals(EXT_TRANSLATION)) {
421        Extension e1 = ExtensionHelper.getExtension(e, "lang");
422
423        if (e1 != null && e1.getValue() instanceof CodeType && ((CodeType) e.getValue()).getValue().equals(lang)) {
424          e1 = ExtensionHelper.getExtension(e, "content");
425          return ((StringType) e.getValue()).getValue();
426        }
427      }
428    }
429    return null;
430  }
431
432  public static void addLanguageTranslation(Element element, String lang, String value) {
433    Extension extension = new Extension().setUrl(EXT_TRANSLATION);
434    extension.addExtension().setUrl("lang").setValue(new StringType(lang));
435    extension.addExtension().setUrl("content").setValue(new StringType(value));
436    element.getExtension().add(extension);
437  }
438
439  public static Type getAllowedUnits(ElementDefinition eld) {
440    for (Extension e : eld.getExtension()) 
441      if (e.getUrl().equals(EXT_ALLOWABLE_UNITS)) 
442        return e.getValue();
443    return null;
444  }
445
446  public static void setAllowableUnits(ElementDefinition eld, CodeableConcept cc) {
447    for (Extension e : eld.getExtension()) 
448      if (e.getUrl().equals(EXT_ALLOWABLE_UNITS)) {
449        e.setValue(cc);
450        return;
451      }
452    eld.getExtension().add(new Extension().setUrl(EXT_ALLOWABLE_UNITS).setValue(cc));
453  }
454
455  public static List<Extension> getExtensions(Element element, String url) {
456    List<Extension> results = new ArrayList<Extension>();
457    for (Extension ex : element.getExtension())
458      if (ex.getUrl().equals(url))
459        results.add(ex);
460    return results;
461  }
462
463  public static List<Extension> getExtensions(DomainResource resource, String url) {
464    List<Extension> results = new ArrayList<Extension>();
465    for (Extension ex : resource.getExtension())
466      if (ex.getUrl().equals(url))
467        results.add(ex);
468    return results;
469  }
470
471  public static void addDEReference(DataElement de, String value) {
472    for (Extension e : de.getExtension()) 
473      if (e.getUrl().equals(EXT_CIMI_REFERENCE)) {
474        e.setValue(new UriType(value));
475        return;
476      }
477    de.getExtension().add(new Extension().setUrl(EXT_CIMI_REFERENCE).setValue(new UriType(value)));
478  }
479
480//  public static void setDeprecated(Element nc) {
481//    for (Extension e : nc.getExtension()) 
482//      if (e.getUrl().equals(EXT_DEPRECATED)) {
483//        e.setValue(new BooleanType(true));
484//        return;
485//      }
486//    nc.getExtension().add(new Extension().setUrl(EXT_DEPRECATED).setValue(new BooleanType(true)));    
487//  }
488
489  public static void setExtension(Element focus, String url, Coding c) {
490    for (Extension e : focus.getExtension()) 
491      if (e.getUrl().equals(url)) {
492        e.setValue(c);
493        return;
494      }
495    focus.getExtension().add(new Extension().setUrl(url).setValue(c));    
496  }
497
498  public static void removeExtension(DomainResource focus, String url) {
499    Iterator<Extension> i = focus.getExtension().iterator();
500    while (i.hasNext()) {
501      Extension e = i.next(); // must be called before you can call i.remove()
502      if (e.getUrl().equals(url)) {
503        i.remove();
504      }
505    }
506  }
507  
508  public static void removeExtension(Element focus, String url) {
509    Iterator<Extension> i = focus.getExtension().iterator();
510    while (i.hasNext()) {
511      Extension e = i.next(); // must be called before you can call i.remove()
512      if (e.getUrl().equals(url)) {
513        i.remove();
514      }
515    }
516  }
517
518  public static boolean hasOID(ValueSet vs) {
519    return hasExtension(vs, EXT_OID);
520  }
521  
522
523  public static void setStringExtension(Element element, String uri, String value) {
524    Extension ext = getExtension(element, uri);
525    if (ext != null)
526      ext.setValue(new StringType(value));
527    else
528      element.getExtension().add(new Extension(new UriType(uri)).setValue(new StringType(value)));
529  }
530  
531}