private static JSONObject contact(Patient patient) { // Default contact info String name = "PhenomeCentral Support"; String institution = "PhenomeCentral"; String href = "mailto:matchmaker@phenomecentral.org"; PatientData<ContactInfo> data = patient.getData("contact"); if (data != null && data.isIndexed() && data.size() > 0) { ContactInfo contact = data.get(0); String contactName = contact.getName(); if (!StringUtils.isBlank(contactName)) { name = contactName; } // Replace institution, even if blank institution = contact.getInstitution(); // TODO: replace this with a URL to a match/contact page List<String> email = contact.getEmails(); if (!email.isEmpty() && !StringUtils.isBlank(email.get(0))) { href = "mailto:" + email.get(0); } } JSONObject contactJson = new JSONObject(); contactJson.put(ApiConfiguration.JSON_CONTACT_NAME, name); // Institution is optional, so only include if non-blank if (!StringUtils.isBlank(institution)) { contactJson.put(ApiConfiguration.JSON_CONTACT_INSTITUTION, institution); } contactJson.put(ApiConfiguration.JSON_CONTACT_HREF, href); return contactJson; }