PatientDiscovery201305Processor implements PatientDiscoveryProcessor { @Override public PRPAIN201306UV02 process201305(PRPAIN201305UV02 request, AssertionType assertion) throws PatientDiscoveryException { String senderOID = extractSenderOID(request); String receiverOID = extractReceiverOID(request); PRPAIN201306UV02 response = queryMpi(request, assertion); if (response != null && response.getControlActProcess() != null) { if (!checkEmptySubject(response)) { response = checkPolicyFormatResponse(request, assertion, response); } else { LOG.warn("No match is found by local MPI"); } } else { LOG.warn("Response from local MPI is null; generating empty response"); response = createEmpty201306(senderOID, receiverOID, request); response = addValidationReasonOf(response); } return response; }  @Override PRPAIN201306UV02 process201305(PRPAIN201305UV02 request, AssertionType assertion); void storeLocalMapping(RespondingGatewayPRPAIN201305UV02RequestType request); PRPAIN201306UV02 queryMpiForPatients(PRPAIN201305UV02 query, AssertionType assertion); PRPAIN201305UV02 createNewRequest(PRPAIN201305UV02 request, String targetCommunityId); II extractPatientIdFrom201305(PRPAIN201305UV02 request);  }
@Test public void testProcess201305() { System.out.println("testProcess201305"); PatientDiscoveryProcessor instance = new PatientDiscovery201305Processor() { @Override protected void storeMapping(PRPAIN201305UV02 request) { } @Override protected PRPAIN201306UV02 queryMpi(PRPAIN201305UV02 query, AssertionType assertion) { JAXBElement<PRPAMT201301UV02Person> person = HL7PatientTransforms.create201301PatientPerson("Joe", "Smith", "M", null, null); PRPAMT201301UV02Patient patient = HL7PatientTransforms.create201301Patient(person, "5678", "2.2.2"); return HL7PRPA201306Transforms.createPRPA201306(patient, "2.2", "1.1.1", "1.1", "2.2.2", query); } @Override protected boolean checkPolicy(PRPAIN201306UV02 response, AssertionType assertion) { return true; } @Override protected void createPatientCorrelation(PRPAIN201306UV02 queryResult, II remotePatient, AssertionType assertion, PRPAIN201305UV02 query) { } @Override protected void createPatientCorrelation(PRPAIN201306UV02 queryResult, AssertionType assertion, PRPAIN201305UV02 query) { } }; JAXBElement<PRPAMT201301UV02Person> person = HL7PatientTransforms.create201301PatientPerson("Joe", "Smith", "M", null, null); PRPAMT201301UV02Patient patient = HL7PatientTransforms.create201301Patient(person, "1234", "1.1.1"); PRPAIN201305UV02 request = HL7PRPA201305Transforms.createPRPA201305(patient, "1.1", "2.2", "1.1.1"); AssertionType assertion = new AssertionType(); PRPAIN201306UV02 result = null; try { result = instance.process201305(request, assertion); } catch (PatientDiscoveryException e) { e.printStackTrace(); } TestHelper.assertPatientFound(result); }
@Test public void testProcess201305PatientNotFound() { System.out.println("testProcess201305PatientNotFound"); PatientDiscoveryProcessor instance = new PatientDiscovery201305Processor() { @Override protected void storeMapping(PRPAIN201305UV02 request) { } @Override protected PRPAIN201306UV02 queryMpi(PRPAIN201305UV02 query, AssertionType assertion) { return HL7PRPA201306Transforms.createPRPA201306(null, "2.2", null, "1.1", null, query); } @Override protected boolean checkPolicy(PRPAIN201306UV02 response, AssertionType assertion) { return false; } @Override protected void createPatientCorrelation(PRPAIN201306UV02 queryResult, II remotePatient, AssertionType assertion, PRPAIN201305UV02 query) { } @Override protected void createPatientCorrelation(PRPAIN201306UV02 queryResult, AssertionType assertion, PRPAIN201305UV02 query) { } }; JAXBElement<PRPAMT201301UV02Person> person = HL7PatientTransforms.create201301PatientPerson("Joe", "Smith", "M", null, null); PRPAMT201301UV02Patient patient = HL7PatientTransforms.create201301Patient(person, "1234", "1.1.1"); PRPAIN201305UV02 request = HL7PRPA201305Transforms.createPRPA201305(patient, "1.1", "2.2", "1.1.1"); AssertionType assertion = new AssertionType(); PRPAIN201306UV02 result = null; try { result = instance.process201305(request, assertion); } catch (PatientDiscoveryException e) { e.printStackTrace(); } TestHelper.assertPatientNotFound(result); }
@Test public void testProcess201305PolicyCheckFailure() { System.out.println("testProcess201305PolicyCheckFailure"); PatientDiscoveryProcessor instance = new PatientDiscovery201305Processor() { @Override protected void storeMapping(PRPAIN201305UV02 request) { } @Override protected PRPAIN201306UV02 queryMpi(PRPAIN201305UV02 query, AssertionType assertion) { return null; } @Override protected boolean checkPolicy(PRPAIN201306UV02 response, AssertionType assertion) { return true; } @Override protected void createPatientCorrelation(PRPAIN201306UV02 queryResult, II remotePatient, AssertionType assertion, PRPAIN201305UV02 query) { } @Override protected void createPatientCorrelation(PRPAIN201306UV02 queryResult, AssertionType assertion, PRPAIN201305UV02 query) { } }; JAXBElement<PRPAMT201301UV02Person> person = HL7PatientTransforms.create201301PatientPerson("Joe", "Smith", "M", null, null); PRPAMT201301UV02Patient patient = HL7PatientTransforms.create201301Patient(person, "1234", "1.1.1"); PRPAIN201305UV02 request = HL7PRPA201305Transforms.createPRPA201305(patient, "1.1", "2.2", "1.1.1"); AssertionType assertion = new AssertionType(); PRPAIN201306UV02 result = null; try { result = instance.process201305(request, assertion); } catch (PatientDiscoveryException e) { e.printStackTrace(); } TestHelper.assertPatientNotFound(result); }