רענון נתונים שקשורים לשירותי בריאות

אחרי הייבוא הראשוני של נתונים למאגר נתוני הבריאות של Agent Search, יכול להיות שביצעתם עדכונים במאגר FHIR של המקור:

  • נוספו משאבי FHIR חדשים
  • עדכון משאבי FHIR קיימים
  • משאבי FHIR שנמחקו

במקרים כאלה, אפשר לסנכרן את השינויים ממקור הנתונים בפורמט FHIR אל מאגר הנתונים של Agent Search בתחום הבריאות.

סקירה כללית של פיוס

אפשר לבצע את התיקון של השינויים באופן מצטבר או מלא. הטבלה הבאה משווה בין שני המצבים.

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

לפני שמתחילים

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

ביצוע ייבוא מצטבר

בדוגמה הבאה מוצג איך לייבא שינויים מצטברים ממאגר FHIR של Cloud Healthcare API באמצעות השיטה documents.import.

REST

  1. מבצעים ייבוא מצטבר.

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -H "X-Goog-User-Project: PROJECT_ID" \
    "https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/us/dataStores/DATA_STORE_ID/branches/0/documents:import" \
    -d '{
       "reconciliation_mode": "INCREMENTAL",
       "fhir_store_source": {"fhir_store": "projects/PROJECT_ID/locations/CLOUD_HEALTHCARE_DATASET_LOCATION/datasets/CLOUD_HEALTHCARE_DATASET_ID/fhirStores/FHIR_STORE_ID"}
    }'
    

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

    • PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
    • DATA_STORE_ID: המזהה של מאגר הנתונים של חיפוש מבוסס סוכנים.
    • CLOUD_HEALTHCARE_DATASET_ID: המזהה של מערך הנתונים ב-Cloud Healthcare API שמכיל את מאגר ה-FHIR של המקור.
    • CLOUD_HEALTHCARE_DATASET_LOCATION: המיקום של מערך הנתונים של Cloud Healthcare API שמכיל את מאגר ה-FHIR של המקור.
    • FHIR_STORE_ID: המזהה של מאגר FHIR R4 ב-Cloud Healthcare API.
  2. בודקים אם פעולת הייבוא של נתוני FHIR הושלמה.

    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://us-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/us/collections/default_collection/dataStores/DATA_STORE_ID/branches/0/operations/IMPORT_OPERATION_ID"
    

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

    • PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
    • DATA_STORE_ID: המזהה של מאגר הנתונים של חיפוש מבוסס סוכנים.
    • IMPORT_OPERATION_ID: מזהה הפעולה של הפעולה הממושכת שמוחזר כשמפעילים את השיטה import.

Python

מידע נוסף מופיע בתיעוד העזר של ה-API של חיפוש מבוסס סוכנים Python.

כדי לבצע אימות ב-חיפוש מבוסס סוכנים, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

from google.api_core.client_options import ClientOptions
from google.cloud import discoveryengine

# TODO(developer): Uncomment these variables before running the sample.
# project_id = "YOUR_PROJECT_ID"
# location = "YOUR_LOCATION" # Values: "us"
# data_store_id = "YOUR_DATA_STORE_ID"
# healthcare_project_id = "YOUR_HEALTHCARE_PROJECT_ID"
# healthcare_location = "YOUR_HEALTHCARE_LOCATION"
# healthcare_dataset_id = "YOUR_HEALTHCARE_DATASET_ID"
# healthcare_fihr_store_id = "YOUR_HEALTHCARE_FHIR_STORE_ID"

#  For more information, refer to:
# https://cloud.google.com/generative-ai-app-builder/docs/locations#specify_a_multi-region_for_your_data_store
client_options = (
    ClientOptions(api_endpoint=f"{location}-discoveryengine.googleapis.com")
    if location != "global"
    else None
)

# Create a client
client = discoveryengine.DocumentServiceClient(client_options=client_options)

# The full resource name of the search engine branch.
# e.g. projects/{project}/locations/{location}/dataStores/{data_store_id}/branches/{branch}
parent = client.branch_path(
    project=project_id,
    location=location,
    data_store=data_store_id,
    branch="default_branch",
)

request = discoveryengine.ImportDocumentsRequest(
    parent=parent,
    fhir_store_source=discoveryengine.FhirStoreSource(
        fhir_store=client.fhir_store_path(
            healthcare_project_id,
            healthcare_location,
            healthcare_dataset_id,
            healthcare_fihr_store_id,
        ),
    ),
    # Options: `FULL`, `INCREMENTAL`
    reconciliation_mode=discoveryengine.ImportDocumentsRequest.ReconciliationMode.INCREMENTAL,
)

# Make the request
operation = client.import_documents(request=request)

print(f"Waiting for operation to complete: {operation.operation.name}")
response = operation.result()

# After the operation is complete,
# get information from operation metadata
metadata = discoveryengine.ImportDocumentsMetadata(operation.metadata)

# Handle the response
print(response)
print(metadata)