@Test public void testGetConflictConsent_no_overlap() { ConsentDto consentDtoMock = mock(ConsentDto.class); consentDtoMock.setId("2"); String userNameMock = "usernamemock"; when(consentDtoMock.getUsername()).thenReturn(userNameMock); List<Consent> consentList = new ArrayList<Consent>(); Consent consent = new Consent(); consent.setId(new Long(1)); consent.setStartDate(new Date()); consent.setEndDate(new Date()); consentList.add(consent); when(consentRepositoryMock.findAllByPatientUsername(userNameMock)) .thenReturn(consentList); when( consentHelperMock.isConsentTermOverlap(consentDtoMock, consent.getStartDate(), consent.getEndDate())) .thenReturn(false); ConsentValidationDto consentValidationDto = cst .getConflictConsent(consentDtoMock); assertNull(consentValidationDto); }
@Override public ConsentValidationDto getConflictConsent(ConsentDto consentDto) { ConsentValidationDto consentValidationDto = null; List<Consent> consents; if (consentDto.getUsername() != null && !consentDto.getUsername().isEmpty()) { consents = consentRepository.findAllByPatientUsername(consentDto .getUsername()); } else { consents = consentRepository.findByPatient(patientRepository .findOne(consentDto.getPatientId())); } boolean isConflict = false; for (Consent consent : consents) { if (consent.getId().toString().equalsIgnoreCase(consentDto.getId())) continue; boolean isOverlap = false; boolean isPOUMatch = false; boolean isProviderMatch = false; boolean isConsentRevoked = false; isOverlap = consentHelper.isConsentTermOverlap(consentDto, consent.getStartDate(), consent.getEndDate()); if (isOverlap) { isPOUMatch = consentHelper.isPOUMatches( consentDto.getShareForPurposeOfUseCodes(), consent.getShareForPurposeOfUseCodes()); if (isPOUMatch) { isProviderMatch = consentHelper.isProviderComboMatch( consent, consentDto); if (isProviderMatch) { isConsentRevoked = consentHelper .isConsentRevoked(consent); if (!isConsentRevoked) { isConflict = true; consentValidationDto = consentHelper .convertConsentToConsentListDto(consent, consentDto); break; } } else { continue; } } else { continue; } } else { continue; } } logger.debug("is conflict found: " + isConflict); return consentValidationDto; }
ConsentCheckServiceImpl implements ConsentCheckService { @Override public ConsentValidationDto getConflictConsent(ConsentDto consentDto) { ConsentValidationDto consentValidationDto = null; List<Consent> consents; if (consentDto.getUsername() != null && !consentDto.getUsername().isEmpty()) { consents = consentRepository.findAllByPatientUsername(consentDto .getUsername()); } else { consents = consentRepository.findByPatient(patientRepository .findOne(consentDto.getPatientId())); } boolean isConflict = false; for (Consent consent : consents) { if (consent.getId().toString().equalsIgnoreCase(consentDto.getId())) continue; boolean isOverlap = false; boolean isPOUMatch = false; boolean isProviderMatch = false; boolean isConsentRevoked = false; isOverlap = consentHelper.isConsentTermOverlap(consentDto, consent.getStartDate(), consent.getEndDate()); if (isOverlap) { isPOUMatch = consentHelper.isPOUMatches( consentDto.getShareForPurposeOfUseCodes(), consent.getShareForPurposeOfUseCodes()); if (isPOUMatch) { isProviderMatch = consentHelper.isProviderComboMatch( consent, consentDto); if (isProviderMatch) { isConsentRevoked = consentHelper .isConsentRevoked(consent); if (!isConsentRevoked) { isConflict = true; consentValidationDto = consentHelper .convertConsentToConsentListDto(consent, consentDto); break; } } else { continue; } } else { continue; } } else { continue; } } logger.debug("is conflict found: " + isConflict); return consentValidationDto; } }
ConsentCheckServiceImpl implements ConsentCheckService { @Override public ConsentValidationDto getConflictConsent(ConsentDto consentDto) { ConsentValidationDto consentValidationDto = null; List<Consent> consents; if (consentDto.getUsername() != null && !consentDto.getUsername().isEmpty()) { consents = consentRepository.findAllByPatientUsername(consentDto .getUsername()); } else { consents = consentRepository.findByPatient(patientRepository .findOne(consentDto.getPatientId())); } boolean isConflict = false; for (Consent consent : consents) { if (consent.getId().toString().equalsIgnoreCase(consentDto.getId())) continue; boolean isOverlap = false; boolean isPOUMatch = false; boolean isProviderMatch = false; boolean isConsentRevoked = false; isOverlap = consentHelper.isConsentTermOverlap(consentDto, consent.getStartDate(), consent.getEndDate()); if (isOverlap) { isPOUMatch = consentHelper.isPOUMatches( consentDto.getShareForPurposeOfUseCodes(), consent.getShareForPurposeOfUseCodes()); if (isPOUMatch) { isProviderMatch = consentHelper.isProviderComboMatch( consent, consentDto); if (isProviderMatch) { isConsentRevoked = consentHelper .isConsentRevoked(consent); if (!isConsentRevoked) { isConflict = true; consentValidationDto = consentHelper .convertConsentToConsentListDto(consent, consentDto); break; } } else { continue; } } else { continue; } } else { continue; } } logger.debug("is conflict found: " + isConflict); return consentValidationDto; } ConsentCheckServiceImpl(ConsentRepository consentRepository,
			PatientRepository patientRepository, ConsentHelper consentHelper); }
ConsentCheckServiceImpl implements ConsentCheckService { @Override public ConsentValidationDto getConflictConsent(ConsentDto consentDto) { ConsentValidationDto consentValidationDto = null; List<Consent> consents; if (consentDto.getUsername() != null && !consentDto.getUsername().isEmpty()) { consents = consentRepository.findAllByPatientUsername(consentDto .getUsername()); } else { consents = consentRepository.findByPatient(patientRepository .findOne(consentDto.getPatientId())); } boolean isConflict = false; for (Consent consent : consents) { if (consent.getId().toString().equalsIgnoreCase(consentDto.getId())) continue; boolean isOverlap = false; boolean isPOUMatch = false; boolean isProviderMatch = false; boolean isConsentRevoked = false; isOverlap = consentHelper.isConsentTermOverlap(consentDto, consent.getStartDate(), consent.getEndDate()); if (isOverlap) { isPOUMatch = consentHelper.isPOUMatches( consentDto.getShareForPurposeOfUseCodes(), consent.getShareForPurposeOfUseCodes()); if (isPOUMatch) { isProviderMatch = consentHelper.isProviderComboMatch( consent, consentDto); if (isProviderMatch) { isConsentRevoked = consentHelper .isConsentRevoked(consent); if (!isConsentRevoked) { isConflict = true; consentValidationDto = consentHelper .convertConsentToConsentListDto(consent, consentDto); break; } } else { continue; } } else { continue; } } else { continue; } } logger.debug("is conflict found: " + isConflict); return consentValidationDto; } ConsentCheckServiceImpl(ConsentRepository consentRepository,
			PatientRepository patientRepository, ConsentHelper consentHelper); @Override ConsentValidationDto getConflictConsent(ConsentDto consentDto); }
ConsentCheckServiceImpl implements ConsentCheckService { @Override public ConsentValidationDto getConflictConsent(ConsentDto consentDto) { ConsentValidationDto consentValidationDto = null; List<Consent> consents; if (consentDto.getUsername() != null && !consentDto.getUsername().isEmpty()) { consents = consentRepository.findAllByPatientUsername(consentDto .getUsername()); } else { consents = consentRepository.findByPatient(patientRepository .findOne(consentDto.getPatientId())); } boolean isConflict = false; for (Consent consent : consents) { if (consent.getId().toString().equalsIgnoreCase(consentDto.getId())) continue; boolean isOverlap = false; boolean isPOUMatch = false; boolean isProviderMatch = false; boolean isConsentRevoked = false; isOverlap = consentHelper.isConsentTermOverlap(consentDto, consent.getStartDate(), consent.getEndDate()); if (isOverlap) { isPOUMatch = consentHelper.isPOUMatches( consentDto.getShareForPurposeOfUseCodes(), consent.getShareForPurposeOfUseCodes()); if (isPOUMatch) { isProviderMatch = consentHelper.isProviderComboMatch( consent, consentDto); if (isProviderMatch) { isConsentRevoked = consentHelper .isConsentRevoked(consent); if (!isConsentRevoked) { isConflict = true; consentValidationDto = consentHelper .convertConsentToConsentListDto(consent, consentDto); break; } } else { continue; } } else { continue; } } else { continue; } } logger.debug("is conflict found: " + isConflict); return consentValidationDto; } ConsentCheckServiceImpl(ConsentRepository consentRepository,
			PatientRepository patientRepository, ConsentHelper consentHelper); @Override ConsentValidationDto getConflictConsent(ConsentDto consentDto);  }