mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-03-09 14:31:17 +00:00
fix up parsing of logical models
This commit is contained in:
parent
798a93bbec
commit
957dc3f733
@ -142,6 +142,23 @@ public abstract class ParserBase {
|
||||
|
||||
|
||||
protected StructureDefinition getDefinition(List<ValidationMessage> errors, int line, int col, String ns, String name) throws FHIRFormatError {
|
||||
if (logical != null) {
|
||||
String expectedName = ToolingExtensions.readStringExtension(logical, "http://hl7.org/fhir/StructureDefinition/elementdefinition-name");
|
||||
if (expectedName == null) {
|
||||
expectedName = logical.getType();
|
||||
}
|
||||
String expectedNamespace = ToolingExtensions.readStringExtension(logical, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace");
|
||||
if (matchesNamespace(expectedNamespace, ns) && matchesName(expectedName, name)) {
|
||||
return logical;
|
||||
} else {
|
||||
if (expectedNamespace == null && ns == null) {
|
||||
logError(errors, ValidationMessage.NO_RULE_DATE, line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.LOGICAL_MODEL_NAME_MISMATCH, name, expectedName), IssueSeverity.FATAL);
|
||||
} else {
|
||||
logError(errors, ValidationMessage.NO_RULE_DATE, line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.LOGICAL_MODEL_QNAME_MISMATCH, qn(ns, name), qn(expectedNamespace, expectedName)), IssueSeverity.FATAL);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (ns == null) {
|
||||
logError(errors, ValidationMessage.NO_RULE_DATE, line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS__CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAMESPACE, name), IssueSeverity.FATAL);
|
||||
return null;
|
||||
@ -160,9 +177,26 @@ public abstract class ParserBase {
|
||||
return sd;
|
||||
}
|
||||
}
|
||||
logError(errors, ValidationMessage.NO_RULE_DATE, line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAMESPACENAME_, ns, name), IssueSeverity.FATAL);
|
||||
logError(errors, ValidationMessage.NO_RULE_DATE, line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAMESPACENAME_, (ns == null ? "(none)" : ns), name), IssueSeverity.FATAL);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Object qn(String ns, String name) {
|
||||
return ns == null ? name : ns+"::"+name;
|
||||
}
|
||||
|
||||
private boolean matchesNamespace(String expectedNamespace, String ns) {
|
||||
if (expectedNamespace == null) {
|
||||
return ns == null || "noNamespace".equals(ns);
|
||||
} else {
|
||||
return expectedNamespace.equals(ns);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean matchesName(String expectedName, String name) {
|
||||
return expectedName != null && expectedName.equals(name);
|
||||
}
|
||||
|
||||
private String urlTail(String type) {
|
||||
return type == null || !type.contains("/") ? type : type.substring(type.lastIndexOf("/")+1);
|
||||
|
@ -541,7 +541,7 @@ public class XmlParser extends ParserBase {
|
||||
}
|
||||
|
||||
private String convertForDateFormatToExternal(String fmt, String av) throws FHIRException {
|
||||
if ("v3".equals(fmt)) {
|
||||
if ("v3".equals(fmt) || "YYYYMMDDHHMMSS.UUUU[+|-ZZzz]".equals(fmt)) {
|
||||
DateTimeType d = new DateTimeType(av);
|
||||
return d.getAsV3();
|
||||
} else
|
||||
|
@ -35388,7 +35388,7 @@ public class JsonParser extends JsonParserBase {
|
||||
return parseVisionPrescription(json);
|
||||
|
||||
} else {
|
||||
throw new FHIRFormatError("Unknown.Unrecognised resource type '"+t+"' (in property 'resourceType')");
|
||||
throw new FHIRFormatError("Unknown/Unrecognised resource type '"+t+"' (in property 'resourceType')");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user