@Override public String getName() { return this.access.isOpenAccess() && this.match != null ? this.match.getName() : null; }
/** creates & returns a new JSON array of all patient clinical diseases (as JSON objects). */ private JSONArray diseasesToJSON(PatientData<Disorder> data) { JSONArray diseasesJSON = new JSONArray(); if (data != null) { for (Disorder disease : data) { diseasesJSON.put(disease.toJSON()); } } return diseasesJSON; }
@Override public JSONObject toJSON() { if (this.match == null && this.reference == null || !this.access.isOpenAccess()) { return new JSONObject(true); } JSONObject result = new JSONObject(); if (this.match != null) { result.element("id", this.match.getId()); result.element("name", this.match.getName()); } if (this.reference != null) { result.element("queryId", this.reference.getId()); } double score = getScore(); if (!Double.isNaN(score)) { result.element("score", score); } return result; }
@Override public void save(Patient patient, DocumentModelBridge doc) { if (doc == null) { throw new NullPointerException(ERROR_MESSAGE_NO_PATIENT_CLASS); } PatientData<Disorder> disorders = patient.getData(this.getName()); if (disorders == null || !disorders.isIndexed()) { return; } XWikiDocument docX = (XWikiDocument) doc; BaseObject data = docX.getXObject(Patient.CLASS_REFERENCE); // new disorders list (for setting values in the Wiki document) List<String> disorderValues = new LinkedList<>(); Iterator<Disorder> iterator = disorders.iterator(); while (iterator.hasNext()) { Disorder disorder = iterator.next(); disorderValues.add(disorder.getValue()); } // update the values in the document (overwriting the old list, if any) data.set(DIAGNOSIS_PROPERTY, disorderValues, this.xcontextProvider.get()); }
public DataSection disordersBody(Patient patient) { String sectionName = "disorders"; Set<String> present = this.enabledHeaderIdsBySection.get(sectionName); if (present == null || present.isEmpty()) { return null; } DataSection bodySection = new DataSection(); Set<? extends Disorder> disorders = patient.getDisorders(); Integer y = 0; for (Disorder disorder : disorders) { bodySection.addCell(new DataCell(disorder.getName(), 0, y)); bodySection.addCell(new DataCell(disorder.getId(), 1, y)); y++; } /* If there is no data, but there are headers present, create empty cells */ if (disorders.isEmpty()) { bodySection.addCell(new DataCell("", 0, y)); bodySection.addCell(new DataCell("", 1, y)); } return bodySection; }
@Override public void save(Patient patient, DocumentModelBridge doc) { PatientData<Disorder> disorders = patient.getData(this.getName()); if (disorders == null || !disorders.isIndexed()) { return; } if (doc == null) { throw new NullPointerException(ERROR_MESSAGE_NO_PATIENT_CLASS); } XWikiDocument docX = (XWikiDocument) doc; BaseObject data = docX.getXObject(Patient.CLASS_REFERENCE); XWikiContext context = this.xcontextProvider.get(); // new disorders list (for setting values in the Wiki document) List<String> disorderValues = new LinkedList<>(); Iterator<Disorder> iterator = disorders.iterator(); while (iterator.hasNext()) { Disorder disorder = iterator.next(); disorderValues.add(disorder.getValue()); } data.set(DISORDER_PROPERTIES_OMIMID, null, context); // update the values in the document (overwriting the old list, if any) data.set(DISORDER_PROPERTIES_OMIMID, disorderValues, context); } }
/** * Searches for a similar disorder in the reference patient, matching one of the matched patient's disorders, or * vice-versa. * * @param toMatch the disorder to match * @param lookIn the list of disorders to look in, either the reference patient or the matched patient diseases * @return one of the disorders from the list, if it matches the target disorder, or {@code null} otherwise */ private Disorder findMatchingDisorder(Disorder toMatch, Set<? extends Disorder> lookIn) { for (Disorder candidate : lookIn) { if (StringUtils.equals(candidate.getId(), toMatch.getId())) { return candidate; } } return null; }
/** creates & returns a new JSON array of all patient clinical diseases (as JSON objects). */ private JSONArray diseasesToJSON(PatientData<Disorder> data) { JSONArray diseasesJSON = new JSONArray(); if (data != null) { for (Disorder disease : data) { diseasesJSON.put(disease.toJSON()); } } return diseasesJSON; }
public DataSection clinicalDiagnosisBody(Patient patient) { String sectionName = "clinicalDiagnosis"; Set<String> present = this.enabledHeaderIdsBySection.get(sectionName); if (present == null || present.isEmpty()) { return null; } int y = 0; DataSection bodySection = new DataSection(); PatientData<Disorder> clinicalDisorders = patient.getData("clinical-diagnosis"); /* If there is no data, but there are headers present, create empty cells */ if (clinicalDisorders == null || clinicalDisorders.size() == 0) { bodySection.addCell(new DataCell("", 0, y)); bodySection.addCell(new DataCell("", 1, y)); return bodySection; } for (Disorder disorder : clinicalDisorders) { bodySection.addCell(new DataCell(disorder.getName(), 0, y)); bodySection.addCell(new DataCell(disorder.getId(), 1, y)); y++; } return bodySection; }
@Override public String getId() { return this.access.isOpenAccess() && this.match != null ? this.match.getId() : null; }
/** creates & returns a new JSON array of all patient diseases (as JSON objects). */ private JSONArray diseasesToJSON(PatientData<Disorder> data, Collection<String> selectedFieldNames) { JSONArray diseasesJSON = new JSONArray(); if (data != null) { Iterator<Disorder> iterator = data.iterator(); while (iterator.hasNext()) { Disorder disease = iterator.next(); JSONObject diseaseJSON = disease.toJSON(); if (diseaseJSON != null) { diseasesJSON.put(diseaseJSON); } } } return diseasesJSON; }
private static JSONArray disorders(Patient patient) { JSONArray disorders = new JSONArray(); for (Disorder disease : patient.getDisorders()) { JSONObject disorderJson = new JSONObject(); disorderJson.put(ApiConfiguration.JSON_DISORDER_ID, disease.getId()); disorders.put(disorderJson); } return disorders; }
/** creates & returns a new JSON array of all patient diseases (as JSON objects). */ private JSONArray diseasesToJSON(PatientData<Disorder> data, Collection<String> selectedFieldNames) { JSONArray diseasesJSON = new JSONArray(); if (data != null) { Iterator<Disorder> iterator = data.iterator(); while (iterator.hasNext()) { Disorder disease = iterator.next(); JSONObject diseaseJSON = disease.toJSON(); if (diseaseJSON != null) { diseasesJSON.put(diseaseJSON); } } } return diseasesJSON; }
JSONArray disordersJSON = new JSONArray(); for (Disorder disorder : disorders) { disordersJSON.add(disorder.toJSON());