@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { if (selectedFieldNames != null && !selectedFieldNames.contains(GENES_ENABLING_FIELD_NAME)) { return; } PatientData<Gene> data = patient.getData(getName()); if (data == null || data.size() == 0) { if (selectedFieldNames == null || selectedFieldNames.contains(GENES_ENABLING_FIELD_NAME)) { json.put(GENES_STRING, new JSONArray()); } return; } JSONArray geneArray = new JSONArray(); for (Gene gene : data) { geneArray.put(gene.toJSON()); } json.put(GENES_STRING, geneArray); }
@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { // this controller is only activated if a deprecated field is explicitly requested if (selectedFieldNames == null || !selectedFieldNames.contains(GENES_ENABLING_FIELD_NAME)) { return; } PatientData<Gene> data = patient.getData(GENES_STRING); if (data == null || data.size() == 0) { json.put(GENES_STRING, new JSONArray()); return; } JSONArray geneArray = new JSONArray(); for (Gene gene : data) { JSONObject geneObj = gene.toJSON(); // change "rejected_candidate" status to "rejected" if (gene.getStatus().equals(INTERNAL_REJECTED_CANDIDATE_VALUE)) { geneObj.put(INTERNAL_STATUS_KEY, INTERNAL_REJECTED_VALUE); String comment = geneObj.optString(JSON_COMMENTS_KEY, ""); if ("".equals(comment)) { geneObj.put(JSON_COMMENTS_KEY, "* Rejected candidate"); } else { geneObj.put(JSON_COMMENTS_KEY, "* Rejected candidate \n\n" + comment); } } geneArray.put(geneObj); } json.put(GENES_STRING, geneArray); }