use of org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent in project gpconnect-demonstrator by nhsconnect.
the class ValueSetValidator method validateCode.
public Boolean validateCode(Coding code) {
String systemUrl = code.getSystem();
ValueSet valSet = loadValueSet(systemUrl);
// Check Code System
@SuppressWarnings("unused") ValueSetComposeComponent codeSys = valSet.getCompose();
@SuppressWarnings("unused") List<ValueSet.ConceptReferenceComponent> concepts;
return true;
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent in project bunsen by cerner.
the class ValueSets method expandValuesIterator.
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();
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent in project bunsen by cerner.
the class ValueSets method addToValueSet.
/**
* Adds the given values to the given value set instance.
*/
private 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());
}
}
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent in project bunsen by cerner.
the class ValueSets method addToValueSet.
@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());
}
}
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent in project bunsen by cerner.
the class ValueSets method expandValuesIterator.
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();
}
Aggregations