@RequestMapping(value = "/provider/view", method = RequestMethod.GET)
 public String searchResult(
     @RequestParam(name = "entityId", required = true) String entityId, Model model) {
   Provider provider = getProvider(entityId);
   List<Facility> facilities = facilities(provider);
   model.addAttribute("provider", provider);
   model.addAttribute("facilities", facilities);
   model.addAttribute("owner", LookupUtility.getOwner(provider.getEntityID()));
   return "provider/provider_view";
 }
 public Provider getProvider(String entityId) {
   CsdQueryClient csdQueryClient = new CsdQueryClient();
   RequestParams requestParams = new RequestParams();
   requestParams.setUniqueID(new Provider(entityId));
   String functionId = "urn:ihe:iti:csd:2014:stored-function:provider-search";
   String httpAddress =
       UrlUtil.PRODUCTION_OPENINFOMAN_CSR_URL
           + LookupUtility.getDirectory(entityId)
           + "/careServicesRequest";
   CallOptions callOptions = new CallOptions();
   CSD csd =
       csdQueryClient.callStandardStoredFunction(
           requestParams, functionId, httpAddress, callOptions);
   List<Provider> providers = csd.getProviderDirectory().getProviders();
   if (providers.isEmpty()) {
     return null;
   } else {
     Provider $provider = providers.get(0);
     return $provider;
   }
 }
  private Facility getFacility(String entityID) {

    CsdQueryClient csdQueryClient = new CsdQueryClient();
    RequestParams requestParams = new RequestParams();
    System.out.println("Entity ID==" + entityID);
    requestParams.setUniqueID(new Provider(entityID));
    String functionId = "urn:ihe:iti:csd:2014:stored-function:facility-search";
    String httpAddress =
        UrlUtil.PRODUCTION_OPENINFOMAN_CSR_URL
            + LookupUtility.getDirectory(entityID)
            + "/careServicesRequest";
    CallOptions callOptions = new CallOptions();
    CSD csd =
        csdQueryClient.callStandardStoredFunction(
            requestParams, functionId, httpAddress, callOptions);
    List<Facility> facilities = csd.getFacilityDirectory().getFacilities();

    for (Facility facility : facilities) {
      if (facility.getEntityID().equalsIgnoreCase(entityID)) {
        return facility;
      }
    }
    return null;
  }