1 | /*
|
---|
2 | * To change this template, choose Tools | Templates
|
---|
3 | * and open the template in the editor.
|
---|
4 | */
|
---|
5 |
|
---|
6 | package gov.hhs.fha.nhinc.adaptercomponentmpi;
|
---|
7 |
|
---|
8 | import gov.hhs.fha.nhinc.mpilib.*;
|
---|
9 | import gov.hhs.fha.nhinc.adaptercomponentmpi.hl7parsers.HL7Parser201306;
|
---|
10 | import org.hl7.v3.II;
|
---|
11 | import org.hl7.v3.PRPAIN201305UV;
|
---|
12 | import org.hl7.v3.PRPAIN201306UV;
|
---|
13 | import org.junit.After;
|
---|
14 | import org.junit.AfterClass;
|
---|
15 | import org.junit.Before;
|
---|
16 | import org.junit.BeforeClass;
|
---|
17 | import org.junit.Test;
|
---|
18 | import static org.junit.Assert.*;
|
---|
19 | import org.apache.commons.logging.Log;
|
---|
20 | import org.apache.commons.logging.LogFactory;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | *
|
---|
24 | * @author Jon Hoppesch
|
---|
25 | */
|
---|
26 | public class PatientCheckerTest {
|
---|
27 | private static Log log = LogFactory.getLog(PatientCheckerTest.class);
|
---|
28 |
|
---|
29 | public PatientCheckerTest() {
|
---|
30 | }
|
---|
31 |
|
---|
32 | @BeforeClass
|
---|
33 | public static void setUpClass() throws Exception {
|
---|
34 | }
|
---|
35 |
|
---|
36 | @AfterClass
|
---|
37 | public static void tearDownClass() throws Exception {
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Before
|
---|
41 | public void setUp() {
|
---|
42 | }
|
---|
43 |
|
---|
44 | @After
|
---|
45 | public void tearDown() {
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Test of FindPatient method, of class PatientChecker.
|
---|
50 | */
|
---|
51 | @Test
|
---|
52 | public void SinglePatientExists() {
|
---|
53 | log.info("SinglePatientExists");
|
---|
54 | II subjectId = new II();
|
---|
55 | subjectId.setRoot("2.16.840.1.113883.3.200");
|
---|
56 | subjectId.setExtension("1234");
|
---|
57 |
|
---|
58 | PRPAIN201305UV query = TestHelper.build201305("Joe", "Smith", "M", "March 1, 1956", subjectId);
|
---|
59 |
|
---|
60 | Identifier patId = new Identifier();
|
---|
61 | patId.setId("1234");
|
---|
62 | patId.setOrganizationId("2.16.840.1.113883.3.200");
|
---|
63 | Patient patient = TestHelper.createMpiPatient("Joe", "Smith", "M", "March 1, 1956", patId);
|
---|
64 |
|
---|
65 | PRPAIN201306UV expResult = HL7Parser201306.BuildMessageFromMpiPatient(patient, query);
|
---|
66 |
|
---|
67 | PRPAIN201306UV result = PatientChecker.FindPatient(query);
|
---|
68 |
|
---|
69 | // Verify the messages match
|
---|
70 | TestHelper.AssertPatientIdsAreSame(expResult, result);
|
---|
71 | TestHelper.AssertPatientGendersAreSame(expResult, result);
|
---|
72 | TestHelper.AssertPatientBdaysAreSame(expResult, result);
|
---|
73 | TestHelper.AssertPatientNamesAreSame(expResult, result);
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Test
|
---|
77 | public void PatientDoesNotExist() {
|
---|
78 | log.info("PatientDoesNotExist");
|
---|
79 | II subjectId = new II();
|
---|
80 | subjectId.setRoot("2.16.840.1.113883.3.200");
|
---|
81 | subjectId.setExtension("1239");
|
---|
82 | PRPAIN201305UV query = TestHelper.build201305("Joe", "Anderson", "M", "March 1, 1956", subjectId);
|
---|
83 | PRPAIN201306UV result = PatientChecker.FindPatient(query);
|
---|
84 | assertNull(result);
|
---|
85 | }
|
---|
86 | }
|
---|