Search in sources :

Example 36 with ValueSetExpansionComponent

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;
}
Also used : ValueSetExpansionComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent) StructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition) TypeRefComponent(org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet)

Example 37 with ValueSetExpansionComponent

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:
    }
}
Also used : ValueSetExpansionComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent) ValueSetExpansionContainsComponent(org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent) ValueSet(org.hl7.fhir.r4.model.ValueSet) Date(java.util.Date)

Aggregations

UriType (org.hl7.fhir.r4b.model.UriType)7 ValueSetExpansionParameterComponent (org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionParameterComponent)7 UriType (org.hl7.fhir.r5.model.UriType)7 ValueSetExpansionParameterComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent)7 ArrayList (java.util.ArrayList)6 ValueSet (org.hl7.fhir.r4.model.ValueSet)5 ValueSetExpansionComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent)5 ValueSetExpansionContainsComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent)5 ValueSet (org.hl7.fhir.r4b.model.ValueSet)5 ValueSet (org.hl7.fhir.r5.model.ValueSet)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)4 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)4 HashMap (java.util.HashMap)3 List (java.util.List)2 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)2 ValueSet (org.hl7.fhir.dstu2016may.model.ValueSet)2 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)2 CodeSystem (org.hl7.fhir.r4b.model.CodeSystem)2 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)2 Extension (org.hl7.fhir.r4b.model.Extension)2