medicafe 0.250728.9__py3-none-any.whl → 0.250805.2__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 +233 -19
- MediBot/MediBot.py +138 -46
- MediBot/MediBot_Crosswalk_Library.py +127 -623
- MediBot/MediBot_Crosswalk_Utils.py +618 -0
- MediBot/MediBot_Preprocessor.py +72 -17
- MediBot/MediBot_Preprocessor_lib.py +470 -76
- MediBot/MediBot_UI.py +32 -17
- MediBot/MediBot_dataformat_library.py +68 -20
- MediBot/MediBot_docx_decoder.py +120 -19
- MediBot/MediBot_smart_import.py +180 -0
- MediBot/__init__.py +89 -0
- MediBot/get_medicafe_version.py +25 -0
- MediBot/update_json.py +35 -6
- MediBot/update_medicafe.py +19 -1
- MediCafe/MediLink_ConfigLoader.py +160 -0
- MediCafe/__init__.py +171 -0
- MediCafe/__main__.py +314 -0
- MediCafe/api_core.py +1098 -0
- MediCafe/api_core_backup.py +427 -0
- MediCafe/api_factory.py +306 -0
- MediCafe/api_utils.py +356 -0
- MediCafe/core_utils.py +450 -0
- MediCafe/graphql_utils.py +445 -0
- MediCafe/logging_config.py +123 -0
- MediCafe/logging_demo.py +61 -0
- MediCafe/migration_helpers.py +463 -0
- MediCafe/smart_import.py +436 -0
- MediLink/MediLink_837p_cob_library.py +28 -28
- MediLink/MediLink_837p_encoder.py +33 -34
- MediLink/MediLink_837p_encoder_library.py +226 -150
- MediLink/MediLink_837p_utilities.py +129 -5
- MediLink/MediLink_API_Generator.py +83 -60
- MediLink/MediLink_API_v3.py +1 -1
- MediLink/MediLink_ClaimStatus.py +177 -31
- MediLink/MediLink_DataMgmt.py +378 -63
- MediLink/MediLink_Decoder.py +20 -1
- MediLink/MediLink_Deductible.py +155 -28
- MediLink/MediLink_Display_Utils.py +72 -0
- MediLink/MediLink_Down.py +127 -5
- MediLink/MediLink_Gmail.py +720 -653
- MediLink/MediLink_PatientProcessor.py +257 -0
- MediLink/MediLink_UI.py +85 -71
- MediLink/MediLink_Up.py +28 -4
- MediLink/MediLink_insurance_utils.py +227 -230
- MediLink/MediLink_main.py +248 -0
- MediLink/MediLink_smart_import.py +264 -0
- MediLink/__init__.py +93 -1
- MediLink/insurance_type_integration_test.py +13 -3
- MediLink/test.py +1 -1
- MediLink/test_timing.py +59 -0
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/METADATA +1 -1
- medicafe-0.250805.2.dist-info/RECORD +81 -0
- medicafe-0.250805.2.dist-info/entry_points.txt +2 -0
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/top_level.txt +1 -0
- medicafe-0.250728.9.dist-info/RECORD +0 -59
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/LICENSE +0 -0
- {medicafe-0.250728.9.dist-info → medicafe-0.250805.2.dist-info}/WHEEL +0 -0
MediBot/__init__.py
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# MediBot package
|
|
2
|
+
"""
|
|
3
|
+
MediBot - Medical Practice Data Entry Automation
|
|
4
|
+
|
|
5
|
+
MediBot provides automated data entry capabilities for medical practice
|
|
6
|
+
management systems, with focus on Medisoft automation.
|
|
7
|
+
|
|
8
|
+
Smart Import Integration:
|
|
9
|
+
Instead of importing MediBot modules directly, use the MediCafe smart
|
|
10
|
+
import system for better dependency management and to avoid circular imports.
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
# Get everything for MediBot preprocessor work
|
|
14
|
+
from MediCafe import setup_for_medibot
|
|
15
|
+
components = setup_for_medibot('medibot_preprocessor')
|
|
16
|
+
|
|
17
|
+
# Get specific MediBot components
|
|
18
|
+
from MediCafe import get_components
|
|
19
|
+
medibot_main = get_components('medibot_main')
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
__version__ = "0.250728.9"
|
|
23
|
+
__author__ = "Daniel Vidaud"
|
|
24
|
+
__email__ = "daniel@personalizedtransformation.com"
|
|
25
|
+
|
|
26
|
+
# Provide information about smart import integration
|
|
27
|
+
def get_smart_import_info():
|
|
28
|
+
"""Get information about using MediBot with the smart import system."""
|
|
29
|
+
return {
|
|
30
|
+
'recommended_approach': 'Use MediCafe smart import system',
|
|
31
|
+
'setup_function': 'setup_for_medibot(module_type)',
|
|
32
|
+
'available_module_types': [
|
|
33
|
+
'medibot_preprocessor',
|
|
34
|
+
'medibot_ui',
|
|
35
|
+
'medibot_crosswalk',
|
|
36
|
+
'medibot_document_processing'
|
|
37
|
+
],
|
|
38
|
+
'example': """
|
|
39
|
+
# Recommended usage:
|
|
40
|
+
from MediCafe import setup_for_medibot
|
|
41
|
+
components = setup_for_medibot('medibot_preprocessor')
|
|
42
|
+
|
|
43
|
+
# Access components:
|
|
44
|
+
api_core = components.get('api_core')
|
|
45
|
+
logging_config = components.get('logging_config')
|
|
46
|
+
preprocessor_lib = components.get('medibot_preprocessor_lib')
|
|
47
|
+
"""
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Show smart import guide
|
|
51
|
+
def show_smart_import_guide():
|
|
52
|
+
"""Display a guide for using MediBot with smart imports."""
|
|
53
|
+
info = get_smart_import_info()
|
|
54
|
+
print("MediBot Smart Import Guide")
|
|
55
|
+
print("=" * 40)
|
|
56
|
+
print("Recommended approach: {}".format(info['recommended_approach']))
|
|
57
|
+
print("Setup function: {}".format(info['setup_function']))
|
|
58
|
+
print("\nAvailable module types:")
|
|
59
|
+
for module_type in info['available_module_types']:
|
|
60
|
+
print(" - {}".format(module_type))
|
|
61
|
+
print("\nExample usage:\n{}".format(info['example']))
|
|
62
|
+
|
|
63
|
+
# Legacy import warning
|
|
64
|
+
def _show_legacy_warning():
|
|
65
|
+
"""Show a warning about direct imports."""
|
|
66
|
+
import warnings
|
|
67
|
+
warnings.warn(
|
|
68
|
+
"Direct MediBot imports may cause circular dependencies. "
|
|
69
|
+
"Consider using 'from MediCafe import setup_for_medibot' instead.",
|
|
70
|
+
FutureWarning,
|
|
71
|
+
stacklevel=3
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Package metadata
|
|
75
|
+
__all__ = [
|
|
76
|
+
'__version__',
|
|
77
|
+
'__author__',
|
|
78
|
+
'__email__',
|
|
79
|
+
'get_smart_import_info',
|
|
80
|
+
'show_smart_import_guide'
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
# Optional: Show guide on import (can be disabled)
|
|
84
|
+
import os
|
|
85
|
+
if os.environ.get('MEDIBOT_SHOW_SMART_IMPORT_GUIDE', '').lower() == 'true':
|
|
86
|
+
try:
|
|
87
|
+
show_smart_import_guide()
|
|
88
|
+
except:
|
|
89
|
+
pass
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
MediCafe Version Detection Script
|
|
5
|
+
Compatible with Python 3.4.4 and Windows XP
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
import pkg_resources
|
|
10
|
+
|
|
11
|
+
def get_medicafe_version():
|
|
12
|
+
"""Get the installed MediCafe package version."""
|
|
13
|
+
try:
|
|
14
|
+
version = pkg_resources.get_distribution('medicafe').version
|
|
15
|
+
print('MediCafe=={}'.format(version))
|
|
16
|
+
return 0
|
|
17
|
+
except pkg_resources.DistributionNotFound:
|
|
18
|
+
print('MediCafe package not found', file=sys.stderr)
|
|
19
|
+
return 1
|
|
20
|
+
except Exception as e:
|
|
21
|
+
print('Error detecting MediCafe version: {}'.format(e), file=sys.stderr)
|
|
22
|
+
return 1
|
|
23
|
+
|
|
24
|
+
if __name__ == '__main__':
|
|
25
|
+
sys.exit(get_medicafe_version())
|
MediBot/update_json.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# update_json.py
|
|
2
2
|
import json
|
|
3
3
|
import sys
|
|
4
|
+
import os
|
|
4
5
|
from collections import OrderedDict
|
|
5
6
|
|
|
6
7
|
def get_current_csv_path(json_file):
|
|
@@ -20,6 +21,32 @@ def get_current_csv_path(json_file):
|
|
|
20
21
|
sys.exit(1)
|
|
21
22
|
return None
|
|
22
23
|
|
|
24
|
+
def normalize_path_for_json(path):
|
|
25
|
+
"""
|
|
26
|
+
Normalize a file path for JSON storage, ensuring proper backslash escaping.
|
|
27
|
+
This function prevents double-processing and ensures consistent formatting.
|
|
28
|
+
"""
|
|
29
|
+
if not path:
|
|
30
|
+
return path
|
|
31
|
+
|
|
32
|
+
# First, normalize the path using os.path to handle any existing issues
|
|
33
|
+
normalized_path = os.path.normpath(path)
|
|
34
|
+
|
|
35
|
+
# Check if the path is already properly formatted for JSON (contains \\\\)
|
|
36
|
+
# We look for the pattern where backslashes are already escaped
|
|
37
|
+
if "\\\\" in normalized_path:
|
|
38
|
+
# Path is already JSON-formatted, return as-is
|
|
39
|
+
return normalized_path
|
|
40
|
+
|
|
41
|
+
# Check if the path contains single backslashes that need escaping
|
|
42
|
+
if "\\" in normalized_path:
|
|
43
|
+
# Escape single backslashes for JSON
|
|
44
|
+
formatted_path = normalized_path.replace("\\", "\\\\")
|
|
45
|
+
return formatted_path
|
|
46
|
+
|
|
47
|
+
# No backslashes found, return as-is
|
|
48
|
+
return normalized_path
|
|
49
|
+
|
|
23
50
|
def update_csv_path(json_file, new_path):
|
|
24
51
|
try:
|
|
25
52
|
with open(json_file, 'r', encoding='utf-8') as file:
|
|
@@ -29,12 +56,14 @@ def update_csv_path(json_file, new_path):
|
|
|
29
56
|
print("Error decoding JSON file '{}': {}".format(json_file, decode_err))
|
|
30
57
|
sys.exit(1)
|
|
31
58
|
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
59
|
+
# Use the improved path normalization function
|
|
60
|
+
formatted_path = normalize_path_for_json(new_path)
|
|
61
|
+
|
|
62
|
+
# Validate that the path doesn't have excessive slashes
|
|
63
|
+
if formatted_path.count("\\\\") > formatted_path.count("\\") * 2:
|
|
64
|
+
print("Warning: Path may have excessive backslashes. Original: {}, Formatted: {}".format(
|
|
65
|
+
new_path, formatted_path))
|
|
66
|
+
|
|
38
67
|
data['CSV_FILE_PATH'] = formatted_path
|
|
39
68
|
|
|
40
69
|
with open(json_file, 'w', encoding='utf-8') as file:
|
MediBot/update_medicafe.py
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
#update_medicafe.py
|
|
2
|
-
import subprocess, sys,
|
|
2
|
+
import subprocess, sys, time, platform
|
|
3
|
+
|
|
4
|
+
# Safe import for pkg_resources with fallback
|
|
5
|
+
try:
|
|
6
|
+
import pkg_resources
|
|
7
|
+
except ImportError:
|
|
8
|
+
pkg_resources = None
|
|
9
|
+
print("Warning: pkg_resources not available. Some functionality may be limited.")
|
|
10
|
+
|
|
11
|
+
# Safe import for requests with fallback
|
|
12
|
+
try:
|
|
13
|
+
import requests
|
|
14
|
+
except ImportError:
|
|
15
|
+
requests = None
|
|
16
|
+
print("Warning: requests module not available. Some functionality may be limited.")
|
|
3
17
|
|
|
4
18
|
def get_installed_version(package):
|
|
5
19
|
try:
|
|
@@ -22,6 +36,10 @@ def get_latest_version(package, retries=3, delay=1):
|
|
|
22
36
|
"""
|
|
23
37
|
Fetch the latest version of the specified package from PyPI with retries.
|
|
24
38
|
"""
|
|
39
|
+
if not requests:
|
|
40
|
+
print("Error: requests module not available. Cannot fetch latest version.")
|
|
41
|
+
return None
|
|
42
|
+
|
|
25
43
|
for attempt in range(1, retries + 1):
|
|
26
44
|
try:
|
|
27
45
|
response = requests.get("https://pypi.org/pypi/{}/json".format(package), timeout=10)
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# MediLink_ConfigLoader.py
|
|
2
|
+
import os, json, logging, sys, platform
|
|
3
|
+
try:
|
|
4
|
+
import yaml
|
|
5
|
+
except ImportError:
|
|
6
|
+
yaml = None
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
from collections import OrderedDict
|
|
9
|
+
|
|
10
|
+
# Global configuration cache to prevent repeated loading
|
|
11
|
+
_CONFIG_CACHE = None
|
|
12
|
+
_CROSSWALK_CACHE = None
|
|
13
|
+
|
|
14
|
+
# Import centralized logging configuration
|
|
15
|
+
try:
|
|
16
|
+
from MediCafe.logging_config import PERFORMANCE_LOGGING
|
|
17
|
+
except ImportError:
|
|
18
|
+
# Fallback to local flag if centralized config is not available
|
|
19
|
+
PERFORMANCE_LOGGING = False
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
This function should be generalizable to have a initialization script over all the Medi* functions
|
|
23
|
+
"""
|
|
24
|
+
def load_configuration(config_path=os.path.join(os.path.dirname(__file__), '..', 'json', 'config.json'), crosswalk_path=os.path.join(os.path.dirname(__file__), '..', 'json', 'crosswalk.json')):
|
|
25
|
+
"""
|
|
26
|
+
Loads endpoint configuration, credentials, and other settings from JSON or YAML files.
|
|
27
|
+
|
|
28
|
+
Returns: A tuple containing dictionaries with configuration settings for the main config and crosswalk.
|
|
29
|
+
"""
|
|
30
|
+
global _CONFIG_CACHE, _CROSSWALK_CACHE
|
|
31
|
+
|
|
32
|
+
# Return cached configuration if available
|
|
33
|
+
if _CONFIG_CACHE is not None and _CROSSWALK_CACHE is not None:
|
|
34
|
+
return _CONFIG_CACHE, _CROSSWALK_CACHE
|
|
35
|
+
|
|
36
|
+
import time
|
|
37
|
+
config_start = time.time()
|
|
38
|
+
if PERFORMANCE_LOGGING:
|
|
39
|
+
print("Configuration loading started...")
|
|
40
|
+
|
|
41
|
+
# TODO (Low Config Upgrade) The Medicare / Private differentiator flag probably needs to be pulled or passed to this.
|
|
42
|
+
# Use provided paths, or fall back to platform-specific defaults
|
|
43
|
+
path_check_start = time.time()
|
|
44
|
+
if not os.path.exists(config_path):
|
|
45
|
+
# Try platform-specific paths as fallback
|
|
46
|
+
if platform.system() == 'Windows' and platform.release() == 'XP':
|
|
47
|
+
# Use F: paths for Windows XP
|
|
48
|
+
config_path = "F:\\Medibot\\json\\config.json"
|
|
49
|
+
crosswalk_path = "G:\\My Drive\\Codes\\MediCafe\\json\\crosswalk.json"
|
|
50
|
+
elif platform.system() == 'Windows':
|
|
51
|
+
# Use G: paths for other versions of Windows
|
|
52
|
+
config_path = "G:\\My Drive\\Codes\\MediCafe\\json\\config.json"
|
|
53
|
+
crosswalk_path = "G:\\My Drive\\Codes\\MediCafe\\json\\crosswalk.json"
|
|
54
|
+
# If not Windows or if local files don't exist, keep the default paths
|
|
55
|
+
|
|
56
|
+
path_check_end = time.time()
|
|
57
|
+
if PERFORMANCE_LOGGING:
|
|
58
|
+
print("Path resolution completed in {:.2f} seconds".format(path_check_end - path_check_start))
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
config_load_start = time.time()
|
|
62
|
+
with open(config_path, 'r') as config_file:
|
|
63
|
+
if config_path.endswith('.yaml') or config_path.endswith('.yml'):
|
|
64
|
+
config = yaml.safe_load(config_file)
|
|
65
|
+
elif config_path.endswith('.json'):
|
|
66
|
+
config = json.load(config_file, object_pairs_hook=OrderedDict)
|
|
67
|
+
else:
|
|
68
|
+
raise ValueError("Unsupported configuration format.")
|
|
69
|
+
|
|
70
|
+
if 'MediLink_Config' not in config:
|
|
71
|
+
raise KeyError("MediLink_Config key is missing from the loaded configuration.")
|
|
72
|
+
|
|
73
|
+
config_load_end = time.time()
|
|
74
|
+
if PERFORMANCE_LOGGING:
|
|
75
|
+
print("Config file loading completed in {:.2f} seconds".format(config_load_end - config_load_start))
|
|
76
|
+
|
|
77
|
+
crosswalk_load_start = time.time()
|
|
78
|
+
with open(crosswalk_path, 'r') as crosswalk_file:
|
|
79
|
+
crosswalk = json.load(crosswalk_file)
|
|
80
|
+
crosswalk_load_end = time.time()
|
|
81
|
+
if PERFORMANCE_LOGGING:
|
|
82
|
+
print("Crosswalk file loading completed in {:.2f} seconds".format(crosswalk_load_end - crosswalk_load_start))
|
|
83
|
+
|
|
84
|
+
config_end = time.time()
|
|
85
|
+
if PERFORMANCE_LOGGING:
|
|
86
|
+
print("Total configuration loading completed in {:.2f} seconds".format(config_end - config_start))
|
|
87
|
+
|
|
88
|
+
# Cache the loaded configuration
|
|
89
|
+
_CONFIG_CACHE = config
|
|
90
|
+
_CROSSWALK_CACHE = crosswalk
|
|
91
|
+
|
|
92
|
+
return config, crosswalk
|
|
93
|
+
except ValueError as e:
|
|
94
|
+
if isinstance(e, UnicodeDecodeError):
|
|
95
|
+
print("Error decoding file: {}".format(e))
|
|
96
|
+
else:
|
|
97
|
+
print("Error parsing file: {}".format(e))
|
|
98
|
+
sys.exit(1) # Exit the script due to a critical error in configuration loading
|
|
99
|
+
except FileNotFoundError:
|
|
100
|
+
print("One or both configuration files not found. Config: {}, Crosswalk: {}".format(config_path, crosswalk_path))
|
|
101
|
+
sys.exit(1) # Exit the script due to a critical error in configuration loading
|
|
102
|
+
except KeyError as e:
|
|
103
|
+
print("Critical configuration is missing: {}".format(e))
|
|
104
|
+
sys.exit(1) # Exit the script due to a critical error in configuration loading
|
|
105
|
+
except Exception as e:
|
|
106
|
+
print("An unexpected error occurred while loading the configuration: {}".format(e))
|
|
107
|
+
sys.exit(1) # Exit the script due to a critical error in configuration loading
|
|
108
|
+
|
|
109
|
+
def clear_config_cache():
|
|
110
|
+
"""Clear the configuration cache to force reloading on next call."""
|
|
111
|
+
global _CONFIG_CACHE, _CROSSWALK_CACHE
|
|
112
|
+
_CONFIG_CACHE = None
|
|
113
|
+
_CROSSWALK_CACHE = None
|
|
114
|
+
|
|
115
|
+
# Logs messages with optional error type and claim data.
|
|
116
|
+
def log(message, config=None, level="INFO", error_type=None, claim=None, verbose=False, console_output=False):
|
|
117
|
+
|
|
118
|
+
# If config is not provided, use cached config or load it
|
|
119
|
+
if config is None:
|
|
120
|
+
if _CONFIG_CACHE is None:
|
|
121
|
+
config, _ = load_configuration()
|
|
122
|
+
else:
|
|
123
|
+
config = _CONFIG_CACHE
|
|
124
|
+
|
|
125
|
+
# Setup logger if not already configured
|
|
126
|
+
if not logging.root.handlers:
|
|
127
|
+
local_storage_path = config['MediLink_Config'].get('local_storage_path', '.') if isinstance(config, dict) else '.'
|
|
128
|
+
log_filename = datetime.now().strftime("Log_%m%d%Y.log")
|
|
129
|
+
log_filepath = os.path.join(local_storage_path, log_filename)
|
|
130
|
+
|
|
131
|
+
# Set logging level based on verbosity
|
|
132
|
+
logging_level = logging.DEBUG if verbose else logging.INFO
|
|
133
|
+
|
|
134
|
+
# Create formatter
|
|
135
|
+
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
|
|
136
|
+
|
|
137
|
+
# Create file handler
|
|
138
|
+
file_handler = logging.FileHandler(log_filepath, mode='a')
|
|
139
|
+
file_handler.setFormatter(formatter)
|
|
140
|
+
|
|
141
|
+
# Create handlers list - always include file handler
|
|
142
|
+
handlers = [file_handler]
|
|
143
|
+
|
|
144
|
+
# Add console handler only if console_output is True
|
|
145
|
+
if console_output:
|
|
146
|
+
console_handler = logging.StreamHandler()
|
|
147
|
+
console_handler.setFormatter(formatter)
|
|
148
|
+
handlers.append(console_handler)
|
|
149
|
+
|
|
150
|
+
# Configure root logger
|
|
151
|
+
logging.basicConfig(level=logging_level, handlers=handlers)
|
|
152
|
+
|
|
153
|
+
# Prepare log message
|
|
154
|
+
claim_data = " - Claim Data: {}".format(claim) if claim else ""
|
|
155
|
+
error_info = " - Error Type: {}".format(error_type) if error_type else ""
|
|
156
|
+
full_message = "{} {}{}".format(message, claim_data, error_info)
|
|
157
|
+
|
|
158
|
+
# Log the message
|
|
159
|
+
logger = logging.getLogger()
|
|
160
|
+
getattr(logger, level.lower())(full_message)
|
MediCafe/__init__.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# MediCafe package
|
|
2
|
+
"""
|
|
3
|
+
MediCafe - Medical Practice Management Automation Suite
|
|
4
|
+
|
|
5
|
+
A comprehensive suite for automating medical administrative tasks in Medisoft.
|
|
6
|
+
Includes MediBot for data entry automation and MediLink for claims processing.
|
|
7
|
+
|
|
8
|
+
Smart Import System:
|
|
9
|
+
The MediCafe package now includes a smart import system that provides
|
|
10
|
+
centralized component management for all MediBot and MediLink modules.
|
|
11
|
+
|
|
12
|
+
Quick Start:
|
|
13
|
+
# Get specific components
|
|
14
|
+
from MediCafe import get_components
|
|
15
|
+
api_core, logging_config = get_components('api_core', 'logging_config')
|
|
16
|
+
|
|
17
|
+
# Setup for MediBot
|
|
18
|
+
from MediCafe import setup_for_medibot
|
|
19
|
+
components = setup_for_medibot('medibot_preprocessor')
|
|
20
|
+
|
|
21
|
+
# Setup for MediLink
|
|
22
|
+
from MediCafe import setup_for_medilink
|
|
23
|
+
components = setup_for_medilink('medilink_main')
|
|
24
|
+
|
|
25
|
+
# Get complete API access
|
|
26
|
+
from MediCafe import get_api_access
|
|
27
|
+
api_suite = get_api_access()
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
__version__ = "0.250728.9"
|
|
31
|
+
__author__ = "Daniel Vidaud"
|
|
32
|
+
__email__ = "daniel@personalizedtransformation.com"
|
|
33
|
+
|
|
34
|
+
# Import and expose the smart import system
|
|
35
|
+
try:
|
|
36
|
+
from .smart_import import (
|
|
37
|
+
# Main interface
|
|
38
|
+
get_components,
|
|
39
|
+
|
|
40
|
+
# Convenience functions
|
|
41
|
+
get_api_access,
|
|
42
|
+
get_logging,
|
|
43
|
+
get_core_utils,
|
|
44
|
+
setup_for_medibot,
|
|
45
|
+
setup_for_medilink,
|
|
46
|
+
|
|
47
|
+
# Discovery functions
|
|
48
|
+
list_components,
|
|
49
|
+
list_module_types,
|
|
50
|
+
describe_module_type,
|
|
51
|
+
|
|
52
|
+
# Validation and utilities
|
|
53
|
+
validate_setup,
|
|
54
|
+
show_usage_examples
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Mark smart import system as available
|
|
58
|
+
__smart_import_available__ = True
|
|
59
|
+
|
|
60
|
+
except ImportError as e:
|
|
61
|
+
# Fallback if smart import system is not available
|
|
62
|
+
__smart_import_available__ = False
|
|
63
|
+
|
|
64
|
+
def _smart_import_unavailable(*args, **kwargs):
|
|
65
|
+
raise ImportError("MediCafe Smart Import System is not available: {}".format(e))
|
|
66
|
+
|
|
67
|
+
# Provide error functions for missing imports
|
|
68
|
+
get_components = _smart_import_unavailable
|
|
69
|
+
get_api_access = _smart_import_unavailable
|
|
70
|
+
get_logging = _smart_import_unavailable
|
|
71
|
+
get_core_utils = _smart_import_unavailable
|
|
72
|
+
setup_for_medibot = _smart_import_unavailable
|
|
73
|
+
setup_for_medilink = _smart_import_unavailable
|
|
74
|
+
list_components = _smart_import_unavailable
|
|
75
|
+
list_module_types = _smart_import_unavailable
|
|
76
|
+
describe_module_type = _smart_import_unavailable
|
|
77
|
+
validate_setup = _smart_import_unavailable
|
|
78
|
+
show_usage_examples = _smart_import_unavailable
|
|
79
|
+
|
|
80
|
+
# Legacy imports for backward compatibility
|
|
81
|
+
try:
|
|
82
|
+
from . import api_core
|
|
83
|
+
from . import logging_config
|
|
84
|
+
from . import core_utils
|
|
85
|
+
__legacy_imports_available__ = True
|
|
86
|
+
except ImportError:
|
|
87
|
+
__legacy_imports_available__ = False
|
|
88
|
+
|
|
89
|
+
# Package information
|
|
90
|
+
__all__ = [
|
|
91
|
+
# Smart import system
|
|
92
|
+
'get_components',
|
|
93
|
+
'get_api_access',
|
|
94
|
+
'get_logging',
|
|
95
|
+
'get_core_utils',
|
|
96
|
+
'setup_for_medibot',
|
|
97
|
+
'setup_for_medilink',
|
|
98
|
+
'list_components',
|
|
99
|
+
'list_module_types',
|
|
100
|
+
'describe_module_type',
|
|
101
|
+
'validate_setup',
|
|
102
|
+
'show_usage_examples',
|
|
103
|
+
|
|
104
|
+
# Package metadata
|
|
105
|
+
'__version__',
|
|
106
|
+
'__author__',
|
|
107
|
+
'__email__',
|
|
108
|
+
'__smart_import_available__',
|
|
109
|
+
'__legacy_imports_available__'
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
def get_package_info():
|
|
113
|
+
"""Get information about the MediCafe package and its capabilities."""
|
|
114
|
+
info = {
|
|
115
|
+
'version': __version__,
|
|
116
|
+
'author': __author__,
|
|
117
|
+
'email': __email__,
|
|
118
|
+
'smart_import_available': __smart_import_available__,
|
|
119
|
+
'legacy_imports_available': __legacy_imports_available__
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if __smart_import_available__:
|
|
123
|
+
try:
|
|
124
|
+
info['available_components'] = len(list_components())
|
|
125
|
+
info['available_module_types'] = len(list_module_types())
|
|
126
|
+
except:
|
|
127
|
+
info['available_components'] = 'unknown'
|
|
128
|
+
info['available_module_types'] = 'unknown'
|
|
129
|
+
|
|
130
|
+
return info
|
|
131
|
+
|
|
132
|
+
def quick_start_guide():
|
|
133
|
+
"""Display a quick start guide for using MediCafe."""
|
|
134
|
+
guide = """
|
|
135
|
+
MediCafe Quick Start Guide
|
|
136
|
+
=========================
|
|
137
|
+
|
|
138
|
+
1. Basic Usage - Get specific components:
|
|
139
|
+
from MediCafe import get_components
|
|
140
|
+
api_core, logging = get_components('api_core', 'logging_config')
|
|
141
|
+
|
|
142
|
+
2. MediBot Setup - Get everything for MediBot:
|
|
143
|
+
from MediCafe import setup_for_medibot
|
|
144
|
+
components = setup_for_medibot('medibot_preprocessor')
|
|
145
|
+
|
|
146
|
+
3. MediLink Setup - Get everything for MediLink:
|
|
147
|
+
from MediCafe import setup_for_medilink
|
|
148
|
+
components = setup_for_medilink('medilink_main')
|
|
149
|
+
|
|
150
|
+
4. API Access - Get complete API suite:
|
|
151
|
+
from MediCafe import get_api_access
|
|
152
|
+
api_suite = get_api_access()
|
|
153
|
+
|
|
154
|
+
5. Discovery - See what's available:
|
|
155
|
+
from MediCafe import list_components, list_module_types
|
|
156
|
+
print("Components:", list_components())
|
|
157
|
+
print("Module types:", list_module_types())
|
|
158
|
+
|
|
159
|
+
6. Validation - Test the system:
|
|
160
|
+
from MediCafe import validate_setup
|
|
161
|
+
validate_setup()
|
|
162
|
+
"""
|
|
163
|
+
print(guide)
|
|
164
|
+
|
|
165
|
+
# Auto-validation message (only if smart import is available)
|
|
166
|
+
if __smart_import_available__:
|
|
167
|
+
try:
|
|
168
|
+
# Silent validation on package import
|
|
169
|
+
pass
|
|
170
|
+
except:
|
|
171
|
+
pass
|