Skip to main content

Amazon Comprehend Medical

Amazon Comprehend Medical คือบริการ NLP เฉพาะทางที่ออกแบบมาสำหรับวิเคราะห์และสกัดข้อมูลทางการแพทย์จากข้อความที่ไม่มีโครงสร้าง (Unstructured Text) เช่น เวชระเบียน รายงานทางคลินิก บันทึกการวินิจฉัย discharge summaries และ clinical trial notes บริการนี้ใช้โมเดล Machine Learning ที่ฝึกด้วยข้อมูลทางการแพทย์จำนวนมหาศาล ทำให้สามารถเข้าใจคำศัพท์ทางการแพทย์ที่ซับซ้อนและบริบทเฉพาะทางได้อย่างแม่นยำ

บริการนี้ช่วยให้โรงพยาบาล บริษัทประกันสุขภาพ นักวิจัย และผู้พัฒนาระบบสาธารณสุขสามารถแปลงข้อความทางการแพทย์ให้กลายเป็น structured data ที่นำไปวิเคราะห์ต่อได้ทันที พร้อมทั้งรองรับมาตรฐานทางการแพทย์สากล เช่น ICD-10-CM, RxNorm และ SNOMED CT

AWS Docs: https://docs.aws.amazon.com/comprehend-medical/latest/dev/comprehendmedical-welcome.html

สถาปัตยกรรม


ฟีเจอร์หลัก

Medical Named Entity Recognition (NER)

ตรวจจับและจำแนก medical entities จากข้อความทางการแพทย์ออกเป็นหมวดหมู่หลัก ได้แก่:

  • Medication ชื่อยา ขนาดยา ความถี่ในการใช้ เส้นทางการให้ยา และระยะเวลา
  • Medical Condition โรค อาการ การวินิจฉัย และสถานะของอาการ (เช่น เรื้อรัง ฉับพลัน)
  • Anatomy อวัยวะ ส่วนของร่างกาย ทิศทาง และตำแหน่งทางกายวิภาค
  • Test, Treatment, Procedure การตรวจ การรักษา ขั้นตอนทางการแพทย์ ผลการตรวจ
  • Time Expression วันที่ เวลา ระยะเวลา และความถี่ที่เกี่ยวข้องกับเหตุการณ์ทางการแพทย์

ICD-10-CM Inference

เชื่อมโยง medical conditions ที่พบในข้อความกับรหัส ICD-10-CM (International Classification of Diseases) โดยอัตโนมัติ ช่วยลดภาระงาน medical coding อย่างมาก และรองรับทั้งการ coding diagnosis หลัก, secondary diagnosis และ symptom codes

RxNorm Inference

เชื่อมโยงชื่อยาที่พบในข้อความกับรหัส RxNorm มาตรฐาน รองรับทั้งชื่อยาสามัญ (Generic Name) และชื่อการค้า (Brand Name) ช่วยให้ระบบสามารถตรวจสอบ drug interaction และ medication reconciliation ได้

SNOMED CT Linking

เชื่อมโยง medical entities กับ SNOMED CT (Systematized Nomenclature of Medicine Clinical Terms) ซึ่งเป็นมาตรฐาน ontology ทางการแพทย์ที่ครอบคลุมที่สุดในโลก เหมาะสำหรับการแลกเปลี่ยนข้อมูลสุขภาพระหว่างระบบ

Protected Health Information (PHI) Detection

ตรวจจับและสกัด PHI ตามมาตรฐาน HIPAA จากข้อความทางการแพทย์ ครอบคลุม 27 ประเภท PHI เช่น ชื่อผู้ป่วย วันเกิด ที่อยู่ หมายเลขโทรศัพท์ เลขที่บัญชีผู้ป่วย และข้อมูลอื่นๆ ที่สามารถระบุตัวบุคคลได้ รองรับการ de-identification เพื่อให้เป็นไปตาม HIPAA compliance

Relationship Extraction

ระบุความสัมพันธ์ระหว่าง entities เช่น ยา A ใช้รักษา โรค B ในขนาด C ต่อวัน ช่วยให้ได้ structured data ที่มีบริบทครบถ้วน ไม่ใช่แค่ entity เดี่ยวๆ

Ontology Linking

เชื่อมโยง entities กับ concept ใน medical ontologies พร้อม score ความมั่นใจ ทำให้สามารถใช้ข้อมูลกับระบบ clinical decision support ได้


การติดตั้งและการตั้งค่า

1. เปิดใช้งานผ่าน AWS Console

  1. เข้า AWS Console และค้นหา "Amazon Comprehend Medical"
  2. บริการพร้อมใช้งานทันทีในภูมิภาคที่รองรับ (us-east-1, us-west-2, eu-west-1, ap-southeast-2)
  3. ไม่ต้อง provision resources ล่วงหน้า

2. ติดตั้ง boto3

pip install boto3

3. IAM Permissions ที่จำเป็น

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"comprehendmedical:DetectEntitiesV2",
"comprehendmedical:DetectPHI",
"comprehendmedical:InferICD10CM",
"comprehendmedical:InferRxNorm",
"comprehendmedical:InferSNOMEDCT",
"comprehendmedical:StartEntitiesDetectionV2Job",
"comprehendmedical:StartPHIDetectionJob",
"comprehendmedical:DescribeEntitiesDetectionV2Job"
],
"Resource": "*"
}
]
}

4. ตัวอย่างการตั้งค่า boto3

import boto3

client = boto3.client(
service_name='comprehendmedical',
region_name='us-east-1'
)

วิธีใช้งาน

Detect Medical Entities

import boto3
import json

client = boto3.client('comprehendmedical', region_name='us-east-1')

# ข้อความจาก clinical note
medical_text = """
Patient presents with chest pain and shortness of breath.
History of hypertension and type 2 diabetes mellitus.
Currently taking Metformin 500mg twice daily and Lisinopril 10mg once daily.
Blood pressure today: 145/90 mmHg. HbA1c: 8.2%.
"""

response = client.detect_entities_v2(Text=medical_text)

for entity in response['Entities']:
print(f"Entity: {entity['Text']}")
print(f" Category: {entity['Category']}")
print(f" Type: {entity['Type']}")
print(f" Score: {entity['Score']:.2f}")

# แสดง attributes (เช่น ขนาดยา ความถี่)
if entity.get('Attributes'):
for attr in entity['Attributes']:
print(f" Attribute: {attr['Type']} = {attr['Text']}")
print()

ICD-10-CM Inference

# Infer ICD-10-CM codes จาก clinical text
response = client.infer_icd10_cm(
Text="Patient diagnosed with acute myocardial infarction and type 2 diabetes"
)

for entity in response['Entities']:
print(f"Condition: {entity['Text']}")
for concept in entity.get('ICD10CMConcepts', []):
print(f" ICD-10-CM Code: {concept['Code']}")
print(f" Description: {concept['Description']}")
print(f" Score: {concept['Score']:.3f}")
print()
# Condition: acute myocardial infarction
# ICD-10-CM Code: I21.9
# Description: Acute myocardial infarction, unspecified
# Score: 0.987

RxNorm Inference

# Infer RxNorm codes สำหรับยา
response = client.infer_rx_norm(
Text="Take Metformin 500mg twice daily with meals for blood sugar control"
)

for entity in response['Entities']:
print(f"Medication: {entity['Text']}")
for concept in entity.get('RxNormConcepts', []):
print(f" RxNorm Code: {concept['Code']}")
print(f" Description: {concept['Description']}")
print(f" Score: {concept['Score']:.3f}")
print()

PHI Detection และ De-identification

# ตรวจจับ PHI สำหรับ HIPAA compliance
phi_text = """
Patient John Smith, DOB 05/15/1980, MRN 12345678.
Address: 123 Main St, Springfield. Phone: (555) 123-4567.
Admitted on 01/10/2024 for knee replacement surgery.
"""

response = client.detect_phi(Text=phi_text)

print("PHI Entities Found:")
for entity in response['Entities']:
print(f" Type: {entity['Type']}")
print(f" Text: {entity['Text']}")
print(f" Position: {entity['BeginOffset']}-{entity['EndOffset']}")
print()

Batch Processing สำหรับเอกสารจำนวนมาก

# เริ่ม batch job สำหรับ clinical notes จำนวนมากใน S3
response = client.start_entities_detection_v2_job(
InputDataConfig={
'S3Bucket': 'my-medical-docs',
'S3Key': 'clinical-notes/',
'S3Region': 'us-east-1'
},
OutputDataConfig={
'S3Bucket': 'my-medical-results',
'S3Key': 'entity-results/'
},
DataAccessRoleArn='arn:aws:iam::123456789:role/ComprehendMedicalRole',
JobName='clinical-notes-batch-job',
LanguageCode='en'
)

job_id = response['JobId']
print(f"Batch job started: {job_id}")

ราคา (ประมาณการในบาท)

อัตราแลกเปลี่ยน: 1 USD = 35 บาท หน่วย (Unit) = 100 ตัวอักษร

APIราคา (USD)ราคา (บาท)
DetectEntitiesV2$0.01/unit0.35 บาท/100 ตัวอักษร
DetectPHI$0.01/unit0.35 บาท/100 ตัวอักษร
InferICD10CM$0.01/unit0.35 บาท/100 ตัวอักษร
InferRxNorm$0.01/unit0.35 บาท/100 ตัวอักษร
InferSNOMEDCT$0.01/unit0.35 บาท/100 ตัวอักษร

Free Tier: 25,000 ตัวอักษร/เดือน ฟรีใน 3 เดือนแรก

ตัวอย่างการคำนวณ:

  • ประมวลผล discharge summaries 10,000 ฉบับ เฉลี่ย 1,000 ตัวอักษร/ฉบับ
  • จำนวน units = 10,000 × (1,000/100) = 100,000 units
  • ค่าใช้จ่าย DetectEntities = 100,000 × $0.01 = $1,000 (~35,000 บาท)
  • ค่าใช้จ่าย InferICD10CM = 100,000 × $0.01 = $1,000 (~35,000 บาท)
  • รวมทั้งหมด = ~$2,000 (~70,000 บาท)

เหมาะสำหรับ

  • โรงพยาบาลและระบบสาธารณสุข ที่ต้องการแปลง clinical notes เป็น structured data สำหรับ analytics และ quality improvement
  • บริษัทประกันสุขภาพ ที่ต้องการ automate การประมวลผล claims จากเวชระเบียนและลดเวลา medical coding
  • นักวิจัยทางการแพทย์ ที่ต้องการ extract ข้อมูลจาก medical literature และ clinical trial documents จำนวนมาก
  • ผู้พัฒนาระบบ HIT/EHR ที่ต้องการเพิ่ม NLP capabilities เข้าสู่ Electronic Health Record systems
  • Health Tech Startups ที่สร้าง clinical decision support, medication management หรือ population health tools
  • หน่วยงานที่ต้องปฏิบัติตาม HIPAA สำหรับ automatic PHI detection และ de-identification

ใช้ร่วมกับ AWS Services

AWS Serviceการผสานรวม
Amazon S3เก็บ clinical documents สำหรับ batch processing
AWS Lambdaประมวลผล medical text แบบ real-time เมื่อมีเอกสารใหม่
Amazon DynamoDBเก็บ structured medical data ที่ extract ได้
Amazon Comprehendใช้ร่วมกันสำหรับ general NLP (sentiment, PII)
AWS HealthLakeเก็บและวิเคราะห์ FHIR-format health data
Amazon Kendraสร้าง medical knowledge search engine
AWS Step Functionsสร้าง medical document processing pipeline
Amazon QuickSightสร้าง clinical analytics dashboard

Use Case ตัวอย่าง

1. ระบบ Medical Coding อัตโนมัติ

บริษัทประกันสุขภาพใช้ Comprehend Medical ประมวลผล discharge summaries ของผู้ป่วยกว่า 10,000 ฉบับต่อวัน ระบบ Lambda trigger ทำงานทันทีเมื่อเอกสารถูกอัปโหลดใน S3 โดยเรียก InferICD10CM เพื่อ extract diagnosis codes และ InferRxNorm สำหรับ medication codes จากนั้นผลลัพธ์จะถูกบันทึกใน DynamoDB และส่งต่อเข้าระบบ billing อัตโนมัติ ลดเวลา medical coding จาก 15 นาทีต่อเคสเหลือ 2 นาที ลดค่าใช้จ่าย medical coders ได้ 60% และลด coding errors จาก 8% เหลือต่ำกว่า 1%

2. ระบบ HIPAA De-identification สำหรับ Research

มหาวิทยาลัยการแพทย์ต้องการใช้ข้อมูลเวชระเบียนผู้ป่วยกว่า 500,000 รายการสำหรับวิจัย แต่ต้องปฏิบัติตาม HIPAA ก่อนส่งข้อมูลให้นักวิจัย ระบบใช้ DetectPHI เพื่อหา PHI ทุกประเภทในเอกสาร จากนั้น Lambda function จะ redact ข้อมูลดังกล่าวและสร้าง de-identified version ใน S3 bucket แยก นักวิจัยสามารถเข้าถึงข้อมูลวิจัยได้โดยไม่ต้องกังวลเรื่อง patient privacy กระบวนการที่เคยใช้เวลาหลายสัปดาห์ลดเหลือเพียงไม่กี่ชั่วโมง

3. Clinical Trial Data Extraction

บริษัทยาใช้ Comprehend Medical extract ข้อมูลจาก clinical trial reports และ academic papers กว่า 100,000 บทความ เพื่อสร้าง database ของ drug-disease-outcome relationships ระบบใช้ Entity Recognition และ Relationship Extraction ระบุว่ายา A ในขนาด B มีผลต่อโรค C อย่างไร จากนั้น SNOMED CT Linking เชื่อมโยงกับ ontology มาตรฐาน ทำให้ทีม R&D สามารถค้นหาและวิเคราะห์ข้อมูลจาก literature ได้ในเวลาไม่กี่วินาที แทนที่จะต้องอ่านด้วยตนเองเป็นเดือนๆ