use of org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method addLanguageRow.
private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List<String> langs) {
XhtmlNode tr = t.tr();
tr.td().addText(c.getCode());
for (String lang : langs) {
String d = null;
for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
String l = cd.getLanguage();
if (lang.equals(l))
d = cd.getValue();
}
tr.td().addText(d == null ? "" : d);
}
}
use of org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method addLangaugesToRow.
public void addLangaugesToRow(ValueSetExpansionContainsComponent c, List<String> langs, XhtmlNode tr) {
for (String lang : langs) {
String d = null;
for (Extension ext : c.getExtension()) {
if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
String l = ToolingExtensions.readStringExtension(ext, "lang");
if (lang.equals(l)) {
d = ToolingExtensions.readStringExtension(ext, "content");
}
}
}
if (d == null) {
for (ConceptReferenceDesignationComponent dd : c.getDesignation()) {
String l = dd.getLanguage();
if (lang.equals(l)) {
d = dd.getValue();
}
}
}
tr.td().addText(d == null ? "" : d);
}
}
use of org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method addLangaugesToRow.
public void addLangaugesToRow(ConceptReferenceComponent c, List<String> langs, XhtmlNode tr) {
for (String lang : langs) {
String d = null;
for (Extension ext : c.getExtension()) {
if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
String l = ToolingExtensions.readStringExtension(ext, "lang");
if (lang.equals(l)) {
d = ToolingExtensions.readStringExtension(ext, "content");
}
}
}
if (d == null) {
for (ConceptReferenceDesignationComponent dd : c.getDesignation()) {
String l = dd.getLanguage();
if (lang.equals(l)) {
d = dd.getValue();
}
}
}
tr.td().addText(d == null ? "" : d);
}
}
use of org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class DataRenderer method describeLang.
protected String describeLang(String lang) {
// special cases:
if ("fr-CA".equals(lang)) {
// this one was omitted from the value set
return "French (Canadian)";
}
ValueSet v = getContext().getWorker().fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages");
if (v != null) {
ConceptReferenceComponent l = null;
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
if (cc.getCode().equals(lang))
l = cc;
}
if (l == null) {
if (lang.contains("-")) {
lang = lang.substring(0, lang.indexOf("-"));
}
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
if (cc.getCode().equals(lang)) {
l = cc;
break;
}
}
if (l == null) {
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
if (cc.getCode().startsWith(lang + "-")) {
l = cc;
break;
}
}
}
}
if (l != null) {
if (lang.contains("-"))
lang = lang.substring(0, lang.indexOf("-"));
String en = l.getDisplay();
String nativelang = null;
for (ConceptReferenceDesignationComponent cd : l.getDesignation()) {
if (cd.getLanguage().equals(lang))
nativelang = cd.getValue();
}
if (nativelang == null)
return en + " (" + lang + ")";
else
return nativelang + " (" + en + ", " + lang + ")";
}
}
return lang;
}
use of org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method describeLang.
private String describeLang(String lang) {
ValueSet v = context.fetchResource(ValueSet.class, "http://hl7.org/fhir/ValueSet/languages");
if (v != null) {
ConceptReferenceComponent l = null;
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
if (cc.getCode().equals(lang))
l = cc;
}
if (l == null) {
if (lang.contains("-"))
lang = lang.substring(0, lang.indexOf("-"));
for (ConceptReferenceComponent cc : v.getCompose().getIncludeFirstRep().getConcept()) {
if (cc.getCode().equals(lang) || cc.getCode().startsWith(lang + "-"))
l = cc;
}
}
if (l != null) {
if (lang.contains("-"))
lang = lang.substring(0, lang.indexOf("-"));
String en = l.getDisplay();
String nativelang = null;
for (ConceptReferenceDesignationComponent cd : l.getDesignation()) {
if (cd.getLanguage().equals(lang))
nativelang = cd.getValue();
}
if (nativelang == null)
return en + " (" + lang + ")";
else
return nativelang + " (" + en + ", " + lang + ")";
}
}
return lang;
}
Aggregations