/** * Returns the list of all consents configured in the system, with "granted"/"not granted" status for the given * patient for each consent. * * @param patientId record on which consents are granted (or not granted) * @return All the consents configured in the system with granted (for the patient) status set for each. Returns * null if patientId is not a valid id. */ public JSONArray getAllConsentsForPatient(String patientId) { try { return this.consentManager.toJSON(this.consentManager.getAllConsentsForPatient(patientId)); } catch (Exception ex) { return null; } } }
/** * Returns the list of all consents configured in the system, with "granted"/"not granted" status for the given * patient for each consent. * * @param patientId record on which consents are granted (or not granted) * @return All the consents configured in the system with granted (for the patient) status set for each. Returns * null if patientId is not a valid id. */ public JSONArray getAllConsentsForPatient(String patientId) { try { return this.consentManager.toJSON(this.consentManager.getAllConsentsForPatient(patientId)); } catch (Exception ex) { return null; } } }
@Override public Response getConsents(String patientId) { this.logger.debug("Retrieving consents from patient record [{}] via REST", patientId); Security security = this.securityCheck(patientId, Right.VIEW); if (security.isAllowed()) { Set<Consent> consents = this.consentManager.getAllConsentsForPatient(security.getPatient()); JSONArray json = this.consentManager.toJSON(consents); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); } else { return security.getFailResponse(); } }