@Override public DocumentReference getReporter() { return this.patient.getReporter(); }
@Override public DocumentReference getReporter() { return this.access.isOpenAccess() ? this.match.getReporter() : null; }
/** * Simple constructor passing both {@link #match the patient} and the {@link #reference reference patient}. * * @param match the matched patient to represent, must not be {@code null} * @param reference the reference patient against which to compare, must not be {@code null} * @throws IllegalArgumentException if one of the patients is {@code null} */ public RestrictedPatientSimilarityView(Patient match, Patient reference) throws IllegalArgumentException { if (match == null || reference == null) { throw new IllegalArgumentException("Similar patients require both a match and a reference"); } this.match = match; this.reference = reference; // FIXME Implement the other access types if (this.match == null || this.reference == null || this.reference.getReporter() == null) { // Not enough information to compute the proper access type, it's safer to refuse any access this.access = AccessType.PRIVATE; } else if (ObjectUtils.equals(this.match.getReporter(), this.reference.getReporter())) { this.access = AccessType.OWNED; } else { this.access = AccessType.MATCH; } matchFeatures(); matchDisorders(); }
@Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); // FIXME URL is missing } // Otherwise, if null user -> user is no longer valid, all we know is the username, already added before the if list.add(contactInfo.build()); return list; } }
@Override public List<ContactInfo> getContacts(Patient patient) { DocumentReference reporter = patient.getReporter(); if (reporter == null) { return Collections.emptyList(); } List<ContactInfo> list = new ArrayList<>(); ContactInfo.Builder contactInfo = new ContactInfo.Builder(); contactInfo.withUserId(this.serializer.serialize(reporter)); User user = this.userManager.getUser(reporter.toString()); if (user != null) { String email = (String) user.getAttribute("email"); String institution = (String) user.getAttribute("company"); contactInfo.withName(user.getName()); contactInfo.withEmail(email); contactInfo.withInstitution(institution); // FIXME URL is missing } // Otherwise, if null user -> user is no longer valid, all we know is the username, already added before the if list.add(contactInfo.build()); return list; } }
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());
input.setField("document", this.referenceSerializer.serialize(patient.getDocumentReference())); String reporter = ""; if (patient.getReporter() != null) { reporter = patient.getReporter().toString();
@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; }