@Test public void testCompareReferenceToId() { assertTrue(SharedUtilities.compareReferenceToId("Patient/1234", "1234")); assertTrue(SharedUtilities.compareReferenceToId("1234", "Patient/1234")); assertTrue(SharedUtilities.compareReferenceToId("1234", "1234")); assertTrue(SharedUtilities.compareReferenceToId("Patient/1234", "Patient/1234")); assertFalse(SharedUtilities.compareReferenceToId("Patient/1234", "4321")); assertFalse(SharedUtilities.compareReferenceToId("1234", "Patient/4321")); assertFalse(SharedUtilities.compareReferenceToId("1234", "4321")); assertFalse(SharedUtilities.compareReferenceToId("Patient/1234", "Patient/4321")); assertFalse(SharedUtilities.compareReferenceToId("Patient/1234", "Practitioner/1234")); assertFalse(SharedUtilities.compareReferenceToId("Patient/1234", "Practitioner/4321")); }
static boolean compareReferenceToId(String reference, String id) { String[] refParts = reference.split("/"); String[] idParts = id.split("/"); if (refParts.length > idParts.length) { return refParts[1].equals(idParts[0]); } else if (refParts.length < idParts.length) { return refParts[0].equals(idParts[1]); } else { if (refParts.length == 1) { return refParts[0].equals(idParts[0]); } else { return refParts[0].equals(idParts[0]) && refParts[1].equals(idParts[1]); } } }
SharedUtilities { static boolean compareReferenceToId(String reference, String id) { String[] refParts = reference.split("/"); String[] idParts = id.split("/"); if (refParts.length > idParts.length) { return refParts[1].equals(idParts[0]); } else if (refParts.length < idParts.length) { return refParts[0].equals(idParts[1]); } else { if (refParts.length == 1) { return refParts[0].equals(idParts[0]); } else { return refParts[0].equals(idParts[0]) && refParts[1].equals(idParts[1]); } } } }
SharedUtilities { static boolean compareReferenceToId(String reference, String id) { String[] refParts = reference.split("/"); String[] idParts = id.split("/"); if (refParts.length > idParts.length) { return refParts[1].equals(idParts[0]); } else if (refParts.length < idParts.length) { return refParts[0].equals(idParts[1]); } else { if (refParts.length == 1) { return refParts[0].equals(idParts[0]); } else { return refParts[0].equals(idParts[0]) && refParts[1].equals(idParts[1]); } } }  }
SharedUtilities { static boolean compareReferenceToId(String reference, String id) { String[] refParts = reference.split("/"); String[] idParts = id.split("/"); if (refParts.length > idParts.length) { return refParts[1].equals(idParts[0]); } else if (refParts.length < idParts.length) { return refParts[0].equals(idParts[1]); } else { if (refParts.length == 1) { return refParts[0].equals(idParts[0]); } else { return refParts[0].equals(idParts[0]) && refParts[1].equals(idParts[1]); } } }  static int calculateAge(Date birthDate); }
SharedUtilities { static boolean compareReferenceToId(String reference, String id) { String[] refParts = reference.split("/"); String[] idParts = id.split("/"); if (refParts.length > idParts.length) { return refParts[1].equals(idParts[0]); } else if (refParts.length < idParts.length) { return refParts[0].equals(idParts[1]); } else { if (refParts.length == 1) { return refParts[0].equals(idParts[0]); } else { return refParts[0].equals(idParts[0]) && refParts[1].equals(idParts[1]); } } }  static int calculateAge(Date birthDate);  }