diff --git a/.idea/Insurance.iml b/.idea/Insurance.iml
index 099709f..235ece6 100644
--- a/.idea/Insurance.iml
+++ b/.idea/Insurance.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 28a0efa..aaa7797 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index da793cc..b6499de 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,12 @@
-
-
+
+
-
+
+
@@ -25,43 +26,43 @@
- {
+ "lastFilter": {
+ "state": "OPEN",
+ "assignee": "vladobb"
}
-}]]>
-
+ {
+ "selectedUrlAndAccountId": {
+ "url": "https://github.com/vladobb/insurance",
+ "accountId": "838a92c2-8532-43e8-a61a-667fe50b88ed"
}
-}]]>
+}
{
"associatedIndex": 1
}
-
+
- {
+ "keyToString": {
+ "Python.01 testik.executor": "Run",
+ "Python.02 testík.executor": "Run",
+ "Python.03 Vyber.executor": "Run",
+ "Python.05 testik.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "git-widget-placeholder": "master",
+ "ignore.virus.scanning.warn.message": "true",
+ "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
}
-}]]>
-
+}
+
@@ -106,7 +107,7 @@
-
+
@@ -119,7 +120,7 @@
-
+
@@ -152,17 +153,17 @@
-
+
+
-
-
+
@@ -175,8 +176,21 @@
1758916129960
+
+
+ 1759066485966
+
+
+
+ 1759066485966
+
+
+
+
+
+
diff --git a/02 testík.py b/02 testík.py
index d3e4d74..810dfc0 100644
--- a/02 testík.py
+++ b/02 testík.py
@@ -15,6 +15,9 @@ from datetime import date
import pymysql
from pymysql.cursors import DictCursor
from pprint import pprint
+from functions import get_medicus_connection
+from functions import get_mysql_connection
+import time, random
# ------------------- CONFIG -------------------
ENDPOINT = "https://prod.b2b.vzp.cz/B2BProxy/HttpProxy/RegistracePojistencePZSB2B" # case-sensitive
@@ -23,8 +26,8 @@ PFX_PASS = "Vlado7309208104++" # <-- your export password
VERIFY = True # or path to CA PEM, e.g. r"C:\certs\vzp_ca.pem"
# Patient + query
-# RC = "7309208104" # rodné číslo without slash
-RC = "280616/091" # rodné číslo without slash
+RC = "7309208104" # rodné číslo without slash
+# RC = "280616/091" # rodné číslo without slash
K_DATU = date.today().isoformat() # YYYY-MM-DD
ODBORNOSTI = ["001"] # VPL (adult GP)
@@ -171,32 +174,85 @@ ON DUPLICATE KEY UPDATE
print(f"\nUpserted rows: {len(payloads)}")
return len(payloads)
+def prepare_processed_rcs():
+ consql=get_mysql_connection()
+ cursql=consql.cursor()
+
+ sql="""
+ WITH ranked AS (
+ SELECT
+ vreg.*,
+ ROW_NUMBER() OVER (
+ PARTITION BY rc
+ ORDER BY query_date DESC
+ ) AS rn
+ FROM vzp_registrace AS vreg
+ )
+ SELECT rc
+ FROM ranked
+ WHERE rn = 1
+ """
+
+ cursql.execute(sql)
+ rows=cursql.fetchall()
+ print(f"Pocet jiz zpracovanych rodnych cisel v MYSQL MEDEVIO je {len(rows)}")
+ rc_set_vzp = {row["rc"] for row in rows}
+ return (rc_set_vzp)
# ------------------- MAIN FLOW -------------------
def main():
- # Build SOAP envelope
- envelope = build_envelope(RC, K_DATU, ODBORNOSTI)
- # mTLS session
- session = requests.Session()
- session.mount("https://", Pkcs12Adapter(pkcs12_filename=PFX_PATH, pkcs12_password=PFX_PASS))
+ con = get_medicus_connection()
+ cur = con.cursor()
+ cur.execute("select rodcis, prijmeni, jmeno from kar where rodcis starting with '0'")
+ # cur.execute("select first 2 rodcis, prijmeni, jmeno from kar where rodcis starting with '0'")
+
+ # Vytvor seznam rodnych cisel, která už máme
+ rc_set_vzp = prepare_processed_rcs()
+
+ rows = cur.fetchall()
+ print(f"Pocet vybranych radku z tabulky KAR je: {len(rows)}")
+
+ for row in rows:
+ if row[0] in rc_set_vzp:
+ continue
+ else:
+ print(row[0], row[1], row[2])
+ K_DATU = date.today().isoformat() # YYYY-MM-DD
+ ODBORNOSTI = ["001"]
+ RC=row[0]
+
+ # Build SOAP envelope
+ envelope = build_envelope(RC, K_DATU, ODBORNOSTI)
+
+ # mTLS session
+ session = requests.Session()
+ session.mount("https://", Pkcs12Adapter(pkcs12_filename=PFX_PATH, pkcs12_password=PFX_PASS))
+
+ headers = {
+ "Content-Type": "text/xml; charset=utf-8",
+ "SOAPAction": "process", # Oracle composite usually expects this
+ }
+
+ # Call service
+ resp = session.post(ENDPOINT, data=envelope.encode("utf-8"),
+ headers=headers, timeout=30, verify=VERIFY)
+ print("HTTP:", resp.status_code)
+
+ # (Optional) Uncomment to see raw XML
+ # print(resp.text)
+
+ # Parse and save
+ rows, stav = parse_registrace(resp.text)
+ upsert_rows(RC, K_DATU, rows, stav, resp.text)
+
+ time.sleep(random.uniform(1, 5))
+
+
- headers = {
- "Content-Type": "text/xml; charset=utf-8",
- "SOAPAction": "process", # Oracle composite usually expects this
- }
- # Call service
- resp = session.post(ENDPOINT, data=envelope.encode("utf-8"),
- headers=headers, timeout=30, verify=VERIFY)
- print("HTTP:", resp.status_code)
- # (Optional) Uncomment to see raw XML
- # print(resp.text)
- # Parse and save
- rows, stav = parse_registrace(resp.text)
- upsert_rows(RC, K_DATU, rows, stav, resp.text)
if __name__ == "__main__":
diff --git a/03 Vyber.py b/03 VyberKontrolaStavuPojisteni.py
similarity index 100%
rename from 03 Vyber.py
rename to 03 VyberKontrolaStavuPojisteni.py