יצירה וניהול של מאגרי FHIR

בדף הזה מוסבר איך ליצור, לערוך, להציג, לרשום ולמחוק מאגרי נתונים של Fast Healthcare Interoperability Resources ‏ (FHIR). מאגרי FHIR מכילים משאבי FHIR, כמו משאבי Claim, משאבי Patient, משאבי Medication ועוד.

‫Cloud Healthcare API תומך בגרסאות FHIR הבאות:

יצירת מאגר FHIR

לפני שיוצרים מאגר FHIR, צריך ליצור מערך נתונים.

בדוגמאות הבאות אפשר לראות איך ליצור מאגר FHIR באמצעות השיטה projects.locations.datasets.fhirStores.create.

המסוף

כדי ליצור מאגר FHIR:

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

    למעבר אל Datasets

  2. בוחרים את מערך הנתונים שבו רוצים ליצור מאגר FHIR.
  3. לוחצים על יצירת מאגר נתונים.
  4. בוחרים באפשרות FHIR כסוג של מאגר הנתונים.
  5. מזינים שם שייחודי למערך הנתונים. אם השם לא ייחודי, יצירת מאגר FHIR תיכשל.
  6. לוחצים על הבא.
  7. כדי להגדיר את מאגר ה-FHIR:
    1. בוחרים את גרסת FHIR לחנות FHIR, אחת מהאפשרויות DSTU2,‏ STU3 או R4.
    2. בוחרים את ההגדרות המתקדמות הרלוונטיות מתוך האפשרויות הבאות:
      • אפשר יצירה של עדכון: בוחרים באפשרות הזו כדי לאפשר יצירה של משאב חדש באמצעות פעולת עדכון עם מזהה שצוין על ידי המשתמש.
      • בדיקות של שלמות רפרנציאלית: בוחרים באפשרות הזו כדי להפעיל שלמות רפרנציאלית בחנות הזו. אי אפשר לשנות את ההגדרה הזו אחרי שיוצרים את החנות.
      • ניהול גרסאות של משאבים: בוחרים באפשרות הזו כדי לשמור באופן אוטומטי גרסאות היסטוריות של משאבים. אי אפשר לשנות את ההגדרה הזו אחרי שיוצרים את החנות.
    3. בוחרים את הגדרות האימות הרלוונטיות של הפרופיל מתוך השדות הבאים. מידע נוסף זמין במאמר בנושא ValidationConfig:
      • הפעלת אימות פרופילים: בוחרים באפשרות הזו כדי להפעיל אימות פרופילים. כדי לאכוף מדריך הטמעה שמופעל במאגר FHIR, צריך להפעיל אימות של פרופילים.
      • הפעלת אימות של שדות חובה: בוחרים באפשרות הזו כדי להפעיל אימות של שדות במשאב בהתאם להגדרות המבנה בפרופיל FHIR.
      • הפעלת אימות של סוג קובץ העזר: בוחרים באפשרות הזו כדי להפעיל אימות של סוג קובץ העזר.
      • הפעלת אימות FHIRPath: בוחרים באפשרות הזו כדי להפעיל בדיקת תאימות ל-FHIRPath.
    4. לוחצים על הבא.
  8. אופציונלי: כדי להפעיל מדריכי הטמעה בחנות FHIR, מבצעים את הפעולות הבאות:
    1. לוחצים על הפעלת מדריכי הטמעה.
    2. לוחצים על הרשימה מדריכי הטמעה כדי להרחיב אותה.
    3. בוחרים את מדריכי ההטמעה הרלוונטיים מהרשימה.

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

    4. לוחצים על ייבוא של IG מותאם אישית מ-Cloud Storage כדי לייבא חבילה של אימות פרופיל מותאם אישית ממיקום ב-Cloud Storage.
    5. בחלונית Select object, בוחרים משאב של חבילת אימות פרופיל ממיקום ב-Cloud Storage. מידע נוסף זמין במאמר בנושא שימוש במסוף Google Cloud להפעלת מדריכי הטמעה.
    6. לוחצים על בחירה.
      • מדריכי ההטמעה שנבחרו מופיעים בטבלה עם הגרסה, כתובת ה-URL והסטטוס שלהם.
      • אם הפעלתם מדריכי הטמעה אבל לא הפעלתם אימות פרופילים, מדריך ההטמעה לא ייכנס לתוקף.
      • לוחצים על הבא.
  9. אופציונלי: כדי לייצא שינויים במשאבים ל-BigQuery בכל פעם שמשאבי ה-FHIR במאגר נוצרים, מתעדכנים, מתוקנים או נמחקים, מבצעים את הפעולות הבאות:
    1. לוחצים על הזרמת שינויים במשאבים ל-BigQuery.
    2. לוחצים על הוספת הגדרת סטרימינג. מידע נוסף על סטרימינג ב-BigQuery זמין במאמר סטרימינג של שינויים במשאבי FHIR ל-BigQuery.
    3. בסרגל Recursive structure depth (עומק המבנה הרקורסיבי), בוחרים את רמת העומק כדי להגדיר את העומק של כל המבנים הרקורסיביים בסכימת הפלט. כברירת מחדל, ערך העומק הרקורסיבי הוא 2.
    4. לוחצים על סיום כדי לשמור את הגדרת הסטרימינג.
    5. לוחצים על הבא.
  10. אופציונלי: כדי להגדיר נושא Pub/Sub למאגר FHIR:
    1. לוחצים על Receive Cloud Pub/Sub notifications (קבלת התראות Cloud Pub/Sub).
    2. לוחצים על Add a Cloud Pub/Sub topic ובוחרים את שם הנושא.

      כשמציינים נושא ב-Pub/Sub, מזינים את ה-URI המלא של הנושא, כמו שמוצג בדוגמה הבאה:

      projects/PROJECT_ID/topics/PUBSUB_TOPIC

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

מאגר ה-FHIR החדש מופיע ברשימה.

gcloud

כדי ליצור מאגר FHIR במערך הנתונים, מריצים את הפקודה gcloud healthcare fhir-stores create.

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

  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים ברמת ההורה של מאגר FHIR
  • ‫FHIR_STORE_ID: מזהה של מאגר FHIR. מזהה מאגר FHIR צריך לכלול את הפרטים הבאים:
    • מזהה ייחודי במערך הנתונים
    • מחרוזת Unicode באורך 1-256 תווים, שכוללת את הרכיבים הבאים:
      • Numbers
      • מכתבים
      • קו תחתון
      • מקפים
      • פרקי הזמן
  • ‫FHIR_STORE_VERSION: גרסת ה-FHIR של מאגר ה-FHIR. האפשרויות הזמינות הן DSTU2,‏ STU3 או R4.

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

‫Linux,‏ macOS או Cloud Shell

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

‏Windows (PowerShell)

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

Windows‏ (cmd.exe)

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

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

תשובה

Created fhirStore [FHIR_STORE_ID].

REST

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

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים ברמת ההורה של מאגר FHIR
  • ‫FHIR_STORE_ID: מזהה של מאגר FHIR. מזהה מאגר FHIR צריך לכלול את הפרטים הבאים:
    • מזהה ייחודי במערך הנתונים
    • מחרוזת Unicode באורך 1-256 תווים, שכוללת את הרכיבים הבאים:
      • Numbers
      • מכתבים
      • קו תחתון
      • מקפים
      • פרקי הזמן
  • ‫FHIR_STORE_VERSION: גרסת ה-FHIR של מאגר ה-FHIR. האפשרויות הזמינות הן DSTU2,‏ STU3 או R4.

תוכן בקשת JSON:

{
  "version": "FHIR_STORE_VERSION"
}

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

curl

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

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

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

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

PowerShell

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

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

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

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

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

APIs Explorer

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

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

Go

import (
	"context"
	"fmt"
	"io"

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

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

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

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

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

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

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

Java

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

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

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

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

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

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

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

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

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

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

Node.js

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

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

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

createFhirStore();

Python

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

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

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

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

    body = {"version": version}

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

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

    return response

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

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

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

המסוף

כדי לערוך מאגר FHIR, מבצעים את השלבים הבאים:

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

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

  3. ברשימה מאגרי נתונים, בוחרים את מאגר ה-FHIR שרוצים לערוך.

  4. כדי לערוך את ההגדרה של מאגר FHIR, לוחצים על FHIR store configuration (הגדרת מאגר FHIR).

    מידע נוסף על אפשרויות ההגדרה של מאגר FHIR זמין במאמר בנושא יצירת מאגר FHIR.

  5. כדי לערוך את מדריכי ההטמעה של החנות, לוחצים על מדריכי הטמעה ובוחרים את מדריכי ההטמעה הרלוונטיים, או מייבאים מדריך הטמעה מותאם אישית מ-Cloud Storage. מידע נוסף זמין במאמר בנושא שימוש במסוף Google Cloud להפעלת מדריכי הטמעה.

    כדי לערוך את מדריכי ההטמעה או לאכוף את מדריכי ההטמעה המופעלים, צריך להפעיל את אימות הפרופיל בקטע FHIR store configuration (הגדרות של מאגר FHIR).

  6. כדי לייצא שינויים במשאבים ל-BigQuery בכל פעם שמשאבי FHIR בחנות נוצרים, מתעדכנים, עוברים תיקון או נמחקים, לוחצים על Add new streaming config בשדה Dataset.

  7. בוחרים מערך נתונים ב-BigQuery שאליו יועברו שינויים במשאבים. מידע נוסף על סטרימינג ב-BigQuery זמין במאמר סטרימינג של שינויים במשאבי FHIR ל-BigQuery.

  8. כדי להגדיר את העומק של כל המבנים הרקורסיביים בסכימת הפלט, לוחצים על העומק הרלוונטי במכוון Recursive Structure Depth (עומק המבנה הרקורסיבי). כברירת מחדל, העומק הרקורסיבי הוא 2.

  9. כדי לייצא שינויים במשאבים רק עבור סוגים ספציפיים של משאבים, בוחרים את סוגי המשאבים מהרשימה Select FHIR resource types (בחירת סוגים של משאבי FHIR).

  10. כדי להגדיר נושא Pub/Sub למאגר הנתונים, בוחרים שם של נושא בקטע Cloud Pub/Sub Notifications. כשמציינים נושא ב-Pub/Sub, מזינים את ה-URI המלא של הנושא, כמו שמוצג בדוגמה הבאה:

    projects/PROJECT_ID/topics/PUBSUB_TOPIC

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

  12. לוחצים על Save.

gcloud

כדי לערוך מאגר FHIR, מריצים את הפקודה gcloud healthcare fhir-stores update.

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

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

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

‫Linux,‏ macOS או Cloud Shell

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

‏Windows (PowerShell)

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

Windows‏ (cmd.exe)

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

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

תשובה

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

REST

כדי לערוך מאגר FHIR, משתמשים בשיטה projects.locations.datasets.fhirStores.patch.

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

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫DATASET_ID: מערך הנתונים ברמת ההורה של מאגר FHIR
  • ‫FHIR_STORE_ID: מזהה מאגר ה-FHIR
  • ‫PUBSUB_TOPIC_ID: נושא Pub/Sub שאליו מתפרסמות הודעות כשמתרחש אירוע במאגר נתונים. כדי לקבוע אילו נתונים צריך לכלול בהתראות Pub/Sub, אפשר לעיין במאמר בנושא התראות FHIR Pub/Sub.
  • ‫KEY1: מפתח התווית הראשון
  • ‫VALUE1: הערך הראשון של התווית
  • ‫KEY2: מפתח התווית השני
  • ‫VALUE2: הערך השני של התווית

תוכן בקשת JSON:

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

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

curl

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

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

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

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

PowerShell

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

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

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

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

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

APIs Explorer

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

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

Go

import (
	"context"
	"fmt"
	"io"

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

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

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

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

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

	// topicName format is "projects/*/locations/*/topics/*"
	notificationConfig := &healthcare.FhirNotificationConfig{
		PubsubTopic: topicName,
	}

	fhirStore := &healthcare.FhirStore{
		NotificationConfigs: []*healthcare.FhirNotificationConfig{notificationConfig},
	}

	patchRequest := storesService.Patch(name, fhirStore).UpdateMask("notificationConfigs")

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

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

	return nil
}

Java

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

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

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

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

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

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

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

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

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

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

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

Node.js

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

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

  try {
    const response =
      await healthcare.projects.locations.datasets.fhirStores.patch(request);
    console.log(
      `Patched FHIR store ${fhirStoreId} with Cloud Pub/Sub topic ${pubsubTopic}`
    );
    console.log(JSON.stringify(response.data, null, 2));
  } catch (error) {
    console.error('Error patching FHIR store:', error.message || error);
  }
};

patchFhirStore();

Python

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

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

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

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

    patch = {
        "notificationConfigs": [{"pubsubTopic": pubsub_topic}] if pubsub_topic else []
    }

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

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

    return response

איך מאחזרים פרטים של מאגר FHIR

בדוגמאות הבאות אפשר לראות איך מקבלים פרטים על מאגר FHIR.

המסוף

כדי לראות את הפרטים של מאגר FHIR:

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

    למעבר אל Datasets

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

gcloud

כדי לקבל פרטים על מאגר FHIR, מריצים את הפקודה gcloud healthcare fhir-stores describe.

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

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

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

‫Linux,‏ macOS או Cloud Shell

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

‏Windows (PowerShell)

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

Windows‏ (cmd.exe)

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

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

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

תשובה

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

REST

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

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

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

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

curl

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

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

PowerShell

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

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

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

APIs Explorer

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

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

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

Go

import (
	"context"
	"fmt"
	"io"

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

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

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

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

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

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

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

Java

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

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

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

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

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

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

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

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

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

Node.js

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

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

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

getFhirStore();

Python

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

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

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

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

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

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

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

הצגת רשימה של מאגרי FHIR במערך נתונים

בדוגמאות הבאות אפשר לראות איך מציגים את רשימת מאגרי ה-FHIR במערך נתונים.

המסוף

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

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

    למעבר אל Datasets

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

gcloud

כדי לראות פרטים על מאגר FHIR, מריצים את הפקודה gcloud healthcare fhir-stores list.

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

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

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

‫Linux,‏ macOS או Cloud Shell

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

‏Windows (PowerShell)

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

Windows‏ (cmd.exe)

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

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

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

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

REST

כדי להציג רשימה של מאגרי FHIR במערך נתונים, משתמשים בשיטה projects.locations.datasets.fhirStores.list.

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

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

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

curl

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

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

PowerShell

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

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

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

APIs Explorer

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

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

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

Go

import (
	"context"
	"fmt"
	"io"

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

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

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

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

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

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

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

Java

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

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

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

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

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

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

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

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

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

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

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

Node.js

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

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

  try {
    const fhirStores =
      await healthcare.projects.locations.datasets.fhirStores.list(request);
    console.log(JSON.stringify(fhirStores.data));
  } catch (error) {
    console.error('Error listing FHIR stores:', error.message || error);
  }
};

listFhirStores();

Python

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

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

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

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

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

    for fhir_store in fhir_stores:
        print(fhir_store)

    return fhir_stores

קבלת היכולות או הצהרת התאימות של מאגר FHIR

בדוגמאות הבאות אפשר לראות איך מקבלים את הצהרת היכולות (STU3,‏ R4 או R5) או את הצהרת התאימות (DSTU2) של מאגר FHIR.

המידע ביכולות או בהצהרת התאימות משקף את ההגדרות במאגר FHIR. לדוגמה, אם הערך של FhirStore.enableUpdateCreate מוגדר כ-true, הערך הזה יופיע בשדה CapabilityStatement.rest.resource.updateCreate של הצהרת היכולות.

בטבלה הבאה מוצגת השיטה של Cloud Healthcare API לקבלת היכולות או הצהרת התאימות של מאגר FHIR, והאינטראקציה המקבילה במפרט FHIR:

שיטת Cloud Healthcare API אינטראקציה עם מפרט FHIR
projects.locations.datasets.fhirStores.fhir.capabilities יכולות (STU3 או R4 או R5) או conformance (DSTU2)

המסוף

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

gcloud

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

REST

כדי לקבל את היכולות או את הצהרת התאימות של מאגר FHIR, משתמשים בשיטה projects.locations.datasets.fhirStores.fhir.capabilities.

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

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

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

curl

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

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

PowerShell

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

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

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

APIs Explorer

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

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

Go

import (
	"context"
	"fmt"
	"io"

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

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

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

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

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

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

	defer resp.Body.Close()

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

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

Java

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

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

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

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

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

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

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

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

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

Node.js

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

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

  try {
    const fhirStore =
      await healthcare.projects.locations.datasets.fhirStores.get(request);
    console.log(JSON.stringify(fhirStore.data, null, 2));
  } catch (error) {
    console.error(
      'Error getting FHIR store capabilities:',
      error.message || error
    );
  }
};

getFhirStoreCapabilities();

Python

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

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

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

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

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

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

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

הגדרת רמת האימות של משאב הבסיס

כברירת מחדל, כל המשאבים בחנות FHIR עוברים אימות של משאבי בסיס. האימות הזה מוודא שהתנאים הבאים מתקיימים כשיוצרים את המשאב:

  • כל שדות החובה מוגדרים.
  • כל סוגי המשאבים שאליהם יש הפניה הם תקינים.
  • המשאב עומד בכל המגבלות של FHIRPath.

כדי להפוך את האימות של משאבי הבסיס לפחות מחמיר, אפשר להשבית סוג אחד או יותר של אימות משאבי בסיס בחנות FHIR.

המסוף

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

gcloud

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

REST

כדי להשבית אימות של משאב בסיסי בחנות FHIR קיימת, משתמשים בשיטה projects.locations.datasets.fhirStores.patch.

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

  • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud
  • ‫DATASET_ID: מערך הנתונים ברמת ההורה של מאגר FHIR
  • ‫LOCATION: המיקום של מערך הנתונים
  • ‫BASE_RESOURCE_VALIDATION_TYPE: סוג האימות של משאב הבסיס שרוצים להשבית. כדי להשבית את האימות, מגדירים את אחד מהשדות הבאים לערך true:
    • disableRequiredFieldValidation
    • disableReferenceTypeValidation
    • disableFhirpathValidation

תוכן בקשת JSON:

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

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

curl

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

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

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

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

PowerShell

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

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

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

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

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

APIs Explorer

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

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

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

מחיקת מאגר FHIR

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

המסוף

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

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

    למעבר אל Datasets

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

gcloud

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

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

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

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

‫Linux,‏ macOS או Cloud Shell

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

‏Windows (PowerShell)

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

Windows‏ (cmd.exe)

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

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

Deleted fhirStore [FHIR_STORE_ID].

REST

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

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

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

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

curl

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

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

PowerShell

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

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

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

APIs Explorer

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

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

Go

import (
	"context"
	"fmt"
	"io"

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

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

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

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

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

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

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

Java

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

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

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

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

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

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

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

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

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

Node.js

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

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

  try {
    await healthcare.projects.locations.datasets.fhirStores.delete(request);
    console.log(`Deleted FHIR store: ${fhirStoreId}`);
  } catch (error) {
    console.error('Error deleting FHIR store:', error.message || error);
  }
};

deleteFhirStore();

Python

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

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

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

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

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

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

    return response

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

איך יוצרים משאבי FHIR ומשתמשים בהם