Correctly parse List resource

This commit is contained in:
jamesagnew 2014-08-26 08:10:15 -04:00
parent e6d6ec88b2
commit 9413bfa47b
11 changed files with 238 additions and 152 deletions

View File

@ -107,6 +107,10 @@
Server now gives a more helpful error message if a @Read method has a search parameter (which is invalid, but Server now gives a more helpful error message if a @Read method has a search parameter (which is invalid, but
previously lead to a very unhelpful error message). Thanks to Tahura Chaudhry of UHN for reporting! previously lead to a very unhelpful error message). Thanks to Tahura Chaudhry of UHN for reporting!
</action> </action>
<action type="fix">
Resource of type "List" failed to parse from a bundle correctly. Thanks to David Hay of Orion Health
for reporting!
</action>
</release> </release>
<release version="0.5" date="2014-Jul-30"> <release version="0.5" date="2014-Jul-30">
<action type="add"> <action type="add">

View File

@ -72,12 +72,14 @@ public class FhirContext {
private volatile INarrativeGenerator myNarrativeGenerator; private volatile INarrativeGenerator myNarrativeGenerator;
private volatile IRestfulClientFactory myRestfulClientFactory; private volatile IRestfulClientFactory myRestfulClientFactory;
private volatile RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition; private volatile RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
private Map<String, String> myNameToResourceType;
private static final List<Class<? extends IResource>> EMPTY_LIST = Collections.emptyList();
/** /**
* Default constructor. In most cases this is the right constructor to use. * Default constructor. In most cases this is the right constructor to use.
*/ */
public FhirContext() { public FhirContext() {
super(); this(EMPTY_LIST);
} }
public FhirContext(Class<? extends IResource> theResourceType) { public FhirContext(Class<? extends IResource> theResourceType) {
@ -146,8 +148,11 @@ public class FhirContext {
if (retVal == null) { if (retVal == null) {
try { try {
String candidateName = Patient.class.getPackage().getName() + "." + resourceName; String className = myNameToResourceType.get(resourceName.toLowerCase());
Class<?> clazz = Class.forName(candidateName); if (className == null) {
return null;
}
Class<?> clazz = Class.forName(className);
if (IResource.class.isAssignableFrom(clazz)) { if (IResource.class.isAssignableFrom(clazz)) {
retVal = scanResourceType((Class<? extends IResource>) clazz); retVal = scanResourceType((Class<? extends IResource>) clazz);
} }
@ -298,6 +303,8 @@ public class FhirContext {
myClassToElementDefinition = classToElementDefinition; myClassToElementDefinition = classToElementDefinition;
myIdToResourceDefinition = idToElementDefinition; myIdToResourceDefinition = idToElementDefinition;
myNameToResourceType = scanner.getNameToResourceType();
return classToElementDefinition; return classToElementDefinition;
} }

View File

@ -82,6 +82,8 @@ class ModelScanner {
// myNameToDatatypeDefinitions = new HashMap<String, // myNameToDatatypeDefinitions = new HashMap<String,
// RuntimeDatatypeDefinition>(); // RuntimeDatatypeDefinition>();
private Map<String, String> myNameToResourceType = new HashMap<String, String>();
private RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition; private RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
private Set<Class<? extends IElement>> myScanAlso = new HashSet<Class<? extends IElement>>(); private Set<Class<? extends IElement>> myScanAlso = new HashSet<Class<? extends IElement>>();
@ -106,10 +108,18 @@ class ModelScanner {
return myClassToElementDefinitions; return myClassToElementDefinitions;
} }
public Map<String, RuntimeResourceDefinition> getIdToResourceDefinition() {
return myIdToResourceDefinition;
}
public Map<String, RuntimeResourceDefinition> getNameToResourceDefinitions() { public Map<String, RuntimeResourceDefinition> getNameToResourceDefinitions() {
return (myNameToResourceDefinitions); return (myNameToResourceDefinitions);
} }
public Map<String, String> getNameToResourceType() {
return myNameToResourceType;
}
public RuntimeChildUndeclaredExtensionDefinition getRuntimeChildUndeclaredExtensionDefinition() { public RuntimeChildUndeclaredExtensionDefinition getRuntimeChildUndeclaredExtensionDefinition() {
return myRuntimeChildUndeclaredExtensionDefinition; return myRuntimeChildUndeclaredExtensionDefinition;
} }
@ -160,9 +170,9 @@ class ModelScanner {
int startSize = myClassToElementDefinitions.size(); int startSize = myClassToElementDefinitions.size();
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
InputStream str = ModelScanner.class.getResourceAsStream("/ca/uhn/fhir/model/dstu/model.properties"); InputStream str = ModelScanner.class.getResourceAsStream("/ca/uhn/fhir/model/dstu/fhirversion.properties");
if (str == null) { if (str == null) {
str = ModelScanner.class.getResourceAsStream("ca/uhn/fhir/model/dstu/model.properties"); str = ModelScanner.class.getResourceAsStream("ca/uhn/fhir/model/dstu/fhirversion.properties");
} }
if (str == null) { if (str == null) {
throw new ConfigurationException("Can not find model property file on classpath: " + "/ca/uhn/fhir/model/dstu/model.properties"); throw new ConfigurationException("Can not find model property file on classpath: " + "/ca/uhn/fhir/model/dstu/model.properties");
@ -170,7 +180,18 @@ class ModelScanner {
Properties prop = new Properties(); Properties prop = new Properties();
try { try {
prop.load(str); prop.load(str);
for (Object nextValue : prop.values()) { for (Entry<Object, Object> nextEntry : prop.entrySet()) {
String nextKey = nextEntry.getKey().toString();
String nextValue = nextEntry.getValue().toString();
if (!nextKey.startsWith("datatype.")) {
if (nextKey.startsWith("resource.")) {
String resName = nextKey.substring("resource.".length()).toLowerCase();
myNameToResourceType.put(resName, nextValue);
}
continue;
}
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<? extends IElement> nextClass = (Class<? extends IElement>) Class.forName((String) nextValue); Class<? extends IElement> nextClass = (Class<? extends IElement>) Class.forName((String) nextValue);
@ -234,8 +255,7 @@ class ModelScanner {
ResourceDef resourceDefinition = theClass.getAnnotation(ResourceDef.class); ResourceDef resourceDefinition = theClass.getAnnotation(ResourceDef.class);
if (resourceDefinition != null) { if (resourceDefinition != null) {
if (!IResource.class.isAssignableFrom(theClass)) { if (!IResource.class.isAssignableFrom(theClass)) {
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
+ theClass.getCanonicalName());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<? extends IResource> resClass = (Class<? extends IResource>) theClass; Class<? extends IResource> resClass = (Class<? extends IResource>) theClass;
@ -253,8 +273,7 @@ class ModelScanner {
Class<? extends IPrimitiveDatatype<?>> resClass = (Class<? extends IPrimitiveDatatype<?>>) theClass; Class<? extends IPrimitiveDatatype<?>> resClass = (Class<? extends IPrimitiveDatatype<?>>) theClass;
scanPrimitiveDatatype(resClass, datatypeDefinition); scanPrimitiveDatatype(resClass, datatypeDefinition);
} else { } else {
throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
+ theClass.getCanonicalName());
} }
} }
@ -265,8 +284,7 @@ class ModelScanner {
Class<? extends IResourceBlock> blockClass = (Class<? extends IResourceBlock>) theClass; Class<? extends IResourceBlock> blockClass = (Class<? extends IResourceBlock>) theClass;
scanBlock(blockClass, blockDefinition); scanBlock(blockClass, blockDefinition);
} else { } else {
throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
+ theClass.getCanonicalName());
} }
} }
@ -357,8 +375,7 @@ class ModelScanner {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1; int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;
for (Field next : theClass.getDeclaredFields()) { for (Field next : theClass.getDeclaredFields()) {
@ -395,8 +412,8 @@ class ModelScanner {
} }
} }
if (order == Child.REPLACE_PARENT) { if (order == Child.REPLACE_PARENT) {
throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT + ") but no parent element with extension URL " + extensionAttr.url()
+ ") but no parent element with extension URL " + extensionAttr.url() + " could be found on type " + next.getDeclaringClass().getSimpleName()); + " could be found on type " + next.getDeclaringClass().getSimpleName());
} }
} else { } else {
@ -411,8 +428,8 @@ class ModelScanner {
} }
} }
if (order == Child.REPLACE_PARENT) { if (order == Child.REPLACE_PARENT) {
throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT + ") but no parent element with name " + elementName + " could be found on type "
+ ") but no parent element with name " + elementName + " could be found on type " + next.getDeclaringClass().getSimpleName()); + next.getDeclaringClass().getSimpleName());
} }
} }
@ -427,7 +444,8 @@ class ModelScanner {
int min = childAnnotation.min(); int min = childAnnotation.min();
int max = childAnnotation.max(); int max = childAnnotation.max();
/* /*
* Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict wityh any given IDs and can be figured out later * Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict wityh any
* given IDs and can be figured out later
*/ */
while (order == Child.ORDER_UNKNOWN && orderMap.containsKey(order)) { while (order == Child.ORDER_UNKNOWN && orderMap.containsKey(order)) {
order--; order--;
@ -439,8 +457,7 @@ class ModelScanner {
} }
if (orderMap.containsKey(order)) { if (orderMap.containsKey(order)) {
throw new ConfigurationException("Detected duplicate field order '" + childAnnotation.order() + "' for element named '" + elementName + "' in type '" + theClass.getCanonicalName() throw new ConfigurationException("Detected duplicate field order '" + childAnnotation.order() + "' for element named '" + elementName + "' in type '" + theClass.getCanonicalName() + "'");
+ "'");
} }
if (elementNames.contains(elementName)) { if (elementNames.contains(elementName)) {
@ -479,8 +496,7 @@ class ModelScanner {
* Child is an extension * Child is an extension
*/ */
Class<? extends IElement> et = (Class<? extends IElement>) nextElementType; Class<? extends IElement> et = (Class<? extends IElement>) nextElementType;
RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et);
extensionAttr.url(), et);
orderMap.put(order, def); orderMap.put(order, def);
if (IElement.class.isAssignableFrom(nextElementType)) { if (IElement.class.isAssignableFrom(nextElementType)) {
addScanAlso((Class<? extends IElement>) nextElementType); addScanAlso((Class<? extends IElement>) nextElementType);
@ -492,8 +508,7 @@ class ModelScanner {
List<Class<? extends IResource>> refTypesList = new ArrayList<Class<? extends IResource>>(); List<Class<? extends IResource>> refTypesList = new ArrayList<Class<? extends IResource>>();
for (Class<? extends IElement> nextType : childAnnotation.type()) { for (Class<? extends IElement> nextType : childAnnotation.type()) {
if (IResource.class.isAssignableFrom(nextType) == false) { if (IResource.class.isAssignableFrom(nextType) == false) {
throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + ResourceReferenceDt.class throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + ResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
+ " but contains a non-resource type: " + nextType.getCanonicalName());
} }
refTypesList.add((Class<? extends IResource>) nextType); refTypesList.add((Class<? extends IResource>) nextType);
addScanAlso(nextType); addScanAlso(nextType);
@ -503,7 +518,8 @@ class ModelScanner {
} else if (IResourceBlock.class.isAssignableFrom(nextElementType)) { } else if (IResourceBlock.class.isAssignableFrom(nextElementType)) {
/* /*
* Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name according to HL7? * Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
* according to HL7?
*/ */
Class<? extends IResourceBlock> blockDef = (Class<? extends IResourceBlock>) nextElementType; Class<? extends IResourceBlock> blockDef = (Class<? extends IResourceBlock>) nextElementType;
@ -542,8 +558,7 @@ class ModelScanner {
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class); CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
if (concept != null) { if (concept != null) {
if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) { if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) {
throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName() throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName() + " but type is not a subtype of " + ICodedDatatype.class.getName());
+ " but type is not a subtype of " + ICodedDatatype.class.getName());
} else { } else {
Class<? extends ICodeEnum> type = concept.type(); Class<? extends ICodeEnum> type = concept.type();
myScanAlsoCodeTable.add(type); myScanAlsoCodeTable.add(type);
@ -589,8 +604,8 @@ class ModelScanner {
String resourceName = resourceDefinition.name(); String resourceName = resourceDefinition.name();
if (isBlank(resourceName)) { if (isBlank(resourceName)) {
Class<?> parent = theClass.getSuperclass(); Class<?> parent = theClass.getSuperclass();
primaryNameProvider=false; primaryNameProvider = false;
while (parent.equals(Object.class)==false && isBlank(resourceName)) { while (parent.equals(Object.class) == false && isBlank(resourceName)) {
ResourceDef nextDef = parent.getAnnotation(ResourceDef.class); ResourceDef nextDef = parent.getAnnotation(ResourceDef.class);
if (nextDef != null) { if (nextDef != null) {
resourceName = nextDef.name(); resourceName = nextDef.name();
@ -602,19 +617,19 @@ class ModelScanner {
} }
} }
// if (myNameToResourceDefinitions.containsKey(resourceName)) { // if (myNameToResourceDefinitions.containsKey(resourceName)) {
// if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) { // if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
// // throw new // // throw new
// // ConfigurationException("Detected duplicate element name '" + // // ConfigurationException("Detected duplicate element name '" +
// // resourceName + "' in types '" + theClass.getCanonicalName() + // // resourceName + "' in types '" + theClass.getCanonicalName() +
// // "' and '" // // "' and '"
// // + // // +
// // myNameToResourceDefinitions.get(resourceName).getImplementingClass() // // myNameToResourceDefinitions.get(resourceName).getImplementingClass()
// // + "'"); // // + "'");
// } else { // } else {
// return resourceName; // return resourceName;
// } // }
// } // }
String resourceId = resourceDefinition.id(); String resourceId = resourceDefinition.id();
if (isBlank(resourceId)) { if (isBlank(resourceId)) {
@ -624,8 +639,7 @@ class ModelScanner {
// theClass.getCanonicalName()); // theClass.getCanonicalName());
} else { } else {
if (myIdToResourceDefinition.containsKey(resourceId)) { if (myIdToResourceDefinition.containsKey(resourceId)) {
throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and " throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and " + myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
+ myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
} }
} }
@ -672,8 +686,7 @@ class ModelScanner {
for (String nextName : searchParam.compositeOf()) { for (String nextName : searchParam.compositeOf()) {
RuntimeSearchParam param = nameToParam.get(nextName); RuntimeSearchParam param = nameToParam.get(nextName);
if (param == null) { if (param == null) {
ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}", new Object[] { ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}", new Object[] { theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() });
theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() });
continue; continue;
} }
compositeOf.add(param); compositeOf.add(param);
@ -684,10 +697,6 @@ class ModelScanner {
} }
} }
public Map<String, RuntimeResourceDefinition> getIdToResourceDefinition() {
return myIdToResourceDefinition;
}
private static Class<?> getGenericCollectionTypeOfCodedField(Field next) { private static Class<?> getGenericCollectionTypeOfCodedField(Field next) {
Class<?> type; Class<?> type;
ParameterizedType collectionType = (ParameterizedType) next.getGenericType(); ParameterizedType collectionType = (ParameterizedType) next.getGenericType();

View File

@ -0,0 +1,95 @@
# This file contains version definitions
resource.AdverseReaction=ca.uhn.fhir.model.dstu.resource.AdverseReaction
resource.Alert=ca.uhn.fhir.model.dstu.resource.Alert
resource.AllergyIntolerance=ca.uhn.fhir.model.dstu.resource.AllergyIntolerance
resource.Appointment=ca.uhn.fhir.model.dstu.resource.Appointment
resource.AppointmentResponse=ca.uhn.fhir.model.dstu.resource.AppointmentResponse
resource.Availability=ca.uhn.fhir.model.dstu.resource.Availability
resource.CarePlan=ca.uhn.fhir.model.dstu.resource.CarePlan
resource.Claim=ca.uhn.fhir.model.dstu.resource.Claim
resource.Composition=ca.uhn.fhir.model.dstu.resource.Composition
resource.ConceptMap=ca.uhn.fhir.model.dstu.resource.ConceptMap
resource.Condition=ca.uhn.fhir.model.dstu.resource.Condition
resource.Conformance=ca.uhn.fhir.model.dstu.resource.Conformance
resource.Coverage=ca.uhn.fhir.model.dstu.resource.Coverage
resource.Device=ca.uhn.fhir.model.dstu.resource.Device
resource.DeviceObservationReport=ca.uhn.fhir.model.dstu.resource.DeviceObservationReport
resource.DiagnosticOrder=ca.uhn.fhir.model.dstu.resource.DiagnosticOrder
resource.DiagnosticReport=ca.uhn.fhir.model.dstu.resource.DiagnosticReport
resource.DocumentManifest=ca.uhn.fhir.model.dstu.resource.DocumentManifest
resource.DocumentReference=ca.uhn.fhir.model.dstu.resource.DocumentReference
resource.Encounter=ca.uhn.fhir.model.dstu.resource.Encounter
resource.FamilyHistory=ca.uhn.fhir.model.dstu.resource.FamilyHistory
resource.GVFMeta=ca.uhn.fhir.model.dstu.resource.GVFMeta
resource.GVFVariant=ca.uhn.fhir.model.dstu.resource.GVFVariant
resource.GeneExpression=ca.uhn.fhir.model.dstu.resource.GeneExpression
resource.GeneticAnalysis=ca.uhn.fhir.model.dstu.resource.GeneticAnalysis
resource.Group=ca.uhn.fhir.model.dstu.resource.Group
resource.ImagingStudy=ca.uhn.fhir.model.dstu.resource.ImagingStudy
resource.Immunization=ca.uhn.fhir.model.dstu.resource.Immunization
resource.ImmunizationRecommendation=ca.uhn.fhir.model.dstu.resource.ImmunizationRecommendation
resource.List=ca.uhn.fhir.model.dstu.resource.ListResource
resource.Location=ca.uhn.fhir.model.dstu.resource.Location
resource.Media=ca.uhn.fhir.model.dstu.resource.Media
resource.Medication=ca.uhn.fhir.model.dstu.resource.Medication
resource.MedicationAdministration=ca.uhn.fhir.model.dstu.resource.MedicationAdministration
resource.MedicationDispense=ca.uhn.fhir.model.dstu.resource.MedicationDispense
resource.MedicationPrescription=ca.uhn.fhir.model.dstu.resource.MedicationPrescription
resource.MedicationStatement=ca.uhn.fhir.model.dstu.resource.MedicationStatement
resource.MessageHeader=ca.uhn.fhir.model.dstu.resource.MessageHeader
resource.Microarray=ca.uhn.fhir.model.dstu.resource.Microarray
resource.Observation=ca.uhn.fhir.model.dstu.resource.Observation
resource.OperationOutcome=ca.uhn.fhir.model.dstu.resource.OperationOutcome
resource.Order=ca.uhn.fhir.model.dstu.resource.Order
resource.OrderResponse=ca.uhn.fhir.model.dstu.resource.OrderResponse
resource.Organization=ca.uhn.fhir.model.dstu.resource.Organization
resource.Other=ca.uhn.fhir.model.dstu.resource.Other
resource.Patient=ca.uhn.fhir.model.dstu.resource.Patient
resource.Practitioner=ca.uhn.fhir.model.dstu.resource.Practitioner
resource.Procedure=ca.uhn.fhir.model.dstu.resource.Procedure
resource.Profile=ca.uhn.fhir.model.dstu.resource.Profile
resource.Provenance=ca.uhn.fhir.model.dstu.resource.Provenance
resource.Query=ca.uhn.fhir.model.dstu.resource.Query
resource.Questionnaire=ca.uhn.fhir.model.dstu.resource.Questionnaire
resource.RelatedPerson=ca.uhn.fhir.model.dstu.resource.RelatedPerson
resource.Remittance=ca.uhn.fhir.model.dstu.resource.Remittance
resource.SecurityEvent=ca.uhn.fhir.model.dstu.resource.SecurityEvent
resource.SequencingAnalysis=ca.uhn.fhir.model.dstu.resource.SequencingAnalysis
resource.SequencingLab=ca.uhn.fhir.model.dstu.resource.SequencingLab
resource.Slot=ca.uhn.fhir.model.dstu.resource.Slot
resource.Specimen=ca.uhn.fhir.model.dstu.resource.Specimen
resource.Substance=ca.uhn.fhir.model.dstu.resource.Substance
resource.Supply=ca.uhn.fhir.model.dstu.resource.Supply
resource.Test=ca.uhn.fhir.model.dstu.resource.Test
resource.User=ca.uhn.fhir.model.dstu.resource.User
resource.ValueSet=ca.uhn.fhir.model.dstu.resource.ValueSet
datatype.Address=ca.uhn.fhir.model.dstu.composite.AddressDt
datatype.Attachment=ca.uhn.fhir.model.dstu.composite.AttachmentDt
datatype.CodeableConcept=ca.uhn.fhir.model.dstu.composite.CodeableConceptDt
datatype.Coding=ca.uhn.fhir.model.dstu.composite.CodingDt
datatype.Contact=ca.uhn.fhir.model.dstu.composite.ContactDt
datatype.HumanName=ca.uhn.fhir.model.dstu.composite.HumanNameDt
datatype.Identifier=ca.uhn.fhir.model.dstu.composite.IdentifierDt
datatype.Period=ca.uhn.fhir.model.dstu.composite.PeriodDt
datatype.Quantity=ca.uhn.fhir.model.dstu.composite.QuantityDt
datatype.Range=ca.uhn.fhir.model.dstu.composite.RangeDt
datatype.Ratio=ca.uhn.fhir.model.dstu.composite.RatioDt
datatype.ResourceReference=ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt
datatype.SampledData=ca.uhn.fhir.model.dstu.composite.SampledDataDt
datatype.Schedule=ca.uhn.fhir.model.dstu.composite.ScheduleDt
datatype.base64Binary=ca.uhn.fhir.model.primitive.Base64BinaryDt
datatype.boolean=ca.uhn.fhir.model.primitive.BooleanDt
datatype.code=ca.uhn.fhir.model.primitive.CodeDt
datatype.date=ca.uhn.fhir.model.primitive.DateDt
datatype.dateTime=ca.uhn.fhir.model.primitive.DateTimeDt
datatype.decimal=ca.uhn.fhir.model.primitive.DecimalDt
datatype.id=ca.uhn.fhir.model.primitive.IdDt
datatype.idref=ca.uhn.fhir.model.primitive.IdrefDt
datatype.instant=ca.uhn.fhir.model.primitive.InstantDt
datatype.integer=ca.uhn.fhir.model.primitive.IntegerDt
datatype.oid=ca.uhn.fhir.model.primitive.OidDt
datatype.string=ca.uhn.fhir.model.primitive.StringDt
datatype.uri=ca.uhn.fhir.model.primitive.UriDt
datatype.xhtml=ca.uhn.fhir.model.primitive.XhtmlDt

View File

@ -72,7 +72,7 @@ public class XmlParserTest {
Binary patient = new Binary(); Binary patient = new Binary();
patient.setContentType("foo"); patient.setContentType("foo");
patient.setContent(new byte[] {1,2,3,4}); patient.setContent(new byte[] { 1, 2, 3, 4 });
String val = ourCtx.newXmlParser().encodeResourceToString(patient); String val = ourCtx.newXmlParser().encodeResourceToString(patient);
assertEquals("<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>", val); assertEquals("<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>", val);
@ -94,7 +94,7 @@ public class XmlParserTest {
@Test @Test
public void testEncodeBundle() throws InterruptedException { public void testEncodeBundle() throws InterruptedException {
Bundle b= new Bundle(); Bundle b = new Bundle();
b.getCategories().addTag("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/message", "Message"); b.getCategories().addTag("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/message", "Message");
InstantDt pub = InstantDt.withCurrentTime(); InstantDt pub = InstantDt.withCurrentTime();
@ -126,15 +126,13 @@ public class XmlParserTest {
strings.addAll(Arrays.asList("<published>", pub.getValueAsString(), "</published>")); strings.addAll(Arrays.asList("<published>", pub.getValueAsString(), "</published>"));
strings.add("<category term=\"http://hl7.org/fhir/tag/message\" label=\"Message\" scheme=\"http://hl7.org/fhir/tag\"/>"); strings.add("<category term=\"http://hl7.org/fhir/tag/message\" label=\"Message\" scheme=\"http://hl7.org/fhir/tag\"/>");
strings.addAll(Arrays.asList("<entry>", "<id>1</id>", "</entry>")); strings.addAll(Arrays.asList("<entry>", "<id>1</id>", "</entry>"));
strings.addAll(Arrays.asList("<entry>", "<id>2</id>", "<link rel=\"alternate\" href=\"http://foo/bar\"/>", "<link rel=\"search\" href=\"http://foo/bar/search\"/>","</entry>")); strings.addAll(Arrays.asList("<entry>", "<id>2</id>", "<link rel=\"alternate\" href=\"http://foo/bar\"/>", "<link rel=\"search\" href=\"http://foo/bar/search\"/>", "</entry>"));
strings.addAll(Arrays.asList("<at:deleted-entry", "ref=\"Patient/3", "/>")); strings.addAll(Arrays.asList("<at:deleted-entry", "ref=\"Patient/3", "/>"));
assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings)); assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings));
assertThat(bundleString, not(containsString("at:by"))); assertThat(bundleString, not(containsString("at:by")));
} }
@Test @Test
public void testEncodeBundleCategory() { public void testEncodeBundleCategory() {
@ -171,7 +169,6 @@ public class XmlParserTest {
} }
@Test @Test
public void testEncodeContainedAndIncludedResources() { public void testEncodeContainedAndIncludedResources() {
@ -187,10 +184,8 @@ public class XmlParserTest {
ourLog.info(str); ourLog.info(str);
} }
@Test @Test
public void testEncodeContainedResources() { public void testEncodeContainedResources() {
@ -233,7 +228,6 @@ public class XmlParserTest {
} }
@Test @Test
public void testEncodeDeclaredExtensionWithResourceContent() { public void testEncodeDeclaredExtensionWithResourceContent() {
IParser parser = ourCtx.newXmlParser(); IParser parser = ourCtx.newXmlParser();
@ -336,7 +330,6 @@ public class XmlParserTest {
ExtensionDt parameter = q.addParameter(); ExtensionDt parameter = q.addParameter();
parameter.setUrl("http://foo").setValue(new StringDt("bar")); parameter.setUrl("http://foo").setValue(new StringDt("bar"));
String val = ourCtx.newXmlParser().encodeResourceToString(q); String val = ourCtx.newXmlParser().encodeResourceToString(q);
ourLog.info(val); ourLog.info(val);
@ -408,7 +401,6 @@ public class XmlParserTest {
} }
@Test @Test
public void testExtensionOnPrimitive() throws Exception { public void testExtensionOnPrimitive() throws Exception {
@ -433,9 +425,6 @@ public class XmlParserTest {
} }
@Test @Test
public void testExtensions() throws DataFormatException { public void testExtensions() throws DataFormatException {
@ -541,7 +530,6 @@ public class XmlParserTest {
assertTrue(d.toString(), d.identical()); assertTrue(d.toString(), d.identical());
} }
@Test @Test
public void testLoadAndEncodeUndeclaredExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException { public void testLoadAndEncodeUndeclaredExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException {
IParser p = ourCtx.newXmlParser(); IParser p = ourCtx.newXmlParser();
@ -607,7 +595,7 @@ public class XmlParserTest {
ourLog.info(result); ourLog.info(result);
} }
// @Test @Test
public void testParseFeedWithListResource() throws ConfigurationException, DataFormatException, IOException { public void testParseFeedWithListResource() throws ConfigurationException, DataFormatException, IOException {
// Use new context here to ensure List isn't already loaded // Use new context here to ensure List isn't already loaded
@ -617,8 +605,9 @@ public class XmlParserTest {
Bundle bundle = p.parseBundle(string); Bundle bundle = p.parseBundle(string);
ListResource res = (ListResource) bundle.toListOfResources().get(2); ListResource res = (ListResource) bundle.toListOfResources().get(2);
} assertEquals("cid:patient@bundle", res.getSubject().getReference().getValue());
}
@Test @Test
public void testLoadPatient() throws ConfigurationException, DataFormatException, IOException { public void testLoadPatient() throws ConfigurationException, DataFormatException, IOException {
@ -673,7 +662,6 @@ public class XmlParserTest {
} }
@Test @Test
public void testMoreExtensions() throws Exception { public void testMoreExtensions() throws Exception {
@ -718,7 +706,6 @@ public class XmlParserTest {
assertThat(enc, containsString("<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>")); assertThat(enc, containsString("<given value=\"Joe\"><extension url=\"http://examples.com#givenext\"><valueString value=\"given\"/></extension></given>"));
} }
@Test @Test
public void testNarrativeGeneration() throws DataFormatException { public void testNarrativeGeneration() throws DataFormatException {
@ -764,19 +751,18 @@ public class XmlParserTest {
// Only one (outer) contained block // Only one (outer) contained block
int idx0 = str.indexOf("<contained>"); int idx0 = str.indexOf("<contained>");
int idx1 = str.indexOf("<contained>",idx0+1); int idx1 = str.indexOf("<contained>", idx0 + 1);
assertNotEquals(-1, idx0); assertNotEquals(-1, idx0);
assertEquals(-1, idx1); assertEquals(-1, idx1);
Observation obs = ourCtx.newXmlParser().parseResource(Observation.class, str); Observation obs = ourCtx.newXmlParser().parseResource(Observation.class, str);
assertEquals("A",obs.getName().getText().getValue()); assertEquals("A", obs.getName().getText().getValue());
Observation obsB = (Observation) obs.getRelatedFirstRep().getTarget().getResource(); Observation obsB = (Observation) obs.getRelatedFirstRep().getTarget().getResource();
assertEquals("B",obsB.getName().getText().getValue()); assertEquals("B", obsB.getName().getText().getValue());
Observation obsC = (Observation) obsB.getRelatedFirstRep().getTarget().getResource(); Observation obsC = (Observation) obsB.getRelatedFirstRep().getTarget().getResource();
assertEquals("C",obsC.getName().getText().getValue()); assertEquals("C", obsC.getName().getText().getValue());
} }
@ -785,7 +771,7 @@ public class XmlParserTest {
Binary val = ourCtx.newXmlParser().parseResource(Binary.class, "<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>"); Binary val = ourCtx.newXmlParser().parseResource(Binary.class, "<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>");
assertEquals("foo", val.getContentType()); assertEquals("foo", val.getContentType());
assertArrayEquals(new byte[] {1,2,3,4}, val.getContent()); assertArrayEquals(new byte[] { 1, 2, 3, 4 }, val.getContent());
} }
@ -893,7 +879,7 @@ public class XmlParserTest {
resource = (ValueSet) entry.getResource(); resource = (ValueSet) entry.getResource();
assertEquals("256a5231-a2bb-49bd-9fea-f349d428b70d", resource.getId().getIdPart()); assertEquals("256a5231-a2bb-49bd-9fea-f349d428b70d", resource.getId().getIdPart());
assertEquals("12345", resource.getId().getVersionIdPart()); assertEquals("12345", resource.getId().getVersionIdPart());
assertEquals("12345", ((IdDt)resource.getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION_ID)).getVersionIdPart()); assertEquals("12345", ((IdDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION_ID)).getVersionIdPart());
} }
@ -927,7 +913,7 @@ public class XmlParserTest {
assertEquals("http://foo/Patient/1/_history/2", entry.getLinkSelf().getValue()); assertEquals("http://foo/Patient/1/_history/2", entry.getLinkSelf().getValue());
assertEquals("1", entry.getResource().getId().getIdPart()); assertEquals("1", entry.getResource().getId().getIdPart());
assertEquals("2", entry.getResource().getId().getVersionIdPart()); assertEquals("2", entry.getResource().getId().getVersionIdPart());
assertEquals("2", ((IdDt)entry.getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION_ID)).getVersionIdPart()); assertEquals("2", ((IdDt) entry.getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION_ID)).getVersionIdPart());
assertEquals("John Doe", entry.getDeletedByName().getValue()); assertEquals("John Doe", entry.getDeletedByName().getValue());
assertEquals("jdoe@example.org", entry.getDeletedByEmail().getValue()); assertEquals("jdoe@example.org", entry.getDeletedByEmail().getValue());
assertEquals("Removed comment spam", entry.getDeletedComment().getValue()); assertEquals("Removed comment spam", entry.getDeletedComment().getValue());
@ -936,7 +922,7 @@ public class XmlParserTest {
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(bundle)); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(bundle));
String encoded = ourCtx.newXmlParser().encodeBundleToString(bundle); String encoded = ourCtx.newXmlParser().encodeBundleToString(bundle);
assertEquals(msg,encoded); assertEquals(msg, encoded);
} }
@ -978,7 +964,6 @@ public class XmlParserTest {
} }
@Test @Test
public void testParseEncodeNarrative() { public void testParseEncodeNarrative() {
@ -1000,8 +985,7 @@ public class XmlParserTest {
} }
/** /**
* This sample has extra elements in <searchParam> that are not actually a * This sample has extra elements in <searchParam> that are not actually a part of the spec any more..
* part of the spec any more..
*/ */
@Test @Test
public void testParseFuroreMetadataWithExtraElements() throws IOException { public void testParseFuroreMetadataWithExtraElements() throws IOException {
@ -1023,19 +1007,9 @@ public class XmlParserTest {
@Test @Test
public void testParseQuery() { public void testParseQuery() {
String msg = "<Query xmlns=\"http://hl7.org/fhir\">\n" + String msg = "<Query xmlns=\"http://hl7.org/fhir\">\n" + " <text>\n" + " <status value=\"generated\"/>\n" + " <div xmlns=\"http://www.w3.org/1999/xhtml\">[Put rendering here]</div>\n" + " </text>\n" + "\n"
" <text>\n" + + " <!-- this is an extermely simple query - a request to execute the query 'example' on the\n" + " responder -->\n" + " <identifier value=\"urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376\"/>\n" + " <parameter url=\"http://hl7.org/fhir/query#_query\">\n"
" <status value=\"generated\"/>\n" + + " <valueString value=\"example\"/>\n" + " </parameter>\n" + "</Query>";
" <div xmlns=\"http://www.w3.org/1999/xhtml\">[Put rendering here]</div>\n" +
" </text>\n" +
"\n" +
" <!-- this is an extermely simple query - a request to execute the query 'example' on the\n" +
" responder -->\n" +
" <identifier value=\"urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376\"/>\n" +
" <parameter url=\"http://hl7.org/fhir/query#_query\">\n" +
" <valueString value=\"example\"/>\n" +
" </parameter>\n" +
"</Query>";
Query query = ourCtx.newXmlParser().parseResource(Query.class, msg); Query query = ourCtx.newXmlParser().parseResource(Query.class, msg);
assertEquals("urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376", query.getIdentifier().getValueAsString()); assertEquals("urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376", query.getIdentifier().getValueAsString());
@ -1155,7 +1129,7 @@ public class XmlParserTest {
//@formatter:on //@formatter:on
String encoded = ourCtx.newXmlParser().encodeTagListToString(tagList); String encoded = ourCtx.newXmlParser().encodeTagListToString(tagList);
assertEquals(expected,encoded); assertEquals(expected, encoded);
} }

View File

@ -12,7 +12,7 @@
<dependent-module archiveName="hapi-fhir-base-0.6-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base"> <dependent-module archiveName="hapi-fhir-base-0.6-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&amp;excludes=META-INF/MANIFEST.MF"> <dependent-module deploy-path="/" handle="module:/overlay/var/M2_REPO/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/0.6-SNAPSHOT/hapi-fhir-testpage-overlay-0.6-SNAPSHOT.war?unpackFolder=target/m2e-wtp/overlays&amp;includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type> <dependency-type>consumes</dependency-type>
</dependent-module> </dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF"> <dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">

View File

@ -130,7 +130,7 @@ public class TinderStructuresMojo extends AbstractMojo {
pp.combineContentMaps(rp); pp.combineContentMaps(rp);
pp.combineContentMaps(dtp); pp.combineContentMaps(dtp);
pp.writeAll(new File(directoryBase, "resource"), null, packageName); pp.writeAll(new File(directoryBase, "resource"), resDirectoryBase, packageName);
} }
@ -139,7 +139,7 @@ public class TinderStructuresMojo extends AbstractMojo {
dtp.combineContentMaps(pp); dtp.combineContentMaps(pp);
dtp.combineContentMaps(rp); dtp.combineContentMaps(rp);
dtp.writeAll(new File(directoryBase, "composite"), null, packageName); dtp.writeAll(new File(directoryBase, "composite"), resDirectoryBase, packageName);
} }
ourLog.info("Writing ValueSet Enums..."); ourLog.info("Writing ValueSet Enums...");

View File

@ -371,9 +371,9 @@ public abstract class BaseStructureParser {
} }
if (next instanceof Resource) { if (next instanceof Resource) {
myNameToResourceClass.put(next.getElementName(), thePackageBase + '.' + elementName); myNameToResourceClass.put(next.getElementName(), thePackageBase + ".resource." + elementName);
} else if (next instanceof Composite) { } else if (next instanceof Composite) {
myNameToDatatypeClass.put(next.getElementName(), thePackageBase + '.' + elementName); myNameToDatatypeClass.put(next.getElementName(), thePackageBase + ".composite." + elementName + "Dt");
} else { } else {
throw new IllegalStateException(next.getClass().toString()); throw new IllegalStateException(next.getClass().toString());
} }

View File

@ -9,18 +9,15 @@ import java.util.List;
import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.MojoFailureException;
import ch.qos.logback.classic.ClassicConstants; import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.tinder.model.BaseRootType;
import ca.uhn.fhir.tinder.model.Composite;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath; import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo; import com.google.common.reflect.ClassPath.ClassInfo;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.tinder.model.BaseRootType;
import ca.uhn.fhir.tinder.model.Composite;
public class DatatypeGeneratorUsingSpreadsheet extends BaseStructureSpreadsheetParser { public class DatatypeGeneratorUsingSpreadsheet extends BaseStructureSpreadsheetParser {
@Override @Override

View File

@ -6,7 +6,7 @@
<dependent-module archiveName="hapi-fhir-base-0.6-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base"> <dependent-module archiveName="hapi-fhir-base-0.6-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/hapi-fhir-base/hapi-fhir-base">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&amp;excludes=META-INF/MANIFEST.MF"> <dependent-module deploy-path="/" handle="module:/overlay/var/M2_REPO/ca/uhn/hapi/fhir/hapi-fhir-testpage-overlay/0.6-SNAPSHOT/hapi-fhir-testpage-overlay-0.6-SNAPSHOT.war?unpackFolder=target/m2e-wtp/overlays&amp;includes=**/**&amp;excludes=META-INF/MANIFEST.MF">
<dependency-type>consumes</dependency-type> <dependency-type>consumes</dependency-type>
</dependent-module> </dependent-module>
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF"> <dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&amp;excludes=META-INF/MANIFEST.MF">