![JAR search and dependency download from the Maven repository](/logo.png)
org.opencds.cqf.tooling.acceleratorkit.CodeCollection Maven / Gradle / Ivy
package org.opencds.cqf.tooling.acceleratorkit;
import org.hl7.fhir.r4.model.Coding;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class CodeCollection {
public CodeCollection() {
this.codes = new ArrayList();
}
public CodeCollection(List codes) {
this.codes = codes;
}
private List codes;
public List getCodes() {
if (this.codes == null) {
this.codes = new ArrayList<>();
}
return this.codes;
}
public List getValidCodes() {
return this.getCodes().stream()
.filter((c) -> !c.getCode().trim().isEmpty())
.collect(Collectors.toList());
}
public List getCodesForSystem(String system) {
if (this.codes == null) {
this.codes = new ArrayList<>();
}
List codes = this.getValidCodes().stream()
.filter((c) -> c.getSystem().equals(system))
.collect(Collectors.toList());
return codes;
}
private ArrayList codeSystemUrls;
public List getCodeSystemUrls() {
if (this.codeSystemUrls == null) {
this.codeSystemUrls = new ArrayList<>();
}
List codeSystemUrls = this.getValidCodes().stream()
.map((c) -> c.getSystem())
.distinct()
.collect(Collectors.toList());
return codeSystemUrls;
}
public int size() {
return getCodes().size();
}
public List toCodings() {
List codings = new ArrayList<>();
for (DictionaryCode code : this.getCodes()) {
Coding coding = new Coding();
coding.setCode(code.getCode());
coding.setSystem(code.getSystem());
coding.setDisplay(code.getDisplay());
codings.add(coding);
}
return codings;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy