/** * Checks if a specific consent is given for the patient record. If consentId is not configured * in the system returns {@code false} regardless of patient consent status. * * @param patientId record in which to test consent * @param consentId of consent which is to be checked * @return {@code true} if the consent was granted for the patient, otherwise {@code false} */ public boolean hasConsent(String patientId, String consentId) { return this.consentManager.hasConsent(patientId, consentId); }
private List<PatientSimilarityView> filterMatches(List<PatientSimilarityView> matches) { // check consent level for each of the patient: exclude patients without explicit MME consent // // TODO: use CollectionUtils.filter once a) updated Apache Commons that support parametrized types are used // and b) a workaround for anonymous classes only being able to use final local variables is testd List<PatientSimilarityView> filteredMatches = new LinkedList<PatientSimilarityView>(); for (PatientSimilarityView match : matches) { if (consentManager.hasConsent(match.getId(), "matching")) { // For now, only include results where the genotype score is high enough to indicate a candidate // gene matched (exome data gives max score of 0.5, and candidate genes have score of 1.0) // // FIXME: once PatientSimilarityView exposes candidate genes, use that to check if candidate genes // matched instead of this indirect test based on the score if (match.getGenotypeScore() >= 1.0) { filteredMatches.add(match); } } else { logger.error("Patient [{}] is excluded form match results because match consent is unchecked", match.getId()); } } return filteredMatches; } }
@Override public List<PatientMatch> findMatches(Patient patient) { // Checking if a patient has a consent for remote matching if (!this.consentManager.hasConsent(patient, REMOTE_MATCHING_CONSENT_ID)) { this.logger.debug("Skipping patient {}. No consent for remote matching", patient.getId()); } this.logger.debug("Finding remote matches for patient {}.", patient.getId()); List<PatientMatch> patientMatches = new LinkedList<>(); List<String> remoteIds = this.getRemotesList(); for (String remoteId : remoteIds) { List<PatientMatch> currentMatches = this.sendAndProcessRequest(patient.getId(), remoteId); patientMatches.addAll(currentMatches); } return patientMatches; }