@Override public String toString() { return "Access rules for " + (this.patient != null ? this.patient.getDocument() : "<unknown patient>"); } }
private String getDescription(Patient patient) { // Add description StringBuilder description = new StringBuilder(patient.getId()); String patientName = ""; PatientData<String> patientNames = patient.getData("patientName"); if (patientNames != null) { String firstName = StringUtils.defaultString(patientNames.get(FIRST_NAME)); String lastName = StringUtils.defaultString(patientNames.get("last_name")); patientName = (firstName + " " + lastName).trim(); if (StringUtils.isNotEmpty(patientName)) { description.append(", name: ").append(patientName); } } String patientExternalId = patient.getExternalId(); if (StringUtils.isNotEmpty(patientExternalId)) { description.append(", identifier: ").append(patientExternalId); } return description.toString(); } }
@Override public String toString() { return "Access rules for " + (this.patient != null ? this.patient.getDocumentReference() : "<unknown patient>"); } }
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; } }
/** * Sets present and absent {@link VocabularyTerm} vocabulary terms from {@link #patient}. */ private void setTerms() { final Set<? extends Feature> features = this.patient.getFeatures(); final PatientData<List<VocabularyTerm>> qualifiers = this.patient.getData(GLOBAL_QUALIFIERS); final Map<String, Set<VocabularyTerm>> terms = extractTerms(features, qualifiers); this.presentTerms = terms.get(PRESENT_TERMS); this.absentTerms = terms.get(ABSENT_TERMS); }
private JSONObject getPatientInformationAsJSON(Patient patient) { JSONObject patientJSON = new JSONObject(); // handle patient names PatientData<String> patientNames = patient.getData("patientName"); String firstName = StringUtils.defaultString(patientNames.get(FIRST_NAME)); String lastName = StringUtils.defaultString(patientNames.get(LAST_NAME)); String patientNameForJSON = String.format("%s %s", firstName, lastName).trim(); // add data to json patientJSON.put(ID, patient.getId()); patientJSON.put(IDENTIFIER, patient.getExternalId()); patientJSON.put(NAME, patientNameForJSON); patientJSON.put(REPORTS, getMedicalReports(patient)); // Patient URL XWikiContext context = this.provider.get(); String url = context.getWiki().getURL(patient.getDocument(), "view", context); patientJSON.put(URL, url); // add permissions information User currentUser = this.userManager.getCurrentUser(); JSONObject permissionJSON = new JSONObject(); permissionJSON.put("hasEdit", this.authorizationService.hasAccess(currentUser, Right.EDIT, patient.getDocument())); permissionJSON.put("hasView", this.authorizationService.hasAccess(currentUser, Right.VIEW, patient.getDocument())); patientJSON.put(PERMISSIONS, permissionJSON); return patientJSON; }
private JSONObject getPatientInformationAsJSON(Patient patient) { JSONObject patientJSON = new JSONObject(); // handle patient names PatientData<String> patientNames = patient.getData("patientName"); String firstName = StringUtils.defaultString(patientNames.get(FIRST_NAME)); String lastName = StringUtils.defaultString(patientNames.get(LAST_NAME)); String patientNameForJSON = String.format("%s %s", firstName, lastName).trim(); // add data to json patientJSON.put(ID, patient.getId()); patientJSON.put(IDENTIFIER, patient.getExternalId()); patientJSON.put(NAME, patientNameForJSON); patientJSON.put(REPORTS, getMedicalReports(patient)); // Patient URL XWikiContext context = this.provider.get(); String url = context.getWiki().getURL(patient.getDocumentReference(), "view", context); patientJSON.put(URL, url); // add permissions information User currentUser = this.userManager.getCurrentUser(); JSONObject permissionJSON = new JSONObject(); permissionJSON.put("hasEdit", this.authorizationService.hasAccess(currentUser, Right.EDIT, patient.getDocumentReference())); permissionJSON.put("hasView", this.authorizationService.hasAccess(currentUser, Right.VIEW, patient.getDocumentReference())); patientJSON.put(PERMISSIONS, permissionJSON); return patientJSON; }
@Override public PatientSummary createPatientSummary(Patient patient, UriInfo uriInfo) { if (patient == null) { return null; } User currentUser = this.users.getCurrentUser(); if (!this.access.hasAccess(currentUser, Right.VIEW, patient.getDocumentReference())) { return null; } PatientSummary result = new PatientSummary(); XWikiDocument doc = patient.getXDocument(); result.withId(patient.getId()).withEid(patient.getExternalId()); result.withCreatedBy(String.valueOf(patient.getReporter())).withLastModifiedBy( String.valueOf(doc.getAuthorReference())); result.withVersion(doc.getVersion()); result.withCreatedOn(new DateTime(doc.getCreationDate()).withZone(DateTimeZone.UTC)); result.withLastModifiedOn(new DateTime(doc.getDate()).withZone(DateTimeZone.UTC)); result.withLinks(this.autolinker.get().forSecondaryResource(PatientResource.class, uriInfo) .withExtraParameters("entity-id", patient.getId()) .withExtraParameters("entity-type", "patients") .build()); return result; }
/** * Returns string as stored in the family members list. */ private String patientLinkString(Patient patient) { return patient.getId(); }
@Override public <T> PatientData<T> getData(String name) { return this.patient.getData(name); }
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 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; }
@SuppressWarnings("unchecked") private Set<String> readConsentIdsFromPatientDoc(Patient patient) { Set<String> ids = new LinkedHashSet<>(); try { XWikiDocument patientDoc = patient.getXDocument(); BaseObject idsHolder = patientDoc.getXObject(this.consentIdsHolderReference); if (idsHolder != null) { List<String> patientConsentIds = idsHolder.getListValue(GRANTED); if (patientConsentIds != null) { ids.addAll(patientConsentIds); } } } catch (Exception ex) { this.logger.error("Could not read consents for patient {}: {}", patient.getId(), ex.getMessage()); } return ids; }
result.element("id", this.match.getDocument().getName()); result.element("token", getContactToken()); result.element("owner", this.match.getReporter().getName()); result.element("myCase", ObjectUtils.equals(this.reference.getReporter(), this.match.getReporter())); result.element("score", getScore()); result.element("featuresCount", this.match.getFeatures().size());
@Override public void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy) { try { final XWikiDocument docX = patient.getXDocument(); final PatientData<Gene> genes = patient.getData(getName()); if (genes == null) { if (PatientWritePolicy.REPLACE.equals(policy)) { docX.removeXObjects(Gene.GENE_CLASS); } } else if (!genes.isIndexed()) { this.logger.info("Wrong data type for gene data"); } else { saveGenes(docX, patient, genes, policy, this.xcontextProvider.get()); } } catch (final Exception ex) { this.logger.error("Failed to save genes data: {}", ex.getMessage(), ex); } }
input.setField("document", this.referenceSerializer.serialize(patient.getDocumentReference())); String reporter = ""; if (patient.getReporter() != null) { reporter = patient.getReporter().toString(); for (Feature phenotype : patient.getFeatures()) { String presence = (phenotype.isPresent() ? "" : "negative_"); String fieldName = presence + phenotype.getType();
protected String getPatientURL(Patient patient, XWikiContext context) { try { XWikiDocument doc = patient.getXDocument(); String url = doc.getURL("view", context); return url; } catch (Exception ex) { this.logger.error("Failed to get patient URL: [{}] {}", ex.getMessage(), ex); return null; } }
return specificity.getScore(); if (patient.getFeatures().isEmpty()) { this.cache.set(key, new PatientSpecificity(0, now(), SCORER_NAME)); return 0; JSONObject data = new JSONObject(); JSONArray features = new JSONArray(); for (Feature f : patient.getFeatures()) { if (StringUtils.isNotEmpty(f.getId())) { JSONObject featureObj = new JSONObject(Collections.singletonMap("id", f.getId())); patient.getDocument(), this.scorerURL, ex.getMessage()); } finally { if (response != null) {
@Override public Set<? extends Feature> getFeatures() { return this.patient.getFeatures(); }
@Override public DocumentReference getReporter() { return this.patient.getReporter(); }