medicafe 0.250820.4__py3-none-any.whl → 0.250820.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
MediBot/MediBot.py CHANGED
@@ -12,6 +12,7 @@ except ImportError:
12
12
  msvcrt = None # Not available on non-Windows systems
13
13
  from collections import OrderedDict
14
14
  from datetime import datetime # Added for primary surgery date logic
15
+ import MediBot_Notepad_Utils # For generating notepad files
15
16
 
16
17
  # ============================================================================
17
18
  # MINIMAL PROTECTION: Import State Validation
@@ -802,11 +803,22 @@ if __name__ == "__main__":
802
803
 
803
804
  # Display existing patients table using the enhanced display function
804
805
  patient_type = "MEDICARE" if is_medicare else "PRIVATE"
806
+ table_title = "{} PATIENTS - EXISTING: The following patient(s) already EXIST in the system but may have new dates of service.\n Their diagnosis codes may need to be updated manually by the user to the following list:".format(patient_type)
805
807
  MediBot_UI.display_enhanced_patient_table(
806
808
  patient_info,
807
- "{} PATIENTS - EXISTING: The following patient(s) already EXIST in the system but may have new dates of service.\n Their diagnosis codes may need to be updated manually by the user to the following list:".format(patient_type),
809
+ table_title,
808
810
  show_line_numbers=False
809
811
  )
812
+
813
+ # Generate and open notepad file with existing patients table
814
+ try:
815
+ notepad_file_path = MediBot_Notepad_Utils.generate_existing_patients_notepad(patient_info, table_title)
816
+ if notepad_file_path:
817
+ print("Existing patients table saved and opened in notepad: {}".format(notepad_file_path))
818
+ else:
819
+ print("Warning: Could not create notepad file for existing patients table")
820
+ except Exception as e:
821
+ print("Warning: Error creating notepad file: {}".format(e))
810
822
 
811
823
  # Update csv_data to exclude existing patients
812
824
  # TODO: Update this logic to handle patients that exist but need new charges added.
@@ -0,0 +1,196 @@
1
+ # -*- coding: ascii -*-
2
+ """
3
+ MediBot Notepad Utilities
4
+ Windows XP + Python 3.4.4 + ASCII-only compatible module for generating notepad files.
5
+
6
+ This module provides utilities to create and open text files containing patient table data
7
+ for manual review and reference.
8
+ """
9
+
10
+ import os
11
+ import subprocess
12
+ import tempfile
13
+ from datetime import datetime
14
+
15
+
16
+ def format_patient_table_for_notepad(patient_info, title):
17
+ """
18
+ Format patient table data for notepad display.
19
+
20
+ Args:
21
+ patient_info: List of tuples (surgery_date, patient_name, patient_id, diagnosis_code, patient_row)
22
+ title: Title for the table section
23
+
24
+ Returns:
25
+ str: Formatted text content suitable for notepad display
26
+ """
27
+ if not patient_info:
28
+ return title + "\n\nNo patients found.\n"
29
+
30
+ lines = []
31
+ lines.append(title)
32
+ lines.append("")
33
+
34
+ # Normalize data to avoid None and unexpected container types in sort key
35
+ normalized_info = []
36
+ for surgery_date, patient_name, patient_id, diagnosis_code, patient_row in patient_info:
37
+ # Normalize date into comparable key and display string
38
+ display_date = None
39
+ current_date_dt = None
40
+ try:
41
+ if hasattr(surgery_date, 'strftime'):
42
+ display_date = surgery_date.strftime('%m-%d')
43
+ current_date_dt = surgery_date
44
+ elif isinstance(surgery_date, str):
45
+ # Date strings may be MM-DD-YYYY or already MM-DD
46
+ parts = surgery_date.split('-') if surgery_date else []
47
+ if len(parts) == 3 and all(parts):
48
+ display_date = "{}-{}".format(parts[0], parts[1])
49
+ try:
50
+ current_date_dt = datetime.strptime(surgery_date, '%m-%d-%Y')
51
+ except Exception:
52
+ current_date_dt = None
53
+ else:
54
+ display_date = surgery_date or 'Unknown Date'
55
+ current_date_dt = None
56
+ else:
57
+ display_date = str(surgery_date) if surgery_date is not None else 'Unknown Date'
58
+ current_date_dt = None
59
+ except Exception:
60
+ display_date = str(surgery_date) if surgery_date is not None else 'Unknown Date'
61
+ current_date_dt = None
62
+
63
+ # Normalize diagnosis display: only show "-Not Found-" when explicitly flagged as N/A
64
+ display_diagnosis = diagnosis_code
65
+ if diagnosis_code == 'N/A':
66
+ display_diagnosis = '-Not Found-'
67
+ elif not diagnosis_code or diagnosis_code.strip() == '':
68
+ display_diagnosis = '-Not Found-'
69
+
70
+ # Extract patient name parts for sorting
71
+ last_name_key = ''
72
+ first_name_key = ''
73
+
74
+ # Try to get last/first from patient_row if available
75
+ if patient_row:
76
+ try:
77
+ last_name_key = str(patient_row.get('Last Name', '')).upper()
78
+ first_name_key = str(patient_row.get('First Name', '')).upper()
79
+ except (AttributeError, TypeError):
80
+ pass
81
+
82
+ # Build primary date for this patient (used for grouping)
83
+ primary_date_dt = current_date_dt
84
+
85
+ # If last/first not available from row, parse from display name "LAST, FIRST ..."
86
+ if not last_name_key and isinstance(patient_name, str):
87
+ try:
88
+ parts = [p.strip() for p in patient_name.split(',')]
89
+ if len(parts) >= 1:
90
+ last_name_key = parts[0].upper()
91
+ if len(parts) >= 2:
92
+ first_name_key = parts[1].split()[0].upper() if parts[1] else ''
93
+ except Exception:
94
+ last_name_key = ''
95
+ first_name_key = ''
96
+
97
+ # Build composite sort key per requirement: by earliest date, then last name within date
98
+ composite_sort_key = (primary_date_dt, last_name_key, first_name_key, str(patient_id or ''))
99
+
100
+ normalized_info.append((composite_sort_key, display_date, str(patient_name or ''), str(patient_id or ''), display_diagnosis))
101
+
102
+ # Sort so that all entries for a patient are grouped under their earliest date
103
+ normalized_info.sort(key=lambda x: x[0])
104
+
105
+ # Calculate column widths for proper alignment
106
+ max_patient_id_len = max(len(pid) for _, _, _, pid, _ in normalized_info)
107
+ max_patient_name_len = max(len(pname) for _, _, pname, _, _ in normalized_info)
108
+ max_diagnosis_len = max(len(dcode) for _, _, _, _, dcode in normalized_info)
109
+
110
+ # Ensure minimum widths for readability
111
+ max_patient_id_len = max(max_patient_id_len, 10) # "Patient ID" header
112
+ max_patient_name_len = max(max_patient_name_len, 12) # "Patient Name" header
113
+ max_diagnosis_len = max(max_diagnosis_len, 9) # "Diagnosis" header
114
+
115
+ # Add table header
116
+ header_format = " {:<6} | {:<" + str(max_patient_id_len) + "} | {:<" + str(max_patient_name_len) + "} | {:<" + str(max_diagnosis_len) + "}"
117
+ lines.append(header_format.format("Date", "Patient ID", "Patient Name", "Diagnosis"))
118
+
119
+ # Add separator line
120
+ separator_format = " {:<6} | {:<" + str(max_patient_id_len) + "} | {:<" + str(max_patient_name_len) + "} | {:<" + str(max_diagnosis_len) + "}"
121
+ lines.append(separator_format.format("-" * 6, "-" * max_patient_id_len, "-" * max_patient_name_len, "-" * max_diagnosis_len))
122
+
123
+ current_patient = None
124
+
125
+ for sort_key, formatted_date, patient_name, patient_id, display_diagnosis in normalized_info:
126
+ if current_patient == patient_id:
127
+ patient_id_dashes = '-' * len(patient_id)
128
+ patient_name_dashes = '-' * len(patient_name)
129
+ secondary_format = " {:<6} | {:<" + str(max_patient_id_len) + "} | {:<" + str(max_patient_name_len) + "} | {:<" + str(max_diagnosis_len) + "}"
130
+ lines.append(secondary_format.format(formatted_date, patient_id_dashes, patient_name_dashes, display_diagnosis))
131
+ else:
132
+ current_patient = patient_id
133
+ primary_format = " {:<6} | {:<" + str(max_patient_id_len) + "} | {:<" + str(max_patient_name_len) + "} | {:<" + str(max_diagnosis_len) + "}"
134
+ lines.append(primary_format.format(formatted_date, patient_id, patient_name, display_diagnosis))
135
+
136
+ lines.append("")
137
+ lines.append("Generated on: {}".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
138
+
139
+ return "\n".join(lines)
140
+
141
+
142
+ def create_and_open_notepad_file(content, filename_prefix="existing_patients"):
143
+ """
144
+ Create a text file with the given content and open it in notepad.
145
+ Compatible with Windows XP and Python 3.4.4.
146
+
147
+ Args:
148
+ content: Text content to write to the file
149
+ filename_prefix: Prefix for the generated filename
150
+
151
+ Returns:
152
+ str: Path to the created file, or None if an error occurred
153
+ """
154
+ try:
155
+ # Generate a unique filename with timestamp
156
+ timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
157
+ filename = "{}_{}.txt".format(filename_prefix, timestamp)
158
+
159
+ # Use the temp directory for the file
160
+ temp_dir = tempfile.gettempdir()
161
+ file_path = os.path.join(temp_dir, filename)
162
+
163
+ # Write the file with ASCII encoding for XP compatibility
164
+ with open(file_path, 'w') as f:
165
+ # Ensure content is ASCII-compatible
166
+ ascii_content = content.encode('ascii', 'replace').decode('ascii')
167
+ f.write(ascii_content)
168
+
169
+ # Open the file in notepad using Windows XP compatible method
170
+ try:
171
+ # Use subprocess to avoid shell=True security issues
172
+ subprocess.Popen(['notepad.exe', file_path])
173
+ except Exception:
174
+ # Fallback method for older systems
175
+ os.system('notepad.exe "{}"'.format(file_path))
176
+
177
+ return file_path
178
+
179
+ except Exception as e:
180
+ # Return None on error - caller should handle gracefully
181
+ return None
182
+
183
+
184
+ def generate_existing_patients_notepad(patient_info, title):
185
+ """
186
+ Generate a notepad file for existing patients table.
187
+
188
+ Args:
189
+ patient_info: List of tuples (surgery_date, patient_name, patient_id, diagnosis_code, patient_row)
190
+ title: Title for the table section
191
+
192
+ Returns:
193
+ str: Path to the created file, or None if an error occurred
194
+ """
195
+ content = format_patient_table_for_notepad(patient_info, title)
196
+ return create_and_open_notepad_file(content, "existing_patients")
@@ -0,0 +1,217 @@
1
+ @echo off
2
+ setlocal enabledelayedexpansion
3
+
4
+ echo [DEBUG] ========================================
5
+ echo [DEBUG] MediBot Debug Version Starting
6
+ echo [DEBUG] ========================================
7
+ echo [DEBUG] Current directory: %CD%
8
+ echo [DEBUG] Current time: %TIME%
9
+ echo [DEBUG] Current date: %DATE%
10
+ echo [DEBUG] Press Enter to continue...
11
+ call :maybe_pause
12
+
13
+ echo [DEBUG] Step 1: Basic environment check
14
+ echo [DEBUG] Checking if we can access basic commands...
15
+ dir >nul 2>&1
16
+ if errorlevel 1 (
17
+ echo [ERROR] Basic dir command failed
18
+ pause
19
+ exit /b 1
20
+ ) else (
21
+ echo [DEBUG] Basic dir command works
22
+ )
23
+
24
+ echo [DEBUG] Press Enter to continue...
25
+ call :maybe_pause
26
+
27
+ echo [DEBUG] Step 2: Python check
28
+ echo [DEBUG] Checking Python installation...
29
+ python --version >nul 2>&1
30
+ if errorlevel 1 (
31
+ echo [ERROR] Python not found or not in PATH
32
+ echo [DEBUG] Current PATH: %PATH%
33
+ echo [DEBUG] Press Enter to exit...
34
+ pause >nul
35
+ exit /b 1
36
+ ) else (
37
+ echo [DEBUG] Python found successfully
38
+ python --version
39
+ )
40
+
41
+ echo [DEBUG] Press Enter to continue...
42
+ call :maybe_pause
43
+
44
+ echo [DEBUG] Step 3: Directory structure check
45
+ echo [DEBUG] Checking current directory contents...
46
+ dir /b
47
+ echo [DEBUG] Press Enter to continue...
48
+ call :maybe_pause
49
+
50
+ echo [DEBUG] Step 4: MediBot directory check
51
+ if exist "MediBot" (
52
+ echo [DEBUG] MediBot directory exists
53
+ echo [DEBUG] MediBot directory contents:
54
+ dir /b MediBot
55
+ ) else (
56
+ echo [WARNING] MediBot directory not found
57
+ )
58
+
59
+ echo [DEBUG] Press Enter to continue...
60
+ call :maybe_pause
61
+
62
+ echo [DEBUG] Step 5: F: drive check
63
+ if exist "F:\" (
64
+ echo [DEBUG] F: drive exists
65
+ if exist "F:\Medibot" (
66
+ echo [DEBUG] F:\Medibot directory exists
67
+ echo [DEBUG] F:\Medibot contents:
68
+ dir /b "F:\Medibot" 2>nul || echo [ERROR] Cannot list F:\Medibot contents
69
+ ) else (
70
+ echo [DEBUG] F:\Medibot directory does not exist
71
+ )
72
+ ) else (
73
+ echo [DEBUG] F: drive does not exist
74
+ )
75
+
76
+ echo [DEBUG] Press Enter to continue...
77
+ call :maybe_pause
78
+
79
+ echo [DEBUG] Step 6: Python package check
80
+ echo [DEBUG] Checking MediCafe package...
81
+ python -c "import pkg_resources; print('MediCafe=='+pkg_resources.get_distribution('medicafe').version)" 2>nul
82
+ if errorlevel 1 (
83
+ echo [ERROR] MediCafe package not found or error accessing
84
+ ) else (
85
+ echo [DEBUG] MediCafe package found
86
+ )
87
+
88
+ echo [DEBUG] Press Enter to continue...
89
+ pause >nul
90
+
91
+ echo [DEBUG] Step 7: Internet connectivity check
92
+ echo [DEBUG] Testing internet connectivity...
93
+ ping -n 1 google.com >nul 2>&1
94
+ if errorlevel 1 (
95
+ echo [WARNING] No internet connection detected
96
+ ) else (
97
+ echo [DEBUG] Internet connection detected
98
+ )
99
+
100
+ echo [DEBUG] Press Enter to continue...
101
+ pause >nul
102
+
103
+ echo [DEBUG] Step 8: Configuration file check
104
+ set "config_file=MediBot\json\config.json"
105
+ echo [DEBUG] Checking for config file: %config_file%
106
+ if exist "%config_file%" (
107
+ echo [DEBUG] Config file exists
108
+ ) else (
109
+ echo [WARNING] Config file not found
110
+ )
111
+
112
+ echo [DEBUG] Press Enter to continue...
113
+ pause >nul
114
+
115
+ echo [DEBUG] Step 9: Update script check
116
+ set "upgrade_medicafe_local=MediBot\update_medicafe.py"
117
+ set "upgrade_medicafe_legacy=F:\Medibot\update_medicafe.py"
118
+
119
+ echo [DEBUG] Checking for update scripts...
120
+ echo [DEBUG] Local path: %upgrade_medicafe_local%
121
+ echo [DEBUG] Legacy path: %upgrade_medicafe_legacy%
122
+
123
+ if exist "%upgrade_medicafe_local%" (
124
+ echo [DEBUG] Local update script found
125
+ ) else (
126
+ echo [DEBUG] Local update script not found
127
+ )
128
+
129
+ if exist "%upgrade_medicafe_legacy%" (
130
+ echo [DEBUG] Legacy update script found
131
+ ) else (
132
+ echo [DEBUG] Legacy update script not found
133
+ )
134
+
135
+ echo [DEBUG] Press Enter to continue...
136
+ pause >nul
137
+
138
+ if defined NON_INTERACTIVE goto skip_simple_menu_test
139
+ echo [DEBUG] Step 10: Simple menu test
140
+ echo [DEBUG] Testing menu functionality...
141
+ echo.
142
+ echo [DEBUG] Simple Menu Test
143
+ echo [DEBUG] 1. Test option 1
144
+ echo [DEBUG] 2. Test option 2
145
+ echo [DEBUG] 3. Exit
146
+ echo.
147
+ set /p test_choice="Enter test choice (1-3): "
148
+
149
+ if "!test_choice!"=="1" (
150
+ echo [DEBUG] Test option 1 selected
151
+ ) else if "!test_choice!"=="2" (
152
+ echo [DEBUG] Test option 2 selected
153
+ ) else if "!test_choice!"=="3" (
154
+ echo [DEBUG] Test exit selected
155
+ goto debug_exit
156
+ ) else (
157
+ echo [DEBUG] Invalid choice: !test_choice!
158
+ )
159
+
160
+ echo [DEBUG] Press Enter to continue...
161
+ call :maybe_pause
162
+
163
+ :skip_simple_menu_test
164
+ echo [DEBUG] Step 11: Python module import test
165
+ echo [DEBUG] Testing Python module imports...
166
+ python -c "import sys; print('Python version:', sys.version)" 2>nul
167
+ if errorlevel 1 (
168
+ echo [ERROR] Python import test failed
169
+ ) else (
170
+ echo [DEBUG] Python import test passed
171
+ )
172
+
173
+ echo [DEBUG] Press Enter to continue...
174
+ call :maybe_pause
175
+
176
+ echo [DEBUG] Step 12: MediCafe module test
177
+ echo [DEBUG] Testing MediCafe module import...
178
+ python -c "import MediCafe; print('MediCafe module imported successfully')" 2>nul
179
+ if errorlevel 1 (
180
+ echo [ERROR] MediCafe module import failed
181
+ ) else (
182
+ echo [DEBUG] MediCafe module import passed
183
+ )
184
+
185
+ echo [DEBUG] Press Enter to continue...
186
+ call :maybe_pause
187
+
188
+ echo [DEBUG] Step 13: Final test - command execution
189
+ echo [DEBUG] Testing command execution...
190
+ echo [DEBUG] This will test if we can execute a simple command
191
+ echo [DEBUG] Command: echo Hello World
192
+ echo Hello World
193
+ if errorlevel 1 (
194
+ echo [ERROR] Command execution failed
195
+ ) else (
196
+ echo [DEBUG] Command execution successful
197
+ )
198
+
199
+ echo [DEBUG] Press Enter to continue...
200
+ pause >nul
201
+
202
+ echo [DEBUG] ========================================
203
+ echo [DEBUG] All debug tests completed successfully
204
+ echo [DEBUG] ========================================
205
+ echo [DEBUG] Press Enter to exit...
206
+ call :maybe_pause
207
+
208
+ :debug_exit
209
+ echo [DEBUG] Exiting debug version
210
+ echo [DEBUG] Press Enter to exit...
211
+ call :maybe_pause
212
+ exit /b 0
213
+
214
+ :maybe_pause
215
+ if defined NON_INTERACTIVE goto :eof
216
+ pause >nul
217
+ goto :eof
MediBot/__init__.py CHANGED
@@ -19,7 +19,7 @@ Smart Import Integration:
19
19
  medibot_main = get_components('medibot_main')
20
20
  """
21
21
 
22
- __version__ = "0.250820.4"
22
+ __version__ = "0.250820.6"
23
23
  __author__ = "Daniel Vidaud"
24
24
  __email__ = "daniel@personalizedtransformation.com"
25
25
 
@@ -0,0 +1,56 @@
1
+ @echo off
2
+ setlocal enabledelayedexpansion
3
+
4
+ :: Determine script and workspace directories
5
+ set "script_dir=%~dp0"
6
+ set "workspace_root=%script_dir%.."
7
+
8
+ :: Paths for deep clear helper script
9
+ set "upgrade_medicafe_local=%script_dir%update_medicafe.py"
10
+ set "upgrade_medicafe_legacy=F:\Medibot\update_medicafe.py"
11
+
12
+ :: Mode selection from first argument
13
+ set "mode=%~1"
14
+ if /i "%mode%"=="--quick" goto quick_clear
15
+ if /i "%mode%"=="--deep" goto deep_clear
16
+
17
+ :: Default behavior (backwards compatible): deep clear
18
+ goto deep_clear
19
+
20
+ :quick_clear
21
+ echo Quick clearing Python cache...
22
+ cd /d "%workspace_root%"
23
+ python -Bc "import compileall; compileall.compile_dir('.', force=True)" 2>nul
24
+ for /d /r . %%d in (__pycache__) do @if exist "%%d" rd /s /q "%%d" 2>nul
25
+ echo [OK] Quick cache clear complete.
26
+ exit /b 0
27
+
28
+ :deep_clear
29
+ echo Deep cache clear (via update_medicafe.py)...
30
+ echo Workspace root: %workspace_root%
31
+ echo.
32
+
33
+ :: F: drive diagnostics (brief)
34
+ if exist "F:\" (
35
+ if exist "F:\Medibot" (
36
+ dir "F:\Medibot\update_medicafe.py" >nul 2>&1 && echo [OK] F:\Medibot\update_medicafe.py exists || echo [WARN] F:\Medibot\update_medicafe.py missing
37
+ ) else (
38
+ echo [WARN] F:\Medibot directory does not exist
39
+ )
40
+ ) else (
41
+ echo [WARN] F: drive is not accessible
42
+ )
43
+
44
+ :: Prefer F: updater first (ensures using shared, unlocked copy), then local
45
+ if exist "%upgrade_medicafe_legacy%" (
46
+ echo Using F: update_medicafe.py for deep clear
47
+ python "%upgrade_medicafe_legacy%" --clear-cache "%workspace_root%"
48
+ exit /b %ERRORLEVEL%
49
+ ) else if exist "%~dp0update_medicafe.py" (
50
+ echo Using local update_medicafe.py for deep clear
51
+ python "%~dp0update_medicafe.py" --clear-cache "%workspace_root%"
52
+ exit /b %ERRORLEVEL%
53
+ ) else (
54
+ echo ERROR: update_medicafe.py not found (F: or local)
55
+ exit /b 1
56
+ )