medicafe 0.240517.0__py3-none-any.whl → 0.240613.0__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.
Potentially problematic release.
This version of medicafe might be problematic. Click here for more details.
- MediBot/MediBot.bat +9 -1
- MediBot/MediBot.py +9 -36
- MediBot/MediBot_Charges.py +0 -28
- MediBot/MediBot_Crosswalk_Library.py +1 -0
- MediBot/MediBot_Post.py +0 -0
- MediBot/MediBot_Preprocessor.py +26 -63
- MediBot/MediBot_Preprocessor_lib.py +182 -43
- MediBot/MediBot_UI.py +2 -7
- MediBot/MediBot_dataformat_library.py +0 -9
- MediBot/MediBot_docx_decoder.py +275 -60
- MediLink/MediLink.py +102 -107
- MediLink/MediLink_837p_encoder.py +3 -28
- MediLink/MediLink_837p_encoder_library.py +14 -25
- MediLink/MediLink_APIs.py +2 -0
- MediLink/MediLink_DataMgmt.py +224 -68
- MediLink/MediLink_Decoder.py +63 -0
- MediLink/MediLink_Down.py +73 -79
- MediLink/MediLink_Gmail.py +453 -74
- MediLink/MediLink_Mailer.py +0 -7
- MediLink/MediLink_Parser.py +111 -0
- MediLink/MediLink_Scan.py +0 -0
- MediLink/MediLink_Scheduler.py +2 -172
- MediLink/MediLink_StatusCheck.py +0 -4
- MediLink/MediLink_UI.py +76 -18
- MediLink/MediLink_Up.py +4 -14
- {medicafe-0.240517.0.dist-info → medicafe-0.240613.0.dist-info}/METADATA +3 -1
- medicafe-0.240613.0.dist-info/RECORD +43 -0
- medicafe-0.240517.0.dist-info/RECORD +0 -39
- {medicafe-0.240517.0.dist-info → medicafe-0.240613.0.dist-info}/LICENSE +0 -0
- {medicafe-0.240517.0.dist-info → medicafe-0.240613.0.dist-info}/WHEEL +0 -0
- {medicafe-0.240517.0.dist-info → medicafe-0.240613.0.dist-info}/top_level.txt +0 -0
MediLink/MediLink_Down.py
CHANGED
|
@@ -1,123 +1,117 @@
|
|
|
1
|
+
# MediLink_Down.py
|
|
1
2
|
import os
|
|
2
3
|
import argparse
|
|
3
4
|
import shutil
|
|
4
|
-
from datetime import datetime
|
|
5
5
|
import glob
|
|
6
|
-
import
|
|
7
|
-
from MediLink_DataMgmt import operate_winscp
|
|
6
|
+
from MediLink_Decoder import process_file
|
|
7
|
+
from MediLink_DataMgmt import operate_winscp, consolidate_csvs
|
|
8
8
|
import MediLink_ConfigLoader
|
|
9
|
+
# Import decoders for other file types
|
|
9
10
|
|
|
10
11
|
"""
|
|
11
|
-
|
|
12
|
+
Main triaging function for handling report downloads and processing from various endpoints. This function
|
|
13
|
+
handles downloading reports, moving files, and decoding them into a readable format. The goal is to
|
|
14
|
+
provide detailed receipt and troubleshooting information for the claims.
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
6. Automated Endpoint Processing: Integrate automated looping through configured endpoints for ERA file retrieval, maximizing efficiency and reducing manual oversight.
|
|
19
|
-
7. Configuration Key Accuracy: Audit the script to correct any inaccuracies in configuration key references, ensuring seamless configuration data retrieval.
|
|
16
|
+
Key Enhancements:
|
|
17
|
+
- Handle multiple file types (ERA, 277, etc.) and integrate respective decoders.
|
|
18
|
+
- Support multi-endpoint processing.
|
|
19
|
+
- Implement progress tracking for long-running operations.
|
|
20
|
+
- Provide both consolidated CSV output and in-memory parsed data for real-time display.
|
|
20
21
|
"""
|
|
21
|
-
|
|
22
|
-
# Because I can't figure out how to get it to work directly in the WinSCP command.
|
|
23
|
-
# And on the Windows XP machine apparently the default path is C:\\ ...
|
|
24
|
-
# This needs to get fixed. Ugh.
|
|
25
|
-
def move_downloaded_files(local_storage_path):
|
|
26
|
-
# Define the target directory for storing downloaded files
|
|
22
|
+
def move_downloaded_files(local_storage_path, config):
|
|
27
23
|
local_response_directory = os.path.join(local_storage_path, "responses")
|
|
28
24
|
|
|
29
25
|
if not os.path.exists(local_response_directory):
|
|
30
26
|
os.makedirs(local_response_directory)
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
downloaded_files = [f for f in os.listdir('C:\\Users\\danie\\OneDrive\\Documents') if f.endswith('.era')]
|
|
28
|
+
download_dir = config['MediLink_Config']['local_storage_path']
|
|
29
|
+
file_extensions = ['.era', '.277'] # Extendable list of file extensions
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
for ext in file_extensions:
|
|
32
|
+
downloaded_files = [f for f in os.listdir(download_dir) if f.endswith(ext)]
|
|
33
|
+
for file in downloaded_files:
|
|
34
|
+
source_path = os.path.join(download_dir, file)
|
|
35
|
+
destination_path = os.path.join(local_response_directory, file)
|
|
36
|
+
shutil.move(source_path, destination_path)
|
|
37
|
+
MediLink_ConfigLoader.log("Moved '{}' to '{}'".format(file, local_response_directory))
|
|
43
38
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
Find all files matching the era_file_path pattern.
|
|
47
|
-
This function normalizes the path and supports wildcard patterns.
|
|
48
|
-
"""
|
|
49
|
-
# Normalize the path to handle slashes correctly
|
|
50
|
-
normalized_path = os.path.normpath(era_file_path)
|
|
39
|
+
def find_files(file_path_pattern):
|
|
40
|
+
normalized_path = os.path.normpath(file_path_pattern)
|
|
51
41
|
|
|
52
|
-
# Handling different wildcard scenarios
|
|
53
42
|
if "*" in normalized_path:
|
|
54
|
-
# Use glob to find all files matching the pattern
|
|
55
43
|
matching_files = glob.glob(normalized_path)
|
|
56
|
-
# Normalize paths in the resulting list
|
|
57
44
|
return [os.path.normpath(file) for file in matching_files]
|
|
58
45
|
else:
|
|
59
|
-
# Single file specified, return it in a list if it exists
|
|
60
46
|
return [normalized_path] if os.path.exists(normalized_path) else []
|
|
61
47
|
|
|
48
|
+
def translate_files(files, output_directory):
|
|
49
|
+
translated_files = []
|
|
50
|
+
for file in files:
|
|
51
|
+
try:
|
|
52
|
+
process_file(file, output_directory)
|
|
53
|
+
csv_file_path = os.path.join(output_directory, os.path.basename(file) + '_decoded.csv')
|
|
54
|
+
MediLink_ConfigLoader.log("Translated file to CSV: {}".format(csv_file_path), level="INFO")
|
|
55
|
+
translated_files.append(csv_file_path)
|
|
56
|
+
except ValueError as ve:
|
|
57
|
+
MediLink_ConfigLoader.log("Unsupported file type: {}".format(file), level="WARNING")
|
|
58
|
+
except Exception as e:
|
|
59
|
+
MediLink_ConfigLoader.log("Error processing file {}: {}".format(file, e), level="ERROR")
|
|
60
|
+
|
|
61
|
+
consolidate_csv_path = consolidate_csvs(output_directory, file_prefix="Consolidated", interactive=True)
|
|
62
|
+
MediLink_ConfigLoader.log("Consolidated CSV path: {}".format(consolidate_csv_path), level="INFO")
|
|
63
|
+
return consolidate_csv_path, translated_files
|
|
64
|
+
|
|
65
|
+
def display_translated_files(translated_files):
|
|
66
|
+
print("\nTranslated Files Summary:")
|
|
67
|
+
for file in translated_files:
|
|
68
|
+
print(" - {}",format(file))
|
|
69
|
+
|
|
62
70
|
def main(desired_endpoint='AVAILITY'):
|
|
63
|
-
parser = argparse.ArgumentParser(description="Process
|
|
64
|
-
parser.add_argument('--config_path', type=str, help='Path to the configuration JSON file', default="json
|
|
71
|
+
parser = argparse.ArgumentParser(description="Process files and convert them to CSV format.")
|
|
72
|
+
parser.add_argument('--config_path', type=str, help='Path to the configuration JSON file', default="json/config.json")
|
|
65
73
|
parser.add_argument('--desired_endpoint', type=str, help='The desired endpoint key from the configuration.', default=desired_endpoint)
|
|
66
|
-
parser.add_argument('--
|
|
74
|
+
parser.add_argument('--file_path_pattern', type=str, help='Optional: Specify a path pattern for files for direct translation.', default=None)
|
|
67
75
|
args = parser.parse_args()
|
|
68
76
|
|
|
69
|
-
# Setup Logger, Load configuration and output directory
|
|
70
77
|
config, _ = MediLink_ConfigLoader.load_configuration(args.config_path)
|
|
71
78
|
local_storage_path = config['MediLink_Config']['local_storage_path']
|
|
72
79
|
output_directory = os.path.join(local_storage_path, "translated_csvs")
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
consolidate_csv_path = MediLink_ERA_decoder.consolidate_csvs(output_directory)
|
|
83
|
-
MediLink_ConfigLoader.log("Translation and consolidation completed.")
|
|
80
|
+
|
|
81
|
+
if args.file_path_pattern:
|
|
82
|
+
files = find_files(args.file_path_pattern)
|
|
83
|
+
if files:
|
|
84
|
+
files_str = ', '.join(files)
|
|
85
|
+
MediLink_ConfigLoader.log("Translating files: {}".format(files_str), level="INFO")
|
|
86
|
+
consolidate_csv_path, translated_files = translate_files(files, output_directory)
|
|
87
|
+
MediLink_ConfigLoader.log("Translation and consolidation completed.", level="INFO")
|
|
88
|
+
display_translated_files(translated_files)
|
|
84
89
|
return consolidate_csv_path
|
|
85
90
|
else:
|
|
86
|
-
MediLink_ConfigLoader.log("No
|
|
91
|
+
MediLink_ConfigLoader.log("No files found matching: {}".format(args.file_path_pattern), level="WARNING")
|
|
87
92
|
return
|
|
88
93
|
|
|
89
|
-
# TODO (Low Remit) This probably needs to be built into a loop that cycles through all 3 endpoints.
|
|
90
|
-
# I think the uploader has something like this implemented already since it sends to all the endpoints.
|
|
91
|
-
# The loop should use the tdqa or whatever the progress bar is called.
|
|
92
|
-
# print("Please wait...\n")
|
|
93
|
-
|
|
94
|
-
# Validate endpoint key
|
|
95
94
|
endpoint_key = args.desired_endpoint
|
|
96
95
|
if endpoint_key not in config['MediLink_Config']['endpoints']:
|
|
97
|
-
MediLink_ConfigLoader.log("Endpoint '{}' not found in configuration. Using default 'AVAILITY'.".format(endpoint_key))
|
|
96
|
+
MediLink_ConfigLoader.log("Endpoint '{}' not found in configuration. Using default 'AVAILITY'.".format(endpoint_key), level="WARNING")
|
|
98
97
|
endpoint_key = 'AVAILITY'
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
local_storage_path = config['MediLink_Config']['local_storage_path']
|
|
103
|
-
|
|
104
|
-
# Download ERA files from the configured endpoint
|
|
105
|
-
downloaded_files = operate_winscp("download", None, endpoint_config, local_storage_path, config)
|
|
99
|
+
endpoint_configs = [config['MediLink_Config']['endpoints'][key] for key in config['MediLink_Config']['endpoints']]
|
|
100
|
+
downloaded_files = []
|
|
106
101
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
102
|
+
for endpoint_config in endpoint_configs:
|
|
103
|
+
downloaded_files += operate_winscp("download", None, endpoint_config, local_storage_path, config)
|
|
104
|
+
|
|
105
|
+
move_downloaded_files(local_storage_path, config)
|
|
106
|
+
|
|
107
|
+
# Implement progress tracking
|
|
108
|
+
# from tqdm import tqdm
|
|
109
|
+
# for file in tqdm(downloaded_files, desc="Translating files"):
|
|
110
|
+
# translate_files([file], output_directory)
|
|
116
111
|
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
consolidate_csv_path, translated_files = translate_files(downloaded_files, output_directory)
|
|
113
|
+
display_translated_files(translated_files)
|
|
119
114
|
|
|
120
|
-
# Return the list of translated CSV file paths
|
|
121
115
|
return consolidate_csv_path
|
|
122
116
|
|
|
123
117
|
if __name__ == "__main__":
|