FIx validation for resources using v2 tables

This commit is contained in:
James Agnew 2015-09-29 10:51:36 -04:00
parent 79047ef6ab
commit 1cc6a05273
13 changed files with 235 additions and 116 deletions

View File

@ -11,7 +11,14 @@ a browser.
<!--*/--> <!--*/-->
<div> <div>
<th:block th:switch="${fhirVersion}">
<th:block th:case="'DSTU1'">
<div class="hapiHeaderText" th:if="${not resource.nameElement.empty}" th:narrative="${resource.name}"></div> <div class="hapiHeaderText" th:if="${not resource.nameElement.empty}" th:narrative="${resource.name}"></div>
</th:block>
<th:block th:case="*">
<div class="hapiHeaderText" th:if="${not resource.code.empty}" th:narrative="${resource.code}"></div>
</th:block>
</th:block>
</div> </div>
<!--/*--> <!--/*-->

View File

@ -13,7 +13,7 @@
<context:annotation-config /> <context:annotation-config />
<websocket:handlers> <websocket:handlers>
<websocket:mapping path="/baseDstu2/websocket" handler="mySubscriptionWebsocketHandler" /> <websocket:mapping path="/websocket/dstu2" handler="mySubscriptionWebsocketHandler" />
</websocket:handlers> </websocket:handlers>
<!-- <!--

View File

@ -183,7 +183,7 @@ public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test {
SimpleEchoSocket socket = new SimpleEchoSocket(subsId); SimpleEchoSocket socket = new SimpleEchoSocket(subsId);
try { try {
client.start(); client.start();
URI echoUri = new URI("ws://localhost:" + ourPort + "/baseDstu2/websocket"); URI echoUri = new URI("ws://localhost:" + ourPort + "/websocket/dstu2");
ClientUpgradeRequest request = new ClientUpgradeRequest(); ClientUpgradeRequest request = new ClientUpgradeRequest();
client.connect(socket, echoUri, request); client.connect(socket, echoUri, request);
ourLog.info("Connecting to : {}", echoUri); ourLog.info("Connecting to : {}", echoUri);

View File

@ -1,5 +1,9 @@
package ca.uhn.fhirtest; package ca.uhn.fhirtest;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import org.apache.derby.drda.NetworkServerControl; import org.apache.derby.drda.NetworkServerControl;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
@ -22,7 +26,30 @@ public class DerbyNetworkServer implements InitializingBean, DisposableBean {
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
server = new NetworkServerControl(); server = new NetworkServerControl();
server.start (null); Writer w = new Writer() {
@Override
public void write(char[] theCbuf, int theOff, int theLen) throws IOException {
ourLog.info("[DERBY] " + new String(theCbuf, theOff, theLen));
}
@Override
public void flush() throws IOException {
// nothing
}
@Override
public void close() throws IOException {
// nothing
}};
server.start (new PrintWriter(w));
}
public static void main(String[] args) throws Exception {
DerbyNetworkServer s = new DerbyNetworkServer();
s.afterPropertiesSet();
s.destroy();
} }
} }

View File

@ -8,6 +8,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.web.context.ContextLoaderListener; import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
@ -35,7 +36,7 @@ public class TestRestfulServer extends RestfulServer {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestRestfulServer.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TestRestfulServer.class);
private ClassPathXmlApplicationContext myAppCtx; private ApplicationContext myAppCtx;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@ -44,6 +45,7 @@ public class TestRestfulServer extends RestfulServer {
// Get the spring context from the web container (it's declared in web.xml) // Get the spring context from the web container (it's declared in web.xml)
WebApplicationContext parentAppCtx = ContextLoaderListener.getCurrentWebApplicationContext(); WebApplicationContext parentAppCtx = ContextLoaderListener.getCurrentWebApplicationContext();
myAppCtx = (parentAppCtx);
// These two parmeters are also declared in web.xml // These two parmeters are also declared in web.xml
String implDesc = getInitParameter("ImplementationDescription"); String implDesc = getInitParameter("ImplementationDescription");
@ -64,9 +66,6 @@ public class TestRestfulServer extends RestfulServer {
String baseUrlProperty; String baseUrlProperty;
switch (fhirVersionParam.trim().toUpperCase()) { switch (fhirVersionParam.trim().toUpperCase()) {
case "DSTU1": { case "DSTU1": {
myAppCtx = new ClassPathXmlApplicationContext(new String[] {
"hapi-fhir-server-database-config-dstu1.xml",
"hapi-fhir-server-resourceproviders-dstu1.xml"}, parentAppCtx);
setFhirContext(FhirContext.forDstu1()); setFhirContext(FhirContext.forDstu1());
beans = myAppCtx.getBean("myResourceProvidersDstu1", List.class); beans = myAppCtx.getBean("myResourceProvidersDstu1", List.class);
systemProviderDstu1 = myAppCtx.getBean("mySystemProviderDstu1", JpaSystemProviderDstu1.class); systemProviderDstu1 = myAppCtx.getBean("mySystemProviderDstu1", JpaSystemProviderDstu1.class);
@ -79,11 +78,6 @@ public class TestRestfulServer extends RestfulServer {
break; break;
} }
case "DSTU2": { case "DSTU2": {
myAppCtx = new ClassPathXmlApplicationContext(new String[] {
"hapi-fhir-server-database-config-dstu2.xml",
"hapi-fhir-server-resourceproviders-dstu2.xml",
"fhir-spring-subscription-config-dstu2.xml"
}, parentAppCtx);
setFhirContext(FhirContext.forDstu2()); setFhirContext(FhirContext.forDstu2());
beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class); beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class);
systemProviderDstu2 = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class); systemProviderDstu2 = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);

View File

@ -12,6 +12,11 @@
/WEB-INF/hapi-fhir-server-config.xml /WEB-INF/hapi-fhir-server-config.xml
/WEB-INF/hapi-fhir-tester-application-context.xml /WEB-INF/hapi-fhir-tester-application-context.xml
/WEB-INF/hapi-fhir-tester-config.xml /WEB-INF/hapi-fhir-tester-config.xml
classpath:/hapi-fhir-server-database-config-dstu1.xml
classpath:/hapi-fhir-server-database-config-dstu2.xml
classpath:hapi-fhir-server-resourceproviders-dstu1.xml
classpath:hapi-fhir-server-resourceproviders-dstu2.xml
classpath:fhir-spring-subscription-config-dstu2.xml
</param-value> </param-value>
</context-param> </context-param>
@ -25,6 +30,7 @@
<param-value> <param-value>
/WEB-INF/hapi-fhir-tester-application-context.xml /WEB-INF/hapi-fhir-tester-application-context.xml
/WEB-INF/hapi-fhir-tester-config.xml /WEB-INF/hapi-fhir-tester-config.xml
classpath:fhir-spring-subscription-config-dstu2.xml
</param-value> </param-value>
</init-param> </init-param>
<load-on-startup>2</load-on-startup> <load-on-startup>2</load-on-startup>

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.narrative; package ca.uhn.fhir.narrative;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -92,7 +93,6 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
} }
@Test @Test
public void testGenerateDiagnosticReport() throws DataFormatException { public void testGenerateDiagnosticReport() throws DataFormatException {
DiagnosticReport value = new DiagnosticReport(); DiagnosticReport value = new DiagnosticReport();
@ -216,4 +216,20 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
} }
@Test
public void testGenerateMedication() {
Medication med = new Medication();
med.getCode().setText("ciproflaxin");
NarrativeDt narrative = new NarrativeDt();
myGen.generateNarrative(med, narrative);
String string = narrative.getDiv().toString();
assertThat(string, containsString("ciproflaxin"));
String title = myGen.generateTitle(med);
assertEquals("ciproflaxin", title);
}
} }

View File

@ -1,5 +1,7 @@
package ca.uhn.fhir.validation; package ca.uhn.fhir.validation;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -21,9 +23,10 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
public class DefaultProfileValidationSupport implements IValidationSupport { public class DefaultProfileValidationSupport implements IValidationSupport {
private Map<String, ValueSet> myDefaultValueSets; private Map<String, ValueSet> myDefaultValueSets;
private Map<String, ValueSet> myCodeSystems;
@Override @Override
public boolean isCodeSystemSupported(String theSystem) { public boolean isCodeSystemSupported(FhirContext theContext, String theSystem) {
return false; return false;
} }
@ -70,17 +73,51 @@ public class DefaultProfileValidationSupport implements IValidationSupport {
} }
@Override @Override
public CodeValidationResult validateCode(String theCodeSystem, String theCode, String theDisplay) { public CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem, String theCode, String theDisplay) {
return new CodeValidationResult(IssueSeverity.INFORMATION, "Unknown code: " + theCodeSystem + " / " + theCode); return new CodeValidationResult(IssueSeverity.INFORMATION, "Unknown code: " + theCodeSystem + " / " + theCode);
} }
@Override @Override
public ValueSet fetchCodeSystem(String theSystem) { public ValueSet fetchCodeSystem(FhirContext theContext, String theSystem) {
return null; Map<String, ValueSet> codeSystems = myCodeSystems;
if (codeSystems == null) {
codeSystems = new HashMap<String, ValueSet>();
loadCodeSystems(theContext, codeSystems, "/org/hl7/fhir/instance/model/valueset/valuesets.xml");
loadCodeSystems(theContext, codeSystems, "/org/hl7/fhir/instance/model/valueset/v2-tables.xml");
loadCodeSystems(theContext, codeSystems, "/org/hl7/fhir/instance/model/valueset/v3-codesystems.xml");
myCodeSystems = codeSystems;
}
return codeSystems.get(theSystem);
}
private void loadCodeSystems(FhirContext theContext, Map<String, ValueSet> codeSystems, String file) {
InputStream valuesetText = DefaultProfileValidationSupport.class.getResourceAsStream(file);
if (valuesetText != null) {
InputStreamReader reader;
try {
reader = new InputStreamReader(valuesetText, "UTF-8");
} catch (UnsupportedEncodingException e) {
// Shouldn't happen!
throw new InternalErrorException("UTF-8 encoding not supported on this platform", e);
}
FhirContext ctx = FhirInstanceValidator.getHl7OrgDstu2Ctx(theContext);
Bundle bundle = ctx.newXmlParser().parseResource(Bundle.class, reader);
for (BundleEntryComponent next : bundle.getEntry()) {
ValueSet nextValueSet = (ValueSet) next.getResource();
String system = nextValueSet.getCodeSystem().getSystem();
if (isNotBlank(system)) {
codeSystems.put(system, nextValueSet);
}
}
}
} }
@Override @Override
public ValueSetExpansionComponent expandValueSet(ConceptSetComponent theInclude) { public ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude) {
return null; return null;
} }

View File

@ -269,7 +269,7 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
@Override @Override
public ValueSetExpansionComponent expandVS(ConceptSetComponent theInc) { public ValueSetExpansionComponent expandVS(ConceptSetComponent theInc) {
return myValidationSupport.expandValueSet(theInc); return myValidationSupport.expandValueSet(myCtx, theInc);
} }
@Override @Override
@ -282,7 +282,7 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
if (myValidationSupport == null) { if (myValidationSupport == null) {
return null; return null;
} else { } else {
return myValidationSupport.fetchCodeSystem(theSystem); return myValidationSupport.fetchCodeSystem(myCtx, theSystem);
} }
} }
@ -335,13 +335,13 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IValid
if (myValidationSupport == null) { if (myValidationSupport == null) {
return false; return false;
} else { } else {
return myValidationSupport.isCodeSystemSupported(theSystem); return myValidationSupport.isCodeSystemSupported(myCtx, theSystem);
} }
} }
@Override @Override
public ValidationResult validateCode(String theSystem, String theCode, String theDisplay) { public ValidationResult validateCode(String theSystem, String theCode, String theDisplay) {
CodeValidationResult result = myValidationSupport.validateCode(theSystem, theCode, theDisplay); CodeValidationResult result = myValidationSupport.validateCode(myCtx, theSystem, theCode, theDisplay);
if (result == null) { if (result == null) {
return null; return null;
} }

View File

@ -18,7 +18,7 @@ public interface IValidationSupport {
* The portion to include * The portion to include
* @return The expansion * @return The expansion
*/ */
ValueSetExpansionComponent expandValueSet(ConceptSetComponent theInclude); ValueSetExpansionComponent expandValueSet(FhirContext theContext, ConceptSetComponent theInclude);
/** /**
* Fetch a code system by ID * Fetch a code system by ID
@ -27,7 +27,7 @@ public interface IValidationSupport {
* The code system * The code system
* @return The valueset (must not be null, but can be an empty ValueSet) * @return The valueset (must not be null, but can be an empty ValueSet)
*/ */
ValueSet fetchCodeSystem(String theSystem); ValueSet fetchCodeSystem(FhirContext theContext, String theSystem);
/** /**
* Loads a resource needed by the validation (a StructureDefinition, or a * Loads a resource needed by the validation (a StructureDefinition, or a
@ -53,7 +53,7 @@ public interface IValidationSupport {
* @return Returns <code>true</code> if codes in the given code system can be * @return Returns <code>true</code> if codes in the given code system can be
* validated * validated
*/ */
boolean isCodeSystemSupported(String theSystem); boolean isCodeSystemSupported(FhirContext theContext, String theSystem);
/** /**
* Validates that the given code exists and if possible returns a display * Validates that the given code exists and if possible returns a display
@ -68,7 +68,7 @@ public interface IValidationSupport {
* The display name, if it should also be validated * The display name, if it should also be validated
* @return Returns a validation result object * @return Returns a validation result object
*/ */
CodeValidationResult validateCode(String theCodeSystem, String theCode, String theDisplay); CodeValidationResult validateCode(FhirContext theContext, String theCodeSystem, String theCode, String theDisplay);
public class CodeValidationResult { public class CodeValidationResult {
private ConceptDefinitionComponent definition; private ConceptDefinitionComponent definition;

View File

@ -24,19 +24,19 @@ public class ValidationSupportChain implements IValidationSupport {
} }
@Override @Override
public ValueSetExpansionComponent expandValueSet(ConceptSetComponent theInclude) { public ValueSetExpansionComponent expandValueSet(FhirContext theCtx, ConceptSetComponent theInclude) {
for (IValidationSupport next : myChain) { for (IValidationSupport next : myChain) {
if (next.isCodeSystemSupported(theInclude.getSystem())) { if (next.isCodeSystemSupported(theCtx, theInclude.getSystem())) {
return next.expandValueSet(theInclude); return next.expandValueSet(theCtx, theInclude);
} }
} }
return myChain.get(0).expandValueSet(theInclude); return myChain.get(0).expandValueSet(theCtx, theInclude);
} }
@Override @Override
public ValueSet fetchCodeSystem(String theSystem) { public ValueSet fetchCodeSystem(FhirContext theCtx, String theSystem) {
for (IValidationSupport next : myChain) { for (IValidationSupport next : myChain) {
ValueSet retVal = next.fetchCodeSystem(theSystem); ValueSet retVal = next.fetchCodeSystem(theCtx, theSystem);
if (retVal != null) { if (retVal != null) {
return retVal; return retVal;
} }
@ -56,9 +56,9 @@ public class ValidationSupportChain implements IValidationSupport {
} }
@Override @Override
public boolean isCodeSystemSupported(String theSystem) { public boolean isCodeSystemSupported(FhirContext theCtx, String theSystem) {
for (IValidationSupport next : myChain) { for (IValidationSupport next : myChain) {
if (next.isCodeSystemSupported(theSystem)) { if (next.isCodeSystemSupported(theCtx, theSystem)) {
return true; return true;
} }
} }
@ -66,13 +66,13 @@ public class ValidationSupportChain implements IValidationSupport {
} }
@Override @Override
public CodeValidationResult validateCode(String theCodeSystem, String theCode, String theDisplay) { public CodeValidationResult validateCode(FhirContext theCtx, String theCodeSystem, String theCode, String theDisplay) {
for (IValidationSupport next : myChain) { for (IValidationSupport next : myChain) {
if (next.isCodeSystemSupported(theCodeSystem)) { if (next.isCodeSystemSupported(theCtx, theCodeSystem)) {
return next.validateCode(theCodeSystem, theCode, theDisplay); return next.validateCode(theCtx, theCodeSystem, theCode, theDisplay);
} }
} }
return myChain.get(0).validateCode(theCodeSystem, theCode, theDisplay); return myChain.get(0).validateCode(theCtx, theCodeSystem, theCode, theDisplay);
} }
} }

View File

@ -16,6 +16,7 @@ import org.apache.commons.io.IOUtils;
import org.hl7.fhir.instance.model.CodeType; import org.hl7.fhir.instance.model.CodeType;
import org.hl7.fhir.instance.model.Observation; import org.hl7.fhir.instance.model.Observation;
import org.hl7.fhir.instance.model.Observation.ObservationStatus; import org.hl7.fhir.instance.model.Observation.ObservationStatus;
import org.hl7.fhir.instance.model.Patient;
import org.hl7.fhir.instance.model.StringType; import org.hl7.fhir.instance.model.StringType;
import org.hl7.fhir.instance.model.ValueSet; import org.hl7.fhir.instance.model.ValueSet;
import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent; import org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent;
@ -61,19 +62,19 @@ public class FhirInstanceValidatorTest {
myValidConcepts = new ArrayList<String>(); myValidConcepts = new ArrayList<String>();
myMockSupport = mock(IValidationSupport.class); myMockSupport = mock(IValidationSupport.class);
when(myMockSupport.expandValueSet(any(ConceptSetComponent.class))).thenAnswer(new Answer<ValueSetExpansionComponent>() { when(myMockSupport.expandValueSet(any(FhirContext.class), any(ConceptSetComponent.class))).thenAnswer(new Answer<ValueSetExpansionComponent>() {
@Override @Override
public ValueSetExpansionComponent answer(InvocationOnMock theInvocation) throws Throwable { public ValueSetExpansionComponent answer(InvocationOnMock theInvocation) throws Throwable {
ConceptSetComponent arg = (ConceptSetComponent)theInvocation.getArguments()[0]; ConceptSetComponent arg = (ConceptSetComponent)theInvocation.getArguments()[0];
ValueSetExpansionComponent retVal = mySupportedCodeSystemsForExpansion.get(arg.getSystem()); ValueSetExpansionComponent retVal = mySupportedCodeSystemsForExpansion.get(arg.getSystem());
if (retVal == null) { if (retVal == null) {
retVal = myDefaultValidationSupport.expandValueSet(arg); retVal = myDefaultValidationSupport.expandValueSet(any(FhirContext.class), arg);
} }
ourLog.info("expandValueSet({}) : {}", new Object[] { theInvocation.getArguments()[0], retVal }); ourLog.info("expandValueSet({}) : {}", new Object[] { theInvocation.getArguments()[0], retVal });
return retVal; return retVal;
} }
}); });
when(myMockSupport.isCodeSystemSupported(any(String.class))).thenAnswer(new Answer<Boolean>() { when(myMockSupport.isCodeSystemSupported(any(FhirContext.class), any(String.class))).thenAnswer(new Answer<Boolean>() {
@Override @Override
public Boolean answer(InvocationOnMock theInvocation) throws Throwable { public Boolean answer(InvocationOnMock theInvocation) throws Throwable {
boolean retVal = mySupportedCodeSystemsForExpansion.containsKey(theInvocation.getArguments()[0]); boolean retVal = mySupportedCodeSystemsForExpansion.containsKey(theInvocation.getArguments()[0]);
@ -93,27 +94,28 @@ public class FhirInstanceValidatorTest {
return retVal; return retVal;
} }
}); });
when(myMockSupport.validateCode(any(String.class), any(String.class), any(String.class))) when(myMockSupport.validateCode(any(FhirContext.class), any(String.class), any(String.class), any(String.class)))
.thenAnswer(new Answer<CodeValidationResult>() { .thenAnswer(new Answer<CodeValidationResult>() {
@Override @Override
public CodeValidationResult answer(InvocationOnMock theInvocation) throws Throwable { public CodeValidationResult answer(InvocationOnMock theInvocation) throws Throwable {
String system = (String) theInvocation.getArguments()[0]; FhirContext ctx = (FhirContext) theInvocation.getArguments()[0];
String code = (String) theInvocation.getArguments()[1]; String system = (String) theInvocation.getArguments()[1];
String code = (String) theInvocation.getArguments()[2];
CodeValidationResult retVal; CodeValidationResult retVal;
if (myValidConcepts.contains(system + "___" + code)) { if (myValidConcepts.contains(system + "___" + code)) {
retVal = new CodeValidationResult(new ConceptDefinitionComponent(new CodeType(code))); retVal = new CodeValidationResult(new ConceptDefinitionComponent(new CodeType(code)));
} else { } else {
retVal = myDefaultValidationSupport.validateCode(system, code, (String) theInvocation.getArguments()[2]); retVal = myDefaultValidationSupport.validateCode(ctx, system, code, (String) theInvocation.getArguments()[2]);
} }
ourLog.info("validateCode({}, {}, {}) : {}", ourLog.info("validateCode({}, {}, {}) : {}",
new Object[] { system, code, (String) theInvocation.getArguments()[2], retVal }); new Object[] { system, code, (String) theInvocation.getArguments()[2], retVal });
return retVal; return retVal;
} }
}); });
when(myMockSupport.fetchCodeSystem(any(String.class))).thenAnswer(new Answer<ValueSet>() { when(myMockSupport.fetchCodeSystem(any(FhirContext.class), any(String.class))).thenAnswer(new Answer<ValueSet>() {
@Override @Override
public ValueSet answer(InvocationOnMock theInvocation) throws Throwable { public ValueSet answer(InvocationOnMock theInvocation) throws Throwable {
ValueSet retVal = myDefaultValidationSupport.fetchCodeSystem((String) theInvocation.getArguments()[0]); ValueSet retVal = myDefaultValidationSupport.fetchCodeSystem((FhirContext) theInvocation.getArguments()[0],(String) theInvocation.getArguments()[1]);
ourLog.info("fetchCodeSystem({}) : {}", new Object[] { (String) theInvocation.getArguments()[0], retVal }); ourLog.info("fetchCodeSystem({}) : {}", new Object[] { (String) theInvocation.getArguments()[0], retVal });
return retVal; return retVal;
} }
@ -306,6 +308,29 @@ public class FhirInstanceValidatorTest {
output.getMessages().get(0).getMessage()); output.getMessages().get(0).getMessage());
} }
@Test
public void testValidateResourceWithValuesetExpansion() {
Patient patient = new Patient();
patient.addIdentifier().setSystem("http://system").setValue("12345").getType().addCoding().setSystem("foo").setCode("bar");
ValidationResult output = myVal.validateWithResult(patient);
List<SingleValidationMessage> all = logResultsAndReturnAll(output);
assertEquals(1, all.size());
assertEquals("/f:Patient/f:identifier/f:type", all.get(0).getLocationString());
assertEquals("None of the codes are in the expected value set http://hl7.org/fhir/ValueSet/identifier-type (http://hl7.org/fhir/ValueSet/identifier-type)", all.get(0).getMessage());
assertEquals(ResultSeverityEnum.WARNING, all.get(0).getSeverity());
patient = new Patient();
patient.addIdentifier().setSystem("http://system").setValue("12345").getType().addCoding().setSystem("http://hl7.org/fhir/v2/0203").setCode("MR");
output = myVal.validateWithResult(patient);
all = logResultsAndReturnAll(output);
assertEquals(0, all.size());
}
@Test @Test
public void testValidateResourceWithExampleBindingCodeValidationFailing() { public void testValidateResourceWithExampleBindingCodeValidationFailing() {
Observation input = new Observation(); Observation input = new Observation();

View File

@ -84,6 +84,13 @@
a more appropriate 400/404 in the JPA server (vread on invalid version, a more appropriate 400/404 in the JPA server (vread on invalid version,
delete with no ID, etc.) delete with no ID, etc.)
</action> </action>
<action type="fix">
Fix narrative generation for DSTU2 Medication resource
</action>
<action type="fix">
Profile validator now works for valuesets which use
v2 tables
</action>
</release> </release>
<release version="1.2" date="2015-09-18"> <release version="1.2" date="2015-09-18">
<action type="add"> <action type="add">