Merge pull request #1095 from hapifhir/gg-202301-misc-fixes

Gg 202301 misc fixes
This commit is contained in:
Grahame Grieve 2023-01-31 08:43:12 +11:00 committed by GitHub
commit 8bface0a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 37 deletions

View File

@ -405,6 +405,8 @@ public class VersionConvertorResourceNameMapper {
return org.hl7.fhir.dstu3.model.MedicationRequest.class.getSimpleName();
case "MedicationUsage":
return org.hl7.fhir.dstu3.model.MedicationStatement.class.getSimpleName();
case "MedicationStatement":
return org.hl7.fhir.dstu3.model.MedicationStatement.class.getSimpleName();
case "MessageDefinition":
return org.hl7.fhir.dstu3.model.MessageDefinition.class.getSimpleName();
case "MessageHeader":

View File

@ -53,9 +53,6 @@ public class DataRequirement40_50 {
private static String convertResourceName4to5(String name) {
if (name == null) return null;
if (name.equals("MedicationStatement")) {
return "MedicationUsage";
}
if (name.equals("DeviceUseStatement")) {
return "DeviceUsage";
}
@ -64,9 +61,6 @@ public class DataRequirement40_50 {
private static String convertResourceName5to4(String name) {
if (name == null) return null;
if (name.equals("MedicationUsage")) {
return "MedicationStatement";
}
if (name.equals("DeviceUsage")) {
return "DeviceUseStatement";
}

View File

@ -53,9 +53,6 @@ public class DataRequirement43_50 {
private static String convertResourceName4to5(String name) {
if (name == null) return null;
if (name.equals("MedicationStatement")) {
return "MedicationUsage";
}
if (name.equals("DeviceUseStatement")) {
return "DeviceUsage";
}
@ -64,9 +61,6 @@ public class DataRequirement43_50 {
private static String convertResourceName5to4(String name) {
if (name == null) return null;
if (name.equals("MedicationUsage")) {
return "MedicationStatement";
}
if (name.equals("DeviceUsage")) {
return "DeviceUseStatement";
}

View File

@ -2135,6 +2135,8 @@ The primary difference between a medicationusage and a medicationadministration
return MEDICATIONREQUEST;
if ("MedicationUsage".equals(codeString))
return MEDICATIONUSAGE;
if ("MedicationStatement".equals(codeString))
return MEDICATIONUSAGE;
if ("MedicinalProductDefinition".equals(codeString))
return MEDICINALPRODUCTDEFINITION;
if ("MessageDefinition".equals(codeString))
@ -3116,6 +3118,8 @@ The primary difference between a medicationusage and a medicationadministration
return AllResourceTypes.MEDICATIONREQUEST;
if ("MedicationUsage".equals(codeString))
return AllResourceTypes.MEDICATIONUSAGE;
if ("MedicationStatement".equals(codeString))
return AllResourceTypes.MEDICATIONUSAGE;
if ("MedicinalProductDefinition".equals(codeString))
return AllResourceTypes.MEDICINALPRODUCTDEFINITION;
if ("MessageDefinition".equals(codeString))
@ -3442,6 +3446,8 @@ The primary difference between a medicationusage and a medicationadministration
return new Enumeration<AllResourceTypes>(this, AllResourceTypes.MEDICATIONREQUEST, code);
if ("MedicationUsage".equals(codeString))
return new Enumeration<AllResourceTypes>(this, AllResourceTypes.MEDICATIONUSAGE, code);
if ("MedicationStatement".equals(codeString))
return new Enumeration<AllResourceTypes>(this, AllResourceTypes.MEDICATIONUSAGE, code);
if ("MedicinalProductDefinition".equals(codeString))
return new Enumeration<AllResourceTypes>(this, AllResourceTypes.MEDICINALPRODUCTDEFINITION, code);
if ("MessageDefinition".equals(codeString))
@ -10016,6 +10022,8 @@ The primary difference between a medicationusage and a medicationadministration
return MEDICATIONREQUEST;
if ("MedicationUsage".equals(codeString))
return MEDICATIONUSAGE;
if ("MedicationStatement".equals(codeString))
return MEDICATIONUSAGE;
if ("MedicinalProductDefinition".equals(codeString))
return MEDICINALPRODUCTDEFINITION;
if ("MessageDefinition".equals(codeString))
@ -11419,6 +11427,8 @@ The primary difference between a medicationusage and a medicationadministration
return FHIRTypes.MEDICATIONREQUEST;
if ("MedicationUsage".equals(codeString))
return FHIRTypes.MEDICATIONUSAGE;
if ("MedicationStatement".equals(codeString))
return FHIRTypes.MEDICATIONUSAGE;
if ("MedicinalProductDefinition".equals(codeString))
return FHIRTypes.MEDICINALPRODUCTDEFINITION;
if ("MessageDefinition".equals(codeString))
@ -11887,6 +11897,8 @@ The primary difference between a medicationusage and a medicationadministration
return new Enumeration<FHIRTypes>(this, FHIRTypes.MEDICATIONREQUEST, code);
if ("MedicationUsage".equals(codeString))
return new Enumeration<FHIRTypes>(this, FHIRTypes.MEDICATIONUSAGE, code);
if ("MedicationStatement".equals(codeString))
return new Enumeration<FHIRTypes>(this, FHIRTypes.MEDICATIONUSAGE, code);
if ("MedicinalProductDefinition".equals(codeString))
return new Enumeration<FHIRTypes>(this, FHIRTypes.MEDICINALPRODUCTDEFINITION, code);
if ("MessageDefinition".equals(codeString))
@ -16282,6 +16294,8 @@ The primary difference between a medicationusage and a medicationadministration
return MEDICATIONREQUEST;
if ("MedicationUsage".equals(codeString))
return MEDICATIONUSAGE;
if ("MedicationStatement".equals(codeString))
return MEDICATIONUSAGE;
if ("MedicinalProductDefinition".equals(codeString))
return MEDICINALPRODUCTDEFINITION;
if ("MessageDefinition".equals(codeString))
@ -17239,6 +17253,8 @@ The primary difference between a medicationusage and a medicationadministration
return ResourceTypeEnum.MEDICATIONREQUEST;
if ("MedicationUsage".equals(codeString))
return ResourceTypeEnum.MEDICATIONUSAGE;
if ("MedicationStatement".equals(codeString))
return ResourceTypeEnum.MEDICATIONUSAGE;
if ("MedicinalProductDefinition".equals(codeString))
return ResourceTypeEnum.MEDICINALPRODUCTDEFINITION;
if ("MessageDefinition".equals(codeString))
@ -17557,6 +17573,8 @@ The primary difference between a medicationusage and a medicationadministration
return new Enumeration<ResourceTypeEnum>(this, ResourceTypeEnum.MEDICATIONREQUEST, code);
if ("MedicationUsage".equals(codeString))
return new Enumeration<ResourceTypeEnum>(this, ResourceTypeEnum.MEDICATIONUSAGE, code);
if ("MedicationStatement".equals(codeString))
return new Enumeration<ResourceTypeEnum>(this, ResourceTypeEnum.MEDICATIONUSAGE, code);
if ("MedicinalProductDefinition".equals(codeString))
return new Enumeration<ResourceTypeEnum>(this, ResourceTypeEnum.MEDICINALPRODUCTDEFINITION, code);
if ("MessageDefinition".equals(codeString))

View File

@ -696,7 +696,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
}
private boolean isBase(String code) {
return code.equals("Element") || code.equals("BackboneElement");
return code != null && (code.equals("Element") || code.equals("BackboneElement"));
}
private List<ElementDefinition> getChildrenForPath(StructureDefinition profile, List<ElementDefinition> elements, String path) throws DefinitionException {
@ -1008,7 +1008,11 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
// we're going to split these up, and create a property for each url
if (p.hasValues()) {
for (BaseWrapper v : p.getValues()) {
Extension ex = (Extension) v.getBase();
Base b = v.getBase();
if (!(b instanceof Extension)) {
throw new FHIRException("huh?");
}
Extension ex = (Extension) b;
String url = ex.getUrl();
StructureDefinition ed = getContext().getWorker().fetchResource(StructureDefinition.class, url);
if (ed == null) {

View File

@ -69,7 +69,7 @@ public class ElementWrappers {
try {
return context.getParser().parseType(xml.toString(StandardCharsets.UTF_8), type);
} catch (Exception e) {
return new StringType("Illegal syntax: "+e.getMessage());
throw new FHIRException(e.getMessage(), e);
}
}
}

View File

@ -930,7 +930,7 @@ public class XhtmlParser {
private boolean isNameChar(char ch)
{
return Character.isLetterOrDigit(ch) || ch == '_' || ch == '-' || ch == ':';
return Character.isLetterOrDigit(ch) || ch == '_' || ch == '-' || ch == ':' || ch == '.';
}
private String readName() throws IOException

View File

@ -164,29 +164,30 @@ public class StructureDefinitionValidator extends BaseValidator {
tc = type.getExtensionValue(ToolingExtensions.EXT_FHIR_TYPE).primitiveValue();
}
if (Utilities.noString(tc) && type.hasChild("code")) {
throw new Error("Snapshot for " + sd.getId() +" element " + path + " has type.code without a value ");
// if (type.getNamedChild("code").hasExtension(" http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type")) {
// tc = "*";
// }
}
typeCodes.add(tc);
Set<String> tcharacteristics = new HashSet<>();
StructureDefinition tsd = context.fetchTypeDefinition(tc);
if (tsd != null && tsd.hasExtension(ToolingExtensions.EXT_TYPE_CHARACTERISTICS)) {
for (Extension ext : tsd.getExtensionsByUrl(ToolingExtensions.EXT_TYPE_CHARACTERISTICS)) {
tcharacteristics.add(ext.getValue().primitiveValue());
if (VersionUtilities.isR4Plus(context.getVersion())) {
throw new Error("Snapshot for " + sd.getId() +" element " + path + " has type.code without a value ");
}
} else {
// nothing specified, so infer from known types
addCharacteristics(tcharacteristics, tc);
}
characteristics.addAll(tcharacteristics);
if (type.hasChildren("targetProfile")) {
ok = rule(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, stack.getLiteralPath(), tcharacteristics.contains("has-target") , I18nConstants.SD_ILLEGAL_CHARACTERISTICS, "targetProfile", tc) && ok;
}
// check the stated profile - must be a constraint on the type
if (snapshot || sd != null) {
ok = validateElementType(errors, type, stack.push(type, -1, null, null), sd, path) && ok;
if (!Utilities.noString(tc)) {
typeCodes.add(tc);
Set<String> tcharacteristics = new HashSet<>();
StructureDefinition tsd = context.fetchTypeDefinition(tc);
if (tsd != null && tsd.hasExtension(ToolingExtensions.EXT_TYPE_CHARACTERISTICS)) {
for (Extension ext : tsd.getExtensionsByUrl(ToolingExtensions.EXT_TYPE_CHARACTERISTICS)) {
tcharacteristics.add(ext.getValue().primitiveValue());
}
} else {
// nothing specified, so infer from known types
addCharacteristics(tcharacteristics, tc);
}
characteristics.addAll(tcharacteristics);
if (type.hasChildren("targetProfile")) {
ok = rule(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, stack.getLiteralPath(), tcharacteristics.contains("has-target") , I18nConstants.SD_ILLEGAL_CHARACTERISTICS, "targetProfile", tc) && ok;
}
// check the stated profile - must be a constraint on the type
if (snapshot || sd != null) {
ok = validateElementType(errors, type, stack.push(type, -1, null, null), sd, path) && ok;
}
}
}
if (typeMustSupport) {