fvandenhende commited on
Commit
fdbd41c
1 Parent(s): 5f3fa2c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -1,12 +1,11 @@
1
  import gradio as gr
2
  import requests
3
  import json
4
- from send_email import send_email
5
  import os
6
  from dotenv import load_dotenv
7
 
8
 
9
- def request_meddra_encode_form(req_reported_term, req_version, icd_dictionary_choice, req_terms_checkbox):
10
  # Check if all required fields are filled and the conditions are met
11
  if not req_reported_term:
12
  return "**Please enter a medical term.**"
@@ -18,17 +17,17 @@ def request_meddra_encode_form(req_reported_term, req_version, icd_dictionary_ch
18
 
19
  req_apikey = os.getenv("SAFETERM_API_KEY")
20
 
21
- encode_output = encode_caller(req_apikey, req_reported_term, req_version, icd_dictionary_choice)
22
  return encode_output
23
 
24
 
25
- def encode_caller(apikey, reported_terms, icd_version, icd_dictionary_choice):
26
  url = os.getenv("SAFETERM_ENCODE_URL")
27
  reported_terms_list = [reported_terms.strip()] # Ensure it's a list of strings
28
 
29
  payload = json.dumps({
30
  "reported_terms": reported_terms_list,
31
- "version": int(icd_version),
32
  "medical_dictionary": icd_dictionary_choice
33
  })
34
 
@@ -90,7 +89,7 @@ with gr.Blocks() as demo:
90
  desc_text = gr.HTML("""
91
  <div style="line-height: 1.6; padding: 10px;">
92
  The ICD (International Classification of Diseases) is a globally recognized system for
93
- categorizing diseases and health conditions. It provides standardized codes for diagnoses,
94
  facilitates health statistics compilation, supports billing processes, and
95
  enables communication among healthcare professionals and researchers.
96
  </div>
@@ -121,9 +120,6 @@ with gr.Blocks() as demo:
121
 
122
  icd_dictionary = gr.Dropdown(choices=icd_dictionaries, label="ICD Dictionary", value='ICD-11')
123
 
124
- # Set the only version as the default value for the dropdown.
125
- encode_version = "2023"
126
-
127
  terms_text = gr.HTML("""
128
  I agree to the Safeterm <a href=https://www.proddis.com/pdf/Proddis_Terms_of_Use.pdf>Terms of Use</a>.
129
  I consent to the storage of my personal data for training and communication purposes.
@@ -138,7 +134,7 @@ with gr.Blocks() as demo:
138
  api_response_encode = gr.Textbox(label="Safeterm Output")
139
 
140
  submit_button.click(request_meddra_encode_form,
141
- inputs=[encode_reported_terms, encode_version, icd_dictionary, terms_checkbox],
142
  outputs=api_response_encode)
143
 
144
 
 
1
  import gradio as gr
2
  import requests
3
  import json
 
4
  import os
5
  from dotenv import load_dotenv
6
 
7
 
8
+ def request_meddra_encode_form(req_reported_term, icd_dictionary_choice, req_terms_checkbox):
9
  # Check if all required fields are filled and the conditions are met
10
  if not req_reported_term:
11
  return "**Please enter a medical term.**"
 
17
 
18
  req_apikey = os.getenv("SAFETERM_API_KEY")
19
 
20
+ encode_output = encode_caller(req_apikey, req_reported_term, icd_dictionary_choice)
21
  return encode_output
22
 
23
 
24
+ def encode_caller(apikey, reported_terms, icd_dictionary_choice):
25
  url = os.getenv("SAFETERM_ENCODE_URL")
26
  reported_terms_list = [reported_terms.strip()] # Ensure it's a list of strings
27
 
28
  payload = json.dumps({
29
  "reported_terms": reported_terms_list,
30
+ "version": 2023,
31
  "medical_dictionary": icd_dictionary_choice
32
  })
33
 
 
89
  desc_text = gr.HTML("""
90
  <div style="line-height: 1.6; padding: 10px;">
91
  The ICD (International Classification of Diseases) is a globally recognized system for
92
+ categorizing diseases and health conditions. <p>It provides standardized codes for diagnoses,
93
  facilitates health statistics compilation, supports billing processes, and
94
  enables communication among healthcare professionals and researchers.
95
  </div>
 
120
 
121
  icd_dictionary = gr.Dropdown(choices=icd_dictionaries, label="ICD Dictionary", value='ICD-11')
122
 
 
 
 
123
  terms_text = gr.HTML("""
124
  I agree to the Safeterm <a href=https://www.proddis.com/pdf/Proddis_Terms_of_Use.pdf>Terms of Use</a>.
125
  I consent to the storage of my personal data for training and communication purposes.
 
134
  api_response_encode = gr.Textbox(label="Safeterm Output")
135
 
136
  submit_button.click(request_meddra_encode_form,
137
+ inputs=[encode_reported_terms, icd_dictionary, terms_checkbox],
138
  outputs=api_response_encode)
139
 
140