如何使用Google Cloud Healthcare API HttpBody类



我很难使用HttpBody类的方法setData((。我将参数作为对象传递给方法,但收到了一条错误消息。

如何传递参数:

public function create(string $resource, $body)
{
$client   = $this->googleClient();
$service  = new CloudHealthcare($client);
$parent   = "projects/my_project_id/locations/my_location/datasets/my_dataset/fhirStores/repository";
$httpBody = new HttpBody();
$httpBody->setContentType('application/fhir+json;charset=utf-8');
$httpBody->setData([
"resourceType" => "Patient",
"id" => "23434",
"meta" => [
"versionId" => "12",
"lastUpdated" => "2014-08-18T15:43:30Z"
],
"text" => [
"status" => "generated",
"div" => "<!-- Snipped for Brevity -->"
],
"extension" => [
[
"url" => "http://example.org/consent#trials",
"valueCode" => "renal"
]
],
"identifier" => [
[
"use" => "usual",
"label" => "MRN",
"system" => "http://www.goodhealth.org/identifiers/mrn",
"value" => "123456"
]
],
"name" => [
[
"family" => [
"Levin"
],
"given" => [
"Henry"
],
"suffix" => [
"The 7th"
]
]
],
"gender" => [
"text" => "Male"
],
"birthDate" => "1932-09-24",
"active" => true
]);
$data     = $service->projects_locations_datasets_fhirStores_fhir->create($parent, $resource, $httpBody);
return $data;
}

我收到错误消息后。错误显示我没有通过resourceType字段,但它通过了:

GoogleServiceException: {
"issue": [
{
"code": "structure",
"details": {
"text": "unparseable_resource"
},
"diagnostics": "missing required field "resourceType"",
"expression": [
""
],
"severity": "error"
}
],
"resourceType": "OperationOutcome"
} in file /usr/share/nginx/vendor/google/apiclient/src/Http/REST.php on line 128

我应该如何传递参数以接收成功消息?Tkanks!

我还没有专门尝试过PHP客户端库,但对于大多数不想使用HttpBody类的语言,这表明该方法接受请求主体中的某些内容,从方法签名的角度来看,这些内容只是文本。我会尝试直接传递JSON字符串。

相关内容

  • 没有找到相关文章

最新更新