medicafe 0.240419.2__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.

Files changed (38) hide show
  1. MediBot/MediBot.bat +174 -38
  2. MediBot/MediBot.py +80 -77
  3. MediBot/MediBot_Charges.py +0 -28
  4. MediBot/MediBot_Crosswalk_Library.py +281 -0
  5. MediBot/MediBot_Post.py +0 -0
  6. MediBot/MediBot_Preprocessor.py +138 -211
  7. MediBot/MediBot_Preprocessor_lib.py +496 -0
  8. MediBot/MediBot_UI.py +80 -35
  9. MediBot/MediBot_dataformat_library.py +79 -35
  10. MediBot/MediBot_docx_decoder.py +295 -0
  11. MediBot/update_medicafe.py +46 -8
  12. MediLink/MediLink.py +207 -108
  13. MediLink/MediLink_837p_encoder.py +299 -214
  14. MediLink/MediLink_837p_encoder_library.py +445 -245
  15. MediLink/MediLink_API_v2.py +174 -0
  16. MediLink/MediLink_APIs.py +139 -0
  17. MediLink/MediLink_ConfigLoader.py +44 -32
  18. MediLink/MediLink_DataMgmt.py +297 -89
  19. MediLink/MediLink_Decoder.py +63 -0
  20. MediLink/MediLink_Down.py +73 -102
  21. MediLink/MediLink_ERA_decoder.py +4 -4
  22. MediLink/MediLink_Gmail.py +479 -4
  23. MediLink/MediLink_Mailer.py +0 -0
  24. MediLink/MediLink_Parser.py +111 -0
  25. MediLink/MediLink_Scan.py +0 -0
  26. MediLink/MediLink_Scheduler.py +2 -131
  27. MediLink/MediLink_StatusCheck.py +0 -4
  28. MediLink/MediLink_UI.py +87 -27
  29. MediLink/MediLink_Up.py +301 -45
  30. MediLink/MediLink_batch.bat +1 -1
  31. MediLink/test.py +74 -0
  32. medicafe-0.240613.0.dist-info/METADATA +55 -0
  33. medicafe-0.240613.0.dist-info/RECORD +43 -0
  34. {medicafe-0.240419.2.dist-info → medicafe-0.240613.0.dist-info}/WHEEL +5 -5
  35. medicafe-0.240419.2.dist-info/METADATA +0 -19
  36. medicafe-0.240419.2.dist-info/RECORD +0 -32
  37. {medicafe-0.240419.2.dist-info → medicafe-0.240613.0.dist-info}/LICENSE +0 -0
  38. {medicafe-0.240419.2.dist-info → medicafe-0.240613.0.dist-info}/top_level.txt +0 -0
MediLink/MediLink_Down.py CHANGED
@@ -1,146 +1,117 @@
1
+ # MediLink_Down.py
1
2
  import os
2
- import logging
3
3
  import argparse
4
4
  import shutil
5
- from datetime import datetime
6
5
  import glob
7
- import MediLink_ERA_decoder
8
- from MediLink_DataMgmt import operate_winscp
6
+ from MediLink_Decoder import process_file
7
+ from MediLink_DataMgmt import operate_winscp, consolidate_csvs
9
8
  import MediLink_ConfigLoader
9
+ # Import decoders for other file types
10
10
 
11
11
  """
12
- We need to make another function that figures out claim rejections and tries to solve them.
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.
13
15
 
14
- 1. Config File Path Adjustment: Ensure the configuration file's path is adaptable for various environments, or clearly document the process for setting this path.
15
- 2. Logging Enhancements: Improve the logging mechanism to offer comprehensive insights through both file and console outputs, aiding in troubleshooting and operational monitoring.
16
- 3. CSV Output Refinement: Update the CSV output structure to include essential ERA data such as Payer Address, ensuring completeness and accuracy of information.
17
- 4. CSV Consolidation Logic: Develop logic for intelligently consolidating CSV outputs from batch-processed ERA files, ensuring coherent and comprehensive data aggregation.
18
- 5. Secure Endpoint Authentication: Establish a secure method for inputting and storing endpoint authentication details, enhancing script security.
19
- 6. Automated Endpoint Processing: Integrate automated looping through configured endpoints for ERA file retrieval, maximizing efficiency and reducing manual oversight.
20
- 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.
21
21
  """
22
-
23
- # Setup basic logging
24
- def setup_logger(local_storage_path):
25
- # Define a reasonable name for the log file, e.g., "MediLink_Down_Process.log"
26
- log_filename = datetime.now().strftime("MediLink_Down_Process_%m%d%Y.log")
27
- log_filepath = os.path.join(local_storage_path, log_filename)
28
-
29
- for handler in logging.root.handlers[:]:
30
- logging.root.removeHandler(handler)
31
-
32
- # Setup logging to file
33
- logging.basicConfig(level=logging.INFO,
34
- format='%(asctime)s - %(levelname)s - %(message)s',
35
- filename=log_filepath, # Direct logging to a file in local_storage_path
36
- filemode='a') # Append mode
37
-
38
- # If you also want to see the logs in the console, add a StreamHandler
39
- #console_handler = logging.StreamHandler()
40
- #console_handler.setLevel(logging.INFO)
41
- #formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
42
- #console_handler.setFormatter(formatter)
43
- #logging.getLogger('').addHandler(console_handler)
44
-
45
- # Because I can't figure out how to get it to work directly in the WinSCP command.
46
- # And on the Windows XP machine apparently the default path is C:\\ ...
47
- # This needs to get fixed. Ugh.
48
- def move_downloaded_files(local_storage_path):
49
- # Define the target directory for storing downloaded files
22
+ def move_downloaded_files(local_storage_path, config):
50
23
  local_response_directory = os.path.join(local_storage_path, "responses")
51
24
 
52
25
  if not os.path.exists(local_response_directory):
53
26
  os.makedirs(local_response_directory)
54
27
 
55
- # Identify all downloaded .era files in the current directory
56
- # downloaded_files = [f for f in os.listdir('.') if f.endswith('.era')]
57
- 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
58
30
 
59
- # Move each file to the local_response_directory
60
- for file in downloaded_files:
61
- source_path = os.path.join('C:\\Users\\danie\\OneDrive\\Documents', file)
62
- # source_path = os.path.join('.', file) for the XP machine? -- This whole thing needs repaired.
63
- destination_path = os.path.join(local_response_directory, file)
64
- shutil.move(source_path, destination_path)
65
- logging.info("Moved '{}' to '{}'".format(file, local_response_directory))
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))
66
38
 
67
- def find_era_files(era_file_path):
68
- """
69
- Find all files matching the era_file_path pattern.
70
- This function normalizes the path and supports wildcard patterns.
71
- """
72
- # Normalize the path to handle slashes correctly
73
- normalized_path = os.path.normpath(era_file_path)
39
+ def find_files(file_path_pattern):
40
+ normalized_path = os.path.normpath(file_path_pattern)
74
41
 
75
- # Handling different wildcard scenarios
76
42
  if "*" in normalized_path:
77
- # Use glob to find all files matching the pattern
78
43
  matching_files = glob.glob(normalized_path)
79
- # Normalize paths in the resulting list
80
44
  return [os.path.normpath(file) for file in matching_files]
81
45
  else:
82
- # Single file specified, return it in a list if it exists
83
46
  return [normalized_path] if os.path.exists(normalized_path) else []
84
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
+
85
70
  def main(desired_endpoint='AVAILITY'):
86
- parser = argparse.ArgumentParser(description="Process ERA files and convert them to CSV format.")
87
- parser.add_argument('--config_path', type=str, help='Path to the configuration JSON file', default="json\\config.json") # Default handling of json path
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")
88
73
  parser.add_argument('--desired_endpoint', type=str, help='The desired endpoint key from the configuration.', default=desired_endpoint)
89
- parser.add_argument('--era_file_path', type=str, help='Optional: Specify a path to an ERA file for direct translation.', default=None)
74
+ parser.add_argument('--file_path_pattern', type=str, help='Optional: Specify a path pattern for files for direct translation.', default=None)
90
75
  args = parser.parse_args()
91
76
 
92
- # Setup Logger, Load configuration and output directory
93
77
  config, _ = MediLink_ConfigLoader.load_configuration(args.config_path)
94
78
  local_storage_path = config['MediLink_Config']['local_storage_path']
95
- setup_logger(local_storage_path)
96
79
  output_directory = os.path.join(local_storage_path, "translated_csvs")
97
-
98
- # Direct ERA file translation if a file path is provided
99
- if args.era_file_path:
100
- era_files = find_era_files(args.era_file_path)
101
- if era_files:
102
- era_files_str = ', '.join(era_files)
103
- logging.info("Translating ERA files: {}".format(era_files_str))
104
- MediLink_ERA_decoder.translate_era_to_csv(era_files, output_directory)
105
- # Instead of returning a single CSV file path, consolidate here
106
- consolidate_csv_path = MediLink_ERA_decoder.consolidate_csvs(output_directory)
107
- logging.info("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)
108
89
  return consolidate_csv_path
109
90
  else:
110
- logging.error("No ERA files found matching: {}".format(args.era_file_path))
91
+ MediLink_ConfigLoader.log("No files found matching: {}".format(args.file_path_pattern), level="WARNING")
111
92
  return
112
93
 
113
- # TODO This probably needs to be built into a loop that cycles through all 3 endpoints.
114
- # The loop should use the tdqa or whatever the progress bar is called.
115
- print("Please wait...\n")
116
-
117
- # Validate endpoint key
118
94
  endpoint_key = args.desired_endpoint
119
95
  if endpoint_key not in config['MediLink_Config']['endpoints']:
120
- logging.error("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")
121
97
  endpoint_key = 'AVAILITY'
122
98
 
123
- # Retrieve endpoint configuration and local storage path
124
- endpoint_config = config['MediLink_Config']['endpoints'][endpoint_key]
125
- local_storage_path = config['MediLink_Config']['local_storage_path']
126
-
127
- # Download ERA files from the configured endpoint
128
- downloaded_files = operate_winscp("download", None, endpoint_config, local_storage_path)
99
+ endpoint_configs = [config['MediLink_Config']['endpoints'][key] for key in config['MediLink_Config']['endpoints']]
100
+ downloaded_files = []
101
+
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)
129
106
 
130
- # Translate downloaded ERA files to CSV format
131
- translated_csv_paths = []
132
- for file in downloaded_files:
133
- # TODO This needs to add functionality for differentiating between ERA and 277 or
134
- # whatever else might be included in the download folders.
135
- MediLink_ERA_decoder.translate_era_to_csv([file], output_directory)
136
- csv_file_path = os.path.join(output_directory, os.path.basename(file) + '.csv')
137
- translated_csv_paths.append(csv_file_path)
138
- logging.info("Translated ERA to CSV: {}".format(csv_file_path))
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)
139
111
 
140
- # Consolidate new CSVs
141
- consolidate_csv_path = MediLink_ERA_decoder.consolidate_csvs(output_directory)
112
+ consolidate_csv_path, translated_files = translate_files(downloaded_files, output_directory)
113
+ display_translated_files(translated_files)
142
114
 
143
- # Return the list of translated CSV file paths
144
115
  return consolidate_csv_path
145
116
 
146
117
  if __name__ == "__main__":
@@ -1,9 +1,10 @@
1
1
  import os
2
- import logging
3
2
  import sys
4
- from MediLink_ConfigLoader import setup_logger, load_configuration
3
+ import csv
4
+ from MediLink_ConfigLoader import load_configuration, log
5
5
  from MediLink_DataMgmt import consolidate_csvs
6
6
 
7
+
7
8
  """
8
9
  1. ERA File Processing: Implement robust mechanisms for reading and parsing ERA files, addressing potential file integrity issues and accommodating scenarios with multiple payer addresses within a single ERA.
9
10
  2. Wildcard File Processing: Enable effective batch processing of ERA files using wildcard patterns in the `--era_file_path` argument, resulting in a unified CSV output.
@@ -170,7 +171,6 @@ if __name__ == "__main__":
170
171
 
171
172
  # Setup logger
172
173
  local_storage_path = config['MediLink_Config']['local_storage_path']
173
- setup_logger(local_storage_path)
174
174
 
175
175
  # Define output directory
176
176
  output_directory = os.path.join(local_storage_path, "translated_csvs")
@@ -178,7 +178,7 @@ if __name__ == "__main__":
178
178
  # Retrieve ERA files from command line arguments
179
179
  files = sys.argv[1:] # Exclude the script name
180
180
  if not files:
181
- logging.error("No ERA files provided as arguments.")
181
+ log("No ERA files provided as arguments.")
182
182
  sys.exit(1)
183
183
 
184
184
  # Translate ERA files to CSV format