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();
|
||||
copyElement(src, tgt);
|
||||
if (src.hasPathElement())
|
||||
tgt.setPathElement(convertString(src.getPathElement()));
|
||||
tgt.setPathElement(convertString(src.getPathElement()));
|
||||
tgt.setRepresentation(src.getRepresentation().stream()
|
||||
.map(VersionConvertor_14_50::convertPropertyRepresentation)
|
||||
.collect(Collectors.toList()));
|
||||
.map(VersionConvertor_14_50::convertPropertyRepresentation)
|
||||
.collect(Collectors.toList()));
|
||||
if (src.hasName())
|
||||
tgt.setSliceNameElement(convertString(src.getNameElement()));
|
||||
tgt.setSliceNameElement(convertString(src.getNameElement()));
|
||||
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));
|
||||
if (src.hasSlicing())
|
||||
tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos));
|
||||
tgt.setSlicing(convertElementDefinitionSlicingComponent(src.getSlicing(), context, pos));
|
||||
if (src.hasShort())
|
||||
tgt.setShortElement(convertString(src.getShortElement()));
|
||||
tgt.setShortElement(convertString(src.getShortElement()));
|
||||
if (src.hasDefinition())
|
||||
tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement()));
|
||||
tgt.setDefinitionElement(convertMarkdown(src.getDefinitionElement()));
|
||||
if (src.hasComments())
|
||||
tgt.setCommentElement(convertMarkdown(src.getCommentsElement()));
|
||||
tgt.setCommentElement(convertMarkdown(src.getCommentsElement()));
|
||||
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());
|
||||
if (src.hasMin())
|
||||
tgt.setMin(src.getMin());
|
||||
tgt.setMin(src.getMin());
|
||||
if (src.hasMax())
|
||||
tgt.setMaxElement(convertString(src.getMaxElement()));
|
||||
tgt.setMaxElement(convertString(src.getMaxElement()));
|
||||
if (src.hasBase())
|
||||
tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
|
||||
tgt.setBase(convertElementDefinitionBaseComponent(src.getBase()));
|
||||
if (src.hasContentReference())
|
||||
tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : src.getType()) convertTypeRefComponent(t, tgt.getType());
|
||||
if (src.hasDefaultValue())
|
||||
tgt.setContentReferenceElement(convertUri(src.getContentReferenceElement()));
|
||||
// work around for problem in R2B definitions:
|
||||
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()));
|
||||
if (src.hasMeaningWhenMissing())
|
||||
if (src.hasMeaningWhenMissing())
|
||||
tgt.setMeaningWhenMissingElement(convertMarkdown(src.getMeaningWhenMissingElement()));
|
||||
if (src.hasFixed())
|
||||
if (src.hasFixed())
|
||||
tgt.setFixed(convertType(src.getFixed()));
|
||||
if (src.hasPattern())
|
||||
if (src.hasPattern())
|
||||
tgt.setPattern(convertType(src.getPattern()));
|
||||
if (src.hasExample())
|
||||
if (src.hasExample())
|
||||
tgt.addExample().setLabel("General").setValue(convertType(src.getExample()));
|
||||
if (src.hasMinValue())
|
||||
if (src.hasMinValue())
|
||||
tgt.setMinValue(convertType(src.getMinValue()));
|
||||
if (src.hasMaxValue())
|
||||
if (src.hasMaxValue())
|
||||
tgt.setMaxValue(convertType(src.getMaxValue()));
|
||||
if (src.hasMaxLength())
|
||||
if (src.hasMaxLength())
|
||||
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.ElementDefinition.ElementDefinitionConstraintComponent t : src.getConstraint()) tgt.addConstraint(convertElementDefinitionConstraintComponent(t));
|
||||
if (src.hasMustSupport())
|
||||
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));
|
||||
if (src.hasMustSupport())
|
||||
tgt.setMustSupportElement(convertBoolean(src.getMustSupportElement()));
|
||||
if (src.hasIsModifier())
|
||||
if (src.hasIsModifier())
|
||||
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);
|
||||
if (Utilities.noString(reason))
|
||||
reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY;
|
||||
reason = VersionConvertorConstants.MODIFIER_REASON_LEGACY;
|
||||
tgt.setIsModifierReason(reason);
|
||||
}
|
||||
if (src.hasIsSummary())
|
||||
}
|
||||
if (src.hasIsSummary())
|
||||
tgt.setIsSummaryElement(convertBoolean(src.getIsSummaryElement()));
|
||||
if (src.hasBinding())
|
||||
if (src.hasBinding())
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
|||
cs = findSpecialCodeSystem(system);
|
||||
}
|
||||
if (cs == null) {
|
||||
warningMessage = "Unable to resolve system "+system+" - system is not specified or implicit";
|
||||
warningMessage = "Unable to resolve system "+system;
|
||||
if (!inExpansion)
|
||||
throw new FHIRException(warningMessage);
|
||||
}
|
||||
|
@ -144,8 +144,12 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
|||
throw new FHIRException(warningMessage);
|
||||
}
|
||||
|
||||
if (cs!=null)
|
||||
if (cs!=null) {
|
||||
res = validateCode(code, cs);
|
||||
} else {
|
||||
// it's in the expansion, but we could find it in a code system
|
||||
res = findCodeInExpansion(code);
|
||||
}
|
||||
} else {
|
||||
inExpansion = checkExpansion(code);
|
||||
}
|
||||
|
@ -175,13 +179,38 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
|||
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())
|
||||
return false;
|
||||
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) {
|
||||
if (containsComponent.getSystem().equals(code.getSystem()) && containsComponent.getCode().equals(code.getCode()))
|
||||
return true;
|
||||
|
|
|
@ -30,6 +30,8 @@ public class XVerExtensionManager {
|
|||
BadVersion, Unknown, Invalid, Valid
|
||||
}
|
||||
|
||||
public static final String XVER_EXT_MARKER = "XVER_EXT_MARKER";
|
||||
|
||||
private Map<String, JsonObject> lists = new HashMap<>();
|
||||
private IWorkerContext context;
|
||||
|
||||
|
@ -81,6 +83,7 @@ public class XVerExtensionManager {
|
|||
JsonObject path = root.getAsJsonObject(e);
|
||||
|
||||
StructureDefinition sd = new StructureDefinition();
|
||||
sd.setUserData(XVER_EXT_MARKER, "true");
|
||||
sd.setUrl(url);
|
||||
sd.setVersion(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_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_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_NOTFOUND = "Extension_EXT_Count_NotFound";
|
||||
public final static String EXTENSION_EXT_FIXED_BANNED = "Extension_EXT_Fixed_Banned";
|
||||
|
|
|
@ -498,3 +498,4 @@ TYPE_SPECIFIC_CHECKS_DT_DECIMAL_CHARS = Found {0} decimal places which exceeds t
|
|||
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_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.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class PackageCacheTests {
|
||||
|
||||
|
@ -17,7 +18,11 @@ public class PackageCacheTests {
|
|||
public void testPath() throws IOException {
|
||||
PackageCacheManager cache = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||
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");
|
||||
npm.loadAllFiles();
|
||||
Assertions.assertNotNull(npm);
|
||||
|
@ -30,6 +35,7 @@ public class PackageCacheTests {
|
|||
npm.save(dir);
|
||||
NpmPackage npm2 = cache.loadPackage("hl7.fhir.pubpack", "file:" + dir.getAbsolutePath());
|
||||
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) {
|
||||
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;
|
||||
} else {
|
||||
if (definition.hasContextInvariant()) {
|
||||
for (StringType s : definition.getContextInvariant()) {
|
||||
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());
|
||||
return false;
|
||||
if (definition.hasUserData(XVerExtensionManager.XVER_EXT_MARKER)) {
|
||||
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