001package org.hl7.fhir.dstu3.utils; 002 003/*- 004 * #%L 005 * org.hl7.fhir.dstu3 006 * %% 007 * Copyright (C) 2014 - 2019 Health Level 7 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023 024import java.util.ArrayList; 025import java.util.List; 026 027import org.hl7.fhir.utilities.Utilities; 028 029 030public class TypesUtilities { 031 032 public static class WildcardInformation { 033 private String typeName; 034 private String comment; 035 public WildcardInformation(String typeName, String comment) { 036 super(); 037 this.typeName = typeName; 038 this.comment = comment; 039 } 040 public WildcardInformation(String typeName) { 041 super(); 042 this.typeName = typeName; 043 } 044 public String getTypeName() { 045 return typeName; 046 } 047 public String getComment() { 048 return comment; 049 } 050 051 } 052 053 public static List<String> wildcardTypes() { 054 List<String> res = new ArrayList<String>(); 055 for (WildcardInformation wi : wildcards()) 056 res.add(wi.getTypeName()); 057 return res; 058 } 059 060 // this is the master list for what data types are allowed where the types = * 061 // that this list is incomplete means that the following types cannot have fixed values in a profile: 062 // Narrative 063 // Meta 064 // Any of the IDMP data types 065 // You have to walk into them to profile them. 066 // 067 public static List<WildcardInformation> wildcards() { 068 List<WildcardInformation> res = new ArrayList<WildcardInformation>(); 069 070 // primitive types 071 res.add(new WildcardInformation("base64Binary")); 072 res.add(new WildcardInformation("boolean")); 073 res.add(new WildcardInformation("canonical")); 074 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)")); 075 res.add(new WildcardInformation("date")); 076 res.add(new WildcardInformation("dateTime")); 077 res.add(new WildcardInformation("decimal")); 078 res.add(new WildcardInformation("id")); 079 res.add(new WildcardInformation("instant")); 080 res.add(new WildcardInformation("integer")); 081 res.add(new WildcardInformation("markdown")); 082 res.add(new WildcardInformation("oid")); 083 res.add(new WildcardInformation("positiveInt")); 084 res.add(new WildcardInformation("string")); 085 res.add(new WildcardInformation("time")); 086 res.add(new WildcardInformation("unsignedInt")); 087 res.add(new WildcardInformation("uri")); 088 res.add(new WildcardInformation("url")); 089 res.add(new WildcardInformation("uuid")); 090 091 // Complex general purpose data types 092 res.add(new WildcardInformation("Address")); 093 res.add(new WildcardInformation("Age")); 094 res.add(new WildcardInformation("Annotation")); 095 res.add(new WildcardInformation("Attachment")); 096 res.add(new WildcardInformation("CodeableConcept")); 097 res.add(new WildcardInformation("Coding")); 098 res.add(new WildcardInformation("ContactPoint")); 099 res.add(new WildcardInformation("Count")); 100 res.add(new WildcardInformation("Distance")); 101 res.add(new WildcardInformation("Duration")); 102 res.add(new WildcardInformation("HumanName")); 103 res.add(new WildcardInformation("Identifier")); 104 res.add(new WildcardInformation("Money")); 105 res.add(new WildcardInformation("Period")); 106 res.add(new WildcardInformation("Quantity")); 107 res.add(new WildcardInformation("Range")); 108 res.add(new WildcardInformation("Ratio")); 109 res.add(new WildcardInformation("Reference", " - a reference to another resource")); 110 res.add(new WildcardInformation("SampledData")); 111 res.add(new WildcardInformation("Signature")); 112 res.add(new WildcardInformation("Timing")); 113 114 // metadata types 115 res.add(new WildcardInformation("ParameterDefinition")); 116 res.add(new WildcardInformation("DataRequirement")); 117 res.add(new WildcardInformation("RelatedArtifact")); 118 res.add(new WildcardInformation("ContactDetail")); 119 res.add(new WildcardInformation("Contributor")); 120 res.add(new WildcardInformation("TriggerDefinition")); 121 res.add(new WildcardInformation("Expression")); 122 res.add(new WildcardInformation("UsageContext")); 123 124 // special cases 125 res.add(new WildcardInformation("Dosage")); 126 return res; 127 } 128 129 public static boolean isPrimitive(String code) { 130 return Utilities.existsInList(code, "boolean", "integer", "string", "decimal", "uri", "url", "canonical", "base64Binary", "instant", "date", "dateTime", "time", "code", "oid", "id", "markdown", "unsignedInt", "positiveInt", "xhtml"); 131 } 132} 133