commit
903eabdfc5
|
@ -1454,68 +1454,71 @@ public class VersionConvertor_14_50 {
|
||||||
org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition();
|
org.hl7.fhir.r5.model.ElementDefinition tgt = new org.hl7.fhir.r5.model.ElementDefinition();
|
||||||
copyElement(src, tgt);
|
copyElement(src, tgt);
|
||||||
if (src.hasPathElement())
|
if (src.hasPathElement())
|
||||||
tgt.setPathElement(convertString(src.getPathElement()));
|
tgt.setPathElement(convertString(src.getPathElement()));
|
||||||
tgt.setRepresentation(src.getRepresentation().stream()
|
tgt.setRepresentation(src.getRepresentation().stream()
|
||||||
.map(VersionConvertor_14_50::convertPropertyRepresentation)
|
.map(VersionConvertor_14_50::convertPropertyRepresentation)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
if (src.hasName())
|
if (src.hasName())
|
||||||
tgt.setSliceNameElement(convertString(src.getNameElement()));
|
tgt.setSliceNameElement(convertString(src.getNameElement()));
|
||||||
if (src.hasLabel())
|
if (src.hasLabel())
|
||||||
tgt.setLabelElement(convertString(src.getLabelElement()));
|
tgt.setLabelElement(convertString(src.getLabelElement()));
|
||||||
for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t));
|
for (org.hl7.fhir.dstu2016may.model.Coding t : src.getCode()) tgt.addCode(convertCoding(t));
|
||||||
if (src.hasSlicing())
|
if (src.hasSlicing())
|
||||||
tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos));
|
tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos));
|
||||||
if (src.hasShort())
|
if (src.hasShort())
|
||||||
tgt.setShortElement(convertString(src.getShortElement()));
|
tgt.setShortElement(convertString(src.getShortElement()));
|
||||||
if (src.hasDefinition())
|
if (src.hasDefinition())
|
||||||
tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement()));
|
tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement()));
|
||||||
if (src.hasComments())
|
if (src.hasComments())
|
||||||
tgt.setCommentElement(convertMarkdown(src.getCommentsElement()));
|
tgt.setCommentElement(convertMarkdown(src.getCommentsElement()));
|
||||||
if (src.hasRequirements())
|
if (src.hasRequirements())
|
||||||
tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement()));
|
tgt.setRequirementsElement(convertMarkdown(src.getRequirementsElement()));
|
||||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue());
|
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getAlias()) tgt.addAlias(t.getValue());
|
||||||
if (src.hasMin())
|
if (src.hasMin())
|
||||||
tgt.setMin(src.getMin());
|
tgt.setMin(src.getMin());
|
||||||
if (src.hasMax())
|
if (src.hasMax())
|
||||||
tgt.setMaxElement(convertString(src.getMaxElement()));
|
tgt.setMaxElement(convertString(src.getMaxElement()));
|
||||||
if (src.hasBase())
|
if (src.hasBase())
|
||||||
tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
|
tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
|
||||||
if (src.hasContentReference())
|
if (src.hasContentReference())
|
||||||
tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement()));
|
tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement()));
|
||||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType());
|
// work around for problem in R2B definitions:
|
||||||
if (src.hasDefaultValue())
|
if (!src.hasContentReference()) {
|
||||||
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType());
|
||||||
|
if (src.hasDefaultValue())
|
||||||
tgt.setDefaultValue(convertType(src.getDefaultValue()));
|
tgt.setDefaultValue(convertType(src.getDefaultValue()));
|
||||||
if (src.hasMeaningWhenMissing())
|
if (src.hasMeaningWhenMissing())
|
||||||
tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement()));
|
tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement()));
|
||||||
if (src.hasFixed())
|
if (src.hasFixed())
|
||||||
tgt.setFixed(convertType(src.getFixed()));
|
tgt.setFixed(convertType(src.getFixed()));
|
||||||
if (src.hasPattern())
|
if (src.hasPattern())
|
||||||
tgt.setPattern(convertType(src.getPattern()));
|
tgt.setPattern(convertType(src.getPattern()));
|
||||||
if (src.hasExample())
|
if (src.hasExample())
|
||||||
tgt.addExample().setLabel("General").setValue(convertType(src.getExample()));
|
tgt.addExample().setLabel("General").setValue(convertType(src.getExample()));
|
||||||
if (src.hasMinValue())
|
if (src.hasMinValue())
|
||||||
tgt.setMinValue(convertType(src.getMinValue()));
|
tgt.setMinValue(convertType(src.getMinValue()));
|
||||||
if (src.hasMaxValue())
|
if (src.hasMaxValue())
|
||||||
tgt.setMaxValue(convertType(src.getMaxValue()));
|
tgt.setMaxValue(convertType(src.getMaxValue()));
|
||||||
if (src.hasMaxLength())
|
if (src.hasMaxLength())
|
||||||
tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement()));
|
tgt.setMaxLengthElement(convertInteger(src.getMaxLengthElement()));
|
||||||
for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue());
|
for (org.hl7.fhir.dstu2016may.model.IdType t : src.getCondition()) tgt.addCondition(t.getValue());
|
||||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
|
||||||
if (src.hasMustSupport())
|
if (src.hasMustSupport())
|
||||||
tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement()));
|
tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement()));
|
||||||
if (src.hasIsModifier())
|
if (src.hasIsModifier())
|
||||||
tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement()));
|
tgt.setIsModifierElement(convertBoolean(src.getIsModifierElement()));
|
||||||
if (tgt.getIsModifier()) {
|
if (tgt.getIsModifier()) {
|
||||||
String reason = org.hl7.fhir.dstu2016may.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION);
|
String reason = org.hl7.fhir.dstu2016may.utils.ToolingExtensions.readStringExtension(src, VersionConvertorConstants.MODIFIER_REASON_EXTENSION);
|
||||||
if (Utilities.noString(reason))
|
if (Utilities.noString(reason))
|
||||||
reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY;
|
reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY;
|
||||||
tgt.setIsModifierReason(reason);
|
tgt.setIsModifierReason(reason);
|
||||||
}
|
}
|
||||||
if (src.hasIsSummary())
|
if (src.hasIsSummary())
|
||||||
tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement()));
|
tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement()));
|
||||||
if (src.hasBinding())
|
if (src.hasBinding())
|
||||||
tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding()));
|
tgt.setBinding(convertElementDefinitionBindingComponent(src.getBinding()));
|
||||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t));
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertElementDefinitionMappingComponent(t));
|
||||||
|
}
|
||||||
return tgt;
|
return tgt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
||||||
cs = findSpecialCodeSystem(system);
|
cs = findSpecialCodeSystem(system);
|
||||||
}
|
}
|
||||||
if (cs == null) {
|
if (cs == null) {
|
||||||
warningMessage = "Unable to resolve system "+system+" - system is not specified or implicit";
|
warningMessage = "Unable to resolve system "+system;
|
||||||
if (!inExpansion)
|
if (!inExpansion)
|
||||||
throw new FHIRException(warningMessage);
|
throw new FHIRException(warningMessage);
|
||||||
}
|
}
|
||||||
|
@ -144,8 +144,12 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
||||||
throw new FHIRException(warningMessage);
|
throw new FHIRException(warningMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs!=null)
|
if (cs!=null) {
|
||||||
res = validateCode(code, cs);
|
res = validateCode(code, cs);
|
||||||
|
} else {
|
||||||
|
// it's in the expansion, but we could find it in a code system
|
||||||
|
res = findCodeInExpansion(code);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
inExpansion = checkExpansion(code);
|
inExpansion = checkExpansion(code);
|
||||||
}
|
}
|
||||||
|
@ -175,13 +179,38 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkExpansion(Coding code) {
|
private ValidationResult findCodeInExpansion(Coding code) {
|
||||||
|
if (valueset==null || !valueset.hasExpansion())
|
||||||
|
return null;
|
||||||
|
return findCodeInExpansion(code, valueset.getExpansion().getContains());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ValidationResult findCodeInExpansion(Coding code, List<ValueSetExpansionContainsComponent> contains) {
|
||||||
|
for (ValueSetExpansionContainsComponent containsComponent: contains) {
|
||||||
|
if (containsComponent.getSystem().equals(code.getSystem()) && containsComponent.getCode().equals(code.getCode())) {
|
||||||
|
ConceptDefinitionComponent ccd = new ConceptDefinitionComponent();
|
||||||
|
ccd.setCode(containsComponent.getCode());
|
||||||
|
ccd.setDisplay(containsComponent.getDisplay());
|
||||||
|
ValidationResult res = new ValidationResult(ccd);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
if (containsComponent.hasContains()) {
|
||||||
|
ValidationResult res = findCodeInExpansion(code, containsComponent.getContains());
|
||||||
|
if (res != null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkExpansion(Coding code) {
|
||||||
if (valueset==null || !valueset.hasExpansion())
|
if (valueset==null || !valueset.hasExpansion())
|
||||||
return false;
|
return false;
|
||||||
return checkExpansion(code, valueset.getExpansion().getContains());
|
return checkExpansion(code, valueset.getExpansion().getContains());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkExpansion(Coding code, List<ValueSetExpansionContainsComponent> contains) {
|
private boolean checkExpansion(Coding code, List<ValueSetExpansionContainsComponent> contains) {
|
||||||
for (ValueSetExpansionContainsComponent containsComponent: contains) {
|
for (ValueSetExpansionContainsComponent containsComponent: contains) {
|
||||||
if (containsComponent.getSystem().equals(code.getSystem()) && containsComponent.getCode().equals(code.getCode()))
|
if (containsComponent.getSystem().equals(code.getSystem()) && containsComponent.getCode().equals(code.getCode()))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -30,6 +30,8 @@ public class XVerExtensionManager {
|
||||||
BadVersion, Unknown, Invalid, Valid
|
BadVersion, Unknown, Invalid, Valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String XVER_EXT_MARKER = "XVER_EXT_MARKER";
|
||||||
|
|
||||||
private Map<String, JsonObject> lists = new HashMap<>();
|
private Map<String, JsonObject> lists = new HashMap<>();
|
||||||
private IWorkerContext context;
|
private IWorkerContext context;
|
||||||
|
|
||||||
|
@ -81,6 +83,7 @@ public class XVerExtensionManager {
|
||||||
JsonObject path = root.getAsJsonObject(e);
|
JsonObject path = root.getAsJsonObject(e);
|
||||||
|
|
||||||
StructureDefinition sd = new StructureDefinition();
|
StructureDefinition sd = new StructureDefinition();
|
||||||
|
sd.setUserData(XVER_EXT_MARKER, "true");
|
||||||
sd.setUrl(url);
|
sd.setUrl(url);
|
||||||
sd.setVersion(context.getVersion());
|
sd.setVersion(context.getVersion());
|
||||||
sd.setFhirVersion(FHIRVersion.fromCode(context.getVersion()));
|
sd.setFhirVersion(FHIRVersion.fromCode(context.getVersion()));
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class I18nConstants {
|
||||||
public final static String CODESYSTEM_CS_VS_MISMATCH = "CodeSystem_CS_VS_MisMatch";
|
public final static String CODESYSTEM_CS_VS_MISMATCH = "CodeSystem_CS_VS_MisMatch";
|
||||||
public final static String CODESYSTEM_CS_VS_WRONGSYSTEM = "CodeSystem_CS_VS_WrongSystem";
|
public final static String CODESYSTEM_CS_VS_WRONGSYSTEM = "CodeSystem_CS_VS_WrongSystem";
|
||||||
public final static String EXTENSION_EXT_CONTEXT_WRONG = "Extension_EXT_Context_Wrong";
|
public final static String EXTENSION_EXT_CONTEXT_WRONG = "Extension_EXT_Context_Wrong";
|
||||||
|
public final static String EXTENSION_EXT_CONTEXT_WRONG_XVER = "EXTENSION_EXT_CONTEXT_WRONG_XVER";
|
||||||
public final static String EXTENSION_EXT_COUNT_MISMATCH = "Extension_EXT_Count_Mismatch";
|
public final static String EXTENSION_EXT_COUNT_MISMATCH = "Extension_EXT_Count_Mismatch";
|
||||||
public final static String EXTENSION_EXT_COUNT_NOTFOUND = "Extension_EXT_Count_NotFound";
|
public final static String EXTENSION_EXT_COUNT_NOTFOUND = "Extension_EXT_Count_NotFound";
|
||||||
public final static String EXTENSION_EXT_FIXED_BANNED = "Extension_EXT_Fixed_Banned";
|
public final static String EXTENSION_EXT_FIXED_BANNED = "Extension_EXT_Fixed_Banned";
|
||||||
|
|
|
@ -497,4 +497,5 @@ TYPE_SPECIFIC_CHECKS_DT_BASE64_TOO_LONG = Base64 size is {0} bytes which exceeds
|
||||||
TYPE_SPECIFIC_CHECKS_DT_DECIMAL_CHARS = Found {0} decimal places which exceeds the stated limit of {1} digits
|
TYPE_SPECIFIC_CHECKS_DT_DECIMAL_CHARS = Found {0} decimal places which exceeds the stated limit of {1} digits
|
||||||
Validation_VAL_Profile_WrongType = Specified profile type was "{0}", but found type "{1}"
|
Validation_VAL_Profile_WrongType = Specified profile type was "{0}", but found type "{1}"
|
||||||
Validation_VAL_Profile_WrongType2 = Type mismatch processing profile {0} at path {1}: The element type is {4}, but the profile {3} is for a different type {2}
|
Validation_VAL_Profile_WrongType2 = Type mismatch processing profile {0} at path {1}: The element type is {4}, but the profile {3} is for a different type {2}
|
||||||
VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT = Illegal constraint in profile {0} at path {1} - cannot constrain to type {2} from base types {3}
|
VALIDATION_VAL_ILLEGAL_TYPE_CONSTRAINT = Illegal constraint in profile {0} at path {1} - cannot constrain to type {2} from base types {3}
|
||||||
|
EXTENSION_EXT_CONTEXT_WRONG_XVER = The extension {0} from FHIR version {3} is not allowed to be used at this point (allowed = {1}; this element is [{2}; this is a warning since contexts may be renamed between FHIR versions)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PackageCacheTests {
|
public class PackageCacheTests {
|
||||||
|
|
||||||
|
@ -17,7 +18,11 @@ public class PackageCacheTests {
|
||||||
public void testPath() throws IOException {
|
public void testPath() throws IOException {
|
||||||
PackageCacheManager cache = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
PackageCacheManager cache = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||||
cache.clear();
|
cache.clear();
|
||||||
Assertions.assertTrue(cache.listPackages().isEmpty());
|
List<String> list = cache.listPackages();
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
System.out.println("remaining packages: "+list.toString());
|
||||||
|
}
|
||||||
|
Assertions.assertTrue(list.isEmpty());
|
||||||
NpmPackage npm = cache.loadPackage("hl7.fhir.pubpack", "0.0.3");
|
NpmPackage npm = cache.loadPackage("hl7.fhir.pubpack", "0.0.3");
|
||||||
npm.loadAllFiles();
|
npm.loadAllFiles();
|
||||||
Assertions.assertNotNull(npm);
|
Assertions.assertNotNull(npm);
|
||||||
|
@ -30,6 +35,7 @@ public class PackageCacheTests {
|
||||||
npm.save(dir);
|
npm.save(dir);
|
||||||
NpmPackage npm2 = cache.loadPackage("hl7.fhir.pubpack", "file:" + dir.getAbsolutePath());
|
NpmPackage npm2 = cache.loadPackage("hl7.fhir.pubpack", "file:" + dir.getAbsolutePath());
|
||||||
Assertions.assertNotNull(npm2);
|
Assertions.assertNotNull(npm2);
|
||||||
Assertions.assertFalse(cache.listPackages().isEmpty());
|
list = cache.listPackages();
|
||||||
|
Assertions.assertFalse(list.isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1567,14 +1567,23 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
rule(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, I18nConstants.EXTENSION_EXT_CONTEXT_WRONG, extUrl, contexts.toString(), plist.toString());
|
if (definition.hasUserData(XVerExtensionManager.XVER_EXT_MARKER)) {
|
||||||
|
warning(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, I18nConstants.EXTENSION_EXT_CONTEXT_WRONG_XVER, extUrl, contexts.toString(), plist.toString());
|
||||||
|
} else {
|
||||||
|
rule(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, I18nConstants.EXTENSION_EXT_CONTEXT_WRONG, extUrl, contexts.toString(), plist.toString());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (definition.hasContextInvariant()) {
|
if (definition.hasContextInvariant()) {
|
||||||
for (StringType s : definition.getContextInvariant()) {
|
for (StringType s : definition.getContextInvariant()) {
|
||||||
if (!fpe.evaluateToBoolean(hostContext, resource, hostContext.getRootResource(), container, fpe.parse(s.getValue()))) {
|
if (!fpe.evaluateToBoolean(hostContext, resource, hostContext.getRootResource(), container, fpe.parse(s.getValue()))) {
|
||||||
rule(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, I18nConstants.PROFILE_EXT_NOT_HERE, extUrl, s.getValue());
|
if (definition.hasUserData(XVerExtensionManager.XVER_EXT_MARKER)) {
|
||||||
return false;
|
warning(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, I18nConstants.PROFILE_EXT_NOT_HERE, extUrl, s.getValue());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
rule(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false, I18nConstants.PROFILE_EXT_NOT_HERE, extUrl, s.getValue());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue