first stage of profile based generation
This commit is contained in:
parent
2ce941c527
commit
5385c313dc
|
@ -0,0 +1,64 @@
|
|||
package org.hl7.fhir.r5.profilemodel;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.ResourceFactory;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.profilemodel.PEBuilder.PEElementPropertiesPolicy;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class TestInstanceGenerator {
|
||||
|
||||
private IWorkerContext context;
|
||||
private Map<String, String> data;
|
||||
|
||||
protected TestInstanceGenerator(IWorkerContext context) {
|
||||
super();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Resource generate(StructureDefinition profile) {
|
||||
PEBuilder builder = new PEBuilder(context, PEElementPropertiesPolicy.NONE, true);
|
||||
PEDefinition definition = builder.buildPEDefinition(profile);
|
||||
Resource res = ResourceFactory.createResource(definition.types().get(0).getType());
|
||||
populateByProfile(res, definition);
|
||||
|
||||
res.getMeta().addProfile(definition.profile.getVersionedUrl());
|
||||
return res;
|
||||
}
|
||||
|
||||
protected void populateByProfile(Base base, PEDefinition definition) {
|
||||
if (definition.types().size() == 1) {
|
||||
for (PEDefinition pe : definition.directChildren(true)) {
|
||||
if (pe.hasFixedValue()) {
|
||||
if (pe.definition().hasPattern()) {
|
||||
base.setProperty(pe.schemaName(), pe.definition().getPattern());
|
||||
} else {
|
||||
base.setProperty(pe.schemaName(), pe.definition().getFixed());
|
||||
}
|
||||
} else if (!pe.isSlicer() && pe.max() == 1) {
|
||||
for (int i = 0; i < pe.min(); i++) {
|
||||
Base b = null;
|
||||
if (pe.schemaName().endsWith("[x]")) {
|
||||
if (pe.types().size() == 1) {
|
||||
b = base.addChild(pe.schemaName().replace("[x]", Utilities.capitalize(pe.types().get(0).getType())));
|
||||
}
|
||||
} else if (!pe.isBaseList()) {
|
||||
b = base.makeProperty(pe.schemaName().hashCode(), pe.schemaName());
|
||||
} else {
|
||||
b = base.addChild(pe.schemaName());
|
||||
}
|
||||
if (b != null) {
|
||||
populateByProfile(b, pe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1180,3 +1180,20 @@ HTA_SCT_MESSAGE = This material contains content that is copyright of SNOMED Int
|
|||
HTA_LOINC_DESC = LOINC
|
||||
HTA_LOINC_MESSAGE = This material contains content from <a href=\"http://loinc.org\">LOINC</a>. LOINC is copyright © 1995-2020, Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee and is available at no cost under the <a href=\"http://loinc.org/license\">license</a>. LOINC® is a registered United States trademark of Regenstrief Institute, Inc.
|
||||
SD_PATH_NO_SLICING = Slicing is not allowed at ''{0}''
|
||||
VS_EXP_IMPORT_CS = Cannot include value set ''{0}'' because it's actually a code system
|
||||
VS_EXP_IMPORT_CS_PINNED = Cannot include value set ''{0}'' version ''{1}'' because it's actually a code system
|
||||
VS_EXP_IMPORT_UNK = Unable to find included value set ''{0}''
|
||||
VS_EXP_IMPORT_UNK_PINNED = Unable to find included value set ''{0}'' version ''{1}''
|
||||
VS_EXP_IMPORT_NULL = Unable to find included value set with no identity
|
||||
VS_EXP_IMPORT_ERROR = Unable to expand included value set ''{0}'': {1}
|
||||
VS_EXP_IMPORT_ERROR = Unable to expand included value set ''{0}'', but no error
|
||||
VS_EXP_IMPORT_CS_X = Cannot exclude value set ''{0}'' because it's actually a code system
|
||||
VS_EXP_IMPORT_CS_PINNED_X = Cannot exclude value set ''{0}'' version ''{1}'' because it's actually a code system
|
||||
VS_EXP_IMPORT_UNK_X = Unable to find excluded value set ''{0}''
|
||||
VS_EXP_IMPORT_UNK_PINNED_X = Unable to find excluded value set ''{0}'' version ''{1}''
|
||||
VS_EXP_IMPORT_NUL_XL = Unable to find excluded value set with no identity
|
||||
VS_EXP_IMPORT_ERROR_X = Unable to expand excluded value set ''{0}'': {1}
|
||||
VS_EXP_IMPORT_ERROR_X = Unable to expand excluded value set ''{0}'', but no error
|
||||
VS_EXP_IMPORT_ERROR_TOO_COSTLY = Unable to expand excluded value set ''{0}'': too costly
|
||||
VS_EXP_FILTER_UNK = ValueSet ''{0}'' Filter by property ''{1}'' and op ''{2}'' is not supported yet
|
||||
|
Loading…
Reference in New Issue