/** * Retrieve a {@link Patient patient} by it's clinical identifier. Only works if external identifiers are enabled * and used. * * @param name the patient's clinical identifier, as set by the patient's reporter * @return the patient data, or {@code null} if the requested patient does not exist, is not a valid patient, or is * not accessible by the current user */ public Patient getByName(String name) { try { return this.internalService.getByName(name); } catch (SecurityException ex) { return null; } }
/** * Retrieve a {@link Patient patient} by it's clinical identifier. Only works if external identifiers are enabled * and used. * * @param externalId the patient's clinical identifier, as set by the patient's reporter * @return the patient data, or {@code null} if the requested patient does not exist, is not a valid patient, or is * not accessible by the current user */ public Patient getPatientByExternalId(String externalId) { try { return this.internalService.getByName(externalId); } catch (SecurityException ex) { return null; } }
@Override public Patient getByName(String name) { Patient patient = this.internalService.getByName(name); return checkAccess(patient, this.userManager.getCurrentUser()); }
@Override public Patient getByName(String name) { Patient patient = this.internalService.getByName(name); return checkAccess(patient, this.userManager.getCurrentUser()); }
@Override public Response deletePatient(String eid) { this.slf4Jlogger.debug("Deleting patient record with external ID [{}] via REST", eid); Patient patient = this.repository.getByName(eid); if (patient == null) { return checkForMultipleRecords(patient, eid); } User currentUser = this.users.getCurrentUser(); if (!this.access.hasAccess(currentUser, Right.DELETE, patient.getDocumentReference())) { this.slf4Jlogger.debug("Delete access denied to user [{}] on patient record [{}]", currentUser, patient.getId()); return Response.status(Status.FORBIDDEN).build(); } try { this.repository.delete(patient); } catch (Exception ex) { this.slf4Jlogger.warn("Failed to delete patient record with external id [{}]: {}", eid, ex.getMessage()); throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } this.slf4Jlogger.debug("Deleted patient record with external id [{}]", eid); return Response.noContent().build(); }
Patient patient = this.repository.getByName(eid); if (patient == null) { return checkRecords(eid, json);
@Override public Response getPatient(String eid) { this.slf4Jlogger.debug("Retrieving patient record with external ID [{}] via REST", eid); Patient patient = this.repository.getByName(eid); if (patient == null) { return checkForMultipleRecords(patient, eid); } User currentUser = this.users.getCurrentUser(); Right grantedRight; if (!this.access.hasAccess(currentUser, Right.VIEW, patient.getDocumentReference())) { this.slf4Jlogger.debug("View access denied to user [{}] on patient record [{}]", currentUser, patient.getId()); return Response.status(Status.FORBIDDEN).build(); } else { grantedRight = Right.VIEW; } if (this.access.hasAccess(currentUser, Right.EDIT, patient.getDocumentReference())) { grantedRight = Right.EDIT; } JSONObject json = patient.toJSON(); json.put("links", this.autolinker.get().forResource(PatientResource.class, this.uriInfo) .withExtraParameters("entity-id", patient.getId()) .withExtraParameters("entity-type", "patients") .withGrantedRight(grantedRight) .build()); return Response.ok(json, MediaType.APPLICATION_JSON_TYPE).build(); }