Merge pull request #1817 from jkiddo/patch-6

Update PECodeGenerator.java
This commit is contained in:
Grahame Grieve 2024-11-20 11:12:47 +11:00 committed by GitHub
commit 2d59c27418
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 81 additions and 82 deletions

View File

@ -28,7 +28,6 @@ package org.hl7.fhir.r4.profilemodel.gen;
POSSIBILITY OF SUCH DAMAGE.
*/
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;
@ -39,22 +38,18 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import com.google.common.base.Strings;
import org.hl7.fhir.r4.context.IWorkerContext;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.ElementDefinition;
import org.hl7.fhir.r4.model.ElementDefinition.ElementDefinitionBindingComponent;
import org.hl7.fhir.r4.model.Identifier;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.StructureDefinition;
import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r4.model.Type;
import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r4.profilemodel.PEBuilder;
import org.hl7.fhir.r4.profilemodel.PEBuilder.PEElementPropertiesPolicy;
import org.hl7.fhir.r4.profilemodel.gen.PECodeGenerator.ExtensionPolicy;
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r4.profilemodel.PEDefinition;
import org.hl7.fhir.r4.profilemodel.PEInstance;
import org.hl7.fhir.r4.profilemodel.PEType;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.TextFile;
@ -364,7 +359,7 @@ public class PECodeGenerator {
type = Utilities.capitalize(field.types().get(0).getName()+"Type");
ptype = getPrimitiveType(sd);
} else {
type = field.types().get(0).getName();
type = Utilities.javaTokenize(field.types().get(0).getName(), true);
}
String ltype = type;
if (field.isList()) {
@ -409,8 +404,10 @@ public class PECodeGenerator {
w(load, " for (PEInstance item : src.children(\""+fname+"\")) {");
if ("BackboneElement".equals(type)) {
w(load, " "+name+".add(("+type+") item.asElement());");
} else {
} else if (!Strings.isNullOrEmpty(typeInfo.getUrl()) && typeInfo.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition")) {
w(load, " "+name+".add(("+type+") item.asDataType());");
} else {
w(load, " "+name+".add("+type+".fromSource(item));");
}
w(load, " }");
} else if (isEnum) {
@ -453,8 +450,10 @@ public class PECodeGenerator {
w(save, " tgt.clear(\""+fname+"\");");
if (isList) {
w(save, " for ("+type+" item : "+name+") {");
if (isExtension) {
if (isExtension && !Strings.isNullOrEmpty(typeInfo.getUrl()) && typeInfo.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition")) {
w(save, " tgt.makeChild(\""+fname+"\").data().setProperty(\"value[x]\", item);");
} else if (isExtension) {
w(save, " tgt.makeChild(\""+fname+"\").data().setProperty(\"value[x]\", item.getData());");
} else {
w(save, " tgt.addChild(\""+fname+"\", item);");
}

View File

@ -366,7 +366,7 @@ public class PECodeGenerator {
type = Utilities.capitalize(field.types().get(0).getName()+"Type");
ptype = getPrimitiveType(sd);
} else {
type = field.types().get(0).getName();
type = Utilities.javaTokenize(field.types().get(0).getName(), true);
}
String ltype = type;
if (field.isList()) {