use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.
the class R4RestFhirTerminologyProviderTest method inOperationReturnsFalseWhenFhirReturnsFalse.
@Test
public void inOperationReturnsFalseWhenFhirReturnsFalse() throws Exception {
ValueSetInfo info = new ValueSetInfo();
info.setId("urn:oid:Test");
Code code = new Code();
code.setSystem(TEST_SYSTEM);
code.setCode(TEST_CODE);
code.setDisplay(TEST_DISPLAY);
Parameters parameters = new Parameters();
parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(false));
mockFhirResourceRetrieval("/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()) + "&system=" + urlencode(code.getSystem()) + "&_format=json", parameters);
boolean result = provider.in(code, info);
assertFalse(result);
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.
the class R4RestFhirTerminologyProviderTest method inOperationReturnsTrueWhenFhirReturnsTrue.
@Test
public void inOperationReturnsTrueWhenFhirReturnsTrue() throws Exception {
ValueSetInfo info = new ValueSetInfo();
info.setId("urn:oid:Test");
Code code = new Code();
code.setSystem(TEST_SYSTEM);
code.setCode(TEST_CODE);
code.setDisplay(TEST_DISPLAY);
Parameters parameters = new Parameters();
parameters.getParameterFirstRep().setName("result").setValue(new BooleanType(true));
mockFhirResourceRetrieval("/ValueSet/Test/$validate-code?code=" + urlencode(code.getCode()) + "&system=" + urlencode(code.getSystem()) + "&_format=json", parameters);
boolean result = provider.in(code, info);
assertTrue(result);
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.
the class R4LibraryResourceFieldHandlerTest method getIdentifiers.
@Test
public void getIdentifiers() {
Identifier identifier = new Identifier().setSystem("system").setValue("value");
Library library = new Library();
library.addIdentifier(identifier);
List<Identifier> libraryIdentifiers = libraryFieldHandler.getIdentifiers(library);
Assert.assertEquals(1, libraryIdentifiers.size());
Assert.assertTrue(identifier.equalsDeep(libraryIdentifiers.get(0)));
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.
the class R4MeasureResourceFieldHandlerTest method getIdentifiers.
@Test
public void getIdentifiers() {
Identifier identifier = new Identifier().setSystem("system").setValue("value");
Measure measure = new Measure();
measure.addIdentifier(identifier);
List<Identifier> measureIdentifiers = measureFieldHandler.getIdentifiers(measure);
Assert.assertEquals(1, measureIdentifiers.size());
Assert.assertTrue(identifier.equalsDeep(measureIdentifiers.get(0)));
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project quality-measure-and-cohort-service by Alvearie.
the class ValueSetUtil method createArtifact.
public static ValueSetArtifact createArtifact(InputStream is, Map<String, String> customCodeSystem) throws IOException {
XSSFSheet informationSheet;
try (XSSFWorkbook wb = new XSSFWorkbook(is)) {
informationSheet = wb.getSheetAt(wb.getSheetIndex("Expansion List"));
} catch (IllegalArgumentException e) {
throw new RuntimeException("Spreadsheet is missing required sheet \"Expansion List\"", e);
}
ValueSet valueSet = new ValueSet();
boolean inCodesSection = false;
valueSet.setStatus(Enumerations.PublicationStatus.ACTIVE);
HashMap<CodeSystemKey, List<ValueSet.ConceptReferenceComponent>> codeSystemToCodes = new HashMap<>();
String url = "http://cts.nlm.nih.gov/fhir/ValueSet/";
String identifier = null;
for (Row currentRow : informationSheet) {
String code = currentRow.getCell(0) == null ? "" : currentRow.getCell(0).getStringCellValue();
if (!code.equals("") && currentRow.getCell(1) != null && !inCodesSection) {
String value;
switch(currentRow.getCell(1).getCellType()) {
case NUMERIC:
value = Double.toString(currentRow.getCell(1).getNumericCellValue());
break;
case STRING:
value = currentRow.getCell(1).getStringCellValue();
break;
default:
throw new RuntimeException("Cell type does not match either String or Numeric for key " + code);
}
switch(currentRow.getCell(0).getStringCellValue().toLowerCase()) {
case "value set name":
valueSet.setName(value);
valueSet.setTitle(value);
break;
case "id":
valueSet.setId(value);
identifier = value;
break;
case "oid":
if (valueSet.getId() == null) {
valueSet.setId(value);
identifier = value;
}
break;
case "url":
// fallthrough
url = value.endsWith("/") ? value : value + "/";
case "definition version":
valueSet.setVersion(value);
break;
case "code":
inCodesSection = true;
break;
default:
break;
}
} else if (inCodesSection) {
String display = currentRow.getCell(1).getStringCellValue();
String codeSystemEntry = currentRow.getCell(2).getStringCellValue();
String codeSystemVersion = currentRow.getCell(3).getStringCellValue();
String codeSystem;
if (codeSystemEntry.startsWith("http://") || codeSystemEntry.startsWith("https://")) {
codeSystem = codeSystemEntry;
} else if (customCodeSystem != null && customCodeSystem.get(codeSystemEntry) != null) {
codeSystem = customCodeSystem.get(codeSystemEntry);
} else {
codeSystem = CodeSystemLookup.getUrlFromName(codeSystemEntry);
}
if (codeSystem == null) {
throw new IllegalArgumentException("Unmatched Code System! " + codeSystemEntry + " not found!");
}
ValueSet.ConceptReferenceComponent concept = new ValueSet.ConceptReferenceComponent();
concept.setCode(code);
concept.setDisplay(display);
List<ValueSet.ConceptReferenceComponent> conceptsSoFar = codeSystemToCodes.computeIfAbsent(new CodeSystemKey(codeSystem, codeSystemVersion), x -> new ArrayList<>());
conceptsSoFar.add(concept);
}
}
if (identifier == null || identifier.equals("")) {
throw new RuntimeException("There must be an Identifier specified! Please populate the ID field");
}
valueSet.setUrl(url + identifier);
valueSet.setId(identifier);
ValueSet.ValueSetComposeComponent compose = new ValueSet.ValueSetComposeComponent();
for (Entry<CodeSystemKey, List<ConceptReferenceComponent>> singleInclude : codeSystemToCodes.entrySet()) {
ValueSet.ConceptSetComponent component = new ValueSet.ConceptSetComponent();
component.setSystem(singleInclude.getKey().getCodeSystem());
component.setVersion(singleInclude.getKey().getCodeSystemVersion());
component.setConcept(singleInclude.getValue());
compose.addInclude(component);
}
valueSet.setCompose(compose);
ValueSetArtifact artifact = new ValueSetArtifact();
artifact.setName(valueSet.getName());
artifact.setFhirResource(valueSet);
artifact.setUrl(valueSet.getUrl());
return artifact;
}
Aggregations