Add null check on code lookup result.
This commit is contained in:
parent
1b387a5740
commit
8e552916ee
|
@ -54,7 +54,7 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPopulateCoding_Read_NullableValidationSupport() {
|
public void testDontPopulateCodingIfLookupReturnsNull_Read() {
|
||||||
myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(new NullableValidationSupport(myCtx)));
|
myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(new NullableValidationSupport(myCtx)));
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
|
@ -72,7 +72,7 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest {
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A");
|
p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A");
|
||||||
IIdType id = myClient.create().resource(p).execute().getId();
|
myClient.create().resource(p).execute();
|
||||||
|
|
||||||
Bundle bundle = myClient.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
|
Bundle bundle = myClient.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
|
||||||
assertEquals(1, bundle.getEntry().size());
|
assertEquals(1, bundle.getEntry().size());
|
||||||
|
@ -82,12 +82,12 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPopulateCoding_Search_NullableValidationSupport() {
|
public void testDontPopulateCodingIfLookupReturnsNull_Search() {
|
||||||
myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(new NullableValidationSupport(myCtx)));
|
myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(new NullableValidationSupport(myCtx)));
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A");
|
p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("zz");
|
||||||
IIdType id = myClient.create().resource(p).execute().getId();
|
myClient.create().resource(p).execute();
|
||||||
|
|
||||||
Bundle bundle = myClient.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
|
Bundle bundle = myClient.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
|
||||||
assertEquals(1, bundle.getEntry().size());
|
assertEquals(1, bundle.getEntry().size());
|
||||||
|
@ -101,7 +101,7 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest {
|
||||||
myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(myCtx.getValidationSupport()));
|
myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(myCtx.getValidationSupport()));
|
||||||
|
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A").setDisplay("FOO");
|
p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("zz").setDisplay("FOO");
|
||||||
IIdType id = myClient.create().resource(p).execute().getId();
|
IIdType id = myClient.create().resource(p).execute().getId();
|
||||||
|
|
||||||
p = myClient.read().resource(Patient.class).withId(id).execute();
|
p = myClient.read().resource(Patient.class).withId(id).execute();
|
||||||
|
@ -119,7 +119,7 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest {
|
||||||
|
|
||||||
p = myClient.read().resource(Patient.class).withId(id).execute();
|
p = myClient.read().resource(Patient.class).withId(id).execute();
|
||||||
assertEquals(1, p.getMaritalStatus().getCoding().size());
|
assertEquals(1, p.getMaritalStatus().getCoding().size());
|
||||||
assertEquals(null, p.getMaritalStatus().getCoding().get(0).getDisplay());
|
assertNull(p.getMaritalStatus().getCoding().get(0).getDisplay());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class NullableValidationSupport implements IValidationSupport {
|
private static class NullableValidationSupport implements IValidationSupport {
|
||||||
|
@ -139,6 +139,11 @@ public class ResponseTerminologyDisplayPopulationInterceptorTest {
|
||||||
public boolean isCodeSystemSupported(ValidationSupportContext theValidationSupportContext, String theSystem) {
|
public boolean isCodeSystemSupported(ValidationSupportContext theValidationSupportContext, String theSystem) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LookupCodeResult lookupCode(ValidationSupportContext theValidationSupportContext, String theSystem, String theCode) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue