feat: new healthcare use case unlocked with genAI
Medical coding errors are common and can lead to denied claims, delayed payments, and even patient safety issues. GenAI can help address these issues by suggesting accurate medical codes, automating tasks, and improving standardization. With a human-in-the-loop approach, this can lead to faster claims processing, better reimbursement, and reduced coder burnout. Google's large language models (LLMs) have the potential to significantly automate the medical coding process, improving both efficiency and accuracy. By first preprocessing medical records using healthcare APIs to identify and extract relevant terms, patterns, and relationships, we can then leverage LLMs to suggest appropriate codes for diagnoses and procedures based on physician notes and reports. This can not only save coders time and effort but also reduce errors and inconsistencies, leading to improved reimbursement rates and better financial management for healthcare providers.
**It is always recommended to have a human-in-the-loop when dealing with medical applications. This colab is meant to accelerate the medical coding processing and not to fully replace a human coder. ***
Read the below section to learn more about different kinds of medical codes:
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Check out this pull request on ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
@elhadik Thanks for the PR, looks good overall! I just have some comments/suggestions to make it easier to read/more optimized.
Note - It looks like your GitHub account does not have the correct email attached to it, which makes the CLA check fail. Can you update your account to have the email ***@google.com instead of ***@googlecom?
Can you change the name of the Notebook to be all lowercase and more concise? Maybe react_gemini_healthcare_api.ipynb ?
And be sure to change the in-notebook links for Open in Colab, etc.
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:17:57Z ----------------------------------------------------------------
This markdown table formatting is off in
the review tool. Can you change this to
use bullet-points?
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:17:58Z ----------------------------------------------------------------
Add an H2 Overview header titled "Overview" or something like that.
The first section is in bold when It
probably shouldn't be.
However the
**It is always recommended section
isn't in bold (One side has 2 asterisks and
one has 3, should be 2 on both sides)
I think there's a spelling error in the
LangChain block ReAct Agen →
ReAct Agent
You might be able to embed that Youtube
video in the markdown with this code:
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/fqNBNE_YSro?si=JKaKOWfzdxeFFADe" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:17:59Z ----------------------------------------------------------------
I appreciate the enthusiasm, but maybe
don't include the exclamation point.
Can you restructure this Installation
section to be like this notebook?
https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/getting-
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:00Z ----------------------------------------------------------------
Remove the output cells
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:01Z ----------------------------------------------------------------
Remove your own project ID, replace with <PROJECT ID>
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:02Z ----------------------------------------------------------------
Remove this output, it could be a security
risk.
There's existing auth instructions using
the gcloud SDK in this notebook
https://github.com/GoogleCloudPlatform/generative-ai/blob/main/language/getting-
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:03Z ----------------------------------------------------------------
Move all library imports later in the
notebook to this cell
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:04Z ----------------------------------------------------------------
Make this header less verbose. Maybe
"Configure and call Healthcare API"?
Add the below bullet points about the API
into this section.
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:05Z ----------------------------------------------------------------
Where did this discharge summary come
from?
Do we have permission to use it?
Also, was it typed? From Speech to Text?
From OCR? Something else? Describe
that in the markdown.
I also don't think this needs to be in the notebook twice, I'd say just have it in the variable
elhadik commented on 2024-01-22T02:04:20Z ----------------------------------------------------------------
yes! it is the same one used by google healthcare API public website
https://cloud.google.com/healthcare-api/docs/how-tos/nlp-demo
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:06Z ----------------------------------------------------------------
Move the bullet points and image to the
top of this section. Also add a
link/description of "Custom Tool"
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:07Z ----------------------------------------------------------------
Can this be restructured to use the
Python discovery library if possible
instead of a raw REST call with the
requests library?
You can find code samples here
https://cloud.google.com/healthcare-api/docs/samples
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:08Z ----------------------------------------------------------------
Be sure to always capitalize "Healthcare
API"
Fix spelling Knowldge Graph
Capitalize Python
Add link to library networkx and put in code font
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:09Z ----------------------------------------------------------------
Once again, use the python discovery
library if possible.
And just a ease of reading change - Move
the function declarations to a separate cell
from the function calling.
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:10Z ----------------------------------------------------------------
Line #31. response = healthcare_nl(TEXT)
Might be different if you switch to the
discovery version, but I think you can
move the .json() call to this line and
not have to do response.json()
throughout this cell
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:11Z ----------------------------------------------------------------
Line #33. response.json()
Do Lines 32 and 33 accomplish anything?
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:12Z ----------------------------------------------------------------
Line #63. kg_df = pd.DataFrame({"source": Source, "target": Target, "edge": Edge})
Here's another way to write this cell that's a little more efficient/readable. Be sure to run/test it before committing.
# Extract the entities from the responseresponse_json = healthcare_nl(TEXT).json()
Create DataFrame for entities
df = pd.DataFrame.from_records([ { "ID": entity["mentionId"], "Desc": f"{entity['type']} : {entity['text']['content']}", "Type": entity["type"], "Content": entity["text"]["content"], } for entity in response_json["entityMentions"] ])
Create DataFrame for knowledge graph
kg_df = pd.DataFrame.from_records([ { "source": df.loc[df["ID"] == relation["subjectId"], "Desc"].values[0], "target": df.loc[df["ID"] == relation["objectId"], "Content"].values[0], "edge": df.loc[df["ID"] == relation["objectId"], "Type"].values[0], } for relation in response_json["relationships"] ])
Create a directed graph from the DataFrame
G = nx.from_pandas_edgelist( kg_df, "source", "target", edge_attr=True, create_using=nx.MultiDiGraph() )
elhadik commented on 2024-01-22T02:40:14Z ----------------------------------------------------------------
worked as well! big thanks
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:13Z ----------------------------------------------------------------
Create a new header that describes this
section.
capitalize LangChain & Healthcare API
Also add a hyperlink to a page about
ReAct
Fix the extra ** characters at the end
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:14Z ----------------------------------------------------------------
Fix the deprecation warning and use
langchain-google-vertexai
Also, looks like there's multiple printed
outputs, can this be made more concise?
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:15Z ----------------------------------------------------------------
Line #6. from langchain.tools import StructuredTool
Add these imports at the beginning of the
notebook
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:16Z ----------------------------------------------------------------
Line #12. tool = StructuredTool.from_function(list_of_medical_terms)
I'd say just create tools here instead of creating a tool variable
tools = [StructuredTool.from_function(list_of_medical_terms)]
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:17Z ----------------------------------------------------------------
Is this block performing the self-
consistency check?
Can you add more to the description
outlining what the code block is doing?
The code can be simplified in this way
(Please double check before committing)
from collections import Counter # Add import to the top of the notebooknum_attempts = 10 outputs = [agent.run(prompt) for _ in range(num_attempts)]
final_output contains the most common output, and vote contains its count
final_output, vote = Counter(outputs).most_common(1)[0]
View / edit / reply to this conversation on ReviewNB
holtskinner commented on 2024-01-17T14:18:54Z ----------------------------------------------------------------
Can you add a description of this code block and how it's different than the first block?
yes! it is the same one used by google healthcare API public website
https://cloud.google.com/healthcare-api/docs/how-tos/nlp-demo
View entire conversation on ReviewNB