in workshops/AI_ML_services_workshop_information/lambda_code/ai_ml_services_lambda.py [0:0]
def call_comprehehend_medical(the_input=None,call_type="detect_entities_v2"):
'''pass the input data to comprehend medical
call_type controls what NLP operation comprehend medical should do.
call_type must be a valid method for CM.
'''
structured_content=None
client = boto3.client('comprehendmedical')
if call_type=='detect_entities_v2':
structured_content = client.detect_entities_v2(Text=the_input)
elif call_type=='infer_icd10_cm':
structured_content = client.infer_icd10_cm(Text=the_input)
elif call_type=='infer_rx_norm':
structured_content = client.infer_rx_norm(Text=the_input)
else:
logging.warning(f'Something is Wrong. Comprehend Medical call type {call_type} may be invalid.')
try:
response=structured_content['ResponseMetadata']['HTTPStatusCode']
if response==200:
pass
except:
logging.warning('Something is wrong. Perhaps there is a problem calling Comprehend Medical?')
structured_content=None
return(structured_content)