notebookVB

This commit is contained in:
2025-10-02 07:17:49 +02:00
parent c41a987dcc
commit 7b8d9b48cf
5 changed files with 124 additions and 54 deletions

2
.idea/Insurance.iml generated
View File

@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" /> <excludeFolder url="file://$MODULE_DIR$/.venv" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.12 (insurance)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.12 (Insurance)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

2
.idea/misc.xml generated
View File

@@ -3,7 +3,7 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="Python 3.12 (insurance)" /> <option name="sdkName" value="Python 3.12 (insurance)" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (insurance)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Insurance)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser"> <component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>

78
.idea/workspace.xml generated
View File

@@ -4,11 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c323bf66-f6a5-4ac2-b555-4106254af180" name="Changes" comment=""> <list default="true" id="c323bf66-f6a5-4ac2-b555-4106254af180" name="Changes" comment="notebookVB">
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/Insurance.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Insurance.iml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/Insurance.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Insurance.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/functions.py" beforeDir="false" afterPath="$PROJECT_DIR$/functions.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/02 testík.py" beforeDir="false" afterPath="$PROJECT_DIR$/02 testík.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/03 Vyber.py" beforeDir="false" afterPath="$PROJECT_DIR$/03 VyberKontrolaStavuPojisteni.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -25,43 +26,43 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="GitHubPullRequestSearchHistory"><![CDATA[{ <component name="GitHubPullRequestSearchHistory">{
"lastFilter": { &quot;lastFilter&quot;: {
"state": "OPEN", &quot;state&quot;: &quot;OPEN&quot;,
"assignee": "vladobb" &quot;assignee&quot;: &quot;vladobb&quot;
} }
}]]></component> }</component>
<component name="GithubPullRequestsUISettings"><![CDATA[{ <component name="GithubPullRequestsUISettings">{
"selectedUrlAndAccountId": { &quot;selectedUrlAndAccountId&quot;: {
"url": "https://github.com/vladobb/insurance", &quot;url&quot;: &quot;https://github.com/vladobb/insurance&quot;,
"accountId": "6e846dd5-17ee-4ac0-9c65-e25808b9f988" &quot;accountId&quot;: &quot;838a92c2-8532-43e8-a61a-667fe50b88ed&quot;
} }
}]]></component> }</component>
<component name="ProjectColorInfo">{ <component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 1 &quot;associatedIndex&quot;: 1
}</component> }</component>
<component name="ProjectId" id="33FcC2tYI91g8V8fLuzrpFNOGkY" /> <component name="ProjectId" id="33FcC2tYI91g8V8fLuzrpFNOGkY" />
<component name="ProjectLevelVcsManager"> <component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" /> <ConfirmationsSetting value="2" id="Add" />
</component> </component>
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Python.01 testik.executor": "Run", &quot;Python.01 testik.executor&quot;: &quot;Run&quot;,
"Python.02 testík.executor": "Run", &quot;Python.02 testík.executor&quot;: &quot;Run&quot;,
"Python.03 Vyber.executor": "Run", &quot;Python.03 Vyber.executor&quot;: &quot;Run&quot;,
"Python.05 testik.executor": "Run", &quot;Python.05 testik.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"git-widget-placeholder": "master", &quot;git-widget-placeholder&quot;: &quot;master&quot;,
"ignore.virus.scanning.warn.message": "true", &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" &quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;
} }
}]]></component> }</component>
<component name="RunManager" selected="Python.03 Vyber"> <component name="RunManager" selected="Python.02 testík">
<configuration name="01 testik" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="01 testik" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Insurance" /> <module name="Insurance" />
<option name="ENV_FILES" value="" /> <option name="ENV_FILES" value="" />
@@ -106,7 +107,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="03 Vyber" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="03 VyberKontrolaStavuPojisteni" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Insurance" /> <module name="Insurance" />
<option name="ENV_FILES" value="" /> <option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@@ -119,7 +120,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/03 Vyber.py" /> <option name="SCRIPT_NAME" value="U:\PycharmProjects\Insurance\03 VyberKontrolaStavuPojisteni.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
@@ -152,17 +153,17 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.03 Vyber" /> <item itemvalue="Python.02 testík" />
<item itemvalue="Python.03 VyberKontrolaStavuPojisteni" />
<item itemvalue="Python.05 testik" /> <item itemvalue="Python.05 testik" />
<item itemvalue="Python.01 testik" /> <item itemvalue="Python.01 testik" />
<item itemvalue="Python.02 testík" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
<component name="SharedIndexes"> <component name="SharedIndexes">
<attachedChunks> <attachedChunks>
<set> <set>
<option value="bundled-python-sdk-890ed5b35930-d9c5bdb153f4-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-251.23774.444" /> <option value="bundled-python-sdk-4f4e415b4190-aa17d162503b-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-243.26053.29" />
</set> </set>
</attachedChunks> </attachedChunks>
</component> </component>
@@ -175,8 +176,21 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1758916129960</updated> <updated>1758916129960</updated>
</task> </task>
<task id="LOCAL-00001" summary="notebookVB">
<option name="closed" value="true" />
<created>1759066485966</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1759066485966</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="notebookVB" />
<option name="LAST_COMMIT_MESSAGE" value="notebookVB" />
</component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>

View File

@@ -15,6 +15,9 @@ from datetime import date
import pymysql import pymysql
from pymysql.cursors import DictCursor from pymysql.cursors import DictCursor
from pprint import pprint from pprint import pprint
from functions import get_medicus_connection
from functions import get_mysql_connection
import time, random
# ------------------- CONFIG ------------------- # ------------------- CONFIG -------------------
ENDPOINT = "https://prod.b2b.vzp.cz/B2BProxy/HttpProxy/RegistracePojistencePZSB2B" # case-sensitive 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" VERIFY = True # or path to CA PEM, e.g. r"C:\certs\vzp_ca.pem"
# Patient + query # Patient + query
# RC = "7309208104" # rodné číslo without slash RC = "7309208104" # rodné číslo without slash
RC = "280616/091" # rodné číslo without slash # RC = "280616/091" # rodné číslo without slash
K_DATU = date.today().isoformat() # YYYY-MM-DD K_DATU = date.today().isoformat() # YYYY-MM-DD
ODBORNOSTI = ["001"] # VPL (adult GP) ODBORNOSTI = ["001"] # VPL (adult GP)
@@ -171,9 +174,54 @@ ON DUPLICATE KEY UPDATE
print(f"\nUpserted rows: {len(payloads)}") print(f"\nUpserted rows: {len(payloads)}")
return 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 ------------------- # ------------------- MAIN FLOW -------------------
def main(): def main():
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 # Build SOAP envelope
envelope = build_envelope(RC, K_DATU, ODBORNOSTI) envelope = build_envelope(RC, K_DATU, ODBORNOSTI)
@@ -198,6 +246,14 @@ def main():
rows, stav = parse_registrace(resp.text) rows, stav = parse_registrace(resp.text)
upsert_rows(RC, K_DATU, rows, stav, resp.text) upsert_rows(RC, K_DATU, rows, stav, resp.text)
time.sleep(random.uniform(1, 5))
if __name__ == "__main__": if __name__ == "__main__":
main() main()