How to use the ComprehendMedical function from aws-sdk

Find comprehensive JavaScript aws-sdk.ComprehendMedical code examples handpicked from public code repositorys.

aws-sdk.ComprehendMedical is a service provided by Amazon Web Services (AWS) that uses natural language processing (NLP) to extract medical information from unstructured text.

3
4
5
6
7
8
9
10
11
12
13
14
15


class TextComprehensionService {


  comprehend = undefined;
  constructor() {
    this.comprehend = new AWS.ComprehendMedical();
  }


  async comprehendText(text, operation) {
    if (operation === ComprehensionType.DETECT_ENTITIES) {
fork icon0
star icon0
watch icon1

+ 20 other calls in file

7
8
9
10
11
12
13
14
15
16
17
const eventStreamMarshaller = new marshaller.EventStreamMarshaller(
  util_utf8_node.toUtf8,
  util_utf8_node.fromUtf8
);


const comprehendMedical = new ComprehendMedical({ 
  region: 'us-west-2', 
  accessKeyId: process.env.AccessKeyId,
  secretAccessKey: process.env.SecretAccessKey
});
fork icon0
star icon0
watch icon1

How does aws-sdk.ComprehendMedical work?

aws-sdk.ComprehendMedical is a service provided by AWS that allows developers to use natural language processing to extract medical information from unstructured text. It works by leveraging machine learning algorithms to analyze unstructured medical text and identify relevant information, such as medical conditions, treatments, and medications. To use aws-sdk.ComprehendMedical, developers first need to create an instance of the service client using their AWS credentials. They can then call the detectEntitiesV2 method on this client, passing in the text to be analyzed. The detectEntitiesV2 method analyzes the text and returns an object containing information about any medical entities it finds in the text. This can include medical conditions, medications, and treatments, as well as other information such as dates and anatomical locations. In addition to the detectEntitiesV2 method, aws-sdk.ComprehendMedical provides a number of other methods for analyzing medical text, including detectPHI, which is used to identify personally identifiable health information (PHI) in text. By using aws-sdk.ComprehendMedical, developers can automate the process of extracting medical information from unstructured text, making it easier to process large amounts of medical data and derive insights from it.

Ai Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const AWS = require("aws-sdk");
const comprehendmedical = new AWS.ComprehendMedical();

const text =
  "The patient has a history of diabetes and hypertension. Current medications include metformin and lisinopril.";

const params = {
  Text: text,
};

comprehendmedical.detectEntitiesV2(params, (err, data) => {
  if (err) console.log(err, err.stack);
  else console.log(data);
});

In this example, we're first creating an instance of the aws-sdk.ComprehendMedical client using the AWS SDK for JavaScript. We then define the text variable to contain the medical text we want to analyze. We then create a params object that contains the Text property, which is set to the text variable. Finally, we call the detectEntitiesV2 method on the comprehendmedical object, passing in the params object and a callback function. The callback function receives either an error object or the results of the analysis as a data object. In this example, we're simply logging the data object to the console.