/** * Returns string as stored in the family members list. */ private String patientLinkString(Patient patient) { return patient.getId(); }
@Override public String getId() { return this.patient.getId(); }
/** * Returns string as stored in the family members list. */ private String patientLinkString(Patient patient) { return patient.getId(); }
/** * Returns true iff the internal ID is specified in {@code jsonInput} and does not correspond with the patient * internal ID, false otherwise. * * @param jsonInput the patient data being imported * @param patient the {@link Patient} object * @return true iff the internal ID is specified in {@code jsonInput} and conflicts with patient internal ID, false * otherwise */ private boolean hasInternalIdConflict(final JSONObject jsonInput, final Patient patient) { final String idFromJson = jsonInput.optString("id"); return StringUtils.isNotBlank(idFromJson) && !patient.getId().equals(idFromJson); } }
public void fireRightsUpdateEvent(Patient targetPatient) { this.manager.fireRightsUpdateEvent(targetPatient.getId()); } }
@Override public boolean isMember(Patient patient) { List<String> members = getMembersIds(); if (members == null) { return false; } String patientId = patient.getId(); return members.contains(patientId); }
/** * Creates a response upon successful creation of a {@link Patient}. * * @param patient the successfully created patient * @return the response for a successfully created patient */ private Response buildCreatedResponse(final Patient patient) { final ResponseBuilder response = Response.created(UriBuilder .fromUri(this.uriInfo.getBaseUri()) .path(PatientResource.class) .build(patient.getId())); return response.build(); }
/** * Creates a response upon successful creation of a {@link Patient}. * * @param patient the successfully created patient * @return the response for a successfully created patient */ private Response buildCreatedResponse(final Patient patient) { final ResponseBuilder response = Response.created(UriBuilder .fromUri(this.uriInfo.getBaseUri()) .path(PatientResource.class) .build(patient.getId())); return response.build(); }
@Override public Map<String, Map<String, String>> getMedicalReports() { Map<String, Map<String, String>> allFamilyLinks = new HashMap<>(); for (Patient patient : getMembers()) { allFamilyLinks.put(patient.getId(), PhenotipsFamily.familyExport.getMedicalReports(patient)); } return allFamilyLinks; }
private Patient checkAccess(Right right, Patient patient, User user) { if (patient != null && this.access.hasAccess(user, right, patient.getDocument())) { return patient; } else if (patient != null) { this.logger.warn("Illegal access requested for patient [{}] by user [{}]", patient.getId(), user); throw new SecurityException("Unauthorized access"); } return null; }
@Override public List<PatientMatch> findMatches(Patient patient) { this.logger.debug("Finding local matches for patient {}.", patient.getId()); List<PatientMatch> matches = new LinkedList<>(); List<PatientSimilarityView> similarPatients = this.finder.findSimilarPatients(patient); for (PatientSimilarityView similarityView : similarPatients) { PatientMatch match = new DefaultPatientMatch(similarityView, null, null); matches.add(match); } return matches; } }
@Override public Map<String, Map<String, String>> getMedicalReports() { Map<String, Map<String, String>> allFamilyLinks = new HashMap<>(); for (Patient patient : getMembers()) { allFamilyLinks.put(patient.getId(), PhenotipsFamily.familyExport.getMedicalReports(patient)); } return allFamilyLinks; }
private XWikiDocument getDocument(Patient patient) { try { DocumentReference document = patient.getDocument(); XWikiDocument patientDocument = getDocument(document); return patientDocument; } catch (XWikiException ex) { this.logger.error("Can't get patient document for patient [{}]: []", patient.getId(), ex); return null; } }
private JSONObject getPatientJSON(Patient patient) { JSONObject patientJSON = new JSONObject(); patientJSON.put("id", patient.getId()); patientJSON.put("identifier", patient.getExternalId()); // Add patient URL patientJSON.put("url", getURL(patient)); String description = getDescription(patient); // Add metadata Map<String, Object> metadata = this.metadataManager.getMetadata(patient); metadata.forEach((key, value) -> patientJSON.put(key, value)); // Add description patientJSON.put("textSummary", description); return patientJSON; }
protected JSONObject generateSuccessfulResponseWithPatientIDs(Patient patient, XWikiContext context) { try { String guid = getPatientGUID(patient); String url = getPatientURL(patient, context); String id = patient.getId(); JSONObject response = generateSuccessfulResponse(); response.put(ShareProtocol.SERVER_JSON_PUSH_KEY_NAME_PATIENTGUID, guid); response.put(ShareProtocol.SERVER_JSON_PUSH_KEY_NAME_PATIENTID, id); response.put(ShareProtocol.SERVER_JSON_PUSH_KEY_NAME_PATIENTURL, url); return response; } catch (Exception ex) { this.logger.error("Failed to get patient GUID/ID/URL: [{}] {}", ex.getMessage(), ex); return generateFailedActionResponse(); } }
private void initializeUser(AccessLevel minimumAccessLevel, UserManager users, Logger logger) { this.currentUser = users.getCurrentUser(); if (this.currentUser == null) { throw new WebApplicationException(Response.Status.UNAUTHORIZED); } else if (!this.patientAccess.hasAccessLevel(this.currentUser.getProfileDocument(), minimumAccessLevel)) { logger.debug("{} access denied to user [{}] on patient record [{}]", minimumAccessLevel.getName(), this.currentUser, this.patient.getId()); throw new WebApplicationException(Response.Status.FORBIDDEN); } }
private void checkIfPatientCanBeAddedToFamily(Family family, Patient patient, User updatingUser) throws PTException { // check rights if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, family.getDocumentReference())) { throw new PTNotEnoughPermissionsOnFamilyException(Right.EDIT, family.getId()); } if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocument())) { throw new PTNotEnoughPermissionsOnPatientException(Right.EDIT, patient.getId()); } // check for logical problems: patient in another family Family familyForLinkedPatient = this.getFamilyForPatient(patient); if (familyForLinkedPatient != null && !familyForLinkedPatient.getId().equals(family.getId())) { throw new PTPatientAlreadyInAnotherFamilyException(patient.getId(), familyForLinkedPatient.getId()); } }
private void checkIfPatientCanBeAddedToFamily(Family family, Patient patient, User updatingUser) throws PTException { // check rights if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, family.getDocumentReference())) { throw new PTNotEnoughPermissionsOnFamilyException(Right.EDIT, family.getId()); } if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocumentReference())) { throw new PTNotEnoughPermissionsOnPatientException(Right.EDIT, patient.getId()); } // check for logical problems: patient in another family Family familyForLinkedPatient = this.getFamilyForPatient(patient); if (familyForLinkedPatient != null && !familyForLinkedPatient.getId().equals(family.getId())) { throw new PTPatientAlreadyInAnotherFamilyException(patient.getId(), familyForLinkedPatient.getId()); } }
private void checkIfPatientCanBeRemovedFromFamily(Family family, Patient patient, User updatingUser) throws PTException { // check rights if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, family.getDocumentReference())) { throw new PTNotEnoughPermissionsOnFamilyException(Right.EDIT, family.getId()); } if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocumentReference())) { throw new PTNotEnoughPermissionsOnPatientException(Right.EDIT, patient.getId()); } }
private void checkIfPatientCanBeRemovedFromFamily(Family family, Patient patient, User updatingUser) throws PTException { // check rights if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, family.getDocumentReference())) { throw new PTNotEnoughPermissionsOnFamilyException(Right.EDIT, family.getId()); } if (!this.authorizationService.hasAccess(updatingUser, Right.EDIT, patient.getDocument())) { throw new PTNotEnoughPermissionsOnPatientException(Right.EDIT, patient.getId()); } }