/** * Creates an empty family. * * @return Family object corresponding to the newly created family. */ public Family createFamily() { return this.familyTools.createFamily(); }
/** * Checks if the current user can delete the family (or the family and all the members). * * @param familyId of the family to delete * @param deleteAllMembers indicator whether to check delete permissions on all family member documents as well * @return true if successful */ public boolean canDeleteFamily(String familyId, boolean deleteAllMembers) { return this.familyTools.currentUserCanDeleteFamily(familyId, deleteAllMembers); } }
/** * Delete family, modifying the both the family and patient records to reflect the change. * * @param familyId of the family to delete * @param deleteAllMembers indicator whether to delete all family member documents as well * @return true if successful; false if deletion failed or curent user has not enough rights */ public boolean deleteFamily(String familyId, boolean deleteAllMembers) { return this.familyTools.deleteFamily(familyId, deleteAllMembers); }
Family family = this.familyTools.getFamilyById(documentId); if (family != null) { this.familyTools.forceRemoveAllMembers(family); } else { return; family = this.familyTools.getFamilyForPatient(documentId); if (family == null) { return; this.familyTools.removeMember(documentId);
if (!this.familyTools.familyExists(familyId)) { return new InvalidFamilyIdResponse(); if (!this.familyTools.currentUserHasAccessRight(familyId, Right.EDIT)) { return new NotEnoughPermissionsOnFamilyResponse(); Family family = this.familyTools.getFamilyById(familyId); this.familyTools.setPedigree(family, pedigree);
@Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.getFamilyById(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); } }
/** * Checks if a patient can be linked to a family. The id of the patient to link is patientItLinkId. The family is * given by documentId: If document is a family id, it is read directly by its id. If it's a patient id, the family * is the one associated with the patient. * * @param familyId a valid family id * @param patientToLinkId id of a patient to link to family * @return JSONObject see {@link JSONResponse} */ public JSONResponse canPatientBeLinked(String familyId, String patientToLinkId) { try { if (!this.familyTools.familyExists(familyId)) { return new InvalidFamilyIdResponse(); } Family family = this.familyTools.getFamilyById(familyId); Patient patient = this.patientRepository.get(patientToLinkId); // an exception will be thrown in case of any errors this.familyTools.canAddToFamily(family, patient, true); return new ValidLinkJSONResponse(); } catch (Exception ex) { return this.convertExceptionIntoJSONResponse(ex); } }
family = this.familyTools.getFamilyForPatient(documentId); if (family == null) { return new PatientHasNoFamilyResponse(); family = this.familyTools.getFamilyById(documentId); if (family == null) { return new InvalidFamilyIdResponse();
/** * Returns family object, or null if doesn't exist or current user has no rights. * * @param familyId a PhenotTips family ID * @return Family object of the family with the given id, or null if familyId is not valid or current user does not * have permissions to view the family. */ public Family getFamilyById(String familyId) { return this.familyTools.getFamilyById(familyId); }
/** * Returns a family ID the patient belongs to. * * @param patientId id of the patient * @return Id of the, or null if patient does not belong to the family or current user has no view rights for the * patient. */ public Family getFamilyForPatient(String patientId) { return this.familyTools.getFamilyForPatient(patientId); }
/** * Adds a patient to the family, modifying both the family and patient records to reflect the change. * * @param patientId of the patient to add * @param familyId of the family to add patient to * @return true if patient was added. false if not, for example, if the patient is already in another family, * or if current user has no edit rights */ public boolean addMember(String patientId, String familyId) { return this.familyTools.addMember(patientId, familyId); }
@Override public boolean currentUserHasAccessRight(String familyId, Right right) { return this.familyTools.currentUserHasAccessRight(familyId, right); }
@Override public boolean forceRemoveAllMembers(Family family) { return this.familyTools.forceRemoveAllMembers(family); }
@Override public boolean familyExists(String familyId) { return this.familyTools.familyExists(familyId); }
@Override public boolean canAddToFamily(Family family, Patient patient, boolean throwException) throws PTException { return this.familyTools.canAddToFamily(family, patient, throwException); }
Family family = this.familyTools.getFamilyById(documentId); if (family != null) { this.familyTools.forceRemoveAllMembers(family); } else { return; family = this.familyTools.getFamilyForPatient(documentId); if (family == null) { return; this.familyTools.removeMember(documentId);
if (!this.familyTools.familyExists(familyId)) { return new InvalidFamilyIdResponse(); if (!this.familyTools.currentUserHasAccessRight(familyId, Right.EDIT)) { return new NotEnoughPermissionsOnFamilyResponse(); Family family = this.familyTools.getFamilyById(familyId); this.familyTools.setPedigree(family, pedigree);
@Override public Response deleteFamily(String id, Boolean deleteMembers) { this.logger.warn("Deleting family record [{}] via REST, deleteAllMembers = [{}]", id, deleteMembers); Family family = this.repository.get(id); if (family == null) { this.logger.warn(NO_SUCH_FAMILY_ERROR_MESSAGE, id); return Response.status(Status.NOT_FOUND).build(); } if (!this.familyTools.currentUserCanDeleteFamily(id, deleteMembers)) { this.logger.error("Delete access denied to user [{}] for family record [{}] with deleteMemebers=[{}]", this.users.getCurrentUser(), id, deleteMembers); return Response.status(Status.FORBIDDEN).build(); } if (!this.familyTools.deleteFamily(id, deleteMembers)) { return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } this.logger.warn("Deleted family record [{}]", id); return Response.noContent().build(); } }
/** * Checks if a patient can be linked to a family. The id of the patient to link is patientItLinkId. The family is * given by documentId: If document is a family id, it is read directly by its id. If it's a patient id, the family * is the one associated with the patient. * * @param familyId a valid family id * @param patientToLinkId id of a patient to link to family * @return JSONObject see {@link JSONResponse} */ public JSONResponse canPatientBeLinked(String familyId, String patientToLinkId) { try { if (!this.familyTools.familyExists(familyId)) { return new InvalidFamilyIdResponse(); } Family family = this.familyTools.getFamilyById(familyId); Patient patient = this.patientRepository.get(patientToLinkId); // an exception will be thrown in case of any errors this.familyTools.canAddToFamily(family, patient, true); return new ValidLinkJSONResponse(); } catch (Exception ex) { return this.convertExceptionIntoJSONResponse(ex); } }
family = this.familyTools.getFamilyForPatient(documentId); if (family == null) { return new PatientHasNoFamilyResponse(); family = this.familyTools.getFamilyById(documentId); if (family == null) { return new InvalidFamilyIdResponse();