Membuat dan mengelola penyimpanan HL7v2

Halaman ini menjelaskan cara membuat, mengedit, melihat, dan menghapus penyimpanan Health Level Seven Versi 2.x (HL7v2). Penyimpanan HL7v2 menyimpan pesan HL7v2, yang digunakan untuk mengirimkan data klinis antar-sistem.

Membuat penyimpanan HL7v2

Agar dapat membuat penyimpanan HL7v2, Anda harus membuat set data.

Saat membuat penyimpanan HL7v2, tentukan versi parser V3. Anda tidak dapat mengubah versi parser setelah membuat penyimpanan HL7v2.

Contoh berikut menunjukkan cara membuat penyimpanan HL7v2 menggunakan parser V3.

Konsol

  1. Di konsol Google Cloud, buka halaman Datasets.

    Buka Set Data

  2. Pilih set data tempat Anda ingin membuat penyimpanan HL7v2. Halaman Dataset akan ditampilkan.

  3. Klik Buat penyimpanan data. Halaman Buat penyimpanan data akan ditampilkan.

  4. Di menu Type, pilih HL7v2.

  5. Di kolom ID, masukkan nama untuk toko HL7v2. Nama dalam set data harus unik. Lihat Persyaratan karakter dan ukuran yang diizinkan untuk persyaratan penamaan lainnya.

  6. Klik Next. Bagian Mengonfigurasi penyimpanan HL7v2 akan ditampilkan.

  7. Konfigurasikan setelan berikut:

    1. Di bagian Version, jangan ubah pilihan V3 default.
    2. Untuk mengizinkan pembuatan dan penyerapan pesan HL7v2 tanpa header, pilih Allow null message headers (MSH).
    3. Untuk menyiapkan terminator segmen khusus, klik Tetapkan terminator segmen khusus dan masukkan terminator di bidang Terminator segmen. Untuk mengetahui informasi selengkapnya, lihat Menyetel terminator segmen.
    4. Untuk menolak pesan HL7v2 masuk dengan byte mentah yang sama dengan pesan HL7v2 yang sudah ada di penyimpanan HL7v2, pilih Reject duplicate messages.
  8. Klik Next. Bagian Receive Cloud Pub/Sub notifications ditampilkan.

  9. Jika ingin menerima notifikasi Pub/Sub saat peristiwa klinis terjadi di penyimpanan HL7v2 Anda, tentukan topik Pub/Sub. Topik harus ada sebelum Anda dapat mengonfigurasinya di penyimpanan HL7v2.

  10. Klik Next. Bagian Tambahkan label untuk mengatur penyimpanan data Anda akan ditampilkan.

  11. Untuk menambahkan satu atau beberapa label kunci/nilai ke penyimpanan HL7v2, klik Tambahkan label. Untuk mengetahui informasi selengkapnya tentang label resource, lihat Menggunakan label resource.

  12. Klik Create. Halaman Set data akan ditampilkan, dan penyimpanan HL7v2 ditampilkan di tabel Penyimpanan data.

gcloud

Google Cloud CLI tidak mendukung penetapan versi parser saat membuat penyimpanan HL7v2. Sebagai gantinya, gunakan konsol Google Cloud, curl, PowerShell, atau bahasa pilihan Anda.

REST

Untuk membuat penyimpanan HL7v2, gunakan metode projects.locations.datasets.hl7V2Stores.create.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

Meminta isi JSON:

{
  "parserConfig": {
    "version": "V3"
  }
}

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Simpan isi permintaan dalam file bernama request.json. Jalankan perintah berikut di terminal untuk membuat atau menimpa file ini di direktori saat ini:

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

Kemudian, jalankan perintah berikut untuk mengirim permintaan REST Anda:

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/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID"

PowerShell

Simpan isi permintaan dalam file bernama request.json. Jalankan perintah berikut di terminal untuk membuat atau menimpa file ini di direktori saat ini:

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

Kemudian jalankan perintah berikut untuk mengirim permintaan REST Anda:

$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/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID" | Select-Object -Expand Content

APIs Explorer

Salin isi permintaan dan buka halaman referensi metode. Panel APIs Explorer akan terbuka di sisi kanan halaman. Anda bisa berinteraksi dengan alat ini untuk mengirim permintaan. Tempelkan isi permintaan di alat ini, lengkapi kolom lainnya yang wajib diisi, lalu klik Jalankan.

Anda akan melihat respons JSON seperti berikut:

Go

import (
	"context"
	"fmt"
	"io"

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

// createHL7V2Store creates an HL7V2 store.
func createHL7V2Store(w io.Writer, projectID, location, datasetID, hl7V2StoreID 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.Hl7V2Stores

	// Set the HL7v2 store parser version to V3.
	store := &healthcare.Hl7V2Store{ParserConfig: &healthcare.ParserConfig{Version: "V3"}}
	parent := fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID)

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

	fmt.Fprintf(w, "Created HL7V2 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.Hl7V2Stores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.Hl7V2Store;
import com.google.api.services.healthcare.v1.model.ParserConfig;
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 Hl7v2StoreCreate {
  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 hl7v2StoreCreate(String datasetName, String hl7v2StoreId) throws IOException {
    // String datasetName =
    // String.format(DATASET_NAME, "your-project-id", "your-region-id",
    // "your-dataset-id");
    // String hl7v2StoreId = "your-hl7v25-id"

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

    // Configure the store to be created.
    Map<String, String> labels = new HashMap<>();
    labels.put("key1", "value1");
    labels.put("key2", "value2");
    Hl7V2Store content =
        new Hl7V2Store().setLabels(labels).setParserConfig(new ParserConfig().setVersion("V3"));

    // Create request and configure any parameters.
    Hl7V2Stores.Create request = client
        .projects()
        .locations()
        .datasets()
        .hl7V2Stores()
        .create(datasetName, content)
        .setHl7V2StoreId(hl7v2StoreId);

    // Execute the request and process the results.
    Hl7V2Store response = request.execute();
    System.out.println("Hl7V2Store 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 createHl7v2Store = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const hl7v2StoreId = 'my-hl7v2-store';
  const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {
    parent,
    hl7V2StoreId: hl7v2StoreId,
    resource: {
      parserConfig: {
        version: 'V3',
      },
    },
  };

  await healthcare.projects.locations.datasets.hl7V2Stores.create(request);
  console.log(`Created HL7v2 store: ${hl7v2StoreId}`);
};

createHl7v2Store();

Python

def create_hl7v2_store(project_id, location, dataset_id, hl7v2_store_id):
    """Creates a new HL7v2 store within the parent dataset.
    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/hl7v2
    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 HL7v2 store's parent dataset ID
    # hl7v2_store_id = 'my-hl7v2-store'  # replace with the HL7v2 store's ID
    hl7v2_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )

    # Use the V3 parser. Immutable after HL7v2 store creation.
    body = {"parserConfig": {"version": "V3"}}

    request = (
        client.projects()
        .locations()
        .datasets()
        .hl7V2Stores()
        .create(parent=hl7v2_store_parent, body=body, hl7V2StoreId=hl7v2_store_id)
    )

    response = request.execute()
    print(f"Created HL7v2 store: {hl7v2_store_id}")
    return response

Menggunakan topik dan filter Pub/Sub

Menggunakan Pub/Sub dan filter dengan penyimpanan HL7v2 adalah kasus penggunaan umum, terutama saat mengirimkan pesan HL7v2 melalui koneksi TCP/IP.

Beberapa contoh di halaman ini menunjukkan cara mengonfigurasi topik Pub/Sub yang ada yang menjadi tujuan pengiriman notifikasi peristiwa klinis oleh Cloud Healthcare API di toko HL7v2. Dengan menentukan daftar topik dan filter Pub/Sub yang ada, Cloud Healthcare API dapat mengirim notifikasi ke beberapa topik, dan Anda dapat menggunakan filter untuk membatasi notifikasi mana yang dikirim. Untuk mengetahui informasi selengkapnya tentang cara mengonfigurasi topik dan filter Pub/Sub, lihat notifikasi HL7v2 dan Melihat notifikasi HL7v2.

Mengedit penyimpanan HL7v2

Contoh berikut menunjukkan cara mengedit daftar topik dan filter Pub/Sub yang digunakan Cloud Healthcare API untuk mengirim notifikasi tentang perubahan penyimpanan HL7v2.

Beberapa contoh juga menunjukkan cara mengedit label di penyimpanan HL7v2.

Saat menentukan topik Pub/Sub, masukkan URI yang memenuhi syarat ke topik tersebut, seperti yang ditunjukkan pada contoh berikut:
projects/PROJECT_ID/topics/PUBSUB_TOPIC
Agar notifikasi dapat berfungsi, Anda harus memberikan izin tambahan ke akun layanan Agen Layanan Cloud Healthcare. Untuk mengetahui informasi selengkapnya, lihat izin Pub/Sub penyimpanan DICOM, FHIR, dan HL7v2.

Konsol

Untuk mengedit penyimpanan HL7v2, selesaikan langkah-langkah berikut:

  1. Di konsol Google Cloud, buka halaman Datasets.

    Buka Set Data

  2. Pilih set data yang berisi penyimpanan HL7v2 yang ingin Anda edit.
  3. Di daftar Penyimpanan data, klik penyimpanan data yang ingin diedit.
  4. Untuk mengedit konfigurasi penyimpanan HL7v2, klik HL7v2 Store Configuration.

    Untuk mengetahui informasi selengkapnya tentang opsi konfigurasi penyimpanan HL7v2, lihat Membuat penyimpanan HL7v2.
  5. Jika Anda ingin mengonfigurasi topik Pub/Sub untuk penyimpanan data, klik Tambahkan topik Pub/Sub dan pilih nama topik. Saat menentukan topik Pub/Sub, masukkan URI yang memenuhi syarat ke topik tersebut, seperti yang ditunjukkan pada contoh berikut:
    projects/PROJECT_ID/topics/PUBSUB_TOPIC
  6. Jika Anda telah menambahkan topik Pub/Sub, klik Selesai.
  7. Untuk menambahkan satu atau beberapa label ke toko, klik Label, klik Tambahkan label, lalu masukkan label kunci/nilai. Untuk mengetahui informasi selengkapnya tentang label resource, lihat Menggunakan label resource.
  8. Klik Save.

gcloud

Gcloud CLI tidak mendukung tindakan ini. Sebagai gantinya, gunakan konsol Google Cloud, curl, PowerShell, atau bahasa pilihan Anda.

REST

Untuk mengedit penyimpanan HL7v2, gunakan metode projects.locations.datasets.hl7V2Stores.patch.

Sebelum menjalankan contoh berikut, Anda harus membuat setidaknya satu topik Pub/Sub dalam project.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: ID project Google Cloud Anda
  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2
  • HL7V2_STORE_ID: ID toko HL7v2
  • PUBSUB_TOPIC1: topik Pub/Sub tempat pesan dipublikasikan saat terjadi peristiwa di penyimpanan data
  • FILTER1: string yang digunakan untuk mencocokkan pesan yang dipublikasikan ke PUBSUB_TOPIC1

    Lihat filter untuk mengetahui contoh nilai filter yang valid.

  • PUBSUB_TOPIC2: topik Pub/Sub tempat pesan dipublikasikan
  • FILTER2: string yang digunakan untuk mencocokkan pesan yang dipublikasikan ke PUBSUB_TOPIC2
  • KEY1: kunci label pertama
  • VALUE1: nilai label pertama
  • KEY2: kunci label kedua
  • VALUE2: nilai label kedua

Meminta isi JSON:

{
  'notificationConfigs': [
    {
      'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC1',
      'filter' : 'FILTER1'
    },
    {
      'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC2',
      'filter': 'FILTER2'
    },
  ],
  'labels': {
    'KEY1':'VALUE1',
    'KEY2':'VALUE2'
  }
}

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Simpan isi permintaan dalam file bernama request.json. Jalankan perintah berikut di terminal untuk membuat atau menimpa file ini di direktori saat ini:

cat > request.json << 'EOF'
{
  'notificationConfigs': [
    {
      'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC1',
      'filter' : 'FILTER1'
    },
    {
      'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC2',
      'filter': 'FILTER2'
    },
  ],
  'labels': {
    'KEY1':'VALUE1',
    'KEY2':'VALUE2'
  }
}
EOF

Kemudian, jalankan perintah berikut untuk mengirim permintaan REST Anda:

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/hl7V2Stores/HL7V2_STORE_ID?updateMask=notificationConfigs,labels"

PowerShell

Simpan isi permintaan dalam file bernama request.json. Jalankan perintah berikut di terminal untuk membuat atau menimpa file ini di direktori saat ini:

@'
{
  'notificationConfigs': [
    {
      'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC1',
      'filter' : 'FILTER1'
    },
    {
      'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC2',
      'filter': 'FILTER2'
    },
  ],
  'labels': {
    'KEY1':'VALUE1',
    'KEY2':'VALUE2'
  }
}
'@  | Out-File -FilePath request.json -Encoding utf8

Kemudian jalankan perintah berikut untuk mengirim permintaan REST Anda:

$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/hl7V2Stores/HL7V2_STORE_ID?updateMask=notificationConfigs,labels" | Select-Object -Expand Content

APIs Explorer

Salin isi permintaan dan buka halaman referensi metode. Panel APIs Explorer akan terbuka di sisi kanan halaman. Anda bisa berinteraksi dengan alat ini untuk mengirim permintaan. Tempelkan isi permintaan di alat ini, lengkapi kolom lainnya yang wajib diisi, lalu klik Jalankan.

Anda akan melihat respons JSON seperti berikut:

Go

import (
	"context"
	"fmt"
	"io"

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

// patchHL7V2Store updates (patches) a HL7V2 store by updating its Pub/sub topic name.
func patchHL7V2Store(w io.Writer, projectID, location, datasetID, hl7v2StoreID, 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.Hl7V2Stores

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

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

	fmt.Fprintf(w, "Patched HL7V2 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.Hl7V2Stores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.Hl7V2NotificationConfig;
import com.google.api.services.healthcare.v1.model.Hl7V2Store;
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 Hl7v2StorePatch {
  private static final String HL7v2_NAME = "projects/%s/locations/%s/datasets/%s/hl7V2Stores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void patchHl7v2Store(String hl7v2StoreName, String pubsubTopic) throws IOException {
    // String hl7v2StoreName =
    //    String.format(
    //        HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-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 HL7v2 store.
    Hl7V2Stores.Get getRequest =
        client.projects().locations().datasets().hl7V2Stores().get(hl7v2StoreName);
    Hl7V2Store store = getRequest.execute();

    Hl7V2NotificationConfig notificationConfig = new Hl7V2NotificationConfig();
    notificationConfig.setPubsubTopic(pubsubTopic);
    List<Hl7V2NotificationConfig> notificationConfigs = new ArrayList<Hl7V2NotificationConfig>();
    notificationConfigs.add(notificationConfig);
    // Update the Hl7v2Store fields as needed as needed. For a full list of Hl7v2Store fields, see:
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Store#Hl7v2Store
    store.setNotificationConfigs(notificationConfigs);

    // Create request and configure any parameters.
    Hl7V2Stores.Patch request =
        client
            .projects()
            .locations()
            .datasets()
            .hl7V2Stores()
            .patch(hl7v2StoreName, store)
            .setUpdateMask("notificationConfigs");

    // Execute the request and process the results.
    store = request.execute();
    System.out.println("HL7v2 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 patchHl7v2Store = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const hl7v2StoreId = 'my-hl7v2-store';
  // const pubsubTopic = 'my-topic'
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/hl7V2Stores/${hl7v2StoreId}`;
  const request = {
    name,
    updateMask: 'notificationConfigs',
    resource: {
      notificationConfigs: [
        {
          pubsubTopic: `projects/${projectId}/topics/${pubsubTopic}`,
        },
      ],
    },
  };

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

patchHl7v2Store();

Python

def patch_hl7v2_store(project_id, location, dataset_id, hl7v2_store_id):
    """Updates the HL7v2 store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/hl7v2
    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 HL7v2 store's parent dataset
    # hl7v2_store_id = 'my-hl7v2-store'  # replace with the HL7v2 store's ID
    hl7v2_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    hl7v2_store_name = f"{hl7v2_store_parent}/hl7V2Stores/{hl7v2_store_id}"

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

    request = (
        client.projects()
        .locations()
        .datasets()
        .hl7V2Stores()
        .patch(name=hl7v2_store_name, updateMask="notificationConfigs", body=patch)
    )

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

Mendapatkan detail toko HL7v2

Contoh berikut menunjukkan cara mendapatkan detail tentang toko HL7v2.

Konsol

Untuk melihat detail toko HL7v2:

  1. Di konsol Google Cloud, buka halaman Datasets.

    Buka Set Data

  2. Pilih set data yang berisi penyimpanan HL7v2 yang ingin Anda lihat.
  3. Klik nama toko HL7v2.
  4. Halaman Detail datastore menampilkan detail penyimpanan HL7v2 yang dipilih.

gcloud

Untuk mendapatkan detail tentang penyimpanan HL7v2, jalankan perintah gcloud healthcare hl7v2-stores describe.

Sebelum menggunakan salah satu data perintah di bawah, lakukan penggantian berikut:

  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2
  • HL7V2_STORE_ID: ID toko HL7v2

Jalankan perintah berikut:

Linux, macOS, atau Cloud Shell

gcloud healthcare hl7v2-stores describe HL7V2_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION

Windows (PowerShell)

gcloud healthcare hl7v2-stores describe HL7V2_STORE_ID `
  --dataset=DATASET_ID `
  --location=LOCATION

Windows (cmd.exe)

gcloud healthcare hl7v2-stores describe HL7V2_STORE_ID ^
  --dataset=DATASET_ID ^
  --location=LOCATION

Anda akan menerima respons seperti berikut.

Jika Anda mengonfigurasi kolom apa pun di resource Hl7V2Store, kolom tersebut juga akan muncul dalam respons.

...
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID
...

REST

Untuk mendapatkan detail tentang toko HL7v2, gunakan metode projects.locations.datasets.hl7V2Stores.get.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: ID project Google Cloud Anda
  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2
  • HL7V2_STORE_ID: ID toko HL7v2

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Jalankan perintah berikut:

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

PowerShell

Jalankan perintah berikut:

$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/hl7V2Stores/HL7V2_STORE_ID" | Select-Object -Expand Content

APIs Explorer

Buka halaman referensi metode. Panel APIs Explorer akan terbuka di sisi kanan halaman. Anda bisa berinteraksi dengan alat ini untuk mengirim permintaan. Lengkapi kolom yang wajib diisi, lalu klik Jalankan.

Anda akan menerima respons seperti berikut.

Jika Anda mengonfigurasi kolom apa pun di resource Hl7V2Store, kolom tersebut juga akan muncul dalam respons.

Go

import (
	"context"
	"fmt"
	"io"

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

// getHL7V2Store gets an HL7V2 store.
func getHL7V2Store(w io.Writer, projectID, location, datasetID, hl7v2StoreID 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.Hl7V2Stores

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

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

	fmt.Fprintf(w, "Got HL7V2 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.Hl7V2Stores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.Hl7V2Store;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

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

  public static void hl7v2eStoreGet(String hl7v2StoreName) throws IOException {
    // String hl7v2StoreName =
    //    String.format(
    //        HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-id");

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

    // Create request and configure any parameters.
    Hl7V2Stores.Get request =
        client.projects().locations().datasets().hl7V2Stores().get(hl7v2StoreName);

    // Execute the request and process the results.
    Hl7V2Store store = request.execute();
    System.out.println("HL7v2 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 getHl7v2Store = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const hl7v2StoreId = 'my-hl7v2-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/hl7V2Stores/${hl7v2StoreId}`;
  const request = {name};

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

getHl7v2Store();

Python

def get_hl7v2_store(project_id, location, dataset_id, hl7v2_store_id):
    """Gets the specified HL7v2 store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/hl7v2
    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 HL7v2 store's parent dataset
    # hl7v2_store_id = 'my-hl7v2-store'  # replace with the HL7v2 store's ID
    hl7v2_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    hl7v2_store_name = f"{hl7v2_store_parent}/hl7V2Stores/{hl7v2_store_id}"

    hl7v2_stores = client.projects().locations().datasets().hl7V2Stores()
    hl7v2_store = hl7v2_stores.get(name=hl7v2_store_name).execute()

    print("Name: {}".format(hl7v2_store.get("name")))
    if hl7v2_store.get("notificationConfigs") is not None:
        print("Notification configs:")
        for notification_config in hl7v2_store.get("notificationConfigs"):
            print(
                "\tPub/Sub topic: {}".format(notification_config.get("pubsubTopic")),
                "\tFilter: {}".format(notification_config.get("filter")),
            )

    return hl7v2_store

Mencantumkan penyimpanan HL7v2 dalam set data

Contoh berikut menunjukkan cara mencantumkan penyimpanan HL7v2 dalam set data.

Konsol

Untuk melihat penyimpanan data dalam sebuah {i>dataset<i}:

  1. Di konsol Google Cloud, buka halaman Datasets.

    Buka Set Data

  2. Pilih {i>dataset<i} berisi penyimpanan data yang ingin Anda lihat.

gcloud

Untuk menampilkan daftar penyimpanan HL7v2 di set data, jalankan perintah gcloud healthcare hl7v2-stores list.

Sebelum menggunakan salah satu data perintah di bawah, lakukan penggantian berikut:

  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2

Jalankan perintah berikut:

Linux, macOS, atau Cloud Shell

gcloud healthcare hl7v2-stores list --dataset=DATASET_ID \
  --location=LOCATION

Windows (PowerShell)

gcloud healthcare hl7v2-stores list --dataset=DATASET_ID `
  --location=LOCATION

Windows (cmd.exe)

gcloud healthcare hl7v2-stores list --dataset=DATASET_ID ^
  --location=LOCATION

Anda akan menerima respons seperti berikut.

Jika Anda mengonfigurasi kolom apa pun di resource Hl7V2Store, kolom tersebut juga akan muncul dalam respons.

ID              LOCATION     TOPIC
HL7V2_STORE_ID  LOCATION     projects/PROJECT_ID/topics/PUBSUB_TOPIC                                   PUBSUB_TOPIC
...

REST

Untuk mencantumkan penyimpanan HL7v2 di set data, gunakan metode projects.locations.datasets.hl7V2Stores.list.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: ID project Google Cloud Anda
  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Jalankan perintah berikut:

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

PowerShell

Jalankan perintah berikut:

$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/hl7V2Stores" | Select-Object -Expand Content

APIs Explorer

Buka halaman referensi metode. Panel APIs Explorer akan terbuka di sisi kanan halaman. Anda bisa berinteraksi dengan alat ini untuk mengirim permintaan. Lengkapi kolom yang wajib diisi, lalu klik Jalankan.

Anda akan menerima respons seperti berikut.

Jika Anda mengonfigurasi kolom apa pun di resource Hl7V2Store, kolom tersebut juga akan muncul dalam respons.

Go

import (
	"context"
	"fmt"
	"io"

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

// listHL7V2Stores prints a list of HL7V2 stores to w.
func listHL7V2Stores(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.Hl7V2Stores

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

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

	fmt.Fprintln(w, "HL7V2 stores:")
	for _, s := range resp.Hl7V2Stores {
		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.Hl7V2Stores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.Hl7V2Store;
import com.google.api.services.healthcare.v1.model.ListHl7V2StoresResponse;
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 Hl7v2StoreList {
  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 hl7v2StoreList(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<Hl7V2Store> stores = new ArrayList<>();
    do {
      // Create request and configure any parameters.
      Hl7V2Stores.List request =
          client
              .projects()
              .locations()
              .datasets()
              .hl7V2Stores()
              .list(datasetName)
              .setPageSize(100) // Specify pageSize up to 1000
              .setPageToken(pageToken);

      // Execute response and collect results.
      ListHl7V2StoresResponse response = request.execute();
      stores.addAll(response.getHl7V2Stores());

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

    // Print results.
    System.out.printf("Retrieved %s HL7v2 stores: \n", stores.size());
    for (Hl7V2Store 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 listHl7v2Stores = 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 hl7v2Stores =
    await healthcare.projects.locations.datasets.hl7V2Stores.list(request);
  console.log(hl7v2Stores.data);
};

listHl7v2Stores();

Python

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

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/hl7v2
    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 HL7v2 store's parent dataset
    hl7v2_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )

    hl7v2_stores = (
        client.projects()
        .locations()
        .datasets()
        .hl7V2Stores()
        .list(parent=hl7v2_store_parent)
        .execute()
        .get("hl7V2Stores", [])
    )

    for hl7v2_store in hl7v2_stores:
        print("HL7v2 store:\nName: {}".format(hl7v2_store.get("name")))
        if hl7v2_store.get("notificationConfigs") is not None:
            print("Notification configs:")
            for notification_config in hl7v2_store.get("notificationConfigs"):
                print(
                    "\tPub/Sub topic: {}".format(
                        notification_config.get("pubsubTopic")
                    ),
                    "\tFilter: {}".format(notification_config.get("filter")),
                )
    return hl7v2_stores

Menghapus penyimpanan HL7v2

Contoh berikut menunjukkan cara menghapus penyimpanan HL7v2.

Konsol

Untuk menghapus penyimpanan data:

  1. Di konsol Google Cloud, buka halaman Datasets.

    Buka Set Data

  2. Pilih set data berisi penyimpanan data yang ingin Anda hapus.
  3. Pilih Hapus dari menu drop-down Tindakan untuk penyimpanan data yang ingin Anda hapus.
  4. Untuk mengonfirmasi, ketik nama penyimpanan data, lalu klik Hapus.

gcloud

Untuk menghapus penyimpanan HL7v2, jalankan perintah gcloud healthcare hl7v2-stores delete.

Sebelum menggunakan salah satu data perintah di bawah, lakukan penggantian berikut:

  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2
  • HL7V2_STORE_ID: ID toko HL7v2

Jalankan perintah berikut:

Linux, macOS, atau Cloud Shell

gcloud healthcare hl7v2-stores delete HL7V2_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION

Windows (PowerShell)

gcloud healthcare hl7v2-stores delete HL7V2_STORE_ID `
  --dataset=DATASET_ID `
  --location=LOCATION

Windows (cmd.exe)

gcloud healthcare hl7v2-stores delete HL7V2_STORE_ID ^
  --dataset=DATASET_ID ^
  --location=LOCATION
Untuk mengonfirmasi, ketik Y. Anda akan menerima respons seperti berikut.
Deleted hl7v2Store [HL7V2_STORE_ID].

REST

Untuk menghapus penyimpanan HL7v2, gunakan metode projects.locations.datasets.hl7V2Stores.delete.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • PROJECT_ID: ID project Google Cloud Anda
  • LOCATION: lokasi set data
  • DATASET_ID: set data induk toko HL7v2
  • HL7V2_STORE_ID: ID toko HL7v2

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Jalankan perintah berikut:

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

PowerShell

Jalankan perintah berikut:

$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/hl7V2Stores/HL7V2_STORE_ID" | Select-Object -Expand Content

APIs Explorer

Buka halaman referensi metode. Panel APIs Explorer akan terbuka di sisi kanan halaman. Anda bisa berinteraksi dengan alat ini untuk mengirim permintaan. Lengkapi kolom yang wajib diisi, lalu klik Jalankan.

Anda akan menerima respons JSON yang serupa dengan berikut ini:

Go

import (
	"context"
	"fmt"
	"io"

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

// deleteHL7V2Store deletes an HL7V2 store.
func deleteHL7V2Store(w io.Writer, projectID, location, datasetID, hl7V2StoreID 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.Hl7V2Stores

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

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

	fmt.Fprintf(w, "Deleted HL7V2 store: %q\n", 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.Hl7V2Stores;
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 Hl7v2StoreDelete {
  private static final String HL7v2_NAME = "projects/%s/locations/%s/datasets/%s/hl7V2Stores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void hl7v2StoreDelete(String hl7v2StoreName) throws IOException {
    // String hl7v2StoreName =
    //    String.format(
    //        HL7v2_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-hl7v2-id");

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

    // Create request and configure any parameters.
    Hl7V2Stores.Delete request =
        client.projects().locations().datasets().hl7V2Stores().delete(hl7v2StoreName);

    // Execute the request and process the results.
    request.execute();
    System.out.println("HL7v2 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 deleteHl7v2Store = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const hl7v2StoreId = 'my-hl7v2-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/hl7V2Stores/${hl7v2StoreId}`;
  const request = {name};

  await healthcare.projects.locations.datasets.hl7V2Stores.delete(request);
  console.log(`Deleted HL7v2 store: ${hl7v2StoreId}`);
};

deleteHl7v2Store();

Python

def delete_hl7v2_store(project_id, location, dataset_id, hl7v2_store_id):
    """Deletes the specified HL7v2 store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/hl7v2
    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 HL7v2 store's parent dataset
    # hl7v2_store_id = 'my-hl7v2-store'  # replace with the HL7v2 store's ID
    hl7v2_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    hl7v2_store_name = f"{hl7v2_store_parent}/hl7V2Stores/{hl7v2_store_id}"

    request = (
        client.projects()
        .locations()
        .datasets()
        .hl7V2Stores()
        .delete(name=hl7v2_store_name)
    )

    response = request.execute()
    print(f"Deleted HL7v2 store: {hl7v2_store_id}")
    return response

Langkah selanjutnya