mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-28 09:09:16 +00:00
Work on term service
This commit is contained in:
parent
21ea81dd7f
commit
cf0ac8fc04
@ -34,6 +34,7 @@ import org.apache.commons.codec.binary.StringUtils;
|
|||||||
import org.hl7.fhir.dstu3.exceptions.TerminologyServiceException;
|
import org.hl7.fhir.dstu3.exceptions.TerminologyServiceException;
|
||||||
import org.hl7.fhir.dstu3.hapi.validation.HapiWorkerContext;
|
import org.hl7.fhir.dstu3.hapi.validation.HapiWorkerContext;
|
||||||
import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport;
|
import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport;
|
||||||
|
import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport.CodeValidationResult;
|
||||||
import org.hl7.fhir.dstu3.model.CodeSystem;
|
import org.hl7.fhir.dstu3.model.CodeSystem;
|
||||||
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
|
import org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent;
|
||||||
import org.hl7.fhir.dstu3.model.CodeableConcept;
|
import org.hl7.fhir.dstu3.model.CodeableConcept;
|
||||||
@ -169,7 +170,6 @@ public class FhirResourceDaoValueSetDstu3 extends FhirResourceDaoDstu3<ValueSet>
|
|||||||
IPrimitiveType<String> theSystem, IPrimitiveType<String> theDisplay, Coding theCoding, CodeableConcept theCodeableConcept) {
|
IPrimitiveType<String> theSystem, IPrimitiveType<String> theDisplay, Coding theCoding, CodeableConcept theCodeableConcept) {
|
||||||
|
|
||||||
List<IIdType> valueSetIds = Collections.emptyList();
|
List<IIdType> valueSetIds = Collections.emptyList();
|
||||||
List<IIdType> codeSystemIds = Collections.emptyList();
|
|
||||||
|
|
||||||
boolean haveCodeableConcept = theCodeableConcept != null && theCodeableConcept.getCoding().size() > 0;
|
boolean haveCodeableConcept = theCodeableConcept != null && theCodeableConcept.getCoding().size() > 0;
|
||||||
boolean haveCoding = theCoding != null && theCoding.isEmpty() == false;
|
boolean haveCoding = theCoding != null && theCoding.isEmpty() == false;
|
||||||
@ -204,6 +204,26 @@ public class FhirResourceDaoValueSetDstu3 extends FhirResourceDaoDstu3<ValueSet>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (valueSetIds.isEmpty()) {
|
||||||
|
// if (haveIdentifierParam) {
|
||||||
|
// myValidationSupport.expandValueSet(getContext(), include);
|
||||||
|
// if (myValidationSupport.isCodeSystemSupported(getContext(), theValueSetIdentifier.getValue())) {
|
||||||
|
// String system = toStringOrNull(theSystem);
|
||||||
|
// String code = toStringOrNull(theCode);
|
||||||
|
// String display = toStringOrNull(theDisplay);
|
||||||
|
// CodeValidationResult result = myValidationSupport.validateCode(getContext(), system, code, display);
|
||||||
|
// if (result != null) {
|
||||||
|
// if (theDisplay != null && isNotBlank(theDisplay.getValue()) && isNotBlank(result.getDisplay())) {
|
||||||
|
// if (!theDisplay.getValue().equals(result.getDisplay())) {
|
||||||
|
// return new ValidateCodeResult(false, "Display for code does not match", result.getDisplay());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return new ValidateCodeResult(true, "Code validates", result.getDisplay());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
for (IIdType nextId : valueSetIds) {
|
for (IIdType nextId : valueSetIds) {
|
||||||
ValueSet expansion = expand(nextId, null);
|
ValueSet expansion = expand(nextId, null);
|
||||||
List<ValueSetExpansionContainsComponent> contains = expansion.getExpansion().getContains();
|
List<ValueSetExpansionContainsComponent> contains = expansion.getExpansion().getContains();
|
||||||
@ -218,20 +238,7 @@ public class FhirResourceDaoValueSetDstu3 extends FhirResourceDaoDstu3<ValueSet>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IIdType nextId : codeSystemIds) {
|
|
||||||
ValueSet expansion = expand(nextId, null);
|
|
||||||
List<ValueSetExpansionContainsComponent> contains = expansion.getExpansion().getContains();
|
|
||||||
ValidateCodeResult result = validateCodeIsInContains(contains, toStringOrNull(theSystem), toStringOrNull(theCode), theCoding, theCodeableConcept);
|
|
||||||
if (result != null) {
|
|
||||||
if (theDisplay != null && isNotBlank(theDisplay.getValue()) && isNotBlank(result.getDisplay())) {
|
|
||||||
if (!theDisplay.getValue().equals(result.getDisplay())) {
|
|
||||||
return new ValidateCodeResult(false, "Display for code does not match", result.getDisplay());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ValidateCodeResult(false, "Code not found", null);
|
return new ValidateCodeResult(false, "Code not found", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,27 +82,11 @@ public class BaseJpaResourceProviderValueSetDstu3 extends JpaResourceProviderDst
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean moreThanOneTrue(boolean... theBooleans) {
|
|
||||||
boolean haveOne = false;
|
|
||||||
for (boolean next : theBooleans) {
|
|
||||||
if (next) {
|
|
||||||
if (haveOne) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
haveOne = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String toFilterString(StringType theFilter) {
|
private String toFilterString(StringType theFilter) {
|
||||||
return theFilter != null ? theFilter.getValue() : null;
|
return theFilter != null ? theFilter.getValue() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Operation(name = "$validate-code", idempotent = true, returnParameters= {
|
@Operation(name = "$validate-code", idempotent = true, returnParameters= {
|
||||||
@ -141,4 +125,20 @@ public class BaseJpaResourceProviderValueSetDstu3 extends JpaResourceProviderDst
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean moreThanOneTrue(boolean... theBooleans) {
|
||||||
|
boolean haveOne = false;
|
||||||
|
for (boolean next : theBooleans) {
|
||||||
|
if (next) {
|
||||||
|
if (haveOne) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
haveOne = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import java.io.IOException;
|
|||||||
import org.hl7.fhir.dstu3.model.BooleanType;
|
import org.hl7.fhir.dstu3.model.BooleanType;
|
||||||
import org.hl7.fhir.dstu3.model.CodeSystem;
|
import org.hl7.fhir.dstu3.model.CodeSystem;
|
||||||
import org.hl7.fhir.dstu3.model.CodeType;
|
import org.hl7.fhir.dstu3.model.CodeType;
|
||||||
import org.hl7.fhir.dstu3.model.Coding;
|
|
||||||
import org.hl7.fhir.dstu3.model.Parameters;
|
import org.hl7.fhir.dstu3.model.Parameters;
|
||||||
import org.hl7.fhir.dstu3.model.StringType;
|
import org.hl7.fhir.dstu3.model.StringType;
|
||||||
import org.hl7.fhir.dstu3.model.UriType;
|
import org.hl7.fhir.dstu3.model.UriType;
|
||||||
@ -20,11 +19,11 @@ import org.hl7.fhir.dstu3.model.ValueSet;
|
|||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
|
||||||
public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test {
|
public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test {
|
||||||
@ -98,6 +97,8 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExpandByIdentifier() {
|
public void testExpandByIdentifier() {
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
@ -120,6 +121,33 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void testValidateCode() {
|
||||||
|
//@formatter:off
|
||||||
|
Parameters respParam = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ValueSet.class)
|
||||||
|
.named("validate-code")
|
||||||
|
.withParameter(Parameters.class, "code", new StringType("BRN"))
|
||||||
|
.andParameter("identifier", new StringType("http://hl7.org/fhir/ValueSet/v2-0487"))
|
||||||
|
.andParameter("system", new StringType("http://hl7.org/fhir/v2/0487"))
|
||||||
|
.useHttpGet()
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
|
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||||
|
ourLog.info(resp);
|
||||||
|
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||||
|
//@formatter:off
|
||||||
|
assertThat(resp, stringContainsInOrder(
|
||||||
|
"<code value=\"11378-7\"/>",
|
||||||
|
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||||
|
//@formatter:on
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExpandByValueSet() throws IOException {
|
public void testExpandByValueSet() throws IOException {
|
||||||
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml");
|
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user