use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireBuilder method makeTypeList.
private ValueSet makeTypeList(StructureDefinition profile, List<TypeRefComponent> types, String path) {
ValueSet vs = new ValueSet();
vs.setName("Type options for " + path);
vs.setDescription(vs.getName());
vs.setStatus(ConformanceResourceStatus.ACTIVE);
vs.setExpansion(new ValueSetExpansionComponent());
vs.getExpansion().setIdentifier(Factory.createUUID());
vs.getExpansion().setTimestampElement(DateTimeType.now());
for (TypeRefComponent t : types) {
ValueSetExpansionContainsComponent cc = vs.getExpansion().addContains();
if (t.getCode().equals("Reference") && (t.hasProfile() && t.getProfile().get(0).getValue().startsWith("http://hl7.org/fhir/StructureDefinition/"))) {
cc.setCode(t.getProfile().get(0).getValue().substring(40));
cc.setSystem("http://hl7.org/fhir/resource-types");
cc.setDisplay(cc.getCode());
} else {
ProfileUtilities pu = new ProfileUtilities(context, null, null);
StructureDefinition ps = null;
if (t.hasProfile())
ps = pu.getProfile(profile, t.getProfile().get(0).getValue());
if (ps != null) {
cc.setCode(t.getProfile().get(0).getValue());
cc.setDisplay(ps.getSnapshot().getElement().get(0).getType().get(0).getCode());
cc.setSystem("http://hl7.org/fhir/resource-types");
} else {
cc.setCode(t.getCode());
cc.setDisplay(t.getCode());
cc.setSystem("http://hl7.org/fhir/data-types");
}
}
t.setUserData("text", cc.getCode());
}
return vs;
}
use of org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent in project CRD by HL7-DaVinci.
the class VSACSVSHandler method startElement.
/**
* Handles the start of an element. Called by the SAX Parser.
*/
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
switch(qName) {
// Handle start of new valueset
case "ns0:DescribedValueSet":
// create value set
this.currentValueSet = new ValueSet();
this.currentValueSet.setId(attributes.getValue("ID"));
this.currentValueSet.setUrl(ValueSetCache.VSAC_CANONICAL_BASE + attributes.getValue("ID"));
this.currentValueSet.setName(attributes.getValue("displayName"));
this.currentExpansion = new ValueSetExpansionComponent();
this.currentExpansion.setTimestamp(new Date());
break;
// Handle a code/concept addition
case "ns0:Concept":
ValueSetExpansionContainsComponent concept = new ValueSetExpansionContainsComponent();
concept.setCode(attributes.getValue("code"));
concept.setVersion(attributes.getValue("codeSystemVersion"));
concept.setDisplay(attributes.getValue("displayName"));
concept.setSystem(CodeSystemTranslator.convertOidToUri(attributes.getValue("codeSystem")));
this.currentExpansion.getContains().add(concept);
break;
// Handle start of Status
case "ns0:Status":
this.isInStatus = true;
this.statusStringBuilder = new StringBuilder();
break;
// Handle start of Source
case "ns0:Source":
this.isInSource = true;
this.sourceStringBuilder = new StringBuilder();
break;
default:
}
}
Aggregations