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);
}
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;
}
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);
}
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;
}
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);
}
Aggregations