KenyaEmrServiceImpl extends BaseOpenmrsService implements KenyaEmrService { @Override public Location getLocationByMflCode(String mflCode) { LocationAttributeType mflCodeAttrType = MetadataUtils.existing(LocationAttributeType.class, FacilityMetadata._LocationAttributeType.MASTER_FACILITY_CODE); Map<LocationAttributeType, Object> attrVals = new HashMap<LocationAttributeType, Object>(); attrVals.put(mflCodeAttrType, mflCode); List<Location> locations = locationService.getLocations(null, null, attrVals, false, null, null); return locations.size() > 0 ? locations.get(0) : null; }  void setKenyaEmrDAO(KenyaEmrDAO dao); @Override boolean isSetupRequired(); @Override void setDefaultLocation(Location location); @Override Location getDefaultLocation(); @Override String getDefaultLocationMflCode(); @Override Location getLocationByMflCode(String mflCode); @Override String getNextHivUniquePatientNumber(String comment); @Override List<Visit> getVisitsByPatientAndDay(Patient patient, Date date); @Override void setupMrnIdentifierSource(String startFrom); @Override void setupHivUniqueIdentifierSource(String startFrom); @Override List<Object> executeSqlQuery(String query, Map<String, Object> substitutions); @Override List<Object> executeHqlQuery(String query, Map<String, Object> substitutions);  }
@Test public void getLocationByMflCode_shouldFindLocationWithCodeOrNull() throws Exception { Assert.assertEquals(Context.getLocationService().getLocation(1), service.getLocationByMflCode("15001")); Assert.assertNull(service.getLocationByMflCode("15003")); Assert.assertNull(service.getLocationByMflCode("XXXXX")); }