<?php

  session_start();

  include ('include_fns.php');


  function BenefitCheck($username, $password, $alias, $membershipno, $birthday, $depno)
  {
   $login = login($username, $password, $alias);

   //if (!$login)
   //{
//     return "999|Incorrect Login Details";
   //}
   //else
   //{

      if ($membershipno == '')
      {
        return '1|Membership No. Required !';
      }   

      if ($birthday == '')
      {
        return '2|Birthday Required !';
      }   

      if ($depno == '')
      {
        return '3|Dependant No. Required !';
      }   

      $query = "SELECT COUNT(*) AS RECORDCOUNT
                FROM PATIENT
                WHERE BIRTHDAY = '$birthday'
                  AND NUMBER = '$membershipno'
                  AND DEPNUM = '$depno'";


      $result = ExecuteQuery($query);


      if ($result)
      {

        if ($result[0][0] > 0)
          return '0|Patient Found';
        else
        if ($result[0][0] == 0)
          return '4|Patient Not Found';

      }
      
    //}

  }


  $e = BenefitCheck("SYSDBA", "masterkey",0, "000179710", "02-10-1980", '');
  
  echo $e;


 /* ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache

  $server = new SoapServer("BenefitCheckWS.wsdl");
  $server->addFunction("BenefitCheck");
  $server->handle();
*/
?>
