This commit is contained in:
jamesagnew 2021-03-16 08:34:43 -04:00
parent 14f12e7dab
commit beecb49d45
1 changed files with 23 additions and 1 deletions

View File

@ -46,6 +46,7 @@ import org.hl7.fhir.r4.model.ElementDefinition;
import org.hl7.fhir.r4.model.Enumerations; import org.hl7.fhir.r4.model.Enumerations;
import org.hl7.fhir.r4.model.Group; import org.hl7.fhir.r4.model.Group;
import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Location;
import org.hl7.fhir.r4.model.Narrative; import org.hl7.fhir.r4.model.Narrative;
import org.hl7.fhir.r4.model.Observation; import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Observation.ObservationStatus; import org.hl7.fhir.r4.model.Observation.ObservationStatus;
@ -73,9 +74,12 @@ import org.springframework.transaction.PlatformTransactionManager;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Collections; import java.util.Collections;
import java.util.Locale;
import java.util.stream.Collectors;
import static org.awaitility.Awaitility.await; import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -670,8 +674,26 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
assertEquals("The code 123 is not valid in the system https://bb", oo.getIssue().get(0).getDiagnostics()); assertEquals("The code 123 is not valid in the system https://bb", oo.getIssue().get(0).getDiagnostics());
} }
@Test
public void testValidateWithFragmentCodeSystem_NoDirectBinding() throws IOException {
myCodeSystemDao.create(loadResourceFromClasspath(CodeSystem.class, "/r4/fragment/codesystem.json"));
Location location = new Location();
location.getPhysicalType().addCoding()
.setSystem("http://example.com/codesystem")
.setCode("foo")
.setDisplay("Foo Code");
MethodOutcome outcome = myLocationDao.validate(location, null, null, null, ValidationModeEnum.CREATE, null, null);
OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome();
String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
ourLog.info(ooString);
assertThat(ooString, containsString("Unknown code in fragment CodeSystem 'http://example.com/codesystem#foo'"));
assertThat(oo.getIssue().stream().map(t->t.getSeverity().toCode()).collect(Collectors.toList()), contains("warning", "warning"));
}
/** /**
@ -680,7 +702,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
* We should generate a warning if a code can't be found but the codesystem is a fragment * We should generate a warning if a code can't be found but the codesystem is a fragment
*/ */
@Test @Test
public void testValidateWithFragmentCodeSystem() throws IOException { public void testValidateWithFragmentCodeSystem_WithDirectBinding() throws IOException {
myStructureDefinitionDao.create(loadResourceFromClasspath(StructureDefinition.class, "/r4/fragment/structuredefinition.json")); myStructureDefinitionDao.create(loadResourceFromClasspath(StructureDefinition.class, "/r4/fragment/structuredefinition.json"));
myCodeSystemDao.create(loadResourceFromClasspath(CodeSystem.class, "/r4/fragment/codesystem.json")); myCodeSystemDao.create(loadResourceFromClasspath(CodeSystem.class, "/r4/fragment/codesystem.json"));
myValueSetDao.create(loadResourceFromClasspath(ValueSet.class, "/r4/fragment/valueset.json")); myValueSetDao.create(loadResourceFromClasspath(ValueSet.class, "/r4/fragment/valueset.json"));