@Override public String getExternalId() { return this.patient.getExternalId(); }
@Override public String getExternalId() { return isLocal() ? this.patient.getExternalId() : ""; }
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; }
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(); } }
private void addPatientDescription(Patient patient, boolean usePatientName) { StringBuilder descriptionSb = new StringBuilder(this.getDescription()); descriptionSb.append(" ["); descriptionSb.append("Patient ").append(patient.getId()); String patientExternalId = patient.getExternalId(); if (StringUtils.isNotEmpty(patientExternalId)) { descriptionSb.append(", identifier: ").append(patientExternalId); } if (usePatientName) { String patientName = ""; if (usePatientName) { PatientData<String> patientNames = patient.getData("patientName"); String firstName = StringUtils.defaultString(patientNames.get("first_name")); String lastName = StringUtils.defaultString(patientNames.get("last_name")); patientName = (firstName + " " + lastName).trim(); } if (StringUtils.isNotEmpty(patientName)) { descriptionSb.append(", name: ").append(patientName); } } descriptionSb.append("]"); this.description = descriptionSb.toString(); }
private void addPatientDescription(Patient patient, boolean usePatientName) { StringBuilder descriptionSb = new StringBuilder(this.getDescription()); descriptionSb.append(" ["); descriptionSb.append("Patient ").append(patient.getId()); String patientExternalId = patient.getExternalId(); if (StringUtils.isNotEmpty(patientExternalId)) { descriptionSb.append(", identifier: ").append(patientExternalId); } if (usePatientName) { String patientName = ""; if (usePatientName) { PatientData<String> patientNames = patient.getData("patientName"); String firstName = StringUtils.defaultString(patientNames.get("first_name")); String lastName = StringUtils.defaultString(patientNames.get("last_name")); patientName = (firstName + " " + lastName).trim(); } if (StringUtils.isNotEmpty(patientName)) { descriptionSb.append(", name: ").append(patientName); } } descriptionSb.append("]"); this.description = descriptionSb.toString(); }
public DataSection idBody(Patient patient) throws Exception { String sectionName = "id"; Set<String> present = this.enabledHeaderIdsBySection.get(sectionName); if (present == null || present.isEmpty()) { return null; } DataSection section = new DataSection(); int x = 0; if (present.contains("id")) { DataCell cell = new DataCell(patient.getId(), x, 0); section.addCell(cell); x++; } if (present.contains("external_id")) { DataCell cell = new DataCell(patient.getExternalId(), x, 0); section.addCell(cell); } // section.finalizeToMatrix(); return section; }
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; }
public DataSection idBody(Patient patient) throws Exception { String sectionName = "id"; Set<String> present = this.enabledHeaderIdsBySection.get(sectionName); if (present == null || present.isEmpty()) { return null; } DataSection section = new DataSection(); int x = 0; if (present.contains("id")) { DataCell cell = new DataCell(patient.getId(), x, 0); section.addCell(cell); x++; } if (present.contains("external_id")) { DataCell cell = new DataCell(patient.getExternalId(), x, 0); section.addCell(cell); } // section.finalizeToMatrix(); return section; }
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; }
@Override public void onEvent(Event event, Object source, Object data) { Patient patient = ((PatientEvent) event).getPatient(); if (StringUtils.isBlank(patient.getExternalId())) { return; } String eventType = "update"; if (event instanceof PatientDeletedEvent) { eventType = "delete"; } else if (((XWikiDocument) source).getOriginalDocument().isNew()) { eventType = "create"; } XWikiContext context = (XWikiContext) this.execution.getContext().getProperty("xwikicontext"); JSONObject payload = getPayload(eventType, patient.getExternalId(), context); List<BaseObject> servers = getRegisteredServers(context); if (servers != null && !servers.isEmpty()) { for (BaseObject serverConfiguration : servers) { notifyServer(payload, serverConfiguration, context); } } }
@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; }