kmsravindra
made qa section collapsible
6cd71cd
raw
history blame contribute delete
No virus
6.8 kB
import streamlit as st
import pandas as pd
narratives = {
"Narrative 1": "My patient needs a crown and build-up on Tooth #4. The current restorations are a large no/allow and a separate OL/allow. These restorations are twenty years old at least - placed while a young teenager. The restoration on tooth #30 does not look good either. Decay is present on mesial with an open margin and also under the BO aspect of this larger MOB. After the removal of the old restorations on both #3 and #32, there will not be enough sound tooth structure remaining to place any other type of treatment other than full coverage crowns. Please approve treatment submitted",
"Narrative 2": "Tooth #13 was extracted on 05/06/2017. A surgical implant was placed to replace the missing tooth on 11/12/2017. Implant crown and custom abutment were placed to restore chewing function in the arch and to retain the integrity of the bone and facial structures",
"Narrative 3": "#14 had existing old(15 years) MODL composite restoration fail with fracture of Distal/Ling cusp. Decay undermining remaining restoration. 50% tooth remaining/50% lost. #14 cold sensitive. Bone healthy/no periodontal issue/ Full crown best to restore bite/ function.",
"Narrative 4": "Initial placement of a crown on tooth #5 due to large old composite filling that is broken & recurrent decay. <50% natural tooth left. A build-up & crown is necessary to properly restore the tooth.",
}
def extract_info(narrative):
info = {}
if narrative == 1:
info = {
"What is the date on which this procedure was performed?": "No info",
"How did injury occur?": "No info",
"What is the affected tooth number?": "3, 4, 30, 32",
"Is the tooth currently causing any symptoms?": "No info",
"Is the tooth damaged due to caries or fracture?": "Caries",
"What is the decay severity?": "No info",
"Is a crown restoration necessary to restore the tooth?": "Y",
"Is the existing crown causing any symptoms?": "No info",
"Are there any open margins on the existing crown?": "No info",
"Is there recurrent decay present?": "Y",
"When was the existing crown initially placed?": "No info",
"Was an initial filling placed on the tooth?": "Y",
"Is the filling broken?Is the filling broken?": "No info",
"Was the tooth extracted?": "N",
"What is the filling type?": "No info",
}
elif narrative == 2:
info = {
"What is the date on which this procedure was performed?": "11/12/2017",
"How did injury occur?": "No info",
"What is the affected tooth number? ": "13",
"Is the tooth currently causing any symptoms?": "No info",
"Is the tooth damaged due to caries or fracture?": "No info",
"What is the decay severity?": "No info",
"Is a crown restoration necessary to restore the tooth?": "Y",
"Is the existing crown causing any symptoms?": "No info",
"Are there any open margins on the existing crown?": "No info",
"Is there recurrent decay present?": "No info",
"When was the existing crown initially placed?": "No info",
"Was an initial filling placed on the tooth?": "N",
"Is the filling broken?": "No info",
"Was the tooth extracted?": "Y",
"What is the filling type?": "No info",
}
elif narrative == 3:
info = {
"What is the date on which this procedure was performed?": "No info",
"How did injury occur?": "No info",
"What is the affected tooth number? ": "14",
"Is the tooth currently causing any symptoms?": "Y",
"Is the tooth damaged due to caries or fracture?": "Caries",
"What is the decay severity?": "No info",
"Is a crown restoration necessary to restore the tooth?": "Y",
"Is the existing crown causing any symptoms?": "No info",
"Are there any open margins on the existing crown?": "No info",
"Is there recurrent decay present?": "No info",
"When was the existing crown initially placed?": "No info",
"Was an initial filling placed on the tooth?": "Y",
"Is the filling broken?": "No info",
"Was the tooth extracted?": "N",
"What is the filling type?": "Composite",
}
return info
st.title("Clinical Narrative Info Extractor - Demo")
narrative_choice = st.selectbox(
"Select a sample narrative",
("Narrative 1", "Narrative 2", "Narrative 3")
)
narrative_number = int(narrative_choice[-1])
info = extract_info(narrative_number)
if narrative_number == 1:
st.write("### Narrative 1")
st.write("""
My patient needs a crown and build-up on Tooth #4. The current restorations are a large no/allow and a separate OL/allow. These restorations are twenty years old at least - placed while a young teenager. The restoration on tooth #30 does not look good either. Decay is present on mesial with an open margin and also under the BO aspect of this larger MOB. After the removal of the old restorations on both #3 and #32, there will not be enough sound tooth structure remaining to place any other type of treatment other than full coverage crowns. Please approve treatment submitted
""")
if narrative_number == 2:
st.write("### Narrative 2")
st.write("""
Tooth #13 was extracted on 05/06/2017. A surgical implant was placed to replace the missing tooth on 11/12/2017. Implant crown and custom abutment were placed to restore chewing function in the arch and to retain the integrity of the bone and facial structures
""")
if narrative_number == 3:
st.write("### Narrative 3")
st.write("""
#14 had existing old(15 years) MODL composite restoration fail with fracture of Distal/Ling cusp. Decay undermining remaining restoration. 50% tooth remaining/50% lost. #14 cold sensitive. Bone healthy/no periodontal issue/ Full crown best to restore bite/ function.
""")
#st.write("### Questions and extracted answers using AI model")
# for question, answer in info.items():
# st.write(f"{question}: {answer}")
with st.expander("Questions and extracted answers using AI model"):
# Create a DataFrame with the extracted information
df = pd.DataFrame(list(info.items()), columns=["Question", "Answer"])
# Display the questions and answers in a table format
st.table(df)
# # Create expanders for each question and display the respective answer
# for question, answer in info.items():
# with st.expander(question):
# st.write(answer)