接入教程
1. 登录AWS控制台并进入Comprehend Medical服务
2. 上传或输入需要分析的临床文本内容
3. 选择分析类型(如实体识别、关系提取)
4. 调用API接口获取JSON格式结果
5. 将返回的医疗实体信息集成到您的应用系统中
使用Python调用AWS Comprehend Medical分析医疗文本
import boto3
client = boto3.client(
service_name='comprehendmedical',
region_name='us-east-1',
aws_access_key_id='YOUR_API_KEY',
aws_secret_access_key='YOUR_SECRET_KEY'
)
text = "患者主诉头痛三天,伴有发热。既往有高血压病史。"
response = client.detect_entities_v2(Text=text)
for entity in response['Entities']:
print(f"实体: {entity['Text']}")
print(f"类别: {entity['Category']}")
print(f"类型: {entity['Type']}")
print("---")
使用PHP调用AWS Comprehend Medical提取医疗实体
<?php
require 'vendor/autoload.php';
use Aws\ComprehendMedical\ComprehendMedicalClient;
use Aws\Credentials\Credentials;
$credentials = new Credentials('YOUR_API_KEY', 'YOUR_SECRET_KEY');
$client = new ComprehendMedicalClient([
'version' => 'latest',
'region' => 'us-east-1',
'credentials' => $credentials
]);
$text = "患者主诉头痛三天,伴有发热。既往有高血压病史。";
$result = $client->detectEntitiesV2([
'Text' => $text
]);
foreach ($result['Entities'] as $entity) {
echo "实体: " . $entity['Text'] . "\n";
echo "类别: " . $entity['Category'] . "\n";
echo "类型: " . $entity['Type'] . "\n";
echo "---\n";
}
?>
使用JavaScript调用AWS Comprehend Medical识别药物信息
const AWS = require('aws-sdk');
AWS.config.update({
region: 'us-east-1',
accessKeyId: 'YOUR_API_KEY',
secretAccessKey: 'YOUR_SECRET_KEY'
});
const comprehendMedical = new AWS.ComprehendMedical();
const params = {
Text: "患者服用阿司匹林100mg每日一次,已持续两周。"
};
comprehendMedical.detectEntitiesV2(params, (err, data) => {
if (err) {
console.log(err, err.stack);
} else {
data.Entities.forEach(entity => {
console.log(`实体: ${entity.Text}`);
console.log(`类别: ${entity.Category}`);
console.log(`类型: ${entity.Type}`);
console.log('---');
});
}
});
常见问题
AWS Comprehend Medical支持哪些医疗实体类型的识别?
AWS Comprehend Medical支持识别多种医疗实体类型,包括疾病诊断、症状、药物名称、剂量、频率、解剖部位、医疗程序、检验检查结果等。服务能够识别实体之间的关系,如药物与剂量关联、症状与疾病关联等。
AWS Comprehend Medical支持中文医疗文本分析吗?
AWS Comprehend Medical目前主要支持英文医疗文本的分析。对于中文医疗文本,建议先使用翻译服务转换为英文,再进行分析处理。AWS自身也提供翻译服务可与Comprehend Medical配合使用。
使用AWS Comprehend Medical需要预先训练模型吗?
不需要。AWS Comprehend Medical提供预训练的医疗自然语言处理模型,开箱即用。用户无需进行模型训练或提供标注数据,只需调用API即可获得分析结果。服务基于大量医疗文献和病历数据训练,适用于通用医疗文本分析场景。
Aitishiku.com