@Override public String toString() { return toJSON().toString(); }
@Override public String toString() { return toJSON().toString(); }
private void convertJSONField(JSONObject nodeJSON, List<String> dateFieldNames) { JSONObject properties = nodeJSON.optJSONObject(PEDIGREE_PROPERTIES_STRING); if (properties != null) { for (String fieldName : dateFieldNames) { JSONObject dateObject = properties.optJSONObject(fieldName); if (dateObject != null) { PhenoTipsDate date = new PhenoTipsDate(dateObject); properties.put(fieldName, date.toJSON()); } } nodeJSON.put(PEDIGREE_PROPERTIES_STRING, properties); } } }
private void convertJSONField(JSONObject nodeJSON, List<String> dateFieldNames) { JSONObject properties = nodeJSON.optJSONObject(PEDIGREE_PROPERTIES_STRING); if (properties != null) { for (String fieldName : dateFieldNames) { JSONObject dateObject = properties.optJSONObject(fieldName); if (dateObject != null) { PhenoTipsDate date = new PhenoTipsDate(dateObject); properties.put(fieldName, date.toJSON()); } } nodeJSON.put(PEDIGREE_PROPERTIES_STRING, properties); } } }
@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<PhenoTipsDate> datesData = patient.getData(DATA_NAME); boolean noData = (datesData == null || !datesData.isNamed()); for (String propertyName : this.getPatientDocumentProperties()) { PhenoTipsDate data = noData ? null : datesData.get(propertyName); // note: get(propertyName) may return null // no specific set of fields was explicitly requested and no data => do not addd anything if (selectedFieldNames == null && data == null) { continue; } // only a subset of fields was explicitly requested, and this field is not included if (selectedFieldNames != null && !selectedFieldNames.contains(getControllingFieldName(propertyName))) { continue; } // in all other cases need to add the property to JSON, either with empoty value or // with proper value json.put(getJSONFieldName(propertyName), ((data == null) ? "" : data.toJSON())); } }
@Override public void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames) { PatientData<PhenoTipsDate> datesData = patient.getData(DATA_NAME); boolean noData = (datesData == null || !datesData.isNamed()); for (String propertyName : this.getPatientDocumentProperties()) { PhenoTipsDate data = noData ? null : datesData.get(propertyName); // note: get(propertyName) may return null // no specific set of fields was explicitly requested and no data => do not addd anything if (selectedFieldNames == null && data == null) { continue; } // only a subset of fields was explicitly requested, and this field is not included if (selectedFieldNames != null && !selectedFieldNames.contains(getControllingFieldName(propertyName))) { continue; } // in all other cases need to add the property to JSON, either with empoty value or // with proper value json.put(getJSONFieldName(propertyName), ((data == null) ? "" : data.toJSON())); } }