fix up cardinality issues
This commit is contained in:
parent
be9c36e037
commit
c1262d50c5
|
@ -65,7 +65,7 @@ public class PEDefinitionSubExtension extends PEDefinition {
|
|||
if (ved.isRequired() || eed.isProhibited()) {
|
||||
return "extension('"+ued.getFixed().primitiveValue()+"').value";
|
||||
} else {
|
||||
return "extension('"+ued.getFixed().primitiveValue()+"').extension";
|
||||
return "extension('"+ued.getFixed().primitiveValue()+"')";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -236,4 +236,8 @@ public class PEInstance {
|
|||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public Base getBase() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,32 @@
|
|||
package org.hl7.fhir.r5.profilemodel.gen;
|
||||
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.profilemodel.PEInstance;
|
||||
|
||||
public class PEGeneratedBase {
|
||||
|
||||
protected PEInstance instance;
|
||||
|
||||
protected void removeChild(String string) {
|
||||
PEInstance child = instance.child("simple");
|
||||
protected void removeChild(String name) {
|
||||
PEInstance child = instance.child(name);
|
||||
if (child != null) {
|
||||
instance.removeChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
protected void removeChildren(String name) {
|
||||
for (PEInstance child : instance.children(name)) {
|
||||
instance.removeChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
public PEInstance getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Base getData() {
|
||||
return instance.getBase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.hl7.fhir.r5.profilemodel.gen;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.CodeType;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
|
@ -60,37 +63,103 @@ public class ProfileExample extends PEGeneratedBase {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ProfileExampleComplexSlice3 extends PEGeneratedBase {
|
||||
private ProfileExampleComplexSlice3(PEInstance instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public List<Coding> getSlice3a() {
|
||||
List<Coding> res = new ArrayList<>();
|
||||
for (PEInstance pe : instance.children("slice3a")) {
|
||||
res.add((Coding) pe.asDataType());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean hasSlice3a() {
|
||||
return instance.children("slice3a").size() > 0;
|
||||
}
|
||||
|
||||
public ProfileExampleComplexSlice3 clearSlice3a() {
|
||||
removeChildren("slice3a");
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public List<StringType> getSlice3b() {
|
||||
List<StringType> res = new ArrayList<>();
|
||||
for (PEInstance pe : instance.children("slice3b")) {
|
||||
res.add((StringType) pe.asDataType());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean hasSlice3b() {
|
||||
return instance.children("slice3b").size() > 0;
|
||||
}
|
||||
|
||||
public ProfileExampleComplexSlice3 clearSlice3b() {
|
||||
removeChildren("slice3b");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ProfileExampleComplex extends PEGeneratedBase {
|
||||
private ProfileExampleComplex(PEInstance instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public Coding getSlice1() {
|
||||
return (Coding) instance.forceChild("slice1").asDataType();
|
||||
public List<Coding> getSlice1() {
|
||||
List<Coding> res = new ArrayList<>();
|
||||
for (PEInstance pe : instance.children("slice1")) {
|
||||
res.add((Coding) pe.asDataType());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean hasSlice1() {
|
||||
return instance.child("slice1") != null;
|
||||
return instance.children("slice1").size() > 0;
|
||||
}
|
||||
|
||||
public ProfileExampleComplex clearSlice1() {
|
||||
removeChild("slice1x`");
|
||||
removeChildren("slice1");
|
||||
return this;
|
||||
}
|
||||
|
||||
public StringType getSlice2() {
|
||||
return (StringType) instance.forceChild("slice2").asDataType();
|
||||
public List<StringType> getSlice2() {
|
||||
List<StringType> res = new ArrayList<>();
|
||||
for (PEInstance pe : instance.children("slice2")) {
|
||||
res.add((StringType) pe.asDataType());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean hasSlice2() {
|
||||
return instance.child("slice1") != null;
|
||||
return instance.children("slice2").size() > 0;
|
||||
}
|
||||
|
||||
public ProfileExampleComplex clearSlice2() {
|
||||
removeChild("slice1");
|
||||
removeChildren("slice1");
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProfileExampleComplexSlice3 getSlice3() {
|
||||
PEInstance pe = instance.forceChild("slice3");
|
||||
return new ProfileExampleComplexSlice3(pe);
|
||||
}
|
||||
|
||||
public boolean hasComplex() {
|
||||
return instance.child("slice3") != null;
|
||||
}
|
||||
|
||||
public ProfileExampleComplex clearComplex() {
|
||||
removeChild("slice3");
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ProfileExample(IWorkerContext context, Observation observation) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.hl7.fhir.r5.profilemodel.PEType;
|
|||
import org.hl7.fhir.r5.profilemodel.gen.ProfileExample;
|
||||
import org.hl7.fhir.r5.profilemodel.gen.ProfileExample.LOINCCodesForCholesterolInSerumPlasma;
|
||||
import org.hl7.fhir.r5.profilemodel.gen.ProfileExample.ProfileExampleComplex;
|
||||
import org.hl7.fhir.r5.profilemodel.gen.ProfileExample.ProfileExampleComplexSlice3;
|
||||
import org.hl7.fhir.r5.profilemodel.PEBuilder;
|
||||
import org.hl7.fhir.r5.profilemodel.PEBuilder.PEElementPropertiesPolicy;
|
||||
import org.hl7.fhir.r5.profilemodel.PEInstance.PEInstanceDataKind;
|
||||
|
@ -351,14 +352,21 @@ public class PETests {
|
|||
Assertions.assertEquals(PEInstanceDataKind.Primitive, slice2.getDataKind());
|
||||
Assertions.assertEquals("A string value", slice2.getPrimitiveAsString());
|
||||
|
||||
PEInstance slice3 = complex.child("slice3");
|
||||
Assertions.assertNotNull(slice3);
|
||||
Assertions.assertEquals("TestProfile.complex.slice3", slice3.getPath());
|
||||
|
||||
ProfileExample ex = new ProfileExample(obs);
|
||||
Assertions.assertEquals(ObservationStatus.FINAL, ex.getStatus());
|
||||
Assertions.assertEquals("76690-7", ex.getCode().getCodingFirstRep().getCode());
|
||||
Assertions.assertEquals(LOINCCodesForCholesterolInSerumPlasma.L14647_2, ex.getSimple());
|
||||
ProfileExampleComplex cplx = ex.getComplex();
|
||||
Assertions.assertNotNull(cplx);
|
||||
Assertions.assertEquals("18767-4", cplx.getSlice1().getCode());
|
||||
Assertions.assertEquals("A string value", cplx.getSlice2().primitiveValue());
|
||||
Assertions.assertEquals("18767-4", cplx.getSlice1().get(0).getCode());
|
||||
Assertions.assertEquals("A string value", cplx.getSlice2().get(0).primitiveValue());
|
||||
ProfileExampleComplexSlice3 sl3 = cplx.getSlice3();
|
||||
Assertions.assertEquals("56874-1", sl3.getSlice3a().get(0).getCode());
|
||||
Assertions.assertEquals("Another string value", sl3.getSlice3b().get(0).primitiveValue());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue