Java源码示例:org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent
示例1
private boolean mergeIntoExisting(List<ConceptSetComponent> include, ConceptSetComponent inc) {
for (ConceptSetComponent dst : include) {
if (Base.compareDeep(dst, inc, false))
return true; // they're actually the same
if (dst.getSystem().equals(inc.getSystem())) {
if (inc.hasFilter() || dst.hasFilter()) {
return false; // just add the new one as a a parallel
} else if (inc.hasConcept() && dst.hasConcept()) {
for (ConceptReferenceComponent cc : inc.getConcept()) {
boolean found = false;
for (ConceptReferenceComponent dd : dst.getConcept()) {
if (dd.getCode().equals(cc.getCode()))
found = true;
if (found) {
if (cc.hasDisplay() && !dd.hasDisplay())
dd.setDisplay(cc.getDisplay());
break;
}
}
if (!found)
dst.getConcept().add(cc.copy());
}
} else
dst.getConcept().clear(); // one of them includes the entire code system
}
}
return false;
}
示例2
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);
}
}
示例3
public static void addVSComment(ConceptReferenceComponent nc, String comment) {
if (!StringUtils.isBlank(comment))
nc.getExtension().add(Factory.newExtension(EXT_VS_COMMENT, Factory.newString_(comment), true));
}
示例4
private boolean generateComposition(ResourceContext rcontext, XhtmlNode x, ValueSet vs, boolean header) throws FHIRException, IOException {
boolean hasExtensions = false;
List<String> langs = new ArrayList<String>();
if (header) {
XhtmlNode h = x.h2();
h.addText(vs.getName());
addMarkdown(x, vs.getDescription());
if (vs.hasCopyrightElement())
generateCopyright(x, vs);
}
XhtmlNode p = x.para();
p.tx("This value set includes codes from the following code systems:");
XhtmlNode ul = x.ul();
XhtmlNode li;
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
hasExtensions = genInclude(rcontext, ul, inc, "Include", langs) || hasExtensions;
}
for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs) || hasExtensions;
}
// now, build observed languages
if (langs.size() > 0) {
Collections.sort(langs);
x.para().b().tx("Additional Language Displays");
XhtmlNode t = x.table( "codes");
XhtmlNode tr = t.tr();
tr.td().b().tx("Code");
for (String lang : langs)
tr.td().b().addText(describeLang(lang));
for (ConceptSetComponent c : vs.getCompose().getInclude()) {
for (ConceptReferenceComponent cc : c.getConcept()) {
addLanguageRow(cc, t, langs);
}
}
}
return hasExtensions;
}
示例5
private static Iterator<Value> expandValuesIterator(ValueSet valueSet) {
List<Value> values = new ArrayList<>();
ValueSetComposeComponent compose = valueSet.getCompose();
for (ConceptSetComponent inclusion: compose.getInclude()) {
for (ConceptReferenceComponent concept: inclusion.getConcept()) {
Value value = new Value();
value.setValueSetUri(valueSet.getUrl());
value.setValueSetVersion(valueSet.getVersion());
value.setSystem(inclusion.getSystem());
value.setVersion(inclusion.getVersion());
value.setValue(concept.getCode());
values.add(value);
}
}
return values.iterator();
}
示例6
@Override
protected void addToValueSet(ValueSet valueSet, Dataset<Value> values) {
ValueSetComposeComponent composeComponent = valueSet.getCompose();
ConceptSetComponent currentInclusion = null;
ConceptReferenceComponent concept = null;
List<Value> sortedValues = values.sort("system", "version", "value").collectAsList();
// Workaround for the decoder producing an immutable array by replacing it with a mutable one
composeComponent.setInclude(new ArrayList<>(composeComponent.getInclude()));
for (Value value: sortedValues) {
if (currentInclusion == null
|| !value.getSystem().equals(currentInclusion.getSystem())
|| !value.getVersion().equals(currentInclusion.getVersion())) {
// Find a matching inclusion
for (ConceptSetComponent candidate: composeComponent.getInclude()) {
if (value.getSystem().equals(candidate.getSystem())
&& value.getVersion().equals(candidate.getVersion())) {
currentInclusion = candidate;
// Workaround for the decoder producing an immutable array by replacing it with a
// mutable one
currentInclusion.setConcept(new ArrayList<>(currentInclusion.getConcept()));
}
}
// No matching inclusion found, so add one
if (currentInclusion == null) {
currentInclusion = composeComponent.addInclude();
currentInclusion.setSystem(value.getSystem());
currentInclusion.setVersion(value.getVersion());
concept = null;
}
}
// Create concept if not exists
if (concept == null || !value.getValue().equals(concept.getCode())) {
concept = currentInclusion.addConcept();
concept.setCode(value.getValue());
}
}
}
示例7
@Override
public CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem,
String theCode, String theDisplay, String theValueSetUrl) {
IssueSeverity severity = IssueSeverity.WARNING;
String message = "Unsupported CodeSystem";
if (isCodeSystemSupported(theContext, theCodeSystem)) {
severity = IssueSeverity.ERROR;
message = "Code not found";
CodeSystem cs = codeSystemMap.get(theCodeSystem);
for (ConceptDefinitionComponent def : cs.getConcept()) {
if (def.getCode().equals(theCode)) {
if (def.getDisplay() != null && theDisplay != null) {
if (def.getDisplay().equals(theDisplay)) {
severity = IssueSeverity.INFORMATION;
message = "Validated Successfully";
} else {
severity = IssueSeverity.WARNING;
message = "Validated Code; Display mismatch";
}
} else {
severity = IssueSeverity.WARNING;
message = "Validated Code; No display";
}
}
}
}
ValueSet vs = fetchValueSet(theContext, theValueSetUrl);
if (vs != null && vs.hasCompose() && vs.getCompose().hasExclude()) {
for (ConceptSetComponent exclude : vs.getCompose().getExclude()) {
if (exclude.getSystem().equals(theCodeSystem) && exclude.hasConcept()) {
for (ConceptReferenceComponent concept : exclude.getConcept()) {
if (concept.getCode().equals(theCode)) {
severity = IssueSeverity.ERROR;
message += "; Code Excluded from ValueSet";
}
}
}
}
}
return new CodeValidationResult(severity, message);
}