use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project kindling by HL7.
the class CodeListToValueSetParser method generateConceptMapV3.
private void generateConceptMapV3(String v3map, ValueSet vs, CodeSystem cs) throws Exception {
if (!v3map.startsWith("http://terminology.hl7.org/ValueSet/v3-"))
v3map = "http://terminology.hl7.org/ValueSet/v3-" + v3map;
ConceptMap cm = new ConceptMap();
cm.setVersion(version);
cm.setId("cm-" + vs.getId() + "-v3");
cm.setUserData("path", cm.getId() + ".html");
cm.setUserData("generate", true);
cm.setUrl("http://hl7.org/fhir/ConceptMap/" + cm.getId());
cm.setName("v3." + vs.getName());
cm.setTitle("v3 map for " + vs.present());
cm.setPublisher("HL7 (FHIR Project)");
for (ContactDetail cc : vs.getContact()) {
ContactDetail cd = cm.addContact();
cd.setName(cc.getName());
for (ContactPoint ccs : cc.getTelecom()) cd.addTelecom(ccs.copy());
}
cm.setCopyright(vs.getCopyright());
// until we publish DSTU, then .review
cm.setStatus(vs.getStatus());
cm.setDate(vs.getDate());
cm.setSource(Factory.newCanonical(vs.getUrl()));
cm.setTarget(Factory.newCanonical(v3map));
if (cs != null)
processV3ConceptDefs(cm, cs.getUrl(), cs.getConcept());
for (ConceptSetComponent cc : vs.getCompose().getInclude()) for (ConceptReferenceComponent c : cc.getConcept()) {
processV3Map(cm, cc.getSystem(), c.getCode(), c.getUserString("v2"));
}
maps.see(cm, packageInfo);
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project kindling by HL7.
the class CodeListToValueSetParser method execute.
public void execute(String v2map, String v3map, boolean utg) throws Exception {
boolean hasDefine = false;
for (int row = 0; row < sheet.rows.size(); row++) {
hasDefine = hasDefine || Utilities.noString(sheet.getColumn(row, "System"));
}
Map<String, ConceptDefinitionComponent> codes = new HashMap<String, ConceptDefinitionComponent>();
Map<String, ConceptDefinitionComponent> codesById = new HashMap<String, ConceptDefinitionComponent>();
Map<String, ConceptSetComponent> includes = new HashMap<String, ConceptSetComponent>();
CodeSystem cs = null;
if (hasDefine) {
cs = new CodeSystem();
if (utg)
cs.setUrl("http://terminology.hl7.org/CodeSystem/" + sheetName);
else
cs.setUrl("http://hl7.org/fhir/" + sheetName);
if (!valueSet.hasCompose())
valueSet.setCompose(new ValueSetComposeComponent());
valueSet.getCompose().addInclude().setSystem(cs.getUrl());
cs.setVersion(version);
cs.setCaseSensitive(true);
cs.setContent(CodeSystemContentMode.COMPLETE);
codeSystems.see(cs, packageInfo);
for (int row = 0; row < sheet.rows.size(); row++) {
if (Utilities.noString(sheet.getColumn(row, "System"))) {
ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
cc.setUserData("id", sheet.getColumn(row, "Id"));
cc.setCode(sheet.getColumn(row, "Code"));
if (codes.containsKey(cc.getCode()))
throw new Exception("Duplicate Code " + cc.getCode());
codes.put(cc.getCode(), cc);
codesById.put(cc.getUserString("id"), cc);
cc.setDisplay(sheet.getColumn(row, "Display"));
if (sheet.getColumn(row, "Abstract").toUpperCase().equals("Y"))
CodeSystemUtilities.setNotSelectable(cs, cc);
if (cc.hasCode() && !cc.hasDisplay())
cc.setDisplay(Utilities.humanize(cc.getCode()));
cc.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Definition")));
if (!Utilities.noString(sheet.getColumn(row, "Comment")))
ToolingExtensions.addCSComment(cc, sheet.getColumn(row, "Comment"));
cc.setUserData("v2", sheet.getColumn(row, "v2"));
cc.setUserData("v3", sheet.getColumn(row, "v3"));
for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
String parent = sheet.getColumn(row, "Parent");
if (Utilities.noString(parent))
cs.addConcept(cc);
else if (parent.startsWith("#") && codesById.containsKey(parent.substring(1)))
codesById.get(parent.substring(1)).addConcept(cc);
else if (codes.containsKey(parent))
codes.get(parent).addConcept(cc);
else
throw new Exception("Parent " + parent + " not resolved in " + sheetName);
}
}
}
for (int row = 0; row < sheet.rows.size(); row++) {
if (!Utilities.noString(sheet.getColumn(row, "System"))) {
String system = sheet.getColumn(row, "System");
ConceptSetComponent t = includes.get(system);
if (t == null) {
if (!valueSet.hasCompose())
valueSet.setCompose(new ValueSetComposeComponent());
t = valueSet.getCompose().addInclude();
t.setSystem(system);
includes.put(system, t);
}
ConceptReferenceComponent cc = t.addConcept();
cc.setCode(sheet.getColumn(row, "Code"));
if (codes.containsKey(cc.getCode()))
throw new Exception("Duplicate Code " + cc.getCode());
codes.put(cc.getCode(), null);
cc.setDisplay(sheet.getColumn(row, "Display"));
if (!Utilities.noString(sheet.getColumn(row, "Definition")))
ToolingExtensions.addDefinition(cc, sheet.getColumn(row, "Definition"));
if (!Utilities.noString(sheet.getColumn(row, "Comment")))
ToolingExtensions.addVSComment(cc, sheet.getColumn(row, "Comment"));
cc.setUserDataINN("v2", sheet.getColumn(row, "v2"));
cc.setUserDataINN("v3", sheet.getColumn(row, "v3"));
for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
}
}
if (!Utilities.noString(v2map)) {
generateConceptMapV2(v2map, valueSet, cs);
}
if (!Utilities.noString(v3map)) {
generateConceptMapV3(v3map, valueSet, cs);
}
if (cs != null)
CodeSystemConvertor.populate(cs, valueSet);
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ICD11Generator method makeFullVs.
private void makeFullVs(String dest, CodeSystem cs) throws IOException {
String url = "http://id.who.int/icd11/ValueSet/all-MMS";
ValueSet vs = new ValueSet();
vs.setId("all-MMS");
vs.setUrl(url);
vs.setName("ICDMMSAll");
vs.setTitle("Value Set for all ICD MMS Codes");
vs.setStatus(PublicationStatus.ACTIVE);
vs.setExperimental(false);
vs.setDate(cs.getDate());
vs.setPublisher("WHO");
vs.setCopyright("Consult WHO For terms of use");
vs.setVersion(cs.getVersion());
vs.setStatus(cs.getStatus());
ConceptSetComponent inc = vs.getCompose().addInclude();
inc.setSystem(cs.getUrl());
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-all-MMS.xml")), vs);
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ICD11Generator method makeFullVs2.
private void makeFullVs2(String dest, CodeSystem cs) throws IOException {
String url = "http://id.who.int/icd11/ValueSet/all-foundation";
ValueSet vs = new ValueSet();
vs.setId("all-foundation");
vs.setUrl(url);
vs.setName("ICDFoundationAll");
vs.setTitle("Value Set for all ICD Foundation Concepts");
vs.setStatus(PublicationStatus.ACTIVE);
vs.setExperimental(false);
vs.setDate(cs.getDate());
vs.setPublisher("WHO");
vs.setCopyright("Consult WHO For terms of use");
vs.setVersion(cs.getVersion());
vs.setStatus(cs.getStatus());
ConceptSetComponent inc = vs.getCompose().addInclude();
inc.setSystem(cs.getUrl());
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-all-foundation.xml")), vs);
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method intersectByExpansion.
private ValueSet intersectByExpansion(ValueSet lvs, ValueSet rvs) {
// this is pretty straight forward - we intersect the lists, and build a compose out of the intersection
ValueSet vs = new ValueSet();
vs.setStatus(PublicationStatus.DRAFT);
Map<String, ValueSetExpansionContainsComponent> left = new HashMap<String, ValueSetExpansionContainsComponent>();
scan(lvs.getExpansion().getContains(), left);
Map<String, ValueSetExpansionContainsComponent> right = new HashMap<String, ValueSetExpansionContainsComponent>();
scan(rvs.getExpansion().getContains(), right);
Map<String, ConceptSetComponent> inc = new HashMap<String, ConceptSetComponent>();
for (String s : left.keySet()) {
if (right.containsKey(s)) {
ValueSetExpansionContainsComponent cc = left.get(s);
ConceptSetComponent c = inc.get(cc.getSystem());
if (c == null) {
c = vs.getCompose().addInclude().setSystem(cc.getSystem());
inc.put(cc.getSystem(), c);
}
c.addConcept().setCode(cc.getCode()).setDisplay(cc.getDisplay());
}
}
return vs;
}
Aggregations