private Set<Consent> getConsentsForPatient(Patient patient, boolean includeGranted) { if (patient == null) { return null; } // List of consent ids a patient has agreed to, read from the database Set<String> xwikiPatientConsents = readConsentIdsFromPatientDoc(patient); Set<Consent> returnedConsents = new LinkedHashSet<>(); // Using system consents to ignore consents set for the patient but no longer configured in the system // (it is faster to check contains() in a set, so iterating through the list and checking the set) Set<Consent> systemConsents = getSystemConsents(); for (Consent systemConsent : systemConsents) { if (xwikiPatientConsents.contains(systemConsent.getId())) { if (includeGranted) { Consent copy = systemConsent.copy(ConsentStatus.YES); returnedConsents.add(copy); } } else { Consent copy = systemConsent.copy(ConsentStatus.NO); returnedConsents.add(copy); } } return returnedConsents; }
private Set<Consent> getConsentsForPatient(Patient patient, boolean includeGranted) { if (patient == null) { return null; } // List of consent ids a patient has agreed to, read from the database Set<String> xwikiPatientConsents = readConsentIdsFromPatientDoc(patient); Set<Consent> returnedConsents = new LinkedHashSet<>(); // Using system consents to ignore consents set for the patient but no longer configured in the system // (it is faster to check contains() in a set, so iterating through the list and checking the set) Set<Consent> systemConsents = getSystemConsents(); for (Consent systemConsent : systemConsents) { if (xwikiPatientConsents.contains(systemConsent.getId())) { if (includeGranted) { Consent copy = systemConsent.copy(ConsentStatus.YES); returnedConsents.add(copy); } } else { Consent copy = systemConsent.copy(ConsentStatus.NO); returnedConsents.add(copy); } } return returnedConsents; }