pilayar commited on
Commit
aec9d05
·
verified ·
1 Parent(s): 6bf4849

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -16
app.py CHANGED
@@ -79,24 +79,16 @@ if uploaded_file:
79
  st.subheader("Federal Registry Verification")
80
  registry_data = get_nppes_data(data.npi_number)
81
 
82
- if registry_data:
83
- # registry_data is the full JSON response.
84
- # We must access the 'results' list first.
85
  results = registry_data.get('results', [])
 
 
86
 
87
- if results:
88
- # Access the first dictionary in the list
89
- first_result = results[0]
90
- basic_info = first_result.get('basic', {})
91
-
92
- # NPPES keys are usually lowercase in the JSON API,
93
- # but let's check both just in case.
94
- first_name = basic_info.get('first_name') or basic_info.get('FIRST_NAME') or "N/A"
95
- last_name = basic_info.get('last_name') or basic_info.get('LAST_NAME') or "N/A"
96
-
97
- st.write(f"**Registry Name:** {first_name} {last_name}")
98
- else:
99
- st.error("Registry returned 0 results for this NPI.")
100
 
101
 
102
  except Exception as e:
 
79
  st.subheader("Federal Registry Verification")
80
  registry_data = get_nppes_data(data.npi_number)
81
 
82
+ if registry_data and registry_data.get('result_count', 0) > 0:
 
 
83
  results = registry_data.get('results', [])
84
+ first_result = results[0]
85
+ basic_info = first_result.get('basic', {})
86
 
87
+ st.write(f"**Found:** {basic_info.get('first_name')} {basic_info.get('last_name')}")
88
+ else:
89
+ st.warning("No matching records found in the NPPES registry.")
90
+ # Show the raw JSON so you can see if the API actually failed or just returned nothing
91
+ st.json(registry_data)
 
 
 
 
 
 
 
 
92
 
93
 
94
  except Exception as e: