fix xver extension synthesis
This commit is contained in:
parent
44893b89b9
commit
3f09f99356
|
@ -64,9 +64,10 @@ public class XVerExtensionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureDefinition makeDefinition(String url) {
|
public StructureDefinition makeDefinition(String url) {
|
||||||
String v = url.substring(20, 23);
|
String verSource = url.substring(20, 23);
|
||||||
|
String verTarget = VersionUtilities.getMajMin(context.getVersion());
|
||||||
String e = url.substring(54);
|
String e = url.substring(54);
|
||||||
JsonObject root = lists.get(v);
|
JsonObject root = lists.get(verSource);
|
||||||
JsonObject path = root.getAsJsonObject(e);
|
JsonObject path = root.getAsJsonObject(e);
|
||||||
|
|
||||||
StructureDefinition sd = new StructureDefinition();
|
StructureDefinition sd = new StructureDefinition();
|
||||||
|
@ -76,8 +77,8 @@ public class XVerExtensionManager {
|
||||||
sd.setKind(StructureDefinitionKind.COMPLEXTYPE);
|
sd.setKind(StructureDefinitionKind.COMPLEXTYPE);
|
||||||
sd.setType("Extension");
|
sd.setType("Extension");
|
||||||
sd.setDerivation(TypeDerivationRule.CONSTRAINT);
|
sd.setDerivation(TypeDerivationRule.CONSTRAINT);
|
||||||
sd.setName("Extension-"+v+"-"+e);
|
sd.setName("Extension-"+verSource+"-"+e);
|
||||||
sd.setTitle("Extension Definition for "+e+" for Version "+v);
|
sd.setTitle("Extension Definition for "+e+" for Version "+verSource);
|
||||||
sd.setStatus(PublicationStatus.ACTIVE);
|
sd.setStatus(PublicationStatus.ACTIVE);
|
||||||
sd.setExperimental(false);
|
sd.setExperimental(false);
|
||||||
sd.setDate(new Date());
|
sd.setDate(new Date());
|
||||||
|
@ -90,7 +91,7 @@ public class XVerExtensionManager {
|
||||||
sd.getDifferential().addElement().setPath("Extension.extension").setMax("0");
|
sd.getDifferential().addElement().setPath("Extension.extension").setMax("0");
|
||||||
sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url));
|
sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url));
|
||||||
ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.value[x]").setMin(1);
|
ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.value[x]").setMin(1);
|
||||||
populateTypes(path, val, v);
|
populateTypes(path, val, verSource, verTarget);
|
||||||
} else if (path.has("elements")) {
|
} else if (path.has("elements")) {
|
||||||
for (JsonElement i : path.getAsJsonArray("elements")) {
|
for (JsonElement i : path.getAsJsonArray("elements")) {
|
||||||
String s = i.getAsString();
|
String s = i.getAsString();
|
||||||
|
@ -102,7 +103,7 @@ public class XVerExtensionManager {
|
||||||
if (!elt.has("types")) {
|
if (!elt.has("types")) {
|
||||||
throw new FHIRException("Internal error - nested elements not supported yet");
|
throw new FHIRException("Internal error - nested elements not supported yet");
|
||||||
}
|
}
|
||||||
populateTypes(elt, val, v);
|
populateTypes(elt, val, verSource, verTarget);
|
||||||
}
|
}
|
||||||
sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url));
|
sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url));
|
||||||
sd.getDifferential().addElement().setPath("Extension.value[x]").setMax("0");
|
sd.getDifferential().addElement().setPath("Extension.value[x]").setMax("0");
|
||||||
|
@ -112,12 +113,12 @@ public class XVerExtensionManager {
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateTypes(JsonObject path, ElementDefinition val, String v) {
|
public void populateTypes(JsonObject path, ElementDefinition val, String verSource, String verTarget) {
|
||||||
for (JsonElement i : path.getAsJsonArray("types")) {
|
for (JsonElement i : path.getAsJsonArray("types")) {
|
||||||
String s = i.getAsString();
|
String s = i.getAsString();
|
||||||
if (s.contains("(")) {
|
if (s.contains("(")) {
|
||||||
String t = s.substring(0, s.indexOf("("));
|
String t = s.substring(0, s.indexOf("("));
|
||||||
TypeRefComponent tr = val.addType().setCode(translateDataType(v, s));
|
TypeRefComponent tr = val.addType().setCode(translateDataType(verTarget, t));
|
||||||
if (hasTargets(tr.getCode()) ) {
|
if (hasTargets(tr.getCode()) ) {
|
||||||
s = s.substring(t.length()+1);
|
s = s.substring(t.length()+1);
|
||||||
for (String p : s.substring(0, s.length()-1).split("\\|")) {
|
for (String p : s.substring(0, s.length()-1).split("\\|")) {
|
||||||
|
@ -125,7 +126,7 @@ public class XVerExtensionManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val.addType().setCode(translateDataType(v, s));
|
val.addType().setCode(translateDataType(verTarget, s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue