Update for regenerated java code in 5.0.0-draft-final

This commit is contained in:
Grahame Grieve 2023-03-01 21:49:49 +11:00
parent 2e11041fc5
commit 68090356cb
18 changed files with 287 additions and 57 deletions

View File

@ -48,6 +48,7 @@ import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.conformance.ElementRedirection;
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities.AllowUnknownProfile;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.elementmodel.ObjectConverter;
import org.hl7.fhir.r5.elementmodel.Property;
@ -129,6 +130,12 @@ import org.hl7.fhir.utilities.xml.SchematronWriter.Section;
*/
public class ProfileUtilities extends TranslatingUtilities {
public enum AllowUnknownProfile {
NONE, // exception if there's any unknown profiles (the default)
NON_EXTNEIONS, // don't raise an exception except on Extension (because more is going on there
ALL_TYPES // allow any unknow profile
}
private static final List<String> INHERITED_ED_URLS = Arrays.asList(
"http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-binding-style",
"http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-extension-style");
@ -272,6 +279,7 @@ public class ProfileUtilities extends TranslatingUtilities {
private boolean wantFixDifferentialFirstElementType;
private Set<String> masterSourceFileNames;
private Map<ElementDefinition, SourcedChildDefinitions> childMapCache = new HashMap<>();
private AllowUnknownProfile allowUnknownProfile = AllowUnknownProfile.ALL_TYPES;
public ProfileUtilities(IWorkerContext context, List<ValidationMessage> messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) {
super();
@ -607,6 +615,9 @@ public class ProfileUtilities extends TranslatingUtilities {
System.out.println("Snapshot: ");
for (ElementDefinition ed : derived.getSnapshot().getElement())
System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed));
System.out.println("diff: ");
for (ElementDefinition ed : diff.getElement())
System.out.println(" "+ed.getId()+" : "+typeSummaryWithProfile(ed)+"["+ed.getMin()+".."+ed.getMax()+"]"+sliceSummary(ed)+" "+constraintSummary(ed)+" [gen = "+(ed.hasUserData(UD_GENERATED_IN_SNAPSHOT) ? ed.getUserData(UD_GENERATED_IN_SNAPSHOT) : "--")+"]");
}
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
//Check that all differential elements have a corresponding snapshot element
@ -1954,7 +1965,20 @@ public class ProfileUtilities extends TranslatingUtilities {
base.getAlias().addAll(e.getAlias());
base.getMapping().clear();
base.getMapping().addAll(e.getMapping());
}
} else if (source.getType().size() == 1 && source.getTypeFirstRep().hasProfile()) {
String type = source.getTypeFirstRep().getWorkingCode();
if ("Extension".equals(type)) {
System.out.println("Can't find Extension definition for "+source.getTypeFirstRep().getProfile().get(0).asStringValue()+" but trying to go on");
if (allowUnknownProfile != AllowUnknownProfile.ALL_TYPES) {
throw new DefinitionException("Unable to find Extension definition for "+source.getTypeFirstRep().getProfile().get(0).asStringValue());
}
} else {
System.out.println("Can't find "+type+" profile "+source.getTypeFirstRep().getProfile().get(0).asStringValue()+" but trying to go on");
if (allowUnknownProfile == AllowUnknownProfile.NONE) {
throw new DefinitionException("Unable to find "+type+" profile "+source.getTypeFirstRep().getProfile().get(0).asStringValue());
}
}
}
if (derived != null) {
if (derived.hasSliceName()) {
base.setSliceName(derived.getSliceName());
@ -3874,5 +3898,13 @@ public class ProfileUtilities extends TranslatingUtilities {
return sd.getDerivation() == TypeDerivationRule.CONSTRAINT && sd.getType().equals("Extension");
}
public AllowUnknownProfile getAllowUnknownProfile() {
return allowUnknownProfile;
}
public void setAllowUnknownProfile(AllowUnknownProfile allowUnknownProfile) {
this.allowUnknownProfile = allowUnknownProfile;
}
}

View File

@ -244,8 +244,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
public SimpleWorkerContext fromPackage(NpmPackage pi, IContextResourceLoader loader) throws IOException, FHIRException {
SimpleWorkerContext context = getSimpleWorkerContextInstance();
context.setAllowLoadingDuplicates(allowLoadingDuplicates);
context.version = pi.getNpm().asString("version");
context.setAllowLoadingDuplicates(allowLoadingDuplicates); context.version = pi.getNpm().asString("version");
context.loadFromPackage(pi, loader);
context.finishLoading();
return build(context);
@ -508,6 +507,9 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
}
if (version == null) {
version = pi.version();
if (version.equals("current")) {
version = "5.0.0";
}
}
return t;
}

View File

@ -11,6 +11,7 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.ConceptMap;
import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent;
import org.hl7.fhir.r5.model.ConceptMap.MappingPropertyComponent;
import org.hl7.fhir.r5.model.ConceptMap.OtherElementComponent;
import org.hl7.fhir.r5.model.ConceptMap.SourceElementComponent;
import org.hl7.fhir.r5.model.ConceptMap.TargetElementComponent;
@ -97,27 +98,28 @@ public class ConceptMapRenderer extends TerminologyRenderer {
String src = grp.getSource();
boolean comment = false;
boolean ok = true;
Map<String, HashSet<String>> props = new HashMap<String, HashSet<String>>();
Map<String, HashSet<String>> sources = new HashMap<String, HashSet<String>>();
Map<String, HashSet<String>> targets = new HashMap<String, HashSet<String>>();
sources.put("code", new HashSet<String>());
targets.put("code", new HashSet<String>());
SourceElementComponent cc = grp.getElement().get(0);
String dst = grp.getTarget();
sources.get("code").add(grp.getSource());
targets.get("code").add(grp.getTarget());
for (SourceElementComponent ccl : grp.getElement()) {
ok = ok && (ccl.getNoMap() || (ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty()));
for (TargetElementComponent ccm : ccl.getTarget()) {
comment = comment || !Utilities.noString(ccm.getComment());
for (MappingPropertyComponent pp : ccm.getProperty()) {
if (!props.containsKey(pp.getCode()))
props.put(pp.getCode(), new HashSet<String>());
}
for (OtherElementComponent d : ccm.getDependsOn()) {
if (!sources.containsKey(d.getProperty()))
sources.put(d.getProperty(), new HashSet<String>());
// sources.get(d.getProperty()).add(d.getSystem());
if (!sources.containsKey(d.getAttribute()))
sources.put(d.getAttribute(), new HashSet<String>());
}
for (OtherElementComponent d : ccm.getProduct()) {
if (!targets.containsKey(d.getProperty()))
targets.put(d.getProperty(), new HashSet<String>());
// targets.get(d.getProperty()).add(d.getSystem());
if (!targets.containsKey(d.getAttribute()))
targets.put(d.getAttribute(), new HashSet<String>());
}
}
}
@ -205,6 +207,7 @@ public class ConceptMapRenderer extends TerminologyRenderer {
if (comment) {
tr.td().b().tx("Comment");
}
tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Properties");
tr = tbl.tr();
if (sources.get("code").size() == 1) {
String url = sources.get("code").iterator().next();
@ -237,8 +240,18 @@ public class ConceptMapRenderer extends TerminologyRenderer {
tr.td().b().addText(getDescForConcept(s));
}
}
if (comment)
if (comment) {
tr.td();
}
for (String s : props.keySet()) {
if (s != null) {
if (props.get(s).size() == 1) {
String url = props.get(s).iterator().next();
renderCSDetailsLink(tr, url, false);
} else
tr.td().b().addText(getDescForConcept(s));
}
}
for (int si = 0; si < grp.getElement().size(); si++) {
SourceElementComponent ccl = grp.getElement().get(si);
@ -333,6 +346,13 @@ public class ConceptMapRenderer extends TerminologyRenderer {
}
if (comment)
tr.td().addText(ccm.getComment());
for (String s : props.keySet()) {
if (s != null) {
td = tr.td();
td.addText(getValue(ccm.getProperty(), s));
}
}
}
}
addUnmapped(tbl, grp);
@ -429,10 +449,13 @@ public class ConceptMapRenderer extends TerminologyRenderer {
}
private String getValue(List<MappingPropertyComponent> list, String s) {
return "todo";
}
private String getValue(List<OtherElementComponent> list, String s, boolean withSystem) {
for (OtherElementComponent c : list) {
if (s.equals(c.getProperty()))
if (s.equals(c.getAttribute()))
if (withSystem)
return /*c.getSystem()+" / "+*/c.getValue().primitiveValue();
else
@ -443,7 +466,7 @@ public class ConceptMapRenderer extends TerminologyRenderer {
private String getDisplay(List<OtherElementComponent> list, String s) {
for (OtherElementComponent c : list) {
if (s.equals(c.getProperty())) {
if (s.equals(c.getAttribute())) {
// return getDisplayForConcept(systemFromCanonical(c.getSystem()), versionFromCanonical(c.getSystem()), c.getValue());
}
}

View File

@ -126,7 +126,21 @@ public class ListRenderer extends ResourceRenderer {
}
tr = t.tr();
if (list.hasSubject()) {
shortForRef(tr.td().txN("Subject: "), list.getSubject());
if (list.getSubject().size() == 1) {
shortForRef(tr.td().txN("Subject: "), list.getSubjectFirstRep());
} else {
XhtmlNode td = tr.td();
td.txN("Subject: ");
int i = 0;
for (Reference subj : list.getSubject()) {
if (i == list.getSubject().size() - 1) {
td.tx(" and ");
} else if (i > 0) {
td.tx(", ");
}
shortForRef(td, subj);
}
}
}
if (list.hasEncounter()) {
shortForRef(tr.td().txN("Encounter: "), list.getEncounter());

View File

@ -6,6 +6,7 @@ import java.io.UnsupportedEncodingException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAll;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.OperationDefinition;
import org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent;
@ -46,11 +47,11 @@ public class OperationDefinitionRenderer extends TerminologyRenderer {
if (opd.getSystem())
x.para().tx("URL: [base]/$"+opd.getCode());
for (CodeType c : opd.getResource()) {
for (Enumeration<VersionIndependentResourceTypesAll> c : opd.getResource()) {
if (opd.getType())
x.para().tx("URL: [base]/"+c.getValue()+"/$"+opd.getCode());
x.para().tx("URL: [base]/"+c.getCode()+"/$"+opd.getCode());
if (opd.getInstance())
x.para().tx("URL: [base]/"+c.getValue()+"/[id]/$"+opd.getCode());
x.para().tx("URL: [base]/"+c.getCode()+"/[id]/$"+opd.getCode());
}
if (opd.hasInputProfile()) {

View File

@ -46,6 +46,7 @@ import org.hl7.fhir.r5.model.Narrative;
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r5.model.Period;
import org.hl7.fhir.r5.model.PrimitiveType;
import org.hl7.fhir.r5.model.ProductShelfLife;
import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Quantity;
import org.hl7.fhir.r5.model.Range;
@ -357,6 +358,9 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
return;
Base e = ew.getBase();
if (e == null) {
return;
}
if (context.isShowComments()) {
x = renderCommentsSpan(x, e);
}
@ -486,7 +490,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
x.tx(((PrimitiveType) e).primitiveValue());
} else if (e instanceof ElementDefinition) {
x.tx("todo-bundle");
} else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
} else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta) && !(e instanceof ProductShelfLife) && !(e instanceof RelatedArtifact)) {
throw new NotImplementedException("type "+e.getClass().getName()+" not handled - should not be here");
}
}
@ -920,6 +924,10 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
if (x.getName().equals("p")) {
return false;
}
if (grandChildren.size() == 0) {
return false;
}
for (ElementDefinition e : grandChildren) {
List<PropertyWrapper> values = getValues(path, p, e);

View File

@ -7,11 +7,12 @@ import java.util.List;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.CodeType;
import org.hl7.fhir.r5.model.Enumeration;
import org.hl7.fhir.r5.model.Enumerations.SearchComparator;
import org.hl7.fhir.r5.model.Enumerations.SearchModifierCode;
import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAll;
import org.hl7.fhir.r5.model.OperationDefinition;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.SearchParameter;
import org.hl7.fhir.r5.model.SearchParameter.SearchComparator;
import org.hl7.fhir.r5.model.SearchParameter.SearchModifierCode;
import org.hl7.fhir.r5.model.SearchParameter.SearchParameterComponentComponent;
import org.hl7.fhir.r5.model.StringType;
import org.hl7.fhir.r5.model.StructureDefinition;
@ -56,8 +57,8 @@ public class SearchParameterRenderer extends TerminologyRenderer {
XhtmlNode tr = tbl.tr();
tr.td().tx(Utilities.pluralize("Resource", spd.getBase().size()));
XhtmlNode td = tr.td();
for (CodeType t : spd.getBase()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString());
for (Enumeration<VersionIndependentResourceTypesAll> t : spd.getBase()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.getCode());
if (sd != null && sd.hasUserData("path")) {
td.sep(", ");
td.ah(sd.getUserString("path")).tx(t.getCode());
@ -85,8 +86,8 @@ public class SearchParameterRenderer extends TerminologyRenderer {
if (isAllConcreteResources(spd.getTarget())) {
td.ah(Utilities.pathURL(context.getLink(KnownLinkType.SPEC), "resourcelist.html")).tx("All Resources");
} else {
for (CodeType t : spd.getTarget()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString());
for (Enumeration<VersionIndependentResourceTypesAll> t : spd.getTarget()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.getCode());
if (sd != null && sd.hasUserData("path")) {
td.sep(", ");
td.ah(sd.getUserString("path")).tx(t.getCode());
@ -156,13 +157,13 @@ public class SearchParameterRenderer extends TerminologyRenderer {
return false;
}
private boolean isAllConcreteResources(List<CodeType> target) {
private boolean isAllConcreteResources(List<Enumeration<VersionIndependentResourceTypesAll>> list) {
for (String s : context.getWorker().getResourceNames()) {
StructureDefinition sd = context.getWorker().fetchTypeDefinition(s);
if (!sd.getAbstract() && !Utilities.existsInList(sd.getType(), "Parameters")) {
boolean found = false;
for (CodeType c : target) {
found = found || sd.getName().equals(c.getValue());
for (Enumeration<VersionIndependentResourceTypesAll> c : list) {
found = found || sd.getName().equals(c.getCode());
}
if (!found) {
return false;

View File

@ -38,7 +38,6 @@ import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent;
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionExampleComponent;
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent;
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionObligationComponent;
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingComponent;
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent;
import org.hl7.fhir.r5.model.ElementDefinition.PropertyRepresentation;
@ -60,6 +59,7 @@ import org.hl7.fhir.r5.model.UriType;
import org.hl7.fhir.r5.model.UsageContext;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.CodeResolver.CodeResolution;
import org.hl7.fhir.r5.renderers.StructureDefinitionRenderer.ObligationWrapper;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.KnownLinkType;
@ -86,6 +86,71 @@ import org.hl7.fhir.utilities.xhtml.XhtmlNodeList;
public class StructureDefinitionRenderer extends ResourceRenderer {
public class ObligationWrapper {
private Extension ext;
public ObligationWrapper(Extension ext) {
this.ext = ext;
}
public boolean hasActor() {
return ext.hasExtension("actor");
}
public boolean hasActor(String id) {
return ext.hasExtension("actor") && id.equals(ext.getExtensionByUrl("actor").getValue().primitiveValue());
}
public Coding getCode() {
Extension code = ext.getExtensionByUrl("code");
if (code != null && code.hasValueCoding()) {
return code.getValueCoding();
}
if (code != null && code.hasValueCodeType()) {
return new Coding().setSystem("http://hl7.org/fhir/tools/CodeSystem/obligation").setCode(code.getValueCodeType().primitiveValue());
}
return null;
}
public boolean hasFilter() {
return ext.hasExtension("filter");
}
public String getFilter() {
Extension code = ext.getExtensionByUrl("filter");
if (code != null && code.getValue() != null) {
return code.getValue().primitiveValue();
}
return null;
}
public boolean hasUsage() {
return ext.hasExtension("usage");
}
public String getFilterDocumentation() {
Extension code = ext.getExtensionByUrl("filter-desc");
if (code != null && code.getValue() != null) {
return code.getValue().primitiveValue();
}
return null;
}
public List<UsageContext> getUsage() {
List<UsageContext> usage = new ArrayList<>();
for (Extension u : ext.getExtensionsByUrl("usage" )) {
if (u.hasValueUsageContext()) {
usage.add(u.getValueUsageContext());
}
}
return usage;
}
}
private List<String> keyRows = new ArrayList<>();
public StructureDefinitionRenderer(RenderingContext context) {
@ -436,10 +501,10 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
private void scanObligations(Set<String> cols, List<ElementDefinition> list, ElementDefinition ed) {
for (ElementDefinitionObligationComponent ob : ed.getObligation()) {
if (ob.hasActor()) {
for (CanonicalType a : ob.getActor()) {
cols.add(a.getValue());
for (Extension ob : ed.getExtensionsByUrl("http://hl7.org/fhir/tools/StructureDefinition/obligation")) {
if (ob.hasExtension("actor")) {
for (Extension a : ob.getExtensionsByUrl("actor")) {
cols.add(a.getValueCanonicalType().primitiveValue());
}
} else
cols.add("$all");
@ -664,7 +729,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
for (Column col : columns) {
Cell gc = gen.new Cell();
row.getCells().add(gc);
List<ElementDefinitionObligationComponent> obligations = collectObligations(element, col.id);
List<ObligationWrapper> obligations = collectObligations(element, col.id);
if (obligations.size() > 0) {
Piece p = gen.new Piece(null);
gc.addPiece(p);
@ -672,7 +737,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
renderObligation(p.getChildren(), obligations.get(0));
} else {
XhtmlNode ul = p.getChildren().ul();
for (ElementDefinitionObligationComponent ob : obligations) {
for (ObligationWrapper ob : obligations) {
renderObligation(ul.li().getChildNodes(), ob);
}
}
@ -681,9 +746,10 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
}
}
private List<ElementDefinitionObligationComponent> collectObligations(ElementDefinition element, String id) {
List<ElementDefinitionObligationComponent> res = new ArrayList<>();
for (ElementDefinitionObligationComponent ob : element.getObligation()) {
private List<ObligationWrapper> collectObligations(ElementDefinition element, String id) {
List<ObligationWrapper> res = new ArrayList<>();
for (Extension ext : element.getExtensionsByUrl("http://hl7.org/fhir/tools/StructureDefinition/obligation")) {
ObligationWrapper ob = new ObligationWrapper(ext);
if (("$all".equals(id) && !ob.hasActor()) || (ob.hasActor(id))) {
res.add(ob);
}
@ -691,7 +757,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
return res;
}
private void renderObligation(XhtmlNodeList children, ElementDefinitionObligationComponent ob) throws IOException {
private void renderObligation(XhtmlNodeList children, ObligationWrapper ob) throws IOException {
if ("http://hl7.org/fhir/tools/CodeSystem/obligation".equals(ob.getCode().getSystem())) {
boolean first = true;
String[] codes = ob.getCode().getCode().split("\\+");

View File

@ -118,10 +118,15 @@ public class TestingUtilities extends BaseTestingUtilities {
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters());
if (!fcontext.hasPackage("hl7.terminology.r5", null)) {
NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology.r5");
NpmPackage utg = pcm.loadPackage("hl7.terminology.r5");
System.out.println("Loading THO: "+utg.name()+"#"+utg.version());
fcontext.loadFromPackage(utg, new TestPackageLoader(new String[]{"CodeSystem", "ValueSet"}));
}
}
if (!fcontext.hasPackage("hl7.fhir.uv.extensions", null)) {
NpmPackage ext = pcm.loadPackage("hl7.fhir.uv.extensions");
System.out.println("Loading Extensions: "+ext.name()+"#"+ext.version());
fcontext.loadFromPackage(ext, new TestPackageLoader(new String[]{"CodeSystem", "ValueSet", "StructureDefinition"}));
}
R5Hacker.fixR5BrokenResources(fcontext);
return fcontext;
} catch (Exception e) {

View File

@ -194,13 +194,13 @@ public class MappingSheetParser {
else {
element.getTargetFirstRep().setRelationship(ConceptMapRelationship.RELATEDTO);
if (row.getCondition() != null)
element.getTargetFirstRep().addDependsOn().setProperty("http://hl7.org/fhirpath").setValue(new StringType(processCondition(row.getCondition())));
element.getTargetFirstRep().addDependsOn().setAttribute("http://hl7.org/fhirpath").setValue(new StringType(processCondition(row.getCondition())));
element.getTargetFirstRep().setCode(row.getAttribute());
element.getTargetFirstRep().setDisplay(row.getType()+" : ["+row.getMinMax()+"]");
element.getTargetFirstRep().addExtension(ToolingExtensions.EXT_MAPPING_TGTTYPE, new StringType(row.getType()));
element.getTargetFirstRep().addExtension(ToolingExtensions.EXT_MAPPING_TGTCARD, new StringType(row.getMinMax()));
if (row.getDerived() != null)
element.getTargetFirstRep().getProductFirstRep().setProperty(row.getDerived()).setValue(new StringType(row.getDerivedMapping()));
element.getTargetFirstRep().getProductFirstRep().setAttribute(row.getDerived()).setValue(new StringType(row.getDerivedMapping()));
if (row.getComments() != null)
element.getTargetFirstRep().setComment(row.getComments());
if (row.getDtMapping() != null)
@ -391,7 +391,7 @@ public class MappingSheetParser {
row.dtMapping = t.getExtensionString("http://hl7.org/fhir/StructureDefinition/ConceptMap-type-mapping");
row.vocabMapping = t.getExtensionString("http://hl7.org/fhir/StructureDefinition/ConceptMap-vocab-mapping");
if (t.getProduct().size() > 0) {
row.derived = t.getProductFirstRep().getProperty();
row.derived = t.getProductFirstRep().getAttribute();
row.derivedMapping = t.getProductFirstRep().getValue().primitiveValue();
}
}
@ -405,7 +405,7 @@ public class MappingSheetParser {
private OtherElementComponent getDependency(TargetElementComponent t, String prop) {
for (OtherElementComponent dep : t.getDependsOn()) {
if (prop.equals(dep.getProperty()))
if (prop.equals(dep.getAttribute()))
return dep;
}
return null;

View File

@ -237,7 +237,7 @@ public class PETests {
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("Additional content defined by implementations", pe.shortDocumentation());
Assertions.assertEquals("May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", pe.documentation());
Assertions.assertEquals("May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", pe.documentation());
iChildren = pe.children("http://hl7.org/fhir/StructureDefinition/Extension");
Assertions.assertEquals(4, iChildren.size());
@ -250,7 +250,7 @@ public class PETests {
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("Additional content defined by implementations", pe.shortDocumentation());
Assertions.assertEquals("May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", pe.documentation());
Assertions.assertEquals("May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", pe.documentation());
iChildren = pe.children("http://hl7.org/fhir/StructureDefinition/Extension");
@ -264,7 +264,7 @@ public class PETests {
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("Additional content defined by implementations", pe.shortDocumentation());
Assertions.assertEquals("May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", pe.documentation());
Assertions.assertEquals("May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and managable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.", pe.documentation());
}

View File

@ -253,7 +253,7 @@ public class NarrativeGenerationTests {
XhtmlNode x = RendererFactory.factory(source, rc).build(source);
String expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".html"));
String actual = HEADER+new XhtmlComposer(true, false).compose(x)+FOOTER;
String actual = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER;
String expectedFileName = CompareUtilities.tempFile("narrative", test.getId() + ".expected.html");
String actualFileName = CompareUtilities.tempFile("narrative", test.getId() + ".actual.html");
TextFile.stringToFile(expected, expectedFileName);

View File

@ -41,11 +41,11 @@ class ResourceTests {
assertTrue(new MessageDefinition().supportsCopyright());
assertTrue(new StructureMap().supportsCopyright());
assertTrue(new ExampleScenario().supportsCopyright());
assertFalse(new SearchParameter().supportsCopyright());
assertFalse(new NamingSystem().supportsCopyright());
assertFalse(new OperationDefinition().supportsCopyright());
assertTrue(new SearchParameter().supportsCopyright());
assertTrue(new NamingSystem().supportsCopyright());
assertTrue(new OperationDefinition().supportsCopyright());
assertFalse(new CompartmentDefinition().supportsCopyright());
assertFalse(new GraphDefinition().supportsCopyright());
assertTrue(new GraphDefinition().supportsCopyright());
}
private String SRC = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\r\n"+

View File

@ -20,6 +20,7 @@ import org.hl7.fhir.r5.DiffUtils;
import org.hl7.fhir.r5.conformance.profile.BindingResolution;
import org.hl7.fhir.r5.conformance.profile.ProfileKnowledgeProvider;
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities.AllowUnknownProfile;
import org.hl7.fhir.r5.test.utils.TestPackageLoader;
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.formats.JsonParser;
@ -109,6 +110,7 @@ public class SnapShotGenerationTests {
private List<StructureDefinition> included = new ArrayList<>();
private StructureDefinition expected;
private StructureDefinition output;
public AllowUnknownProfile allow;
public TestDetails(Element test) {
super();
@ -127,6 +129,16 @@ public class SnapShotGenerationTests {
rules.add(new Rule(rule));
rule = XMLUtil.getNextSibling(rule);
}
String aa = test.getAttribute("allow");
if (Utilities.noString(aa)) {
allow = AllowUnknownProfile.ALL_TYPES;
} else if ("no-extensions".equals(aa)) {
allow = AllowUnknownProfile.NON_EXTNEIONS;
} else if ("none".equals(aa)) {
allow = AllowUnknownProfile.NONE;
} else {
allow = AllowUnknownProfile.ALL_TYPES;
}
}
public String getId() {
@ -478,8 +490,8 @@ public class SnapShotGenerationTests {
pu.sortDifferential(base, test.getOutput(), test.getOutput().getUrl(), errors, false);
if (!errors.isEmpty())
throw new FHIRException(errors.get(0));
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml")));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("snapshot", test.getId() + "-actual.xml")), test.getOutput());
// IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml")));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml")), test.getOutput());
Assertions.assertTrue(test.expected.equalsDeep(test.output), "Output does not match expected");
}
@ -488,6 +500,7 @@ public class SnapShotGenerationTests {
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null);
pu.setNewSlicingProcessing(true);
pu.setAllowUnknownProfile(test.allow);
for (StructureDefinition sd : test.included) {
pu.setIds(sd, false);
}
@ -520,6 +533,7 @@ public class SnapShotGenerationTests {
pu.setThrowException(false);
pu.setDebug(test.isDebug());
pu.setIds(test.getSource(), false);
pu.setAllowUnknownProfile(test.allow);
if (!TestingUtilities.getSharedWorkerContext().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) {
NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
TestingUtilities.getSharedWorkerContext().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"});
@ -560,8 +574,8 @@ public class SnapShotGenerationTests {
File dst = new File(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml"));
if (dst.exists())
dst.delete();
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(dst));
String actualFilePath = TestingUtilities.tempFile("snapshot", test.getId() + "-actual.xml");
// IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "snapshot-generation", test.getId() + "-expected.xml"), new FileOutputStream(dst));
String actualFilePath = TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml");
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(actualFilePath), output);
StructureDefinition t1 = test.expected.copy();
t1.setText(null);

View File

@ -9,3 +9,26 @@ v: {
"class" : "SERVER_ERROR"
}
-------------------------------------------------------------------------------------
{"hierarchical" : false, "valueSet" :{
"resourceType" : "ValueSet",
"compose" : {
"inactive" : true,
"include" : [{
"system" : "urn:ietf:bcp:47"
}]
}
}}####
e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------
{"hierarchical" : false, "url": "http://hl7.org/fhir/ValueSet/all-languages", "version": "5.0.0-snapshot3"}####
e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------
{"hierarchical" : false, "url": "http://hl7.org/fhir/ValueSet/all-languages", "version": "5.0.0-draft-final"}####
e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------

View File

@ -22,3 +22,8 @@ e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------
{"hierarchical" : false, "url": "http://hl7.org/fhir/ValueSet/mimetypes", "version": "5.0.0-draft-final"}####
e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------

View File

@ -0,0 +1,31 @@
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://hl7.org/fhir/tools/CodeSystem/obligation",
"code" : "will-send"
}, "valueSet" :null, "lang":"en-US", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"true"}####
v: {
"severity" : "error",
"error" : "Local Error: Unable to resolve system http://hl7.org/fhir/tools/CodeSystem/obligation. Server Error: Attempt to use Terminology server when no Terminology server is available",
"class" : "SERVER_ERROR"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://hl7.org/fhir/tools/CodeSystem/obligation",
"code" : "display"
}, "valueSet" :null, "lang":"en-US", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"true"}####
v: {
"severity" : "error",
"error" : "Local Error: Unable to resolve system http://hl7.org/fhir/tools/CodeSystem/obligation. Server Error: Attempt to use Terminology server when no Terminology server is available",
"class" : "SERVER_ERROR"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://hl7.org/fhir/tools/CodeSystem/obligation",
"code" : "preserve"
}, "valueSet" :null, "lang":"en-US", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"true"}####
v: {
"severity" : "error",
"error" : "Local Error: Unable to resolve system http://hl7.org/fhir/tools/CodeSystem/obligation. Server Error: Attempt to use Terminology server when no Terminology server is available",
"class" : "SERVER_ERROR"
}
-------------------------------------------------------------------------------------

View File

@ -129,3 +129,8 @@ e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------
{"hierarchical" : false, "url": "http://hl7.org/fhir/ValueSet/units-of-time", "version": "5.0.0-draft-final"}####
e: {
"error" : "Cannot invoke \"org.hl7.fhir.r5.terminologies.TerminologyClient.expandValueset(org.hl7.fhir.r5.model.ValueSet, org.hl7.fhir.r5.model.Parameters, java.util.Map)\" because \"this.txClient\" is null"
}
-------------------------------------------------------------------------------------