diff --git a/.idea/Medicus1.iml b/.idea/Medicus.iml similarity index 100% rename from .idea/Medicus1.iml rename to .idea/Medicus.iml diff --git a/Form.py b/Form.py new file mode 100644 index 0000000..800213c --- /dev/null +++ b/Form.py @@ -0,0 +1,7 @@ +def console_form(): + print("=== Registration Form ===") + name = input("Enter your name: ") + email = input("Enter your email: ") + print(f"\nThank you, {name}! We'll contact you at {email}.") + +console_form() \ No newline at end of file diff --git a/MobilniCisla.py b/MobilniCisla.py new file mode 100644 index 0000000..203d3d5 --- /dev/null +++ b/MobilniCisla.py @@ -0,0 +1,28 @@ +import os, fdb +from lxml import etree +import hashlib + +# Connect to the Firebird database +conn = fdb.connect( + dsn=r'localhost:u:\medicus 3\data\medicus.fdb', # Database path + user='SYSDBA', # Username + password="masterkey", # Password, + charset="win1250") +cur = conn.cursor() + + + + + +# cur.execute("select distinct recept.idpac, rodcis, upper(kar.PRIJMENI || ', ' || kar.jmeno) as jmeno,notifikace_kontakt " +# "from recept join kar on recept.idpac=kar.idpac " +# "join registr on recept.idpac=registr.idpac where datum_zruseni is null " +# "and notifikace_kontakt is not null " +# "order by recept.datum desc") + +cur.execute("select kar.idpac, kar.prijmeni, kar.rodcis,poradi, kontakt, popis, karkontakt.typ, vztah from karkontakt join kar on kar.idpac=karkontakt.idpac") + +for radek in cur.fetchall(): + print(radek) + + diff --git a/SMS.py b/SMS.py new file mode 100644 index 0000000..142d936 --- /dev/null +++ b/SMS.py @@ -0,0 +1,40 @@ +import requests + + +def send_sms_via_diafaan(): + # Diafaan SMS Server configuration + server_url = "http://localhost:9710/http/send-message" # Replace with your server address + username = "admin" # Replace with your Diafaan username + password = "" # Replace with your Diafaan password + + # SMS details + to_number = "420775735276" # Recipient number with country code + message = "Hello from Python via Diafaan SMS Server!" + sender_id = "" # Optional sender ID + + # Prepare the request parameters + params = { + 'username': username, + 'password': password, + 'to': to_number, + 'message': message, + 'from': sender_id + } + + try: + # Send the HTTP GET request + response = requests.get(server_url, params=params) + + # Check the response + if response.status_code == 200: + print("SMS sent successfully!") + print("Response:", response.text) + else: + print(f"Failed to send SMS. Status code: {response.status_code}") + print("Response:", response.text) + except Exception as e: + print(f"An error occurred: {str(e)}") + + +# Call the function +send_sms_via_diafaan() \ No newline at end of file diff --git a/sms received json.py b/sms received json.py new file mode 100644 index 0000000..44bc05b --- /dev/null +++ b/sms received json.py @@ -0,0 +1,82 @@ +import requests +from datetime import datetime, timedelta + + +def get_received_sms(): + # Diafaan server configuration + server_url = "http://192.168.1.113:9710/http/request-received-messages" + username = "admin" + password = "" + + # Optional filters (adjust as needed) + params = { + 'username': username, + 'password': password, + 'limit': 10, # Number of messages to retrieve + # 'startdate': (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d'), # Last 24 hours + # 'enddate': datetime.now().strftime('%Y-%m-%d'), + # 'unread': 'true' # Only get unread messages (optional) + } + + try: + response = requests.get(server_url, params=params) + + if response.status_code == 200: + # Parse the response (typically CSV or XML format) + if 'text/csv' in response.headers.get('Content-Type', ''): + messages = parse_csv_response(response.text) + else: + messages = parse_xml_response(response.text) + + print(f"Retrieved {len(messages)} messages:") + for msg in messages: + print(f"From: {msg['sender']}, Received: {msg['date']}, Message: {msg['text']}") + + return messages + else: + print(f"Failed to retrieve messages. Status code: {response.status_code}") + print("Response:", response.text) + return None + + except Exception as e: + print(f"An error occurred: {str(e)}") + return None + + +def parse_csv_response(csv_data): + """Parse CSV formatted response from Diafaan""" + messages = [] + for line in csv_data.splitlines()[1:]: # Skip header + if line.strip(): + parts = line.split(',') + if len(parts) >= 4: + messages.append({ + 'id': parts[0], + 'date': parts[1], + 'sender': parts[2], + 'text': ','.join(parts[3:]) # Handle commas in message text + }) + return messages + + +def parse_xml_response(xml_data): + """Parse XML formatted response from Diafaan""" + try: + from xml.etree import ElementTree + messages = [] + root = ElementTree.fromstring(xml_data) + for msg in root.findall('message'): + messages.append({ + 'id': msg.find('id').text if msg.find('id') is not None else '', + 'date': msg.find('date').text if msg.find('date') is not None else '', + 'sender': msg.find('sender').text if msg.find('sender') is not None else '', + 'text': msg.find('text').text if msg.find('text') is not None else '' + }) + return messages + except Exception as e: + print(f"Error parsing XML: {str(e)}") + return [] + + +# Call the function +received_messages = get_received_sms() \ No newline at end of file