Merge pull request #547 from hapifhir/gg-20210625-misc2
Gg 20210625 misc2
This commit is contained in:
commit
bb3b01fd1f
|
@ -662,7 +662,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
if (!derived.getSnapshot().getElementFirstRep().getType().isEmpty())
|
||||
if (derived.getKind() != StructureDefinitionKind.LOGICAL && !derived.getSnapshot().getElementFirstRep().getType().isEmpty())
|
||||
throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_SNAPSHOT_ELEMENT_FOR__IN__FROM_, derived.getSnapshot().getElementFirstRep().getPath(), derived.getUrl(), base.getUrl()));
|
||||
updateMaps(base, derived);
|
||||
|
||||
|
@ -785,7 +785,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (derived.hasDifferential() && !derived.getDifferential().getElementFirstRep().getPath().contains(".") && !derived.getDifferential().getElementFirstRep().getType().isEmpty()) {
|
||||
if (wantFixDifferentialFirstElementType && typeMatchesAncestor(derived.getDifferential().getElementFirstRep().getType(), derived.getBaseDefinition())) {
|
||||
derived.getDifferential().getElementFirstRep().getType().clear();
|
||||
} else {
|
||||
} else if (derived.getKind() != StructureDefinitionKind.LOGICAL) {
|
||||
throw new Error(context.formatMessage(I18nConstants.TYPE_ON_FIRST_DIFFERENTIAL_ELEMENT));
|
||||
}
|
||||
}
|
||||
|
@ -3004,10 +3004,10 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
if (dest.hasFixed()) {
|
||||
checkTypeOk(dest, dest.getFixed().fhirType());
|
||||
checkTypeOk(dest, dest.getFixed().fhirType(), srcSD);
|
||||
}
|
||||
if (dest.hasPattern()) {
|
||||
checkTypeOk(dest, dest.getPattern().fhirType());
|
||||
checkTypeOk(dest, dest.getPattern().fhirType(), srcSD);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3072,14 +3072,20 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
|
||||
public void checkTypeOk(ElementDefinition dest, String ft) {
|
||||
public void checkTypeOk(ElementDefinition dest, String ft, StructureDefinition sd) {
|
||||
boolean ok = false;
|
||||
Set<String> types = new HashSet<>();
|
||||
for (TypeRefComponent t : dest.getType()) {
|
||||
if (t.hasCode()) {
|
||||
types.add(t.getWorkingCode());
|
||||
if (dest.getPath().contains(".")) {
|
||||
for (TypeRefComponent t : dest.getType()) {
|
||||
if (t.hasCode()) {
|
||||
types.add(t.getWorkingCode());
|
||||
}
|
||||
ok = ft.equals(t.getWorkingCode());
|
||||
}
|
||||
ok = ft.equals(t.getWorkingCode());
|
||||
} else {
|
||||
types.add(sd.getType());
|
||||
ok = ft.equals(sd.getType());
|
||||
|
||||
}
|
||||
if (!ok) {
|
||||
messages.add(new ValidationMessage(Source.InstanceValidator, IssueType.CONFLICT, dest.getId(), "The fixed value has type '"+ft+"' which is not valid (valid "+Utilities.pluralize("type", dest.getType().size())+": "+types.toString()+")", IssueSeverity.ERROR));
|
||||
|
|
|
@ -755,7 +755,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
|
||||
@Override
|
||||
public void generateSnapshot(StructureDefinition p, boolean logical) throws DefinitionException, FHIRException {
|
||||
if (!p.hasSnapshot() && (logical || p.getKind() != StructureDefinitionKind.LOGICAL)) {
|
||||
if ((!p.hasSnapshot() || isProfileNeedsRegenerate(p) ) && (logical || p.getKind() != StructureDefinitionKind.LOGICAL)) {
|
||||
if (!p.hasBaseDefinition())
|
||||
throw new DefinitionException(formatMessage(I18nConstants.PROFILE___HAS_NO_BASE_AND_NO_SNAPSHOT, p.getName(), p.getUrl()));
|
||||
StructureDefinition sd = fetchResource(StructureDefinition.class, p.getBaseDefinition());
|
||||
|
@ -791,6 +791,15 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||
}
|
||||
}
|
||||
|
||||
// work around the fact that some Implementation guides were published with old snapshot generators that left invalid snapshots behind.
|
||||
private boolean isProfileNeedsRegenerate(StructureDefinition p) {
|
||||
boolean needs = !p.hasUserData("hack.regnerated") && Utilities.existsInList(p.getUrl(), "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse");
|
||||
if (needs) {
|
||||
p.setUserData("hack.regnerated", "yes");
|
||||
}
|
||||
return needs;
|
||||
}
|
||||
|
||||
public boolean isIgnoreProfileErrors() {
|
||||
return ignoreProfileErrors;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class XVerExtensionManager {
|
|||
public XVerExtensionStatus status(String url) throws FHIRException {
|
||||
String v = url.substring(20, 23);
|
||||
if ("5.0".equals(v)) {
|
||||
v = Constants.VERSION_MM;
|
||||
v = "4.5"; // for now
|
||||
}
|
||||
String e = url.substring(54);
|
||||
if (!lists.containsKey(v)) {
|
||||
|
@ -76,7 +76,7 @@ public class XVerExtensionManager {
|
|||
public StructureDefinition makeDefinition(String url) {
|
||||
String verSource = url.substring(20, 23);
|
||||
if ("5.0".equals(verSource)) {
|
||||
verSource = Constants.VERSION_MM;
|
||||
verSource = "4.5"; // for now
|
||||
}
|
||||
String verTarget = VersionUtilities.getMajMin(context.getVersion());
|
||||
String e = url.substring(54);
|
||||
|
|
|
@ -359,7 +359,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
}
|
||||
|
||||
if (npm.name() == null || id == null || !id.equalsIgnoreCase(npm.name())) {
|
||||
if (!id.equals("hl7.fhir.r5.core")) {// temporary work around
|
||||
if (!id.equals("hl7.fhir.r5.core") && !id.equals("hl7.fhir.us.immds")) {// temporary work around
|
||||
throw new IOException("Attempt to import a mis-identified package. Expected " + id + ", got " + npm.name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -503,7 +503,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
|
||||
private boolean isKnownExtension(String url) {
|
||||
// Added structuredefinition-expression and following extensions explicitly because they weren't defined in the version of the spec they need to be used with
|
||||
if ((allowExamples && (url.contains("example.org") || url.contains("acme.com"))) || url.contains("nema.org") || url.startsWith("http://hl7.org/fhir/tools/StructureDefinition/") || url.equals("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression"))
|
||||
if ((allowExamples && (url.contains("example.org") || url.contains("acme.com"))) || url.contains("nema.org") ||
|
||||
url.startsWith("http://hl7.org/fhir/tools/StructureDefinition/") || url.equals("http://hl7.org/fhir/StructureDefinition/structuredefinition-expression") ||
|
||||
url.equals("http://hl7.org/fhir/StructureDefinition/codesystem-properties-mode"))
|
||||
return true;
|
||||
for (String s : extensionDomains)
|
||||
if (url.startsWith(s))
|
||||
|
|
Loading…
Reference in New Issue