SimpleObject simplify(UiUtils ui, EmrApiProperties emrApiProperties, Patient patient) { PersonName name = patient.getPersonName(); SimpleObject preferredName = SimpleObject.fromObject(name, ui, "givenName", "middleName", "familyName", "familyName2"); preferredName.put("name", ui.format(name)); PatientIdentifierType primaryIdentifierType = emrApiProperties.getPrimaryIdentifierType(); List<PatientIdentifier> primaryIdentifiers = patient.getPatientIdentifiers(primaryIdentifierType); SimpleObject o = SimpleObject.fromObject( patient, ui, "patientId", "gender", "age", "birthdate", "birthdateEstimated"); o.put("preferredName", preferredName); o.put("primaryIdentifiers", SimpleObject.fromCollection(primaryIdentifiers, ui, "identifier")); return o; }