use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class ValueSetGenerator method genMessageEvents.
private void genMessageEvents(ValueSet vs) {
if (!vs.hasCompose())
vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/message-events");
vs.setUserData("filename", "valueset-" + vs.getId());
if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
} else {
String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
if (!ec.equals("fhir"))
System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 10: is " + ec + ", want to set to " + "fhir");
}
vs.setUserData("path", "valueset-" + vs.getId() + ".html");
CodeSystem cs = new CodeSystem();
CodeSystemConvertor.populate(cs, vs);
cs.setUserData("filename", vs.getUserString("filename").replace("valueset-", "codesystem-"));
cs.setUserData("path", vs.getUserString("path").replace("valueset-", "codesystem-"));
cs.setUrl("http://hl7.org/fhir/message-events");
cs.setVersion(version);
cs.setCaseSensitive(true);
cs.setContent(CodeSystemContentMode.COMPLETE);
definitions.getCodeSystems().see(cs, packageInfo);
List<String> codes = new ArrayList<String>();
codes.addAll(definitions.getEvents().keySet());
Collections.sort(codes);
for (String s : codes) {
ConceptDefinitionComponent c = cs.addConcept();
EventDefn e = definitions.getEvents().get(s);
c.setCode(s);
c.setDisplay(transform(e.getCode(), e.getTitle()));
c.setDefinition(e.getDefinition());
}
markSpecialStatus(vs, cs, false);
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class ValueSetGenerator method genDataTypes.
private void genDataTypes(ValueSet vs) throws Exception {
if (!vs.hasCompose())
vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().addInclude().setSystem("http://hl7.org/fhir/data-types");
vs.setUserData("filename", "valueset-" + vs.getId());
if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
} else {
String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
if (!ec.equals("fhir"))
System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 6: is " + ec + ", want to set to " + "fhir");
}
vs.setUserData("path", "valueset-" + vs.getId() + ".html");
CodeSystem cs = new CodeSystem();
CodeSystemConvertor.populate(cs, vs);
cs.setUrl("http://hl7.org/fhir/data-types");
cs.setVersion(version);
cs.setCaseSensitive(true);
cs.setContent(CodeSystemContentMode.COMPLETE);
definitions.getCodeSystems().see(cs, packageInfo);
List<String> codes = new ArrayList<String>();
for (TypeRef t : definitions.getKnownTypes()) codes.add(t.getName());
Collections.sort(codes);
for (String s : codes) {
if (!definitions.dataTypeIsSharedInfo(s)) {
ConceptDefinitionComponent c = cs.addConcept();
c.setCode(s);
c.setDisplay(s);
if (definitions.getPrimitives().containsKey(s))
c.setDefinition(definitions.getPrimitives().get(s).getDefinition());
else if (definitions.getConstraints().containsKey(s))
// don't add these: c.setDefinition(definitions.getConstraints().get(s).getDefinition());
;
else if (definitions.hasElementDefn(s))
c.setDefinition(definitions.getElementDefn(s).getDefinition());
else
c.setDefinition("...to do...");
}
}
ToolingExtensions.addCSComment(cs.addConcept().setCode("xhtml").setDisplay("XHTML").setDefinition("XHTML format, as defined by W3C, but restricted usage (mainly, no active content)"), "Special case: xhtml can only be used in the narrative Data Type");
markSpecialStatus(vs, cs, true);
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class ValueSetGenerator method loadOperationOutcomeValueSet.
public void loadOperationOutcomeValueSet(BindingSpecification cd) throws Exception {
ValueSet vs = new ValueSet();
cd.setValueSet(vs);
cd.setBindingMethod(BindingMethod.ValueSet);
vs.setId("operation-outcome");
vs.setUrl("http://hl7.org/fhir/ValueSet/" + vs.getId());
vs.setName("OperationOutcomeCodes");
vs.setTitle("Operation Outcome Codes");
vs.setPublisher("HL7 (FHIR Project)");
vs.setVersion(version);
vs.setUserData("filename", "valueset-" + vs.getId());
if (!vs.hasExtension(ToolingExtensions.EXT_WORKGROUP)) {
vs.addExtension().setUrl(ToolingExtensions.EXT_WORKGROUP).setValue(new CodeType("fhir"));
} else {
String ec = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP);
if (!ec.equals("fhir"))
System.out.println("ValueSet " + vs.getUrl() + " WG mismatch 11: is " + ec + ", want to set to " + "fhir");
}
vs.setUserData("path", "valueset-" + vs.getId() + ".html");
ContactDetail c = vs.addContact();
c.addTelecom().setSystem(ContactPointSystem.URL).setValue("http://hl7.org/fhir");
c.addTelecom().setSystem(ContactPointSystem.EMAIL).setValue("fhir@lists.hl7.org");
vs.setDescription("Operation Outcome codes used by FHIR test servers (see Implementation file translations.xml)");
vs.setStatus(PublicationStatus.DRAFT);
if (!vs.hasCompose())
vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().addInclude().setSystem("http://terminology.hl7.org/CodeSystem/operation-outcome");
CodeSystem cs = new CodeSystem();
cs.setHierarchyMeaning(CodeSystemHierarchyMeaning.ISA);
Set<String> codes = translator.listTranslations("ecode");
for (String s : sorted(codes)) {
Map<String, String> langs = translator.translations(s);
ConceptDefinitionComponent cv = cs.addConcept();
cv.setCode(s);
cv.setDisplay(langs.get("en"));
for (String lang : langs.keySet()) {
if (!lang.equals("en")) {
String value = langs.get(lang);
ConceptDefinitionDesignationComponent dc = cv.addDesignation();
dc.setLanguage(lang);
dc.setValue(value);
dc.getUse().setSystem("http://terminology.hl7.org/CodeSystem/designation-usage").setCode("display");
}
}
}
CodeSystemConvertor.populate(cs, vs);
cs.setUrl("http://terminology.hl7.org/CodeSystem/operation-outcome");
cs.setVersion(version);
cs.setCaseSensitive(true);
cs.setContent(CodeSystemContentMode.COMPLETE);
definitions.getCodeSystems().see(cs, packageInfo);
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class CodeListToValueSetParser method processV2ConceptDefs.
private void processV2ConceptDefs(ConceptMap cm, String url, List<ConceptDefinitionComponent> list) throws Exception {
for (ConceptDefinitionComponent c : list) {
processV2Map(cm, url, c.getCode(), c.getUserString("v2"));
processV2ConceptDefs(cm, url, c.getConcept());
}
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.
the class IEEE11073Convertor method generateMDC.
public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
CSVReader csv = new CSVReader(new FileInputStream(src));
csv.readHeaders();
CodeSystem cs = new CodeSystem();
Map<String, String> ucumIssues = new HashMap<String, String>();
int errorCount = 0;
cs.setId("MDC");
cs.setUrl("urn:iso:std:iso:11073:10101");
cs.setVersion("[todo]");
cs.setName("11073:10101 codes for the FHIR community");
cs.setStatus(PublicationStatus.ACTIVE);
cs.setExperimental(false);
cs.setDateElement(new DateTimeType());
cs.setPublisher("HL7 (FHIR Project)");
ContactDetail cd = cs.addContact();
ContactPoint cp = cd.addTelecom();
cp.setSystem(ContactPointSystem.URL);
cp.setValue("http://ieee?");
cs.setDescription("1073 Codes for the FHIR community (generated from the Rosetta data");
Identifier i = new Identifier();
cs.setIdentifier(i);
i.setSystem("urn:ietf:rfc:3986");
i.setValue("urn:oid:2.16.840.1.113883.6.24");
cs.setCaseSensitive(false);
cs.setContent(CodeSystemContentMode.COMPLETE);
cs.addProperty().setCode("ucum").setDescription("UCUM units associated with Concept").setType(PropertyType.STRING);
cs.addProperty().setCode("unit").setDescription("MDC units associated with Concept").setType(PropertyType.STRING);
cs.addProperty().setCode("refid").setDescription("MDC Reference Id for Concept").setType(PropertyType.CODE);
Set<String> codes = new HashSet<String>();
while (csv.line()) {
if (csv.has("CF_CODE10")) {
String code = csv.cell("CF_CODE10");
if (codes.contains(code))
System.out.println("Duplicate Code " + code);
else {
codes.add(code);
ConceptDefinitionComponent c = cs.addConcept();
c.setCode(code);
c.setDisplay(csv.cell("Common Term"));
c.setDefinition(csv.cell("Term Description"));
String vd = csv.cell("Vendor_Description");
if (!c.hasDefinition())
c.setDefinition(vd);
if (!c.hasDisplay())
c.setDisplay(vd);
String refid = csv.cell("REFID");
c.addProperty().setCode("refid").setValue(new CodeType().setValue(refid));
if (csv.has("Synonym"))
c.addDesignation().setValue(csv.cell("Synonym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("synonym"));
if (csv.has("Acronym"))
c.addDesignation().setValue(csv.cell("Acronym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setDisplay("acronym"));
if (csv.has("Systematic Name")) {
String sysName = csv.cell("Systematic Name");
if (!c.hasDefinition())
c.setDefinition(sysName);
c.addDesignation().setValue(sysName).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("structured-name"));
}
if (csv.has("UOM_MDC"))
c.addProperty().setCode("unit").setValue(new StringType().setValue(csv.cell("UOM_MDC")));
if (csv.has("UOM_UCUM")) {
CommaSeparatedStringBuilder ul = new CommaSeparatedStringBuilder();
for (String u : csv.cell("UOM_UCUM").split(" ")) {
String msg = ucum.validate(u);
if (msg != null) {
errorCount++;
ucumIssues.put(u, msg);
} else
ul.append(u);
}
if (ul.length() > 0)
c.addProperty().setCode("ucum").setValue(new StringType().setValue(ul.toString()));
}
}
}
}
csv.close();
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
System.out.println(errorCount + "UCUM errors");
for (String u : sorted(ucumIssues.keySet())) System.out.println("Invalid UCUM code: " + u + " because " + ucumIssues.get(u));
return cs;
}
Aggregations