Merge remote-tracking branch 'origin/master' into hl7org_structs

This commit is contained in:
James Agnew 2014-12-10 16:11:08 -05:00
commit 2f92e3515b
1 changed files with 8 additions and 9 deletions

View File

@ -244,7 +244,7 @@ public class FhirDstu1 implements IFhirVersion {
retVal.setId(new IdDt(myId)); retVal.setId(new IdDt(myId));
// Scan for extensions // Scan for extensions
scanForExtensions(retVal, def); scanForExtensions(retVal, def, new HashMap<RuntimeChildDeclaredExtensionDefinition, String>());
Collections.sort(retVal.getExtensionDefn(), new Comparator<ExtensionDefn>() { Collections.sort(retVal.getExtensionDefn(), new Comparator<ExtensionDefn>() {
@Override @Override
public int compare(ExtensionDefn theO1, ExtensionDefn theO2) { public int compare(ExtensionDefn theO1, ExtensionDefn theO2) {
@ -268,12 +268,11 @@ public class FhirDstu1 implements IFhirVersion {
return retVal; return retVal;
} }
private Map<RuntimeChildDeclaredExtensionDefinition, String> scanForExtensions(Profile theProfile, BaseRuntimeElementDefinition<?> def) { private Map<RuntimeChildDeclaredExtensionDefinition, String> scanForExtensions(Profile theProfile, BaseRuntimeElementDefinition<?> def, Map<RuntimeChildDeclaredExtensionDefinition, String> theExtensionDefToCode) {
BaseRuntimeElementCompositeDefinition<?> cdef = ((BaseRuntimeElementCompositeDefinition<?>) def); BaseRuntimeElementCompositeDefinition<?> cdef = ((BaseRuntimeElementCompositeDefinition<?>) def);
Map<RuntimeChildDeclaredExtensionDefinition, String> extensionDefToCode = new HashMap<RuntimeChildDeclaredExtensionDefinition, String>();
for (RuntimeChildDeclaredExtensionDefinition nextChild : cdef.getExtensions()) { for (RuntimeChildDeclaredExtensionDefinition nextChild : cdef.getExtensions()) {
if (extensionDefToCode.containsKey(nextChild)) { if (theExtensionDefToCode.containsKey(nextChild)) {
continue; continue;
} }
@ -290,10 +289,10 @@ public class FhirDstu1 implements IFhirVersion {
} }
defn.setCode(code); defn.setCode(code);
if (extensionDefToCode.values().contains(code)) { if (theExtensionDefToCode.values().contains(code)) {
throw new IllegalStateException("Duplicate extension code: " + code); throw new IllegalStateException("Duplicate extension code: " + code);
} }
extensionDefToCode.put(nextChild, code); theExtensionDefToCode.put(nextChild, code);
if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) { if (nextChild.getChildType() != null && IPrimitiveDatatype.class.isAssignableFrom(nextChild.getChildType())) {
RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow(); RuntimePrimitiveDatatypeDefinition pdef = (RuntimePrimitiveDatatypeDefinition) nextChild.getSingleChildOrThrow();
@ -303,18 +302,18 @@ public class FhirDstu1 implements IFhirVersion {
defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName())); defn.getDefinition().addType().setCode(DataTypeEnum.VALUESET_BINDER.fromCodeString(pdef.getName()));
} else { } else {
RuntimeResourceBlockDefinition pdef = (RuntimeResourceBlockDefinition) nextChild.getSingleChildOrThrow(); RuntimeResourceBlockDefinition pdef = (RuntimeResourceBlockDefinition) nextChild.getSingleChildOrThrow();
scanForExtensions(theProfile, pdef); scanForExtensions(theProfile, pdef, theExtensionDefToCode);
for (RuntimeChildDeclaredExtensionDefinition nextChildExt : pdef.getExtensions()) { for (RuntimeChildDeclaredExtensionDefinition nextChildExt : pdef.getExtensions()) {
StructureElementDefinitionType type = defn.getDefinition().addType(); StructureElementDefinitionType type = defn.getDefinition().addType();
type.setCode(DataTypeEnum.EXTENSION); type.setCode(DataTypeEnum.EXTENSION);
type.setProfile("#" + extensionDefToCode.get(nextChildExt)); type.setProfile("#" + theExtensionDefToCode.get(nextChildExt));
} }
} }
} }
return extensionDefToCode; return theExtensionDefToCode;
} }
@Override @Override