PatientCorrelationOrchImpl implements PatientCorrelationOrch { @Override public RetrievePatientCorrelationsResponseType retrievePatientCorrelations( PRPAIN201309UV02 retrievePatientCorrelationsRequest, AssertionType assertion) { PRPAMT201307UV02PatientIdentifier patIdentifier = PRPAIN201309UVParser .parseHL7PatientPersonFrom201309Message(retrievePatientCorrelationsRequest); if (patIdentifier == null) { return null; } List<II> listII = patIdentifier.getValue(); if (listII.isEmpty()) { LOG.warn("patient identifier was null"); return null; } II inputPatientId = listII.get(0); List<String> dataSourceList = extractDataSourceList(retrievePatientCorrelationsRequest); QualifiedPatientIdentifier inputQualifiedPatientIdentifier = qualifiedPatientIdentifierFactory(inputPatientId); List<QualifiedPatientIdentifier> qualifiedPatientIdentifiers = retrieveQualifiedPatientIdentifiers( inputQualifiedPatientIdentifier, dataSourceList); List<II> iiList = buildList(qualifiedPatientIdentifiers); PRPAIN201310UV02 IN201310 = PixRetrieveResponseBuilder .createPixRetrieveResponse(retrievePatientCorrelationsRequest, iiList); RetrievePatientCorrelationsResponseType result = new RetrievePatientCorrelationsResponseType(); result.setPRPAIN201310UV02(IN201310); return result; } PatientCorrelationOrchImpl(CorrelatedIdentifiersDao dao); @Override RetrievePatientCorrelationsResponseType retrievePatientCorrelations(
        PRPAIN201309UV02 retrievePatientCorrelationsRequest, AssertionType assertion); @Override AddPatientCorrelationResponseType addPatientCorrelation(PRPAIN201301UV02 addPatientCorrelationRequest,
        AssertionType assertion); static Date calculateCorrelationExpirationDate(String assigningAuthority); static Date calculateCorrelationExpirationDate(Expiration config); @Override void addPatientCorrelationPLQ(PatientLocationQueryResponseType plqRecords,
        AssertionType assertion);  }
@Test public void testRetrievePatientCorrelations() { RetrievePatientCorrelationsResponseType result = new RetrievePatientCorrelationsResponseType(); PatientCorrelationOrchImpl orchImpl = new PatientCorrelationOrchImpl(dao) { @Override protected List<QualifiedPatientIdentifier> retrieveQualifiedPatientIdentifiers(QualifiedPatientIdentifier inputQualifiedPatientIdentifier, List<String> dataSourceList) { List<QualifiedPatientIdentifier> qualifiedPatientIdentifiers = new ArrayList<>(); QualifiedPatientIdentifier patIdentifier = new QualifiedPatientIdentifier(); patIdentifier.setAssigningAuthority("2.2"); patIdentifier.setPatientId("D123401"); qualifiedPatientIdentifiers.add(patIdentifier); return qualifiedPatientIdentifiers; } }; try { result = orchImpl.retrievePatientCorrelations(createMessage(), createAssertion()); } catch (Exception e) { e.printStackTrace(); } assertEquals(result.getPRPAIN201310UV02().getControlActProcess().getSubject().get(0).getRegistrationEvent() .getSubject1().getPatient().getId().get(0).getRoot(),"2.2"); assertEquals(result.getPRPAIN201310UV02().getControlActProcess().getSubject().get(0).getRegistrationEvent() .getSubject1().getPatient().getId().get(0).getExtension(),"D123401"); }
@Test public void testRetrievePatientCorrelationsWhenPatIdentifierNull(){ PatientCorrelationOrchImpl orchImpl = new PatientCorrelationOrchImpl(dao); assertNull(orchImpl.retrievePatientCorrelations(createMessagePatIdentifierNull(), createAssertion())); }
@Test public void testRetrievePatientCorrelationsWhenDataSourceNull(){ RetrievePatientCorrelationsResponseType result = new RetrievePatientCorrelationsResponseType(); PatientCorrelationOrchImpl orchImpl = new PatientCorrelationOrchImpl(dao) { @Override protected List<QualifiedPatientIdentifier> retrieveQualifiedPatientIdentifiers(QualifiedPatientIdentifier inputQualifiedPatientIdentifier, List<String> dataSourceList) { List<QualifiedPatientIdentifier> qualifiedPatientIdentifiers = new ArrayList<>(); QualifiedPatientIdentifier patIdentifier = new QualifiedPatientIdentifier(); patIdentifier.setAssigningAuthority("2.2"); patIdentifier.setPatientId("D123401"); qualifiedPatientIdentifiers.add(patIdentifier); return qualifiedPatientIdentifiers; } }; try { result = orchImpl.retrievePatientCorrelations(createMessageForRetrieveWhenDataSourceNull(), createAssertion()); } catch (Exception e) { e.printStackTrace(); } assertTrue(result.getPRPAIN201310UV02().getControlActProcess().getQueryByParameter().getValue() .getParameterList().getDataSource().isEmpty()); }
@Test public void testRetrievePatientCorrelationsWhenPatIdentifierValueNull(){ PatientCorrelationOrchImpl orchImpl = new PatientCorrelationOrchImpl(dao); assertNull(orchImpl.retrievePatientCorrelations(createMessagePatIdentifierValueNull(), createAssertion())); }