@Test public void checkLocations() { Patient patient = TestUtils.getPatient(7); Form moh257 = MetadataUtils.existing(Form.class, HivMetadata._Form.MOH_257_VISIT_SUMMARY); VisitType outpatient = MetadataUtils.existing(VisitType.class, CommonMetadata._VisitType.OUTPATIENT); Visit visit0 = TestUtils.saveVisit(patient, outpatient, TestUtils.date(2012, 1, 1), null); Visit visit1 = TestUtils.saveVisit(patient, outpatient, TestUtils.date(2012, 1, 1), null); visit1.setLocation(Context.getLocationService().getLocation(1)); Visit visit2 = TestUtils.saveVisit(patient, outpatient, TestUtils.date(2012, 1, 1), null); visit2.setLocation(Context.getLocationService().getLocation(2)); Encounter encounter = TestUtils.saveEncounter(patient, moh257, TestUtils.date(2012, 1, 1)); Assert.assertThat(EmrVisitAssignmentHandler.checkLocations(visit0, encounter), is(true)); Assert.assertThat(EmrVisitAssignmentHandler.checkLocations(visit1, encounter), is(true)); Assert.assertThat(EmrVisitAssignmentHandler.checkLocations(visit2, encounter), is(false)); }
protected static boolean checkLocations(Visit visit, Encounter encounter) { return visit.getLocation() == null || Location.isInHierarchy(encounter.getLocation(), visit.getLocation()); }
EmrVisitAssignmentHandler extends BaseEncounterVisitHandler implements ExistingEncounterVisitHandler { protected static boolean checkLocations(Visit visit, Encounter encounter) { return visit.getLocation() == null || Location.isInHierarchy(encounter.getLocation(), visit.getLocation()); } }
EmrVisitAssignmentHandler extends BaseEncounterVisitHandler implements ExistingEncounterVisitHandler { protected static boolean checkLocations(Visit visit, Encounter encounter) { return visit.getLocation() == null || Location.isInHierarchy(encounter.getLocation(), visit.getLocation()); }  }
EmrVisitAssignmentHandler extends BaseEncounterVisitHandler implements ExistingEncounterVisitHandler { protected static boolean checkLocations(Visit visit, Encounter encounter) { return visit.getLocation() == null || Location.isInHierarchy(encounter.getLocation(), visit.getLocation()); }  @Override String getDisplayName(Locale locale); @Override void beforeCreateEncounter(Encounter encounter); @Override void beforeEditEncounter(Encounter encounter); }
EmrVisitAssignmentHandler extends BaseEncounterVisitHandler implements ExistingEncounterVisitHandler { protected static boolean checkLocations(Visit visit, Encounter encounter) { return visit.getLocation() == null || Location.isInHierarchy(encounter.getLocation(), visit.getLocation()); }  @Override String getDisplayName(Locale locale); @Override void beforeCreateEncounter(Encounter encounter); @Override void beforeEditEncounter(Encounter encounter);  }