Pranay25 commited on
Commit
d372b37
·
verified ·
1 Parent(s): 8ce4fcc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -24,10 +24,10 @@ GENDER_MAPPING = {
24
  "Other": "Others" # Map 'Other' to 'Others' to match Salesforce picklist
25
  }
26
 
27
- # Salesforce credentials
28
- SALESFORCE_USERNAME = "sathkruthatech@hms.com"
29
- SALESFORCE_PASSWORD = "Hms@2025"
30
- SALESFORCE_SECURITY_TOKEN = "5W0grf0aX0M9cD3yDZ2C5F"
31
 
32
  # Initialize PaddleOCR
33
  ocr = PaddleOCR(use_angle_cls=True, lang='en')
@@ -46,7 +46,7 @@ def extract_attributes(extracted_text):
46
 
47
  # Patterns for extracting personal information
48
  patterns = {
49
- "Name": r"Name[:\-]?\s*([A-Za-z]+)", # Extracts names without spaces
50
  "Age": r"Age[:\-]?\s*(\d{1,3})", # Extracts 1-3 digit age
51
  "Gender": r"Gender[:\-]?\s*(Male|Female|Other)", # Extracts Male, Female, or Other
52
  "Phone Number": r"(?:(?:Phone Number)|Phone|Mobile|Phonenumber)[:\-]?\s*(?:\+91)?([6-9]\d{9})" # Indian phone number: 10 digits, starts with 6-9
@@ -81,8 +81,10 @@ def interact_with_salesforce(attributes):
81
  username=SALESFORCE_USERNAME,
82
  password=SALESFORCE_PASSWORD,
83
  security_token=SALESFORCE_SECURITY_TOKEN,
84
- domain="test" # Sandbox instance
 
85
  )
 
86
 
87
  # Reference the Patient_Registration__c object
88
  object_name = "Patient_Registration__c"
@@ -91,6 +93,11 @@ def interact_with_salesforce(attributes):
91
  # Get the object's schema to validate fields
92
  schema = sf_object.describe()
93
  valid_fields = {field["name"] for field in schema["fields"]}
 
 
 
 
 
94
 
95
  # Filter attributes to match valid Salesforce fields
96
  filtered_attributes = filter_valid_attributes(attributes, valid_fields)
 
24
  "Other": "Others" # Map 'Other' to 'Others' to match Salesforce picklist
25
  }
26
 
27
+ # Salesforce credentials from environment variables
28
+ SALESFORCE_USERNAME = os.getenv("SALESFORCE_USERNAME", "sathkruthatech@hms.com")
29
+ SALESFORCE_PASSWORD = os.getenv("SALESFORCE_PASSWORD", "Hms@2025")
30
+ SALESFORCE_SECURITY_TOKEN = os.getenv("SALESFORCE_SECURITY_TOKEN", "5W0grf0aX0M9cD3yDZ2C5F")
31
 
32
  # Initialize PaddleOCR
33
  ocr = PaddleOCR(use_angle_cls=True, lang='en')
 
46
 
47
  # Patterns for extracting personal information
48
  patterns = {
49
+ "Name": r"Name[:\-]?\s*([A-Za-z\s]+)", # Supports spaces in names
50
  "Age": r"Age[:\-]?\s*(\d{1,3})", # Extracts 1-3 digit age
51
  "Gender": r"Gender[:\-]?\s*(Male|Female|Other)", # Extracts Male, Female, or Other
52
  "Phone Number": r"(?:(?:Phone Number)|Phone|Mobile|Phonenumber)[:\-]?\s*(?:\+91)?([6-9]\d{9})" # Indian phone number: 10 digits, starts with 6-9
 
81
  username=SALESFORCE_USERNAME,
82
  password=SALESFORCE_PASSWORD,
83
  security_token=SALESFORCE_SECURITY_TOKEN,
84
+ domain="test",
85
+ version="60.0"
86
  )
87
+ print(f"Successfully connected to Salesforce as {SALESFORCE_USERNAME}")
88
 
89
  # Reference the Patient_Registration__c object
90
  object_name = "Patient_Registration__c"
 
93
  # Get the object's schema to validate fields
94
  schema = sf_object.describe()
95
  valid_fields = {field["name"] for field in schema["fields"]}
96
+ print(f"Valid fields for {object_name}: {valid_fields}")
97
+
98
+ # Check field permissions
99
+ field_permissions = {field["name"]: field["createable"] for field in schema["fields"]}
100
+ print(f"Field permissions (createable): {field_permissions}")
101
 
102
  # Filter attributes to match valid Salesforce fields
103
  filtered_attributes = filter_valid_attributes(attributes, valid_fields)