Skip to content

Commit

Permalink
added tests covering specifying a patient reference as search parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ohr committed Jan 20, 2017
1 parent bdbca15 commit e0d2490
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.openehealth.ipf.platform.camel.ihe.fhir.iti66;

import ca.uhn.fhir.rest.gclient.ICriterion;
import ca.uhn.fhir.rest.gclient.ReferenceClientParam;
import ca.uhn.fhir.rest.gclient.TokenClientParam;
import org.hl7.fhir.instance.model.Bundle;
import org.hl7.fhir.instance.model.DocumentManifest;
Expand All @@ -41,11 +42,15 @@ public static void startServer(String contextDescriptor) throws ServletException
startClient(String.format("http://localhost:%d/", FhirTestContainer.DEMO_APP_PORT));
}

protected ICriterion<?> manifestParameters() {
protected ICriterion<?> manifestPatientIdentifierParameter() {
return new TokenClientParam("patient.identifier").exactly()
.systemAndIdentifier("urn:oid:2.16.840.1.113883.3.37.4.1.1.2.1.1", "1");
}

protected ICriterion<?> manifestPatientReferenceParameter() {
return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1");
}

protected Bundle sendManually(ICriterion<?> requestData) {
return client.search()
.forResource(DocumentManifest.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void setUpClass() throws ServletException {
@Test(expected = InternalErrorException.class)
public void testSendManuallyReturningError() {
try {
sendManually(manifestParameters());
sendManually(manifestPatientIdentifierParameter());
} catch (InternalErrorException e) {
assertAndRethrow(e, OperationOutcome.IssueType.PROCESSING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ActiveParticipantCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes;
import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881ParticipantObjectCodes;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.ActiveParticipantType;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.AuditMessage;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.AuditSourceIdentificationType;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.CodedValueType;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.ParticipantObjectIdentificationType;
import org.openhealthtools.ihe.atna.auditor.models.rfc3881.*;

import javax.servlet.ServletException;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

/**
*
Expand All @@ -58,13 +52,13 @@ public void testGetConformance() {

@Test
public void testSendManualIti66() {
Bundle result = sendManually(manifestParameters());
Bundle result = sendManually(manifestPatientIdentifierParameter());

assertEquals(Bundle.BundleType.SEARCHSET, result.getType());
assertEquals(ResourceType.Bundle, result.getResourceType());
assertEquals(1, result.getTotal());

DocumentManifest p = (DocumentManifest)result.getEntry().get(0).getResource();
DocumentManifest p = (DocumentManifest) result.getEntry().get(0).getResource();
assertEquals("9bc72458-49b0-11e6-8a1c-3c1620524153", p.getIdElement().getIdPart());

// Check ATNA Audit
Expand Down Expand Up @@ -127,6 +121,17 @@ public void testSendManualIti66() {
assertEquals("MobileDocumentManifestQuery", query.getParticipantObjectID());
}

@Test
public void testSendIti66WithPatientReference() {
Bundle result = sendManually(manifestPatientReferenceParameter());
assertEquals(Bundle.BundleType.SEARCHSET, result.getType());
assertEquals(ResourceType.Bundle, result.getResourceType());
assertEquals(1, result.getTotal());

DocumentManifest p = (DocumentManifest) result.getEntry().get(0).getResource();
assertEquals("9bc72458-49b0-11e6-8a1c-3c1620524153", p.getIdElement().getIdPart());
}

@Test
public void testGetResource() {
DocumentManifest p = client.read()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.openehealth.ipf.platform.camel.ihe.fhir.iti67;

import ca.uhn.fhir.rest.gclient.ICriterion;
import ca.uhn.fhir.rest.gclient.ReferenceClientParam;
import ca.uhn.fhir.rest.gclient.TokenClientParam;
import org.hl7.fhir.instance.model.Bundle;
import org.hl7.fhir.instance.model.DocumentReference;
Expand All @@ -41,11 +42,15 @@ public static void startServer(String contextDescriptor) throws ServletException
startClient(String.format("http://localhost:%d/", FhirTestContainer.DEMO_APP_PORT));
}

protected ICriterion<?> referenceParameters() {
protected ICriterion<?> referencePatientIdentifierParameter() {
return new TokenClientParam("patient.identifier").exactly()
.systemAndIdentifier("urn:oid:2.16.840.1.113883.3.37.4.1.1.2.1.1", "1");
}

protected ICriterion<?> referencePatientReferenceParameter() {
return new ReferenceClientParam("patient").hasId("http://fhirserver.org/Patient/1");
}

protected Bundle sendManually(ICriterion<?> requestData) {
return client.search()
.forResource(DocumentReference.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void setUpClass() throws ServletException {
@Test(expected = InternalErrorException.class)
public void testSendManuallyReturningError() {
try {
sendManually(referenceParameters());
sendManually(referencePatientIdentifierParameter());
} catch (InternalErrorException e) {
assertAndRethrow(e, OperationOutcome.IssueType.PROCESSING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testGetConformance() {
@Test
public void testSendManualIti67() {

Bundle result = sendManually(referenceParameters());
Bundle result = sendManually(referencePatientIdentifierParameter());

assertEquals(Bundle.BundleType.SEARCHSET, result.getType());
assertEquals(ResourceType.Bundle, result.getResourceType());
Expand Down Expand Up @@ -128,6 +128,17 @@ public void testSendManualIti67() {
assertEquals("MobileDocumentReferenceQuery", query.getParticipantObjectID());
}

@Test
public void testSendIti66WithPatientReference() {
Bundle result = sendManually(referencePatientReferenceParameter());
assertEquals(Bundle.BundleType.SEARCHSET, result.getType());
assertEquals(ResourceType.Bundle, result.getResourceType());
assertEquals(1, result.getTotal());

DocumentReference p = (DocumentReference) result.getEntry().get(0).getResource();
assertEquals("63ab1c29-4225-11e6-9b33-0050569b0094", p.getIdElement().getIdPart());
}

@Test
public void testGetResource() {
DocumentReference p = client.read()
Expand Down

0 comments on commit e0d2490

Please sign in to comment.