Search in sources :

Example 91 with ConceptDefinitionComponent

use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSet10_30 method processConcept.

public static void processConcept(List<ValueSet.ConceptDefinitionComponent> concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException {
    org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent();
    concepts.add(ct);
    ct.setCode(cs.getCode());
    ct.setDisplay(cs.getDisplay());
    ct.setDefinition(cs.getDefinition());
    if (CodeSystemUtilities.isNotSelectable(srcCS, cs))
        ct.setAbstract(true);
    for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
        org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent();
        cst.setLanguage(csd.getLanguage());
        cst.setUse(Coding10_30.convertCoding(csd.getUse()));
        cst.setValue(csd.getValue());
    }
    for (ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, srcCS);
}
Also used : CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet)

Example 92 with ConceptDefinitionComponent

use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSet10_30 method convertCodeSystem.

public static ValueSet.ValueSetCodeSystemComponent convertCodeSystem(CodeSystem src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    ValueSet.ValueSetCodeSystemComponent tgt = new ValueSet.ValueSetCodeSystemComponent();
    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
    if (src.hasUrlElement())
        tgt.setSystemElement(Uri10_30.convertUri(src.getUrlElement()));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_30.convertString(src.getVersionElement()));
    if (src.hasCaseSensitiveElement())
        tgt.setCaseSensitiveElement(Boolean10_30.convertBoolean(src.getCaseSensitiveElement()));
    for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc));
    return tgt;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet)

Example 93 with ConceptDefinitionComponent

use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSet10_30 method processConcept.

public static void processConcept(List<ConceptDefinitionComponent> concepts, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException {
    org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent();
    concepts.add(ct);
    ct.setCode(cs.getCode());
    ct.setDisplay(cs.getDisplay());
    ct.setDefinition(cs.getDefinition());
    if (cs.getAbstract())
        CodeSystemUtilities.setNotSelectable(tgtcs, ct);
    for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
        org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent();
        cst.setLanguage(csd.getLanguage());
        cst.setUse(Coding10_30.convertCoding(csd.getUse()));
        cst.setValue(csd.getValue());
    }
    for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, tgtcs);
}
Also used : CodeSystem(org.hl7.fhir.dstu3.model.CodeSystem) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet)

Example 94 with ConceptDefinitionComponent

use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ValueSet10_40 method convertCodeSystem.

public static ValueSet.ValueSetCodeSystemComponent convertCodeSystem(CodeSystem src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    ValueSet.ValueSetCodeSystemComponent tgt = new ValueSet.ValueSetCodeSystemComponent();
    ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
    if (src.hasUrlElement())
        tgt.setSystemElement(Uri10_40.convertUri(src.getUrlElement()));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_40.convertString(src.getVersionElement()));
    if (src.hasCaseSensitiveElement())
        tgt.setCaseSensitiveElement(Boolean10_40.convertBoolean(src.getCaseSensitiveElement()));
    for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(src, cc));
    return tgt;
}
Also used : ConceptDefinitionComponent(org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet)

Example 95 with ConceptDefinitionComponent

use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.

the class ICPC2Importer method go.

public void go() throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(false);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(new FileInputStream(sourceFileName));
    ValueSet vs = new ValueSet();
    vs.setUrl("http://hl7.org/fhir/sid/icpc2/vs");
    Element title = XMLUtil.getNamedChild(doc.getDocumentElement(), "Title");
    vs.setVersion(title.getAttribute("version"));
    vs.setName(title.getAttribute("name"));
    vs.setImmutable(true);
    Element identifier = XMLUtil.getNamedChild(doc.getDocumentElement(), "Identifier");
    vs.setPublisher(identifier.getAttribute("authority"));
    vs.addIdentifier(new Identifier().setValue(identifier.getAttribute("uid")));
    List<Element> authors = new ArrayList<Element>();
    XMLUtil.getNamedChildren(XMLUtil.getNamedChild(doc.getDocumentElement(), "Authors"), "Author", authors);
    for (Element a : authors) if (!a.getAttribute("name").contains("+"))
        vs.addContact().setName(a.getTextContent());
    vs.setCopyright("The copyright of ICPC, both in hard copy and in electronic form, is owned by Wonca. See http://www.kith.no/templates/kith_WebPage____1110.aspx");
    vs.setStatus(PublicationStatus.ACTIVE);
    vs.setDateElement(new DateTimeType(title.getAttribute("date")));
    vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/sid/icpc2");
    CodeSystem cs = new CodeSystem();
    cs.setUrl("http://hl7.org/fhir/sid/icpc2");
    cs.setVersion(title.getAttribute("version"));
    cs.setName(title.getAttribute("name"));
    identifier = XMLUtil.getNamedChild(doc.getDocumentElement(), "Identifier");
    cs.setPublisher(identifier.getAttribute("authority"));
    cs.setIdentifier(new Identifier().setValue(identifier.getAttribute("uid")));
    cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.CLASSIFIEDWITH);
    authors = new ArrayList<Element>();
    XMLUtil.getNamedChildren(XMLUtil.getNamedChild(doc.getDocumentElement(), "Authors"), "Author", authors);
    for (Element a : authors) if (!a.getAttribute("name").contains("+"))
        cs.addContact().setName(a.getTextContent());
    cs.setCopyright("The copyright of ICPC, both in hard copy and in electronic form, is owned by Wonca. See http://www.kith.no/templates/kith_WebPage____1110.aspx");
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setDateElement(new DateTimeType(title.getAttribute("date")));
    cs.setValueSet(vs.getUrl());
    Map<String, ConceptDefinitionComponent> concepts = new HashMap<String, ConceptDefinitionComponent>();
    List<Element> classes = new ArrayList<Element>();
    XMLUtil.getNamedChildren(doc.getDocumentElement(), "Class", classes);
    for (Element cls : classes) {
        processClass(cls, concepts, cs);
    }
    XmlParser xml = new XmlParser();
    xml.setOutputStyle(OutputStyle.PRETTY);
    xml.compose(new FileOutputStream(targetFileNameVS), vs);
    xml.compose(new FileOutputStream(targetFileNameCS), cs);
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) HashMap(java.util.HashMap) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) FileInputStream(java.io.FileInputStream) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) DocumentBuilder(javax.xml.parsers.DocumentBuilder) FileOutputStream(java.io.FileOutputStream)

Aggregations

ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)54 ArrayList (java.util.ArrayList)26 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)26 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)22 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)21 ConceptDefinitionComponent (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent)17 ConceptDefinitionComponent (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent)16 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)15 FHIRException (org.hl7.fhir.exceptions.FHIRException)14 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)12 ConceptPropertyComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent)10 ConceptPropertyComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptPropertyComponent)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 NotImplementedException (org.apache.commons.lang3.NotImplementedException)9 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)9 FileNotFoundException (java.io.FileNotFoundException)8 ConceptDefinitionComponent (org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent)8 ValidationResult (org.hl7.fhir.r5.context.IWorkerContext.ValidationResult)8 ConceptDefinitionDesignationComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionDesignationComponent)8