pilayar commited on
Commit
9efc99e
·
verified ·
1 Parent(s): aec9d05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -79,17 +79,27 @@ if uploaded_file:
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:
95
  st.error(f"Processing Error: {e}")
 
79
  st.subheader("Federal Registry Verification")
80
  registry_data = get_nppes_data(data.npi_number)
81
 
82
+ if registry_data:
83
+ # Based on your st.json, registry_data is the single record dictionary
84
+ basic_info = registry_data.get('basic', {})
 
85
 
86
+ # Check if it's an Organization (NPI-2) or Individual (NPI-1)
87
+ if registry_data.get('enumeration_type') == 'NPI-2':
88
+ display_name = basic_info.get('organization_name', 'Unnamed Organization')
89
+ st.info(f"Verified as Organizational NPI: {display_name}")
90
+ else:
91
+ f_name = basic_info.get('first_name', '')
92
+ l_name = basic_info.get('last_name', '')
93
+ display_name = f"{f_name} {l_name}".strip()
94
+ st.success(f"Verified as Individual Provider: {display_name}")
95
+
96
+ st.write(f"**Registry Name:** {display_name}")
97
+
98
+ # Taxonomy parsing (based on your JSON structure)
99
+ taxonomies = registry_data.get('taxonomies', [])
100
+ if taxonomies:
101
+ st.write(f"**Primary Taxonomy:** {taxonomies[0].get('desc', 'N/A')}")
102
+ st.write(f"**Associated License:** {taxonomies[0].get('license', 'N/A')}")
103
 
104
  except Exception as e:
105
  st.error(f"Processing Error: {e}")