יצירה וניהול של חנויות HL7v2

בדף הזה מוסבר איך ליצור, לערוך, להציג ולמחוק מאגרי Health Level Seven‏ (HL7) בגרסה 2.x. מאגרי HL7v2 מכילים הודעות HL7v2, שמשמשות להעברת נתונים קליניים בין מערכות.

יצירת מאגר HL7v2

לפני שיוצרים חנות HL7v2, צריך ליצור מערך נתונים.

כשיוצרים חנות HL7v2, צריך לציין את גרסת מנתח התוכן V3. אי אפשר לשנות את גרסת כלי הניתוח אחרי שיוצרים את מאגר HL7v2.

בדוגמאות הבאות מוצג איך ליצור מאגר HL7v2 באמצעות מנתח V3.

המסוף

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שבו רוצים ליצור את החנות HL7v2. יוצג הדף Dataset.

  3. לוחצים על יצירת מאגר נתונים. יוצג הדף Create data store.

  4. בתפריט סוג, בוחרים באפשרות HL7v2.

  5. בשדה ID, מזינים שם למאגר HL7v2. השם חייב להיות ייחודי במערך הנתונים. מידע נוסף על הדרישות בנוגע לשמות זמין במאמר תווים מותרים ודרישות גודל.

  6. לוחצים על הבא. מוצג הקטע Configure your HL7v2 store (הגדרת מאגר HL7v2).

  7. מגדירים את ההגדרות הבאות:

    1. בקטע Version (גרסה), משאירים את ברירת המחדל V3 ללא שינוי.
    2. כדי לאפשר יצירה והזנה של הודעות HL7v2 ללא כותרת, בוחרים באפשרות התרת כותרות הודעות (MSH) עם ערך null.
    3. כדי להגדיר סיום פלח בהתאמה אישית, לוחצים על הגדרת סיום פלח בהתאמה אישית ומזינים את הסיום בשדה סיום פלח. מידע נוסף זמין במאמר הגדרת סיום הפלח.
    4. כדי לדחות הודעות נכנסות של HL7v2 עם אותם בייטים גולמיים כמו הודעה של HL7v2 שכבר קיימת במאגר HL7v2, בוחרים באפשרות דחיית הודעות כפולות.
  8. לוחצים על הבא. מוצג הקטע קבלת התראות Cloud Pub/Sub.

  9. אם רוצים לקבל התראות Pub/Sub כשמתרחש אירוע קליני במאגר HL7v2, צריך לציין את נושא ה-Pub/Sub. הנושא צריך להתקיים לפני שאפשר להגדיר אותו במאגר HL7v2.

  10. לוחצים על הבא. מוצג הקטע הוספת תוויות לארגון מאגרי הנתונים.

  11. כדי להוסיף תווית אחת או יותר של מפתח/ערך למאגר HL7v2, לוחצים על הוספת תווית. מידע נוסף על תוויות משאבים זמין במאמר שימוש בתוויות משאבים.

  12. לוחצים על יצירה. יוצג הדף מערך נתונים, והחנות ב-HL7v2 תוצג בטבלה מאגרי נתונים.

gcloud

כדי ליצור חנות HL7v2, מריצים את הפקודה gcloud healthcare hl7v2-stores create.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או Cloud Shell

gcloud healthcare hl7v2-stores create HL7V2_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION \
  --parser-version=v3

‏Windows (PowerShell)

gcloud healthcare hl7v2-stores create HL7V2_STORE_ID `
  --dataset=DATASET_ID `
  --location=LOCATION `
  --parser-version=v3

Windows‏ (cmd.exe)

gcloud healthcare hl7v2-stores create HL7V2_STORE_ID ^
  --dataset=DATASET_ID ^
  --location=LOCATION ^
  --parser-version=v3

אמורים לקבל תגובה שדומה לזו:

תשובה

Created hl7V2Store [HL7V2_STORE_ID].

REST

כדי ליצור מאגר HL7v2, משתמשים ב-method‏ projects.locations.datasets.hl7V2Stores.create.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

תוכן בקשת JSON:

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

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

cat > request.json << 'EOF'
{
  "parserConfig": {
    "version": "V3"
  }
}
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/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

@'
{
  "parserConfig": {
    "version": "V3"
  }
}
'@  | 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/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID" | Select-Object -Expand Content

APIs Explorer

מעתיקים את גוף הבקשה ופותחים את דף העזר של השיטה. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. מדביקים את גוף הבקשה בכלי הזה, ממלאים את כל שדות החובה ולוחצים על Execute.

אתם אמורים לקבל תגובת JSON שדומה לזו:

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> 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

שימוש בנושאים ובמסננים ב-Pub/Sub

שימוש ב-Pub/Sub ובמסננים עם מאגרי HL7v2 הוא תרחיש שימוש נפוץ, במיוחד כשמעבירים הודעות HL7v2 בחיבורי TCP/IP.

חלק מהדוגמאות בדף הזה מראות איך להגדיר נושא קיים ב-Pub/Sub שאליו Cloud Healthcare API שולח התראות על אירועים קליניים במאגר HL7v2. באמצעות ציון של רשימת נושאי Pub/Sub ומסננים קיימים, Cloud Healthcare API יכול לשלוח התראות לכמה נושאים, ואפשר להשתמש במסננים כדי להגביל את ההתראות שנשלחות. מידע נוסף על הגדרת נושאים ומסננים ב-Pub/Sub זמין במאמרים התראות HL7v2 והצגת התראות HL7v2.

עריכה של מאגר HL7v2

בדוגמאות הבאות מוצגות דרכים לערוך את רשימת הנושאים והמסננים של Pub/Sub שבהם Cloud Healthcare API משתמש כדי לשלוח התראות על שינויים במאגר HL7v2.

חלק גדול מהדוגמאות גם מראות איך לערוך את התוויות בחנות HL7v2.

כשמציינים נושא ב-Pub/Sub, מזינים את ה-URI המלא של הנושא, כמו שמוצג בדוגמה הבאה:
projects/PROJECT_ID/topics/PUBSUB_TOPIC
כדי שההתראות יפעלו, צריך להעניק הרשאות נוספות לסוכן השירות של Cloud Healthcare חשבון השירות. מידע נוסף זמין במאמר הרשאות Pub/Sub בחנות DICOM,‏ FHIR ו-HL7v2.

המסוף

כדי לערוך מאגר HL7v2:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר HL7v2 שרוצים לערוך.
  3. ברשימה מאגרי נתונים, לוחצים על מאגר הנתונים שרוצים לערוך.
  4. כדי לערוך את ההגדרה של חנות HL7v2, לוחצים על HL7v2 Store Configuration (הגדרת חנות HL7v2).

    מידע נוסף על אפשרויות ההגדרה של חנות HL7v2 זמין במאמר יצירת חנות HL7v2.
  5. כדי להגדיר נושא Pub/Sub למאגר הנתונים, לוחצים על Add Pub/Sub topic ובוחרים את שם הנושא. כשמציינים נושא ב-Pub/Sub, מזינים את ה-URI המלא של הנושא, כמו שמוצג בדוגמה הבאה:
    projects/PROJECT_ID/topics/PUBSUB_TOPIC
  6. אם הוספתם נושא Pub/Sub, לוחצים על סיום.
  7. כדי להוסיף תווית אחת או יותר לחנות, לוחצים על תוויות, לוחצים על הוספת תווית ומזינים את התווית של המפתח/הערך. מידע נוסף על תוויות משאבים זמין במאמר שימוש בתוויות משאבים.
  8. לוחצים על Save.

gcloud

אי אפשר לבצע את הפעולה הזו באמצעות ה-CLI של gcloud. במקום זאת, אפשר להשתמש במסוף Google Cloud , ב-curl, ב-PowerShell או בשפה המועדפת עליכם.

REST

כדי לערוך חנות HL7v2, משתמשים בשיטה projects.locations.datasets.hl7V2Stores.patch.

כדי להריץ את הדוגמאות הבאות, צריך ליצור לפחות נושא Pub/Sub אחד בפרויקט.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2
  • ‫HL7V2_STORE_ID: מזהה מאגר HL7v2
  • ‫PUBSUB_TOPIC1: נושא Pub/Sub שאליו מתפרסמות הודעות כשמתרחש אירוע במאגר נתונים
  • ‫FILTER1: מחרוזת שמשמשת להתאמת הודעות שפורסמו ב-PUBSUB_TOPIC1

    דוגמאות לערכי מסנן תקינים מופיעות במאמר filter.

  • ‫PUBSUB_TOPIC2: נושא ב-Pub/Sub שההודעות מתפרסמות בו
  • ‫FILTER2: מחרוזת שמשמשת להתאמת הודעות שפורסמו ב-PUBSUB_TOPIC2
  • ‫KEY1: מפתח התווית הראשון
  • ‫VALUE1: הערך הראשון של התווית
  • ‫KEY2: מפתח התווית השני
  • ‫VALUE2: הערך השני של התווית

תוכן בקשת 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'
  }
}

כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:

curl

שומרים את גוף הבקשה בקובץ בשם request.json. כדי ליצור או להחליף את הקובץ הזה בספרייה הנוכחית, מריצים את הפקודה הבאה בטרמינל:

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

לאחר מכן מבצעים את הפקודה הבאה כדי לשלוח את בקשת ה-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/hl7V2Stores/HL7V2_STORE_ID?updateMask=notificationConfigs,labels"

PowerShell

שומרים את גוף הבקשה בקובץ בשם request.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'
  }
}
'@  | 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/hl7V2Stores/HL7V2_STORE_ID?updateMask=notificationConfigs,labels" | Select-Object -Expand Content

APIs Explorer

מעתיקים את גוף הבקשה ופותחים את דף העזר של השיטה. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. מדביקים את גוף הבקשה בכלי הזה, ממלאים את כל שדות החובה ולוחצים על Execute.

אתם אמורים לקבל תגובת JSON שדומה לזו:

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 notificationConfigs = new ArrayList();
    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

קבלת פרטים על מאגר HL7v2

בדוגמאות הבאות מוסבר איך לקבל פרטים על חנות HL7v2.

המסוף

כדי לראות את הפרטים של חנות HL7v2:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את החנות ב-HL7v2 שרוצים להציג.
  3. לוחצים על השם של החנות ב-HL7v2.
  4. בדף פרטי מאגר הנתונים מוצגים הפרטים של מאגר HL7v2 שנבחר.

gcloud

כדי לקבל פרטים על חנות HL7v2, מריצים את הפקודה gcloud healthcare hl7v2-stores describe.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2
  • ‫HL7V2_STORE_ID: מזהה מאגר HL7v2

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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

אמורה להתקבל תגובה שדומה לזו:

אם הגדרתם שדות כלשהם במשאב Hl7V2Store, הם יופיעו גם בתשובה.

תשובה

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

REST

כדי לקבל פרטים על מאגר HL7v2, משתמשים בשיטה projects.locations.datasets.hl7V2Stores.get.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2
  • ‫HL7V2_STORE_ID: מזהה מאגר HL7v2

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

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

APIs Explorer

פותחים את דף העזר של ה-method. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. ממלאים את כל שדות החובה ולוחצים על Execute.

אמורה להתקבל תגובה שדומה לזו:

אם הגדרתם שדות כלשהם במשאב Hl7V2Store, הם יופיעו גם בתשובה.

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

הצגת רשימה של החנויות ב-HL7v2 במערך נתונים

בדוגמאות הבאות מוסבר איך להציג רשימה של החנויות ב-HL7v2 במערך נתונים.

המסוף

כדי לראות את מאגרי הנתונים במערך נתונים:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר הנתונים שרוצים להציג.

gcloud

כדי להציג רשימה של החנויות ב-HL7v2 במערך נתונים, מריצים את הפקודה gcloud healthcare hl7v2-stores list.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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

אמורה להתקבל תגובה שדומה לזו:

אם הגדרתם שדות כלשהם במשאב Hl7V2Store, הם יופיעו גם בתשובה.

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

REST

כדי להציג רשימה של החנויות ב-HL7v2 במערך נתונים, משתמשים בשיטה projects.locations.datasets.hl7V2Stores.list.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

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/hl7V2Stores"

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

APIs Explorer

פותחים את דף העזר של ה-method. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. ממלאים את כל שדות החובה ולוחצים על Execute.

אמורה להתקבל תגובה שדומה לזו:

אם הגדרתם שדות כלשהם במשאב Hl7V2Store, הם יופיעו גם בתשובה.

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 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

מחיקת מאגר HL7v2

בדוגמאות הבאות אפשר לראות איך מוחקים מאגר HL7v2.

המסוף

כדי למחוק מאגר נתונים:

  1. נכנסים לדף Datasets במסוף Google Cloud .

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שמכיל את מאגר הנתונים שרוצים למחוק.
  3. ברשימה הנפתחת פעולות, בוחרים באפשרות מחיקה של מאגר הנתונים שרוצים למחוק.
  4. כדי לאשר, מקלידים את השם של מאגר הנתונים ולוחצים על מחיקה.

gcloud

כדי למחוק מאגר HL7v2, מריצים את הפקודה gcloud healthcare hl7v2-stores delete.

לפני השימוש בנתוני הפקודה הבאים, צריך להחליף את הנתונים הבאים:

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2
  • ‫HL7V2_STORE_ID: מזהה מאגר HL7v2

מריצים את הפקודה הבאה:

‫Linux,‏ macOS או 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
כדי לאשר, מקלידים Y. אמורה להתקבל תגובה שדומה לזו:
Deleted hl7v2Store [HL7V2_STORE_ID].

REST

כדי למחוק מאגר HL7v2, משתמשים בשיטה projects.locations.datasets.hl7V2Stores.delete.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים הראשי של החנות ב-HL7v2
  • ‫HL7V2_STORE_ID: מזהה מאגר HL7v2

כדי לשלוח את הבקשה אתם צריכים לבחור אחת מהאפשרויות הבאות:

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

APIs Explorer

פותחים את דף העזר של ה-method. החלונית של API Explorer תיפתח בצד שמאל של הדף. אפשר להשתמש בכלי הזה כדי לשלוח בקשות. ממלאים את כל שדות החובה ולוחצים על Execute.

אתם אמורים לקבל תגובת JSON שדומה לזו:

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

המאמרים הבאים