Correctly parse List resource
This commit is contained in:
parent
e6d6ec88b2
commit
9413bfa47b
|
@ -107,6 +107,10 @@
|
|||
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!
|
||||
</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 version="0.5" date="2014-Jul-30">
|
||||
<action type="add">
|
||||
|
|
|
@ -72,12 +72,14 @@ public class FhirContext {
|
|||
private volatile INarrativeGenerator myNarrativeGenerator;
|
||||
private volatile IRestfulClientFactory myRestfulClientFactory;
|
||||
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.
|
||||
*/
|
||||
public FhirContext() {
|
||||
super();
|
||||
this(EMPTY_LIST);
|
||||
}
|
||||
|
||||
public FhirContext(Class<? extends IResource> theResourceType) {
|
||||
|
@ -146,8 +148,11 @@ public class FhirContext {
|
|||
|
||||
if (retVal == null) {
|
||||
try {
|
||||
String candidateName = Patient.class.getPackage().getName() + "." + resourceName;
|
||||
Class<?> clazz = Class.forName(candidateName);
|
||||
String className = myNameToResourceType.get(resourceName.toLowerCase());
|
||||
if (className == null) {
|
||||
return null;
|
||||
}
|
||||
Class<?> clazz = Class.forName(className);
|
||||
if (IResource.class.isAssignableFrom(clazz)) {
|
||||
retVal = scanResourceType((Class<? extends IResource>) clazz);
|
||||
}
|
||||
|
@ -298,6 +303,8 @@ public class FhirContext {
|
|||
myClassToElementDefinition = classToElementDefinition;
|
||||
myIdToResourceDefinition = idToElementDefinition;
|
||||
|
||||
myNameToResourceType = scanner.getNameToResourceType();
|
||||
|
||||
return classToElementDefinition;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@ class ModelScanner {
|
|||
// myNameToDatatypeDefinitions = new HashMap<String,
|
||||
// RuntimeDatatypeDefinition>();
|
||||
|
||||
private Map<String, String> myNameToResourceType = new HashMap<String, String>();
|
||||
|
||||
private RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
|
||||
|
||||
private Set<Class<? extends IElement>> myScanAlso = new HashSet<Class<? extends IElement>>();
|
||||
|
@ -106,10 +108,18 @@ class ModelScanner {
|
|||
return myClassToElementDefinitions;
|
||||
}
|
||||
|
||||
public Map<String, RuntimeResourceDefinition> getIdToResourceDefinition() {
|
||||
return myIdToResourceDefinition;
|
||||
}
|
||||
|
||||
public Map<String, RuntimeResourceDefinition> getNameToResourceDefinitions() {
|
||||
return (myNameToResourceDefinitions);
|
||||
}
|
||||
|
||||
public Map<String, String> getNameToResourceType() {
|
||||
return myNameToResourceType;
|
||||
}
|
||||
|
||||
public RuntimeChildUndeclaredExtensionDefinition getRuntimeChildUndeclaredExtensionDefinition() {
|
||||
return myRuntimeChildUndeclaredExtensionDefinition;
|
||||
}
|
||||
|
@ -160,9 +170,9 @@ class ModelScanner {
|
|||
int startSize = myClassToElementDefinitions.size();
|
||||
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) {
|
||||
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) {
|
||||
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();
|
||||
try {
|
||||
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 {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IElement> nextClass = (Class<? extends IElement>) Class.forName((String) nextValue);
|
||||
|
@ -234,8 +255,7 @@ class ModelScanner {
|
|||
ResourceDef resourceDefinition = theClass.getAnnotation(ResourceDef.class);
|
||||
if (resourceDefinition != null) {
|
||||
if (!IResource.class.isAssignableFrom(theClass)) {
|
||||
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": "
|
||||
+ theClass.getCanonicalName());
|
||||
throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends IResource> resClass = (Class<? extends IResource>) theClass;
|
||||
|
@ -253,8 +273,7 @@ class ModelScanner {
|
|||
Class<? extends IPrimitiveDatatype<?>> resClass = (Class<? extends IPrimitiveDatatype<?>>) theClass;
|
||||
scanPrimitiveDatatype(resClass, datatypeDefinition);
|
||||
} else {
|
||||
throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": "
|
||||
+ theClass.getCanonicalName());
|
||||
throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,8 +284,7 @@ class ModelScanner {
|
|||
Class<? extends IResourceBlock> blockClass = (Class<? extends IResourceBlock>) theClass;
|
||||
scanBlock(blockClass, blockDefinition);
|
||||
} else {
|
||||
throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": "
|
||||
+ theClass.getCanonicalName());
|
||||
throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,8 +375,7 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef,
|
||||
TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
|
||||
private void scanCompositeElementForChildren(Class<? extends ICompositeElement> theClass, Set<String> elementNames, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToElementDef, TreeMap<Integer, BaseRuntimeDeclaredChildDefinition> theOrderToExtensionDef) {
|
||||
int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;
|
||||
|
||||
for (Field next : theClass.getDeclaredFields()) {
|
||||
|
@ -395,8 +412,8 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
if (order == 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() + " could be found on type " + next.getDeclaringClass().getSimpleName());
|
||||
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()
|
||||
+ " could be found on type " + next.getDeclaringClass().getSimpleName());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -411,8 +428,8 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
if (order == 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 " + next.getDeclaringClass().getSimpleName());
|
||||
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 "
|
||||
+ next.getDeclaringClass().getSimpleName());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -427,7 +444,8 @@ class ModelScanner {
|
|||
int min = childAnnotation.min();
|
||||
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)) {
|
||||
order--;
|
||||
|
@ -439,8 +457,7 @@ class ModelScanner {
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -479,8 +496,7 @@ class ModelScanner {
|
|||
* Child is an extension
|
||||
*/
|
||||
Class<? extends IElement> et = (Class<? extends IElement>) nextElementType;
|
||||
RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName,
|
||||
extensionAttr.url(), et);
|
||||
RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et);
|
||||
orderMap.put(order, def);
|
||||
if (IElement.class.isAssignableFrom(nextElementType)) {
|
||||
addScanAlso((Class<? extends IElement>) nextElementType);
|
||||
|
@ -492,8 +508,7 @@ class ModelScanner {
|
|||
List<Class<? extends IResource>> refTypesList = new ArrayList<Class<? extends IResource>>();
|
||||
for (Class<? extends IElement> nextType : childAnnotation.type()) {
|
||||
if (IResource.class.isAssignableFrom(nextType) == false) {
|
||||
throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + ResourceReferenceDt.class
|
||||
+ " but contains a non-resource type: " + nextType.getCanonicalName());
|
||||
throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + ResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
|
||||
}
|
||||
refTypesList.add((Class<? extends IResource>) nextType);
|
||||
addScanAlso(nextType);
|
||||
|
@ -503,7 +518,8 @@ class ModelScanner {
|
|||
|
||||
} 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;
|
||||
|
@ -542,8 +558,7 @@ class ModelScanner {
|
|||
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
|
||||
if (concept != null) {
|
||||
if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) {
|
||||
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());
|
||||
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());
|
||||
} else {
|
||||
Class<? extends ICodeEnum> type = concept.type();
|
||||
myScanAlsoCodeTable.add(type);
|
||||
|
@ -589,8 +604,8 @@ class ModelScanner {
|
|||
String resourceName = resourceDefinition.name();
|
||||
if (isBlank(resourceName)) {
|
||||
Class<?> parent = theClass.getSuperclass();
|
||||
primaryNameProvider=false;
|
||||
while (parent.equals(Object.class)==false && isBlank(resourceName)) {
|
||||
primaryNameProvider = false;
|
||||
while (parent.equals(Object.class) == false && isBlank(resourceName)) {
|
||||
ResourceDef nextDef = parent.getAnnotation(ResourceDef.class);
|
||||
if (nextDef != null) {
|
||||
resourceName = nextDef.name();
|
||||
|
@ -602,19 +617,19 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
|
||||
// if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
||||
// if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||
// // throw new
|
||||
// // ConfigurationException("Detected duplicate element name '" +
|
||||
// // resourceName + "' in types '" + theClass.getCanonicalName() +
|
||||
// // "' and '"
|
||||
// // +
|
||||
// // myNameToResourceDefinitions.get(resourceName).getImplementingClass()
|
||||
// // + "'");
|
||||
// } else {
|
||||
// return resourceName;
|
||||
// }
|
||||
// }
|
||||
// if (myNameToResourceDefinitions.containsKey(resourceName)) {
|
||||
// if (!myNameToResourceDefinitions.get(resourceName).getImplementingClass().equals(theClass)) {
|
||||
// // throw new
|
||||
// // ConfigurationException("Detected duplicate element name '" +
|
||||
// // resourceName + "' in types '" + theClass.getCanonicalName() +
|
||||
// // "' and '"
|
||||
// // +
|
||||
// // myNameToResourceDefinitions.get(resourceName).getImplementingClass()
|
||||
// // + "'");
|
||||
// } else {
|
||||
// return resourceName;
|
||||
// }
|
||||
// }
|
||||
|
||||
String resourceId = resourceDefinition.id();
|
||||
if (isBlank(resourceId)) {
|
||||
|
@ -624,8 +639,7 @@ class ModelScanner {
|
|||
// theClass.getCanonicalName());
|
||||
} else {
|
||||
if (myIdToResourceDefinition.containsKey(resourceId)) {
|
||||
throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and "
|
||||
+ myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
|
||||
throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and " + myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -672,8 +686,7 @@ class ModelScanner {
|
|||
for (String nextName : searchParam.compositeOf()) {
|
||||
RuntimeSearchParam param = nameToParam.get(nextName);
|
||||
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[] {
|
||||
theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() });
|
||||
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() });
|
||||
continue;
|
||||
}
|
||||
compositeOf.add(param);
|
||||
|
@ -684,10 +697,6 @@ class ModelScanner {
|
|||
}
|
||||
}
|
||||
|
||||
public Map<String, RuntimeResourceDefinition> getIdToResourceDefinition() {
|
||||
return myIdToResourceDefinition;
|
||||
}
|
||||
|
||||
private static Class<?> getGenericCollectionTypeOfCodedField(Field next) {
|
||||
Class<?> type;
|
||||
ParameterizedType collectionType = (ParameterizedType) next.getGenericType();
|
||||
|
|
|
@ -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
|
|
@ -72,7 +72,7 @@ public class XmlParserTest {
|
|||
|
||||
Binary patient = new Binary();
|
||||
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);
|
||||
assertEquals("<Binary xmlns=\"http://hl7.org/fhir\" contentType=\"foo\">AQIDBA==</Binary>", val);
|
||||
|
@ -94,7 +94,7 @@ public class XmlParserTest {
|
|||
|
||||
@Test
|
||||
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");
|
||||
|
||||
InstantDt pub = InstantDt.withCurrentTime();
|
||||
|
@ -126,15 +126,13 @@ public class XmlParserTest {
|
|||
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.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", "/>"));
|
||||
assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings));
|
||||
assertThat(bundleString, not(containsString("at:by")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeBundleCategory() {
|
||||
|
||||
|
@ -171,7 +169,6 @@ public class XmlParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedAndIncludedResources() {
|
||||
|
||||
|
@ -187,10 +184,8 @@ public class XmlParserTest {
|
|||
|
||||
ourLog.info(str);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedResources() {
|
||||
|
||||
|
@ -233,7 +228,6 @@ public class XmlParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeDeclaredExtensionWithResourceContent() {
|
||||
IParser parser = ourCtx.newXmlParser();
|
||||
|
@ -336,7 +330,6 @@ public class XmlParserTest {
|
|||
ExtensionDt parameter = q.addParameter();
|
||||
parameter.setUrl("http://foo").setValue(new StringDt("bar"));
|
||||
|
||||
|
||||
String val = ourCtx.newXmlParser().encodeResourceToString(q);
|
||||
ourLog.info(val);
|
||||
|
||||
|
@ -408,7 +401,6 @@ public class XmlParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExtensionOnPrimitive() throws Exception {
|
||||
|
||||
|
@ -433,9 +425,6 @@ public class XmlParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testExtensions() throws DataFormatException {
|
||||
|
||||
|
@ -541,7 +530,6 @@ public class XmlParserTest {
|
|||
assertTrue(d.toString(), d.identical());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLoadAndEncodeUndeclaredExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException {
|
||||
IParser p = ourCtx.newXmlParser();
|
||||
|
@ -607,7 +595,7 @@ public class XmlParserTest {
|
|||
ourLog.info(result);
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void testParseFeedWithListResource() throws ConfigurationException, DataFormatException, IOException {
|
||||
|
||||
// Use new context here to ensure List isn't already loaded
|
||||
|
@ -617,8 +605,9 @@ public class XmlParserTest {
|
|||
Bundle bundle = p.parseBundle(string);
|
||||
|
||||
ListResource res = (ListResource) bundle.toListOfResources().get(2);
|
||||
}
|
||||
assertEquals("cid:patient@bundle", res.getSubject().getReference().getValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadPatient() throws ConfigurationException, DataFormatException, IOException {
|
||||
|
@ -673,7 +662,6 @@ public class XmlParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
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>"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNarrativeGeneration() throws DataFormatException {
|
||||
|
||||
|
@ -764,19 +751,18 @@ public class XmlParserTest {
|
|||
|
||||
// Only one (outer) contained block
|
||||
int idx0 = str.indexOf("<contained>");
|
||||
int idx1 = str.indexOf("<contained>",idx0+1);
|
||||
int idx1 = str.indexOf("<contained>", idx0 + 1);
|
||||
assertNotEquals(-1, idx0);
|
||||
assertEquals(-1, idx1);
|
||||
|
||||
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();
|
||||
assertEquals("B",obsB.getName().getText().getValue());
|
||||
assertEquals("B", obsB.getName().getText().getValue());
|
||||
|
||||
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>");
|
||||
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();
|
||||
assertEquals("256a5231-a2bb-49bd-9fea-f349d428b70d", resource.getId().getIdPart());
|
||||
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("1", entry.getResource().getId().getIdPart());
|
||||
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("jdoe@example.org", entry.getDeletedByEmail().getValue());
|
||||
assertEquals("Removed comment spam", entry.getDeletedComment().getValue());
|
||||
|
@ -936,7 +922,7 @@ public class XmlParserTest {
|
|||
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(bundle));
|
||||
|
||||
String encoded = ourCtx.newXmlParser().encodeBundleToString(bundle);
|
||||
assertEquals(msg,encoded);
|
||||
assertEquals(msg, encoded);
|
||||
|
||||
}
|
||||
|
||||
|
@ -978,7 +964,6 @@ public class XmlParserTest {
|
|||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testParseEncodeNarrative() {
|
||||
|
||||
|
@ -1000,8 +985,7 @@ public class XmlParserTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* This sample has extra elements in <searchParam> that are not actually a
|
||||
* part of the spec any more..
|
||||
* This sample has extra elements in <searchParam> that are not actually a part of the spec any more..
|
||||
*/
|
||||
@Test
|
||||
public void testParseFuroreMetadataWithExtraElements() throws IOException {
|
||||
|
@ -1023,19 +1007,9 @@ public class XmlParserTest {
|
|||
|
||||
@Test
|
||||
public void testParseQuery() {
|
||||
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" +
|
||||
" <!-- 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>";
|
||||
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"
|
||||
+ " <!-- 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);
|
||||
|
||||
assertEquals("urn:uuid:42b253f5-fa17-40d0-8da5-44aeb4230376", query.getIdentifier().getValueAsString());
|
||||
|
@ -1155,7 +1129,7 @@ public class XmlParserTest {
|
|||
//@formatter:on
|
||||
|
||||
String encoded = ourCtx.newXmlParser().encodeTagListToString(tagList);
|
||||
assertEquals(expected,encoded);
|
||||
assertEquals(expected, encoded);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&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&includes=**/**&excludes=META-INF/MANIFEST.MF">
|
||||
<dependency-type>consumes</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&excludes=META-INF/MANIFEST.MF">
|
||||
|
|
|
@ -130,7 +130,7 @@ public class TinderStructuresMojo extends AbstractMojo {
|
|||
|
||||
pp.combineContentMaps(rp);
|
||||
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(rp);
|
||||
dtp.writeAll(new File(directoryBase, "composite"), null, packageName);
|
||||
dtp.writeAll(new File(directoryBase, "composite"), resDirectoryBase, packageName);
|
||||
}
|
||||
|
||||
ourLog.info("Writing ValueSet Enums...");
|
||||
|
|
|
@ -371,9 +371,9 @@ public abstract class BaseStructureParser {
|
|||
}
|
||||
|
||||
if (next instanceof Resource) {
|
||||
myNameToResourceClass.put(next.getElementName(), thePackageBase + '.' + elementName);
|
||||
myNameToResourceClass.put(next.getElementName(), thePackageBase + ".resource." + elementName);
|
||||
} else if (next instanceof Composite) {
|
||||
myNameToDatatypeClass.put(next.getElementName(), thePackageBase + '.' + elementName);
|
||||
myNameToDatatypeClass.put(next.getElementName(), thePackageBase + ".composite." + elementName + "Dt");
|
||||
} else {
|
||||
throw new IllegalStateException(next.getClass().toString());
|
||||
}
|
||||
|
|
|
@ -9,18 +9,15 @@ import java.util.List;
|
|||
|
||||
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.reflect.ClassPath;
|
||||
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 {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/" handle="module:/overlay/prj/hapi-fhir-testpage-overlay?includes=**/**&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&includes=**/**&excludes=META-INF/MANIFEST.MF">
|
||||
<dependency-type>consumes</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/" handle="module:/overlay/slf/?includes=**/**&excludes=META-INF/MANIFEST.MF">
|
||||
|
|
Loading…
Reference in New Issue