001package org.hl7.fhir.dstu3.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.util.ArrayList;
035import java.util.List;
036
037import org.hl7.fhir.utilities.Utilities;
038
039
040@Deprecated
041public class TypesUtilities {
042
043  public static class WildcardInformation {
044    private String typeName;
045    private String comment;
046    public WildcardInformation(String typeName, String comment) {
047      super();
048      this.typeName = typeName;
049      this.comment = comment;
050    }
051    public WildcardInformation(String typeName) {
052      super();
053      this.typeName = typeName;
054    }
055    public String getTypeName() {
056      return typeName;
057    }
058    public String getComment() {
059      return comment;
060    }
061    
062  }
063  
064  public static List<String> wildcardTypes() {
065    List<String> res = new ArrayList<String>();
066    for (WildcardInformation wi : wildcards())
067      res.add(wi.getTypeName());
068    return res;
069  }
070  
071  // this is the master list for what data types are allowed where the types = *
072  // that this list is incomplete means that the following types cannot have fixed values in a profile:
073  //   Narrative
074  //   Meta
075  //   Any of the IDMP data types
076  // You have to walk into them to profile them.
077  //
078  public static List<WildcardInformation> wildcards() {
079    List<WildcardInformation> res = new ArrayList<WildcardInformation>();
080
081    // primitive types
082    res.add(new WildcardInformation("base64Binary"));
083    res.add(new WildcardInformation("boolean"));
084    res.add(new WildcardInformation("canonical"));
085    res.add(new WildcardInformation("code", "(only if the extension definition provides a <a href=\"terminologies.html#code\">fixed</a> binding to a suitable set of codes)"));
086    res.add(new WildcardInformation("date"));
087    res.add(new WildcardInformation("dateTime"));
088    res.add(new WildcardInformation("decimal"));
089    res.add(new WildcardInformation("id"));
090    res.add(new WildcardInformation("instant"));
091    res.add(new WildcardInformation("integer"));
092    res.add(new WildcardInformation("markdown"));
093    res.add(new WildcardInformation("oid"));
094    res.add(new WildcardInformation("positiveInt"));
095    res.add(new WildcardInformation("string"));
096    res.add(new WildcardInformation("time"));
097    res.add(new WildcardInformation("unsignedInt"));
098    res.add(new WildcardInformation("uri"));
099    res.add(new WildcardInformation("url"));
100    res.add(new WildcardInformation("uuid"));
101
102    // Complex general purpose data types
103    res.add(new WildcardInformation("Address"));
104    res.add(new WildcardInformation("Age"));
105    res.add(new WildcardInformation("Annotation"));
106    res.add(new WildcardInformation("Attachment"));
107    res.add(new WildcardInformation("CodeableConcept"));
108    res.add(new WildcardInformation("Coding"));
109    res.add(new WildcardInformation("ContactPoint"));
110    res.add(new WildcardInformation("Count"));
111    res.add(new WildcardInformation("Distance"));
112    res.add(new WildcardInformation("Duration"));
113    res.add(new WildcardInformation("HumanName"));
114    res.add(new WildcardInformation("Identifier"));
115    res.add(new WildcardInformation("Money"));
116    res.add(new WildcardInformation("Period"));
117    res.add(new WildcardInformation("Quantity"));
118    res.add(new WildcardInformation("Range"));
119    res.add(new WildcardInformation("Ratio"));
120    res.add(new WildcardInformation("Reference", " - a reference to another resource"));
121    res.add(new WildcardInformation("SampledData"));
122    res.add(new WildcardInformation("Signature"));
123    res.add(new WildcardInformation("Timing"));
124    
125    // metadata types
126    res.add(new WildcardInformation("ParameterDefinition"));
127    res.add(new WildcardInformation("DataRequirement"));
128    res.add(new WildcardInformation("RelatedArtifact"));
129    res.add(new WildcardInformation("ContactDetail"));
130    res.add(new WildcardInformation("Contributor"));
131    res.add(new WildcardInformation("TriggerDefinition"));
132    res.add(new WildcardInformation("Expression"));
133    res.add(new WildcardInformation("UsageContext"));
134    
135    // special cases
136    res.add(new WildcardInformation("Dosage"));
137    return res;
138  }
139
140  public static boolean isPrimitive(String code) {
141    return Utilities.existsInList(code, "boolean", "integer", "string", "decimal", "uri", "url", "canonical", "base64Binary", "instant", "date", "dateTime", "time", "code", "oid", "id", "markdown", "unsignedInt", "positiveInt", "xhtml");
142  }
143}