upgrade test case dependency

This commit is contained in:
Grahame Grieve 2022-12-24 08:42:02 +13:00
parent f87394b46e
commit 900f471dda
5 changed files with 124 additions and 17 deletions

View File

@ -25,7 +25,7 @@ public class PEElement extends ProfiledElement {
for (CanonicalType u : t.getProfile()) {
res.add(t.getWorkingCode()+"["+u.getValue()+"]");
}
} else {
} else if (!t.getCode().startsWith("http://hl7.org/fhirpath/")) {
res.add(t.getWorkingCode());
}
}

View File

@ -74,7 +74,9 @@ public abstract class ProfiledElement {
}
/**
* @return a list of types. There is always at least one type; it might be Element, Type, BackboneElement or BackboneType
* @return a list of types. There is usually at least one type; it might be Element, Type, BackboneElement or BackboneType
*
* The following elements don't have types (true primitives): Element.id. Extension.url, PrimitiveType.value
*/
public abstract List<String> types();
@ -206,7 +208,7 @@ public abstract class ProfiledElement {
@Override
public String toString() {
return name+"("+schemaName()+"):"+types().toString()+" ["+min()+":"+max()+"] \""+shortDocumentation()+"\"";
return name+"("+schemaName()+"):"+types().toString()+" ["+min()+":"+(max() == Integer.MAX_VALUE ? "*" : max() )+"] \""+shortDocumentation()+"\"";
}
}

View File

@ -9,6 +9,7 @@ import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.CanonicalType;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.ElementDefinition.SlicingRules;
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ResourceFactory;
@ -38,8 +39,8 @@ public class ProfiledElementBuilder {
*
* When built with this method, the profile element can't have instance data
*
* Warning: profiles and resources can be recursive; you can't iterate this tree until it you get
* to the leaves because you will never get to a child that doesn't have children
* Warning: profiles and resources are recursive; you can't iterate this tree until it you get
* to the leaves because there are nodes that don't terminate (extensions have extensions)
*
*/
public ProfiledElement buildProfileElement(String url) {
@ -154,14 +155,27 @@ public class ProfiledElementBuilder {
protected List<ProfiledElement> listChildren(StructureDefinition baseStructure, ElementDefinition baseDefinition, StructureDefinition profileStructure, ElementDefinition profileDefinition, TypeRefComponent t) {
if (profileDefinition.getType().size() == 1 || (!profileDefinition.getPath().contains("."))) {
assert profileDefinition.getType().size() != 1 || profileDefinition.getType().contains(t);
List<ElementDefinition> list = pu.getChildList(profileStructure, profileDefinition);
if (list != null && list.size() > 0) {
List<ProfiledElement> res = new ArrayList<>();
StructureDefinition profile = profileStructure;
List<ElementDefinition> list = pu.getChildList(profile, profileDefinition);
if (list.size() == 0) {
profile = t.hasProfile() ? context.fetchResource(StructureDefinition.class, t.getProfile().get(0).getValue()) : context.fetchTypeDefinition(t.getWorkingCode());
list = pu.getChildList(profile, profile.getSnapshot().getElementFirstRep());
}
if (list.size() > 0) {
StructureDefinition base = baseStructure;
List<ElementDefinition> blist = pu.getChildList(baseStructure, baseDefinition);
List<ProfiledElement> res = new ArrayList<>();
if (blist.size() == 0) {
base = context.fetchTypeDefinition(t.getWorkingCode());
blist = pu.getChildList(base, base.getSnapshot().getElementFirstRep());
}
int i = 0;
while (i < list.size()) {
ElementDefinition defn = list.get(i);
if (defn.hasSlicing()) {
if (defn.getSlicing().getRules() != SlicingRules.CLOSED) {
res.add(new PEElement(this, base, getByName(blist, defn), profileStructure, defn));
}
i++;
while (i < list.size() && list.get(i).getPath().equals(defn.getPath())) {
StructureDefinition ext = getExtensionDefinition(list.get(i));
@ -173,14 +187,12 @@ public class ProfiledElementBuilder {
i++;
}
} else {
res.add(new PEElement(this, baseStructure, getByName(blist, defn), profileStructure, defn));
res.add(new PEElement(this, base, getByName(blist, defn), profileStructure, defn));
i++;
}
}
return res;
} else {
throw new DefinitionException("not done yet");
}
return res;
} else {
throw new DefinitionException("not done yet");
}
@ -198,11 +210,12 @@ public class ProfiledElementBuilder {
private ElementDefinition getByName(List<ElementDefinition> blist, ElementDefinition defn) {
for (ElementDefinition ed : blist) {
if (ed.getPath().equals(defn.getPath())) {
if (ed.getName().equals(defn.getName())) {
return ed;
}
}
return null;
}
}

View File

@ -36,9 +36,9 @@ public class ProfiledElementTests {
Assertions.assertEquals("\\-", pe.documentation());
List<ProfiledElement> children = pe.children("Patient");
Assertions.assertEquals(27, children.size());
Assertions.assertEquals(28, children.size());
pe = children.get(8);
pe = children.get(9);
Assertions.assertEquals("birthsex", pe.name());
Assertions.assertEquals("extension", pe.schemaName());
Assertions.assertEquals(0, pe.min());
@ -49,7 +49,7 @@ public class ProfiledElementTests {
Assertions.assertEquals("Extension", pe.shortDocumentation());
Assertions.assertEquals("A code classifying the person's sex assigned at birth as specified by the [Office of the National Coordinator for Health IT (ONC)](https://www.healthit.gov/newsroom/about-onc).", pe.documentation());
pe = children.get(7);
pe = children.get(8);
Assertions.assertEquals("ethnicity", pe.name());
Assertions.assertEquals("extension", pe.schemaName());
@ -61,6 +61,98 @@ public class ProfiledElementTests {
Assertions.assertEquals("US Core ethnicity Extension", pe.shortDocumentation());
Assertions.assertEquals("Concepts classifying the person into a named category of humans sharing common history, traits, geographical origin or nationality. The ethnicity codes used to represent these concepts are based upon the [CDC ethnicity and Ethnicity Code Set Version 1.0](http://www.cdc.gov/phin/resources/vocabulary/index.html) which includes over 900 concepts for representing race and ethnicity of which 43 reference ethnicity. The ethnicity concepts are grouped by and pre-mapped to the 2 OMB ethnicity categories: - Hispanic or Latino - Not Hispanic or Latino.", pe.documentation());
pe = children.get(12);
Assertions.assertEquals("identifier", pe.name());
Assertions.assertEquals("identifier", pe.schemaName());
Assertions.assertEquals(1, pe.min());
Assertions.assertEquals(Integer.MAX_VALUE, pe.max());
Assertions.assertEquals("Identifier", pe.types().get(0));
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("An identifier for this patient", pe.shortDocumentation());
Assertions.assertEquals("An identifier for this patient.", pe.documentation());
List<ProfiledElement> iChildren = pe.children("Identifier");
Assertions.assertEquals(8, iChildren.size());
pe = iChildren.get(2);
Assertions.assertEquals("use", pe.name());
Assertions.assertEquals("use", pe.schemaName());
Assertions.assertEquals(0, pe.min());
Assertions.assertEquals(1, pe.max());
Assertions.assertEquals("code", pe.types().get(0));
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("usual | official | temp | secondary | old (If known)", pe.shortDocumentation());
Assertions.assertEquals("The purpose of this identifier.", pe.documentation());
iChildren = pe.children("code");
Assertions.assertEquals(3, iChildren.size());
pe = iChildren.get(2);
Assertions.assertEquals("value", pe.name());
Assertions.assertEquals("value", pe.schemaName());
Assertions.assertEquals(0, pe.min());
Assertions.assertEquals(1, pe.max());
Assertions.assertEquals(0, pe.types().size());
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("Primitive value for code", pe.shortDocumentation());
Assertions.assertEquals("Primitive value for code", pe.documentation());
pe = iChildren.get(0);
Assertions.assertEquals("id", pe.name());
Assertions.assertEquals("id", pe.schemaName());
Assertions.assertEquals(0, pe.min());
Assertions.assertEquals(1, pe.max());
Assertions.assertEquals(0, pe.types().size());
Assertions.assertNotNull(pe.definition());
Assertions.assertNotNull(pe.baseDefinition());
Assertions.assertEquals("xml:id (or equivalent in JSON)", pe.shortDocumentation());
Assertions.assertEquals("unique id for the element within a resource (for internal references)", pe.documentation());
// let's go down the rabbit hole
pe = iChildren.get(1);
Assertions.assertEquals("extension", pe.name());
Assertions.assertEquals("extension", pe.schemaName());
Assertions.assertEquals(0, pe.min());
Assertions.assertEquals(Integer.MAX_VALUE, pe.max());
Assertions.assertEquals("Extension", pe.types().get(0));
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());
iChildren = pe.children("Extension");
Assertions.assertEquals(4, iChildren.size());
pe = iChildren.get(1);
Assertions.assertEquals("extension", pe.name());
Assertions.assertEquals("extension", pe.schemaName());
Assertions.assertEquals(0, pe.min());
Assertions.assertEquals(Integer.MAX_VALUE, pe.max());
Assertions.assertEquals("Extension", pe.types().get(0));
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());
iChildren = pe.children("Extension");
Assertions.assertEquals(4, iChildren.size());
pe = iChildren.get(1);
Assertions.assertEquals("extension", pe.name());
Assertions.assertEquals("extension", pe.schemaName());
Assertions.assertEquals(0, pe.min());
Assertions.assertEquals(Integer.MAX_VALUE, pe.max());
Assertions.assertEquals("Extension", pe.types().get(0));
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());
}
}

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>6.2.1</hapi_fhir_version>
<validator_test_case_version>1.2.4</validator_test_case_version>
<validator_test_case_version>1.2.5-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version>