Python용 Azure Cognitive Services Health Insights 임상 일치 클라이언트 라이브러리 - 버전 1.0.0b1

Health Insights 는 여러 Cognitive Services, 의료 API 서비스 및 기타 Azure 리소스를 활용하는 Azure Cognitive Services 프레임워크를 사용하여 빌드된 Azure Applied AI Service입니다. 임상 일치 모델은 환자 데이터 및 임상 시험 프로토콜을 수신하고 자격 기준에 따라 관련 임상 시험을 제공합니다.

소스 코드 | 패키지(PyPI) | API 참조 설명서 | 제품 설명서 | 샘플

시작

필수 조건

  • 이 패키지를 사용하려면 Python 3.7 이상이 필요합니다.
  • 이 패키지를 사용하려면 Azure 구독 이 필요합니다.
  • 기존 Cognitive Services Health Insights instance.

패키지 설치

pip install azure-healthinsights-clinicalmatching

다음 표에서는 SDK 버전 및 지원되는 API 버전의 서비스 간 관계를 보여 줍니다.

SDK 버전 지원되는 API 버전의 서비스
1.0.0b1 2023-03-01-preview

클라이언트 인증

엔드포인트 가져오기

Azure Portal 또는 Azure CLI를 사용하여 Health Insights 서비스 리소스에 대한 엔드포인트를 찾을 수 있습니다.

# Get the endpoint for the Health Insights service resource
az cognitiveservices account show --name "resource-name" --resource-group "resource-group-name" --query "properties.endpoint"

API 키 가져오기

Azure Portal의 Health Insights 서비스 리소스에서 API 키를 가져올 수 있습니다. 또는 아래 Azure CLI 코드 조각을 사용하여 리소스의 API 키를 가져올 수 있습니다.

az cognitiveservices account keys list --resource-group <your-resource-group-name> --name <your-resource-name>

API 키 자격 증명을 사용하여 ClinicalMatchingClient 만들기

API 키에 대한 값이 있으면 AzureKeyCredential의 instance 문자열로 전달할 수 있습니다. 키를 자격 증명 매개 변수로 사용하여 클라이언트를 인증합니다.

import os
from azure.core.credentials import AzureKeyCredential
from azure.healthinsights.clinicalmatching import ClinicalMatchingClient

KEY = os.environ["HEALTHINSIGHTS_KEY"]
ENDPOINT = os.environ["HEALTHINSIGHTS_ENDPOINT"]

trial_matcher_client = ClinicalMatchingClient(endpoint=ENDPOINT, credential=AzureKeyCredential(KEY))

Long-Running 작업

장기 실행 작업은 작업을 시작하기 위해 서비스로 전송된 초기 요청으로 구성된 작업이며, 그 다음에는 간격으로 서비스를 폴링하여 작업이 완료되었는지 또는 실패했는지, 성공했는지 여부를 확인하여 결과를 가져옵니다.

의료 분석, 사용자 지정 텍스트 분석 또는 여러 분석을 지원하는 메서드는 장기 실행 작업으로 모델링됩니다. 클라이언트는 폴러 개체를 begin_<method-name> 반환하는 메서드를 노출합니다. 호출자는 메서드에서 begin_<method-name> 반환된 폴러 개체를 호출 result() 하여 작업이 완료되기를 기다려야 합니다. 샘플 코드 조각은 아래의 장기 실행 작업 를 사용하여 설명하기 위해 제공됩니다.

주요 개념

평가판 일치자는 서비스 사용자에게 두 가지 기본 운영 모드인 환자 중심 및 임상 시험 중심을 제공합니다.

  • 환자 중심 모드에서 평가판 일치 모델은 환자 및/또는 서비스 사용자가 우선 순위를 지정할 수 있는 임상 상태, 위치, 우선 순위, 자격 기준 및 기타 기준에 따라 환자 일치를 기반으로 합니다. 이 모델은 특정 환자가 자격을 갖춘 것으로 보이는 더 작은 시험 세트로 관련 임상 시험 세트를 좁히고 우선 순위를 지정하는 데 도움이됩니다.
  • 임상 시험 중심에서, 시험 일치자는 잠재적으로 임상 시험에 적격한 환자의 그룹을 찾고 있습니다. 시험 일치자는 환자를 좁혀, 먼저 임상 상태에 필터링 및 선택한 임상 관찰, 다음 기준 기준을 충족 그 환자에 초점을 맞추고, 시험에 적격 환자로 보이는 환자의 그룹을 찾기 위해.

예제

다음 섹션에서는 다음과 같은 가장 일반적인 Health Insights - 임상 일치 서비스 작업 중 일부를 다루는 몇 가지 코드 조각을 제공합니다.

평가판 일치

환자를 위한 잠재적인 적격 예심을 찾는.

import os
import datetime
from azure.core.credentials import AzureKeyCredential
from azure.healthinsights.clinicalmatching import ClinicalMatchingClient, models

KEY = os.environ["HEALTHINSIGHTS_KEY"]
ENDPOINT = os.environ["HEALTHINSIGHTS_ENDPOINT"]

# Create a Trial Matcher client
# <client>
trial_matcher_client = ClinicalMatchingClient(endpoint=ENDPOINT,
                                              credential=AzureKeyCredential(KEY))
# </client>

# Create clinical info list
# <clinicalInfo>
clinical_info_list = [models.ClinicalCodedElement(system="http://www.nlm.nih.gov/research/umls",
                                                  code="C0032181",
                                                  name="Platelet count",
                                                  value="250000"),
                      models.ClinicalCodedElement(system="http://www.nlm.nih.gov/research/umls",
                                                  code="C0002965",
                                                  name="Unstable Angina",
                                                  value="true"),
                      models.ClinicalCodedElement(system="http://www.nlm.nih.gov/research/umls",
                                                  code="C1522449",
                                                  name="Radiotherapy",
                                                  value="false"),
                      models.ClinicalCodedElement(system="http://www.nlm.nih.gov/research/umls",
                                                  code="C0242957",
                                                  name="GeneOrProtein-Expression",
                                                  value="Negative;EntityType:GENEORPROTEIN-EXPRESSION"),
                      models.ClinicalCodedElement(system="http://www.nlm.nih.gov/research/umls",
                                                  code="C1300072",
                                                  name="cancer stage",
                                                  value="2")]

# </clinicalInfo>

# Construct Patient
# <PatientConstructor>
patient_info = models.PatientInfo(sex=models.PatientInfoSex.MALE, birth_date=datetime.date(1965, 12, 26),
                                  clinical_info=clinical_info_list)
patient1 = models.PatientRecord(id="patient_id", info=patient_info)
# </PatientConstructor>

# Create registry filter
registry_filters = models.ClinicalTrialRegistryFilter()
# Limit the trial to a specific patient condition ("Non-small cell lung cancer")
registry_filters.conditions = ["non small cell lung cancer (nsclc)"]
# Specify the clinical trial registry source as ClinicalTrials.Gov
registry_filters.sources = [models.ClinicalTrialSource.CLINICALTRIALS_GOV]
# Limit the clinical trial to a certain location, in this case California, USA
registry_filters.facility_locations = [
    models.GeographicLocation(country_or_region="United States", city="Gilbert", state="Arizona")]
# Limit the trial to a specific recruitment status
registry_filters.recruitment_statuses = [models.ClinicalTrialRecruitmentStatus.RECRUITING]

# Construct ClinicalTrial instance and attach the registry filter to it.
clinical_trials = models.ClinicalTrials(registry_filters=[registry_filters])

# Create TrialMatcherRequest
configuration = models.TrialMatcherModelConfiguration(clinical_trials=clinical_trials)
trial_matcher_data = models.TrialMatcherData(patients=[patient1], configuration=configuration)

poller = trial_matcher_client.begin_match_trials(trial_matcher_data)
trial_matcher_result = poller.result()
if trial_matcher_result.status == models.JobStatus.SUCCEEDED:
    tm_results = trial_matcher_result.results
    for patient_result in tm_results.patients:
        print(f"Inferences of Patient {patient_result.id}")
        for tm_inferences in patient_result.inferences:
            print(f"Trial Id {tm_inferences.id}")
            print(f"Type: {str(tm_inferences.type)}  Value: {tm_inferences.value}")
            print(f"Description {tm_inferences.description}")
else:
    tm_errors = trial_matcher_result.errors
    if tm_errors is not None:
        for error in tm_errors:
            print(f"{error.code} : {error.message}")

문제 해결

일반

Health Insights 임상 일치 클라이언트 라이브러리는 Azure Core에 정의된 예외를 발생합니다.

로깅

이 라이브러리는 로깅에 표준 로깅 라이브러리를 사용합니다.

HTTP 세션(URL, 헤더 등)에 대한 기본 정보는 수준에서 기록됩니다 INFO .

DEBUG 요청/응답 본문 및 수정되지 않은 헤더를 포함한 자세한 수준 로깅은 클라이언트 또는 키워드(keyword) 인수를 logging_enable 사용하여 작업별로 사용하도록 설정할 수 있습니다.

여기에 예제가 있는 전체 SDK 로깅 설명서를 참조 하세요.

선택적 구성

선택적 키워드(keyword) 인수는 클라이언트 및 작업별 수준에서 전달할 수 있습니다. azure-core 참조 설명서 에서는 재시도, 로깅, 전송 프로토콜 등에 사용할 수 있는 구성에 대해 설명합니다.

다음 단계

추가 설명서

Azure Health Insights 임상 일치에 대한 보다 광범위한 설명서는 docs.microsoft.com 대한 임상 일치 설명서를 참조하세요 .

참여

이 프로젝트에 대한 기여와 제안을 환영합니다. 대부분의 경우 기여하려면 권한을 부여하며 실제로 기여를 사용할 권한을 당사에 부여한다고 선언하는 CLA(기여자 라이선스 계약)에 동의해야 합니다. 자세한 내용은 https://cla.microsoft.com 을 참조하세요.

끌어오기 요청을 제출하면 CLA-bot은 CLA를 제공하고 PR을 적절하게 데코레이팅해야 하는지 여부를 자동으로 결정합니다(예: 레이블, 설명). 봇에서 제공하는 지침을 따르기만 하면 됩니다. 이 작업은 CLA를 사용하여 모든 리포지토리에서 한 번만 수행하면 됩니다.

이 프로젝트에는 Microsoft Open Source Code of Conduct(Microsoft 오픈 소스 준수 사항)가 적용됩니다. 자세한 내용은 준수 사항 FAQ를 참조하거나 opencode@microsoft.com에 추가 질문 또는 의견을 알려주세요.