Fix snapshot generation - always populate constraint source properly
This commit is contained in:
parent
2ff53e9bf1
commit
d7754a321f
|
@ -1091,6 +1091,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
updateConstraintSources(outcome, srcSD.getUrl());
|
||||
markDerived(outcome);
|
||||
if (resultPathBase == null)
|
||||
resultPathBase = outcome.getPath();
|
||||
|
@ -1927,6 +1928,15 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return res;
|
||||
}
|
||||
|
||||
private void updateConstraintSources(ElementDefinition ed, String url) {
|
||||
for (ElementDefinitionConstraintComponent c : ed.getConstraint()) {
|
||||
if (!c.hasSource()) {
|
||||
c.setSource(url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Set<String> getListOfTypes(ElementDefinition e) {
|
||||
Set<String> result = new HashSet<>();
|
||||
for (TypeRefComponent t : e.getType()) {
|
||||
|
@ -2422,6 +2432,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
StructureDefinition sd = null;
|
||||
if (type.hasProfile()) {
|
||||
sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue());
|
||||
if (sd == null) {
|
||||
if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) {
|
||||
sd = xver.makeDefinition(type.getProfile().get(0).getValue());
|
||||
}
|
||||
}
|
||||
if (sd == null)
|
||||
System.out.println("Failed to find referenced profile: " + type.getProfile());
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent;
|
||||
import org.hl7.fhir.r5.model.IntegerType;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
||||
|
@ -51,6 +52,12 @@ public class ProfileUtilitiesTests {
|
|||
f.setBase(null);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
ok = Base.compareDeep(b, f, true);
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +90,12 @@ public class ProfileUtilitiesTests {
|
|||
if (ok) {
|
||||
ElementDefinition b = base.getSnapshot().getElement().get(i);
|
||||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath()))
|
||||
ok = false;
|
||||
else {
|
||||
|
@ -128,6 +141,12 @@ public class ProfileUtilitiesTests {
|
|||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
|
||||
ok = false;
|
||||
}
|
||||
|
@ -174,6 +193,12 @@ public class ProfileUtilitiesTests {
|
|||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
|
||||
ok = false;
|
||||
}
|
||||
|
@ -221,6 +246,12 @@ public class ProfileUtilitiesTests {
|
|||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
|
||||
ok = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue