Kareo API在PHP中调用create Encounter API时出错

时间:2018-09-05 07:19:23

标签: php api soap

大家好,能否为我提供以下代码,我的PHP Kareo API代码如下:

ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);
ini_set('default_socket_timeout', 5000);


try{
    $user = 'xxxxxx';
    $password = 'xxxxx';
    $customerKey = 'xxxxxx';
    $wsdl = 'https://webservice.kareo.com/services/soap/2.1/KareoServices.svc?singleWsdl';


//set the Headers of Soap Client. 
$client = new SoapClient($wsdl, array(
    'trace' => true, 
    'keep_alive' => true,
    'connection_timeout' => 5000,
    'cache_wsdl' => WSDL_CACHE_NONE,
    'compression'   => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
));
    $date =  reset(date_create(date('Y-m-d')));

    $request = array (
        'RequestHeader'             => array('User' => $user, 'Password' => $password, 'CustomerKey' => $customerKey, 'ClientVersion' => 1.0),
        'EncounterCreate'           =>  array('ServiceStartDate'=> $date, 'PostDate' => $date),
        'PracticeIdentifierReq'     =>  array('PracticeName' => 'Allergy Specialists Medical Group'),
        'EncounterServiceLocation'  =>  array('LocationName' => "Irvine Office"),
        'PatientIdentifierReq'      =>  array('FirstName' => 'Divyang', 'LastName' => 'Parekh'),
        'PatientCaseIdentifierReq'  =>  array('CaseName' => 'Secondary Case'),
        'ProviderIdentifierDetailedReq' => array('FirstName' => 'Paige', 'LastName' => 'McAndrews'),
        'ServiceLineReq'            => array('ServiceStartDate'=> $date, 'ProcedureCode' => '99201', 'DiagnosisCode1' => "600.00", 'Units' => 1 , 'UnitCharge' => 3.4) ,
    );
    $params = array('request' => $request);

    //$response = $client->GetPractices($params);

    $response = $client->CreateEncounter(  $params );
    echo "<pre>";
    print_r($response);

    } catch (Exception $err) {
        print "Error: ". $err->getMessage();
    }

每当我尝试调用此方式时,总是会遇到如下错误:

KareoStructCreateEncounterResponse Object
(
    [CreateEncounterResult] => KareoStructCreateEncounterResp Object
        (
            [AppointmentExternalID] => 
            [AppointmentID] => -1
            [EncounterExternalID] => 
            [EncounterID] => -1
            [ExternalVendorID] => -1
            [PTAProviderExternalID] => 
            [PatientCaseExternalID] => 
            [PatientCaseID] => -1
            [PatientExternalID] => 
            [PatientID] => -1
            [PaymentMethod] => 
            [PracticeExternalID] => 
            [PracticeID] => -1
            [PracticeName] => 
            [ReferringProviderExternalID] => 
            [ReferringProviderID] => -1
            [RenderingProviderExternalID] => 
            [RenderingProviderID] => -1
            [SchedulingProviderExternalID] => 
            [SchedulingProviderID] => -1
            [ServiceLinesAdded] => 
            [ServiceLocationID] => -1
            [SupervisingProviderExternalID] => 
            [SupervisingProviderID] => -1
            [ErrorResponse] => KareoStructErrorResponse Object
                (
                    [ErrorMessage] => You need to pass in a valid CreateEncounterRequest.Encounter
                    [IsError] => 1
                    [StackTrace] =>    at KareoServicesWCF.serializationHelper.ThrowInvalidParameterError(String parameter) in c:\BuildAgent\work\9b4e47f3eaa8cae\Software\Application\KareoServicesWCF\2.1\KareoServicesWCF\serializationHelper.cs:line 34
   at KareoServicesWCF.KareoServices.CreateEncounter(CreateEncounterReq request) in c:\BuildAgent\work\9b4e47f3eaa8cae\Software\Application\KareoServicesWCF\2.1\KareoServicesWCF\KareoServices.cs:line 1031
                    [result:KareoWsdlClass:private] => 
                    [lastError:KareoWsdlClass:private] => 
                    [internArrayToIterate:KareoWsdlClass:private] => 
                    [internArrayToIterateIsArray:KareoWsdlClass:private] => 
                    [internArrayToIterateOffset:KareoWsdlClass:private] => 
                )

            [SecurityResponse] => 
            [result:KareoWsdlClass:private] => 
            [lastError:KareoWsdlClass:private] => 
            [internArrayToIterate:KareoWsdlClass:private] => 
            [internArrayToIterateIsArray:KareoWsdlClass:private] => 
            [internArrayToIterateOffset:KareoWsdlClass:private] => 
        )

    [result:KareoWsdlClass:private] => 
    [lastError:KareoWsdlClass:private] => 
    [internArrayToIterate:KareoWsdlClass:private] => 
    [internArrayToIterateIsArray:KareoWsdlClass:private] => 
    [internArrayToIterateOffset:KareoWsdlClass:private] => 
)

请帮我解决这个问题,如果您有创建Encounter和CreatePatient的示例,对我来说太好了。

祝您有美好的一天

0 个答案:

没有答案