FHIR 저장소 만들기 및 관리

이 페이지에서는 FHIR(Fast Healthcare Interoperability Resources) 저장소를 생성, 수정, 조회, 삭제하는 방법을 설명합니다. FHIR 저장소에는 클레임 리소스, 환자 리소스, 의약품 리소스 등과 같은 FHIR 리소스가 저장됩니다.

Cloud Healthcare API는 다음 FHIR 버전을 지원합니다.

FHIR 저장소 만들기

FHIR 저장소를 만들려면 먼저 데이터 세트를 만들어야 합니다.

다음 샘플은 projects.locations.datasets.fhirStores.create 메서드를 사용하여 FHIR 저장소를 만드는 방법을 보여줍니다.

Console

FHIR 저장소를 만들려면 다음 단계를 완료하세요.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. FHIR 저장소를 만들 데이터 세트를 선택합니다.
  3. 데이터 스토어 만들기를 클릭합니다.
  4. FHIR을 데이터 스토어 유형으로 선택합니다.
  5. 데이터 세트에서 고유한 이름을 입력합니다. 이름이 고유하지 않으면 FHIR 저장소를 만들 수 없습니다.
  6. 다음을 클릭합니다.
  7. FHIR 저장소를 구성하려면 다음을 수행합니다.
    1. FHIR 저장소의 FHIR 버전(DSTU2, STU3 또는 R4)을 선택합니다.
    2. 다음에서 해당하는 고급 설정을 선택합니다.
      • 업데이트 생성 허용: 사용자 지정 ID로 업데이트 작업을 사용하여 새 리소스를 생성할 수 있도록 선택합니다.
      • 참조 무결성 검사: 이 저장소에서 참조 무결성을 사용 설정하려면 선택합니다. 저장소를 만든 후에는 변경할 수 없습니다.
      • 리소스 버전 관리: 리소스의 이전 버전을 자동으로 기록하려면 선택합니다. 저장소를 만든 후에는 변경할 수 없습니다.
    3. 다음 필드에서 해당하는 프로필 유효성 검사 설정을 선택합니다. 자세한 내용은 ValidationConfig를 참조하세요.
      • 프로필 유효성 검사 사용 설정: 프로필 유효성 검사를 사용 설정하려면 선택합니다. FHIR 저장소에 사용 설정된 구현 가이드를 적용하려면 프로필 유효성 검사를 사용 설정해야 합니다.
      • 필수 필드 유효성 검사 사용 설정: FHIR 프로필의 구조 정의에 대한 리소스 필드 유효성 검사를 사용 설정하려면 선택합니다.
      • 참조 유형 유효성 검사 사용 설정: 참조 유형 유효성 검사를 사용 설정하려면 선택합니다.
      • FHIRPath 유효성 검사 사용 설정: FHIRPath 호환성 검사를 사용 설정하려면 선택합니다.
    4. 다음을 클릭합니다.
  8. 선택사항: FHIR 저장소에서 구현 가이드를 사용 설정하려면 다음을 수행합니다.
    1. 구현 가이드 사용 설정을 클릭합니다.
    2. 구현 가이드 목록을 클릭하여 펼칩니다.
    3. 목록에서 해당 구현 가이드를 선택합니다.

      각 구현 가이드는 특정 FHIR 버전을 지원합니다. 이 목록에는 선택한 FHIR 저장소 버전과 호환되는 구현 가이드만 표시됩니다.

    4. Cloud Storage에서 커스텀 IG 가져오기를 클릭하여 Cloud Storage 위치에서 커스텀 프로필 유효성 검사 번들을 가져옵니다.
    5. 객체 선택 패널의 Cloud Storage 위치에서 프로필 유효성 검사 번들 리소스를 선택합니다. 자세한 내용은 Google Cloud 콘솔을 사용하여 구현 가이드 사용 설정을 참조하세요.
    6. 선택을 클릭합니다.
      • 선택한 구현 가이드는 버전, URL, 상태와 함께 표에 나열되어 있습니다.
      • 구현 가이드를 사용 설정했지만 프로필 유효성 검사를 사용 설정하지 않은 경우 구현 가이드가 적용되지 않습니다.
      • 다음을 클릭합니다.
  9. 선택사항: 저장소의 FHIR 리소스가 생성, 업데이트, 패치 또는 삭제될 때마다 BigQuery로 리소스 변경사항을 내보내려면 다음을 수행합니다.
    1. BigQuery로 리소스 변경사항 스트리밍을 클릭합니다.
    2. 스트리밍 구성 추가를 클릭합니다. BigQuery 스트리밍에 대한 자세한 내용은 BigQuery로 FHIR 리소스 변경사항 스트리밍을 참조하세요.
    3. 재귀 구조 깊이 슬라이더에서 깊이 수준을 선택하여 출력 스키마의 모든 재귀 구조에 대한 깊이를 설정합니다. 기본적으로 재귀 깊이 값은 2입니다.
    4. 완료를 클릭하여 스트리밍 구성을 저장합니다.
    5. 다음을 클릭합니다.
  10. 선택사항: FHIR 저장소에 대해 Pub/Sub 주제를 구성하려면 다음을 수행합니다.
    1. Cloud Pub/Sub 알림 수신을 클릭합니다.
    2. Cloud Pub/Sub 주제 추가를 클릭하고 주제 이름을 선택합니다.

      Pub/Sub 주제를 지정할 때 다음 샘플과 같이 주제에 대해 정규화된 URI를 입력합니다.

      projects/PROJECT_ID/topics/PUBSUB_TOPIC
      

    3. 다음을 클릭합니다.
  11. 선택사항: 저장소에 라벨을 추가하려면 다음을 수행합니다.
    1. 데이터 저장소 구성을 위해 라벨 추가를 클릭합니다.
    2. 라벨의 키 및 값을 입력합니다. 리소스 라벨에 대한 자세한 내용은 리소스 라벨 사용을 참조하세요.
    3. 만들기를 클릭합니다.

새 FHIR 저장소가 목록에 표시됩니다.

gcloud

데이터 세트에 FHIR 저장소를 만들려면 gcloud healthcare fhir-stores create 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소의 식별자. FHIR 저장소 ID는 다음을 포함해야 합니다.
    • 데이터 세트의 고유 ID
    • 다음으로 구성된 1~256자의 유니코드 문자열:
      • 숫자
      • 문자
      • 밑줄
      • 대시
      • 마침표
  • FHIR_STORE_VERSION: FHIR 저장소의 FHIR 버전입니다. 사용 가능한 옵션은 DSTU2, STU3 또는 R4입니다.

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud healthcare fhir-stores create FHIR_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION \
  --version=FHIR_STORE_VERSION

Windows(PowerShell)

gcloud healthcare fhir-stores create FHIR_STORE_ID `
  --dataset=DATASET_ID `
  --location=LOCATION `
  --version=FHIR_STORE_VERSION

Windows(cmd.exe)

gcloud healthcare fhir-stores create FHIR_STORE_ID ^
  --dataset=DATASET_ID ^
  --location=LOCATION ^
  --version=FHIR_STORE_VERSION

다음과 비슷한 응답이 표시됩니다.

응답

Created fhirStore [FHIR_STORE_ID].

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소의 식별자. FHIR 저장소 ID는 다음을 포함해야 합니다.
    • 데이터 세트의 고유 ID
    • 다음으로 구성된 1~256자의 유니코드 문자열:
      • 숫자
      • 문자
      • 밑줄
      • 대시
      • 마침표
  • FHIR_STORE_VERSION: FHIR 저장소의 FHIR 버전입니다. 사용 가능한 옵션은 DSTU2, STU3 또는 R4입니다.

JSON 요청 본문:

{
  "version": "FHIR_STORE_VERSION"
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

cat > request.json << 'EOF'
{
  "version": "FHIR_STORE_VERSION"
}
EOF

그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores?fhirStoreId=FHIR_STORE_ID"

PowerShell

요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

@'
{
  "version": "FHIR_STORE_VERSION"
}
'@  | Out-File -FilePath request.json -Encoding utf8

그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores?fhirStoreId=FHIR_STORE_ID" | Select-Object -Expand Content

API 탐색기

요청 본문을 복사하고 메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 요청 본문을 이 도구에 붙여넣고 다른 필수 필드를 입력한 후 실행을 클릭합니다.

다음과 비슷한 JSON 응답이 표시됩니다.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// createFHIRStore creates an FHIR store.
func createFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.FhirStores

	parent := fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID)
	version := "R4"

	resp, err := storesService.Create(parent, &healthcare.FhirStore{Version: version}).FhirStoreId(fhirStoreID).Do()
	if err != nil {
		return fmt.Errorf("Create: %w", err)
	}

	fmt.Fprintf(w, "Created FHIR store: %q\n", resp.Name)
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.FhirStore;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class FhirStoreCreate {
  private static final String DATASET_NAME = "projects/%s/locations/%s/datasets/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void fhirStoreCreate(String datasetName, String fhirStoreId) throws IOException {
    // String datasetName =
    //     String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
    // String fhirStoreId = "your-fhir-id"

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Configure the FhirStore to be created.
    Map<String, String> labels = new HashMap<>();
    labels.put("key1", "value1");
    labels.put("key2", "value2");
    String version = "STU3";
    FhirStore content = new FhirStore().setLabels(labels).setVersion(version);

    // Create request and configure any parameters.
    FhirStores.Create request =
        client
            .projects()
            .locations()
            .datasets()
            .fhirStores()
            .create(datasetName, content)
            .setFhirStoreId(fhirStoreId);

    // Execute the request and process the results.
    FhirStore response = request.execute();
    System.out.println("FHIR store created: " + response.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const createFhirStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const fhirStoreId = 'my-fhir-store';
  // const version = 'STU3';
  const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {
    parent,
    fhirStoreId,
    resource: {
      version,
    },
  };

  await healthcare.projects.locations.datasets.fhirStores.create(request);
  console.log(`Created FHIR store: ${fhirStoreId}`);
};

createFhirStore();

Python

def create_fhir_store(project_id, location, dataset_id, fhir_store_id, version):
    """Creates a new FHIR store within the parent dataset.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the FHIR store's parent dataset ID
    # fhir_store_id = 'my-fhir-store'  # replace with the FHIR store's ID
    # version = 'R4'  # replace with the FHIR store version
    fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )

    body = {"version": version}

    request = (
        client.projects()
        .locations()
        .datasets()
        .fhirStores()
        .create(parent=fhir_store_parent, body=body, fhirStoreId=fhir_store_id)
    )

    response = request.execute()
    print(f"Created FHIR store: {fhir_store_id}")

    return response

FHIR 저장소 수정

다음 샘플은 FHIR 저장소를 수정하는 방법을 보여줍니다. FHIR 저장소를 수정하여 다음과 같은 속성을 수정할 수 있습니다.

  • Cloud Healthcare API가 FHIR 저장소 변경사항의 알림을 보내는 Pub/Sub 주제.
  • FHIR 저장소의 라벨. 라벨은 Google Cloud 리소스를 구성하는 데 도움이 되는 키-값 쌍입니다.
Pub/Sub 주제를 지정할 때 다음 샘플과 같이 주제에 대해 정규화된 URI를 입력합니다.
projects/PROJECT_ID/topics/PUBSUB_TOPIC
알림이 작동하려면 Cloud Healthcare Service Agent 서비스 계정에 추가 권한을 부여해야 합니다. 자세한 내용은 DICOM, FHIR, HL7v2 저장소 Pub/Sub 권한을 참조하세요.

콘솔

FHIR 저장소를 수정하려면 다음 단계를 완료하세요.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.
    데이터 세트로 이동

  2. 수정할 FHIR 저장소가 포함된 데이터 세트를 선택합니다.

  3. 데이터 스토어 목록에서 수정할 FHIR 저장소를 선택합니다.

  4. 저장소의 구성을 수정하려면 FHIR 저장소 구성을 클릭합니다.

    FHIR 저장소의 구성 옵션에 대한 자세한 내용은 FHIR 저장소 만들기를 참조하세요.

  5. 저장소의 구현 가이드를 수정하려면 구현 가이드를 클릭하고 적용 가능한 구현 가이드를 선택하거나 Cloud Storage에서 커스텀 구현 가이드를 가져옵니다. 자세한 내용은 Google Cloud 콘솔을 사용하여 구현 가이드 사용 설정을 참조하세요.

    구현 가이드를 수정하거나 사용 설정된 구현 가이드를 시행하려면 FHIR 저장소 구성 섹션에서 프로필 유효성 검사를 사용 설정해야 합니다.

  6. 저장소의 FHIR 리소스가 생성, 업데이트, 패치 또는 삭제될 때마다 BigQuery로 리소스 변경사항을 내보내려면 데이터 세트 필드의 새 스트리밍 구성 추가를 클릭합니다.

  7. 리소스 변경사항이 스트리밍될 BigQuery 데이터 세트를 선택합니다. BigQuery 스트리밍에 대한 자세한 내용은 BigQuery로 FHIR 리소스 변경사항 스트리밍을 참조하세요.

  8. 출력 스키마의 모든 재귀 구조에 대해 깊이를 설정하려면 재귀 구조 깊이 슬라이더에서 관련 깊이를 클릭합니다. 기본적으로 재귀 깊이는 2입니다.

  9. 특정 리소스 유형의 리소스 변경사항만 내보내려면 FHIR 리소스 유형 선택 목록에서 리소스 유형을 선택합니다.

  10. 데이터 스토어의 Pub/Sub 주제를 구성하려면 Cloud Pub/Sub 알림 섹션에서 주제 이름을 선택합니다. Pub/Sub 주제를 지정할 때 다음 샘플과 같이 주제에 대해 정규화된 URI를 입력합니다.

    projects/PROJECT_ID/topics/PUBSUB_TOPIC
    

  11. 저장소에 라벨을 하나 이상 추가하려면 라벨, 라벨 추가를 차례로 클릭하고 키/값 라벨을 입력합니다. 리소스 라벨에 대한 자세한 내용은 리소스 라벨 사용을 참조하세요.

  12. 저장을 클릭합니다.

gcloud

FHIR 저장소를 수정하려면 gcloud healthcare fhir-stores update 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID
  • PUBSUB_TOPIC_ID: 데이터 스토어에서 이벤트가 발생할 때 메시지가 게시되는 Pub/Sub 주제

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud healthcare fhir-stores update FHIR_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION \
  --pubsub-topic=projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID

Windows(PowerShell)

gcloud healthcare fhir-stores update FHIR_STORE_ID `
  --dataset=DATASET_ID `
  --location=LOCATION `
  --pubsub-topic=projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID

Windows(cmd.exe)

gcloud healthcare fhir-stores update FHIR_STORE_ID ^
  --dataset=DATASET_ID ^
  --location=LOCATION ^
  --pubsub-topic=projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID

다음과 비슷한 응답이 표시됩니다.

응답

Updated fhirStore [FHIR_STORE_ID].
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID
notificationConfig:
 pubsubTopic: projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID
version: FHIR_STORE_VERSION

REST

FHIR 저장소를 수정하려면 projects.locations.datasets.fhirStores.patch 메서드를 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID
  • PUBSUB_TOPIC_ID: Pub/Sub 주제 ID Pub/Sub 알림에 포함할 데이터를 결정하려면 FHIR Pub/Sub 알림을 참조하세요.
  • KEY1: 첫 번째 라벨 키
  • VALUE1: 첫 번째 라벨 값
  • KEY2: 두 번째 라벨 키
  • VALUE2: 두 번째 라벨 값

JSON 요청 본문:

{
  "notificationConfig": {
    "pubsubTopic": "projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID"
  },
  "labels": {
    "KEY1": "VALUE1",
    "KEY2": "VALUE2"
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

cat > request.json << 'EOF'
{
  "notificationConfig": {
    "pubsubTopic": "projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID"
  },
  "labels": {
    "KEY1": "VALUE1",
    "KEY2": "VALUE2"
  }
}
EOF

그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID?updateMask=notificationConfig,labels"

PowerShell

요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

@'
{
  "notificationConfig": {
    "pubsubTopic": "projects/PROJECT_ID/topics/PUBSUB_TOPIC_ID"
  },
  "labels": {
    "KEY1": "VALUE1",
    "KEY2": "VALUE2"
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID?updateMask=notificationConfig,labels" | Select-Object -Expand Content

API 탐색기

요청 본문을 복사하고 메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 요청 본문을 이 도구에 붙여넣고 다른 필수 필드를 입력한 후 실행을 클릭합니다.

다음과 비슷한 JSON 응답이 표시됩니다.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// patchFHIRStore updates (patches) a FHIR store by updating its Pub/sub topic name.
func patchFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID, topicName string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.FhirStores

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/fhirStores/%s", projectID, location, datasetID, fhirStoreID)

	if _, err := storesService.Patch(name, &healthcare.FhirStore{
		NotificationConfig: &healthcare.NotificationConfig{
			PubsubTopic: topicName, // format is "projects/*/locations/*/topics/*"
		},
	}).UpdateMask("notificationConfig").Do(); err != nil {
		return fmt.Errorf("Patch: %w", err)
	}

	fmt.Fprintf(w, "Patched FHIR store %s with Pub/sub topic %s\n", datasetID, topicName)

	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.FhirStore;
import com.google.api.services.healthcare.v1.model.NotificationConfig;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

public class FhirStorePatch {
  private static final String FHIR_NAME = "projects/%s/locations/%s/datasets/%s/fhirStores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void fhirStorePatch(String fhirStoreName, String pubsubTopic) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
    // String pubsubTopic = "projects/your-project-id/topics/your-pubsub-topic";

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Fetch the initial state of the FHIR store.
    FhirStores.Get getRequest =
        client.projects().locations().datasets().fhirStores().get(fhirStoreName);
    FhirStore store = getRequest.execute();

    // Update the FhirStore fields as needed as needed. For a full list of FhirStore fields, see:
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.fhirStores#FhirStore
    store.setNotificationConfig(new NotificationConfig().setPubsubTopic(pubsubTopic));

    // Create request and configure any parameters.
    FhirStores.Patch request =
        client
            .projects()
            .locations()
            .datasets()
            .fhirStores()
            .patch(fhirStoreName, store)
            .setUpdateMask("notificationConfig");

    // Execute the request and process the results.
    store = request.execute();
    System.out.println("Fhir store patched: \n" + store.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const patchFhirStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const fhirStoreId = 'my-fhir-store';
  // const pubsubTopic = 'my-topic'
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
  const request = {
    name,
    updateMask: 'notificationConfig',
    resource: {
      notificationConfig: {
        pubsubTopic: `projects/${projectId}/topics/${pubsubTopic}`,
      },
    },
  };

  await healthcare.projects.locations.datasets.fhirStores.patch(request);
  console.log(
    `Patched FHIR store ${fhirStoreId} with Cloud Pub/Sub topic ${pubsubTopic}`
  );
};

patchFhirStore();

Python

def patch_fhir_store(project_id, location, dataset_id, fhir_store_id):
    """Updates the FHIR store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Instantiates an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the dataset's location
    # dataset_id = 'my-dataset'  # replace with your dataset ID
    # fhir_store_id = 'my-fhir-store'  # replace with the FHIR store's ID
    fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    fhir_store_name = f"{fhir_store_parent}/fhirStores/{fhir_store_id}"

    # TODO(developer): Replace with the full URI of an existing Pub/Sub topic
    patch = {"notificationConfig": None}

    request = (
        client.projects()
        .locations()
        .datasets()
        .fhirStores()
        .patch(name=fhir_store_name, updateMask="notificationConfig", body=patch)
    )

    response = request.execute()
    print(f"Patched FHIR store {fhir_store_id} with Cloud Pub/Sub topic: None")

    return response

FHIR 저장소 세부정보 가져오기

다음 샘플은 FHIR 저장소에 대한 세부정보를 가져오는 방법을 보여줍니다.

콘솔

FHIR 저장소의 세부정보를 보려면 다음 안내를 따르세요.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. FHIR 스토어가 포함된 데이터 세트를 선택합니다.
  3. FHIR 저장소의 이름을 클릭합니다.

gcloud

FHIR 저장소에 대한 세부정보를 가져오려면 gcloud healthcare fhir-stores describe 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud healthcare fhir-stores describe FHIR_STORE_ID \
 --dataset=DATASET_ID \
 --location=LOCATION

Windows(PowerShell)

gcloud healthcare fhir-stores describe FHIR_STORE_ID `
 --dataset=DATASET_ID `
 --location=LOCATION

Windows(cmd.exe)

gcloud healthcare fhir-stores describe FHIR_STORE_ID ^
 --dataset=DATASET_ID ^
 --location=LOCATION

다음과 비슷한 응답이 표시됩니다.

FhirStore 리소스에서 필드를 구성한 경우 응답에도 표시됩니다.

응답

...
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID
...
version: FHIR_STORE_VERSION

REST

FHIR 저장소에 대한 세부정보를 가져오려면 projects.locations.datasets.fhirStores.get 메서드를 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID" | Select-Object -Expand Content

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

다음과 비슷한 응답이 표시됩니다.

FhirStore 리소스에서 필드를 구성한 경우 응답에도 표시됩니다.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// getFHIRStore gets an FHIR store.
func getFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.FhirStores

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/fhirStores/%s", projectID, location, datasetID, fhirStoreID)

	store, err := storesService.Get(name).Do()
	if err != nil {
		return fmt.Errorf("Get: %w", err)
	}

	fmt.Fprintf(w, "Got FHIR store: %q\n", store.Name)
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.FhirStore;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

public class FhirStoreGet {
  private static final String FHIR_NAME = "projects/%s/locations/%s/datasets/%s/fhirStores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void fhirStoreGet(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Create request and configure any parameters.
    FhirStores.Get request =
        client.projects().locations().datasets().fhirStores().get(fhirStoreName);

    // Execute the request and process the results.
    FhirStore store = request.execute();
    System.out.println("FHIR store retrieved: \n" + store.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const getFhirStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const fhirStoreId = 'my-fhir-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
  const request = {name};

  const fhirStore =
    await healthcare.projects.locations.datasets.fhirStores.get(request);
  console.log(fhirStore.data);
};

getFhirStore();

Python

def get_fhir_store(project_id, location, dataset_id, fhir_store_id):
    """Gets the specified FHIR store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    # Imports Python's built-in "json" module
    import json

    api_version = "v1"
    service_name = "healthcare"
    # Instantiates an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the FHIR store's parent dataset
    # fhir_store_id = 'my-fhir-store'  # replace with the FHIR store's ID
    fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    fhir_store_name = f"{fhir_store_parent}/fhirStores/{fhir_store_id}"

    fhir_stores = client.projects().locations().datasets().fhirStores()
    fhir_store = fhir_stores.get(name=fhir_store_name).execute()

    print(json.dumps(fhir_store, indent=2))
    return fhir_store

데이터 세트의 FHIR 저장소 나열

다음 샘플은 데이터 세트의 FHIR 저장소를 나열하는 방법을 보여줍니다.

콘솔

데이터 세트의 데이터 스토어를 보려면 다음 안내를 따르세요.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. 보려는 데이터 스토어가 포함된 데이터 세트를 선택합니다.

gcloud

FHIR 저장소에 대한 세부정보를 보려면 gcloud healthcare fhir-stores list 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • LOCATION: 데이터 세트 위치

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud healthcare fhir-stores list --dataset=DATASET_ID --location=LOCATION

Windows(PowerShell)

gcloud healthcare fhir-stores list --dataset=DATASET_ID --location=LOCATION

Windows(cmd.exe)

gcloud healthcare fhir-stores list --dataset=DATASET_ID --location=LOCATION

다음과 비슷한 응답이 표시됩니다.

FhirStore 리소스에서 필드를 구성한 경우 응답에도 표시됩니다.

ID             LOCATION     REF_INT  RES_VER  UPDATE_CREATE  TOPIC
FHIR_STORE_ID  LOCATION                                       PUBSUB_TOPIC
...

REST

데이터 세트의 FHIR 저장소를 나열하려면 projects.locations.datasets.fhirStores.list 메서드를 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • LOCATION: 데이터 세트 위치

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores" | Select-Object -Expand Content

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

다음과 비슷한 응답이 표시됩니다.

FhirStore 리소스에서 필드를 구성한 경우 응답에도 표시됩니다.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// listFHIRStores prints a list of FHIR stores to w.
func listFHIRStores(w io.Writer, projectID, location, datasetID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.FhirStores

	parent := fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID)

	resp, err := storesService.List(parent).Do()
	if err != nil {
		return fmt.Errorf("List: %w", err)
	}

	fmt.Fprintln(w, "FHIR stores:")
	for _, s := range resp.FhirStores {
		fmt.Fprintln(w, s.Name)
	}
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.FhirStore;
import com.google.api.services.healthcare.v1.model.ListFhirStoresResponse;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class FhirStoreList {
  private static final String DATASET_NAME = "projects/%s/locations/%s/datasets/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void fhirStoreList(String datasetName) throws IOException {
    // String datasetName =
    //    String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Results are paginated, so multiple queries may be required.
    String pageToken = null;
    List<FhirStore> stores = new ArrayList<>();
    do {
      // Create request and configure any parameters.
      FhirStores.List request =
          client
              .projects()
              .locations()
              .datasets()
              .fhirStores()
              .list(datasetName)
              .setPageSize(100) // Specify pageSize up to 1000
              .setPageToken(pageToken);

      // Execute response and collect results.
      ListFhirStoresResponse response = request.execute();
      stores.addAll(response.getFhirStores());

      // Update the page token for the next request.
      pageToken = response.getNextPageToken();
    } while (pageToken != null);

    // Print results.
    System.out.printf("Retrieved %s Fhir stores: \n", stores.size());
    for (FhirStore data : stores) {
      System.out.println("\t" + data.toPrettyString());
    }
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const listFhirStores = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {parent};

  const fhirStores =
    await healthcare.projects.locations.datasets.fhirStores.list(request);
  console.log(JSON.stringify(fhirStores.data));
};

listFhirStores();

Python

def list_fhir_stores(project_id, location, dataset_id):
    """Lists the FHIR stores in the given dataset.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Instantiates an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the dataset's location
    # dataset_id = 'my-dataset'  # replace with the parent dataset's ID
    fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )

    fhir_stores = (
        client.projects()
        .locations()
        .datasets()
        .fhirStores()
        .list(parent=fhir_store_parent)
        .execute()
        .get("fhirStores", [])
    )

    for fhir_store in fhir_stores:
        print(fhir_store)

    return fhir_stores

FHIR 저장소의 기능 또는 적합성 명세 가져오기

다음 샘플은 FHIR 저장소의 기능(STU3 또는 R4) 또는 적합성(DSTU2) 명세를 가져오는 방법을 보여줍니다.

기능 또는 적합성 명세의 정보에는 FHIR 저장소의 설정이 반영됩니다. 예를 들어 FhirStore.enableUpdateCreatetrue로 설정된 경우 기능 명세의 CapabilityStatement.rest.resource.updateCreate 필드에 반영됩니다.

다음 표에서는 FHIR 저장소의 기능 또는 적합성 명세를 가져오는 Cloud Healthcare API 메서드와 이에 상응하는 FHIR 사양 상호작용을 보여줍니다.

Cloud Healthcare API 메서드 FHIR 사양 상호작용
projects.locations.datasets.fhirStores.fhir.capabilities 기능(STU3 또는 R4) 또는 conformance (DSTU2)

콘솔

Google Cloud 콘솔과 gcloud CLI는 이 작업을 지원하지 않습니다. 대신 curl, PowerShell 또는 사용자가 선호하는 언어를 사용합니다.

gcloud

Google Cloud 콘솔과 gcloud CLI는 이 작업을 지원하지 않습니다. 대신 curl, PowerShell 또는 사용자가 선호하는 언어를 사용합니다.

REST

FHIR 저장소의 기능 또는 적합성 명세를 가져오려면 projects.locations.datasets.fhirStores.fhir.capabilities 메서드를 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/metadata"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/metadata" | Select-Object -Expand Content

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

다음과 비슷한 JSON 응답이 표시됩니다.

Go

import (
	"context"
	"fmt"
	"io"
	"io/ioutil"

	healthcare "google.golang.org/api/healthcare/v1"
)

// getFHIRMetadata gets FHIR store metadata.
func getFHIRMetadata(w io.Writer, projectID, location, datasetID, fhirStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	fhirService := healthcareService.Projects.Locations.Datasets.FhirStores.Fhir

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/fhirStores/%s", projectID, location, datasetID, fhirStoreID)

	resp, err := fhirService.Capabilities(name).Do()
	if err != nil {
		return fmt.Errorf("Capabilities: %w", err)
	}

	defer resp.Body.Close()

	respBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return fmt.Errorf("could not read response: %w", err)
	}

	if resp.StatusCode > 299 {
		return fmt.Errorf("Capabilities: status %d %s: %s", resp.StatusCode, resp.Status, respBytes)
	}
	fmt.Fprintf(w, "%s", respBytes)
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores.Fhir.Capabilities;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.HttpBody;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

public class FhirStoreGetMetadata {
  private static final String FHIR_NAME = "projects/%s/locations/%s/datasets/%s/fhirStores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void fhirStoreGetMetadata(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "project-id", "region-id", "dataset-id", "store-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Create request and configure any parameters.
    Capabilities request =
        client.projects().locations().datasets().fhirStores().fhir().capabilities(fhirStoreName);

    // Execute the request and process the results.
    HttpBody response = request.execute();
    System.out.println("FHIR store metadata retrieved: " + response.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const getFhirStoreCapabilities = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const fhirStoreId = 'my-fhir-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/metadata`;
  const request = {name};

  const fhirStore =
    await healthcare.projects.locations.datasets.fhirStores.get(request);
  console.log(JSON.stringify(fhirStore.data, null, 2));
};

getFhirStoreCapabilities();

Python

def get_fhir_store_metadata(project_id, location, dataset_id, fhir_store_id):
    """Gets the FHIR capability statement (STU3, R4), or the conformance statement
    in the DSTU2 case for the store, which contains a description of functionality
    supported by the server.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    # Imports Python's built-in "json" module
    import json

    api_version = "v1"
    service_name = "healthcare"
    # Instantiates an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the parent dataset's ID
    # fhir_store_id = 'my-fhir-store' # replace with the FHIR store ID
    fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    fhir_store_name = f"{fhir_store_parent}/fhirStores/{fhir_store_id}"

    fhir_stores = client.projects().locations().datasets().fhirStores()
    response = fhir_stores.fhir().capabilities(name=fhir_store_name).execute()

    print(json.dumps(response, indent=2))
    return response

기본 리소스 유효성 검사 수준 설정

기본적으로 FHIR 저장소의 모든 리소스에는 리소스에 적용되는 기본 리소스 유효성 검사가 있습니다. 유효성 검사에서는 리소스를 만들 때 리소스가 다음과 같은지 확인합니다.

  • 모든 필수 필드가 정의되어 있습니다.
  • 참조된 모든 리소스 유형이 유효합니다.
  • 리소스가 모든 FHIRPath 제약조건을 충족합니다.

FHIR 저장소에 대한 이러한 유형의 기본 리소스 유효성 검사 중 하나 이상을 중지하면 기본 리소스 유효성 검사를 덜 엄격하게 적용할 수 있습니다.

콘솔

Google Cloud 콘솔과 gcloud CLI는 이 작업을 지원하지 않습니다. 대신 curl, PowerShell 또는 사용자가 선호하는 언어를 사용합니다.

gcloud

Google Cloud 콘솔과 gcloud CLI는 이 작업을 지원하지 않습니다. 대신 curl, PowerShell 또는 사용자가 선호하는 언어를 사용합니다.

REST

기존 FHIR 저장소의 기본 리소스 유효성 검사를 중지하려면 projects.locations.datasets.fhirStores.patch 메서드를 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • LOCATION: 데이터 세트 위치
  • BASE_RESOURCE_VALIDATION_TYPE: 중지할 기본 리소스 유효성 검사 유형 유효성 검사를 중지하려면 다음 필드 중 하나를 true로 설정합니다.
    • disableRequiredFieldValidation
    • disableReferenceTypeValidation
    • disableFhirpathValidation

JSON 요청 본문:

{
  "validationConfig": {
    "BASE_RESOURCE_VALIDATION_TYPE": true
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

cat > request.json << 'EOF'
{
  "validationConfig": {
    "BASE_RESOURCE_VALIDATION_TYPE": true
  }
}
EOF

그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID?updateMask=validationConfig"

PowerShell

요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

@'
{
  "validationConfig": {
    "BASE_RESOURCE_VALIDATION_TYPE": true
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID?updateMask=validationConfig" | Select-Object -Expand Content

API 탐색기

요청 본문을 복사하고 메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 요청 본문을 이 도구에 붙여넣고 다른 필수 필드를 입력한 후 실행을 클릭합니다.

다음과 비슷한 응답이 표시됩니다.

FhirStore 리소스에서 필드를 구성한 경우 응답에도 표시됩니다.

FHIR 저장소 삭제

다음 샘플은 FHIR 저장소 삭제 방법을 보여줍니다.

콘솔

데이터 스토어를 삭제하려면 다음 안내를 따르세요.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.

    데이터 세트로 이동

  2. 삭제할 데이터 스토어가 포함된 데이터 세트를 선택합니다.
  3. 삭제할 데이터 스토어의 작업 드롭다운 목록에서 삭제를 선택합니다.
  4. 확인하려면 데이터 스토어 이름을 입력한 다음 삭제를 클릭합니다.

gcloud

FHIR 저장소를 삭제하려면 gcloud healthcare fhir-stores delete 명령어를 실행합니다.

아래의 명령어 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID

다음 명령어를 실행합니다.

Linux, macOS 또는 Cloud Shell

gcloud healthcare fhir-stores delete FHIR_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION

Windows(PowerShell)

gcloud healthcare fhir-stores delete FHIR_STORE_ID `
  --dataset=DATASET_ID `
  --location=LOCATION

Windows(cmd.exe)

gcloud healthcare fhir-stores delete FHIR_STORE_ID ^
  --dataset=DATASET_ID ^
  --location=LOCATION

다음과 비슷한 응답이 표시됩니다.

Deleted fhirStore [FHIR_STORE_ID].

REST

FHIR 저장소를 삭제하려면 projects.locations.datasets.fhirStores.delete 메서드를 사용합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_ID: Google Cloud 프로젝트의 ID
  • LOCATION: 데이터 세트 위치
  • DATASET_ID: FHIR 저장소의 상위 데이터 세트
  • FHIR_STORE_ID: FHIR 저장소 ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID" | Select-Object -Expand Content

API 탐색기

메서드 참조 페이지를 엽니다. 페이지 오른쪽에 API 탐색기 패널이 열립니다. 이 도구를 사용하여 요청을 보낼 수 있습니다. 모든 필수 필드를 입력하고 실행을 클릭합니다.

다음과 비슷한 JSON 응답이 표시됩니다.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// deleteFHIRStore deletes an FHIR store.
func deleteFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.FhirStores

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/fhirStores/%s", projectID, location, datasetID, fhirStoreID)

	if _, err := storesService.Delete(name).Do(); err != nil {
		return fmt.Errorf("Delete: %w", err)
	}

	fmt.Fprintf(w, "Deleted FHIR store: %q\n", fhirStoreID)
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

public class FhirStoreDelete {
  private static final String FHIR_NAME = "projects/%s/locations/%s/datasets/%s/fhirStores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void fhirStoreDelete(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Create request and configure any parameters.
    FhirStores.Delete request =
        client.projects().locations().datasets().fhirStores().delete(fhirStoreName);

    // Execute the request and process the results.
    request.execute();
    System.out.println("FHIR store deleted.");
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const deleteFhirStore = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const fhirStoreId = 'my-fhir-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
  const request = {name};

  await healthcare.projects.locations.datasets.fhirStores.delete(request);
  console.log(`Deleted FHIR store: ${fhirStoreId}`);
};

deleteFhirStore();

Python

def delete_fhir_store(project_id, location, dataset_id, fhir_store_id):
    """Deletes the specified FHIR store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the FHIR store's parent dataset
    # fhir_store_id = 'my-fhir-store'  # replace with the FHIR store's ID
    fhir_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    fhir_store_name = f"{fhir_store_parent}/fhirStores/{fhir_store_id}"

    request = (
        client.projects()
        .locations()
        .datasets()
        .fhirStores()
        .delete(name=fhir_store_name)
    )

    response = request.execute()
    print(f"Deleted FHIR store: {fhir_store_id}")

    return response

다음 단계

FHIR 리소스를 만들고 사용하는 방법 알아보기