This commit is contained in:
michaela.buzalkova
2025-09-28 15:33:05 +02:00
parent aa52a70bcc
commit adfa781cd0
5 changed files with 118 additions and 36 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>

10
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (insurance)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (insurance)" project-jdk-type="Python SDK" />
<component name="PythonCompatibilityInspectionAdvertiser">
<option name="version" value="3" />
</component>
</project>

94
.idea/workspace.xml generated
View File

@@ -5,14 +5,10 @@
</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="">
<change afterPath="$PROJECT_DIR$/.idea/Insurance.iml" afterDir="false" /> <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/Insurance.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Insurance.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/functions.py" beforeDir="false" afterPath="$PROJECT_DIR$/functions.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/01 testik.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/02 testík.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/functions.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" />
@@ -29,11 +25,23 @@
<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="ProjectColorInfo"><![CDATA[{ <component name="GitHubPullRequestSearchHistory"><![CDATA[{
"associatedIndex": 1 "lastFilter": {
"state": "OPEN",
"assignee": "vladobb"
}
}]]></component> }]]></component>
<component name="GithubPullRequestsUISettings"><![CDATA[{
"selectedUrlAndAccountId": {
"url": "https://github.com/vladobb/insurance",
"accountId": "6e846dd5-17ee-4ac0-9c65-e25808b9f988"
}
}]]></component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 1
}</component>
<component name="ProjectId" id="33FcC2tYI91g8V8fLuzrpFNOGkY" /> <component name="ProjectId" id="33FcC2tYI91g8V8fLuzrpFNOGkY" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true"> <component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" /> <ConfirmationsSetting value="2" id="Add" />
</component> </component>
<component name="ProjectViewState"> <component name="ProjectViewState">
@@ -44,13 +52,16 @@
"keyToString": { "keyToString": {
"Python.01 testik.executor": "Run", "Python.01 testik.executor": "Run",
"Python.02 testík.executor": "Run", "Python.02 testík.executor": "Run",
"Python.03 Vyber.executor": "Run",
"Python.05 testik.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "master", "git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
} }
}]]></component> }]]></component>
<component name="RunManager" selected="Python.01 testik"> <component name="RunManager" selected="Python.03 Vyber">
<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="" />
@@ -95,8 +106,54 @@
<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">
<module name="Insurance" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/03 Vyber.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="05 testik" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="Insurance" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/05 testik.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.03 Vyber" />
<item itemvalue="Python.05 testik" />
<item itemvalue="Python.01 testik" /> <item itemvalue="Python.01 testik" />
<item itemvalue="Python.02 testík" /> <item itemvalue="Python.02 testík" />
</list> </list>
@@ -105,7 +162,7 @@
<component name="SharedIndexes"> <component name="SharedIndexes">
<attachedChunks> <attachedChunks>
<set> <set>
<option value="bundled-python-sdk-4f4e415b4190-aa17d162503b-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-243.26053.29" /> <option value="bundled-python-sdk-890ed5b35930-d9c5bdb153f4-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-251.23774.444" />
</set> </set>
</attachedChunks> </attachedChunks>
</component> </component>
@@ -120,4 +177,15 @@
</task> </task>
<servers /> <servers />
</component> </component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/functions.py</url>
<line>62</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project> </project>

View File

@@ -1,7 +1,7 @@
from functions import get_medicus_connection from functions import get_medicus_connection
from functions import get_mysql_connection from functions import get_mysql_connection
from functions import check_insurance from functions import check_insurance
import time import time, random
def prepare_processed_rcs(): def prepare_processed_rcs():
consql=get_mysql_connection() consql=get_mysql_connection()
@@ -43,4 +43,4 @@ for row in rows:
else: else:
print(row[0], row[1],row[2]) print(row[0], row[1],row[2])
print(check_insurance(row[0])) print(check_insurance(row[0]))
time.sleep(5) time.sleep(random.uniform(1, 5))

View File

@@ -43,8 +43,15 @@ def get_medicus_connection():
print(f"Medicus DB connection failed: {e}") print(f"Medicus DB connection failed: {e}")
return None return None
# -------- MySQL (Medevio, etc.) -------
MYSQL_CFG = dict(
def get_mysql_connection():
"""
Return a PyMySQL connection or None if the connection fails.
"""
if socket.gethostname().strip() == "NTBVBHP470G10":
MYSQL_CFG = dict(
host="192.168.1.76", host="192.168.1.76",
port=3307, port=3307,
user="root", user="root",
@@ -52,12 +59,17 @@ MYSQL_CFG = dict(
database="medevio", database="medevio",
cursorclass=DictCursor, cursorclass=DictCursor,
autocommit=True, # or False if you prefer manual commit autocommit=True, # or False if you prefer manual commit
) )
elif socket.gethostname().strip() == "SESTRA":
def get_mysql_connection(): MYSQL_CFG = dict(
""" host="127.0.0.1",
Return a PyMySQL connection or None if the connection fails. port=3307,
""" user="root",
password="Vlado9674+",
database="medevio",
cursorclass=DictCursor,
autocommit=True, # or False if you prefer manual commit
)
try: try:
return pymysql.connect(**MYSQL_CFG) return pymysql.connect(**MYSQL_CFG)
except pymysql.MySQLError as e: except pymysql.MySQLError as e:
@@ -73,15 +85,7 @@ EP_STAV = "https://prod.b2b.vzp.cz/B2BProxy/HttpProxy/stavPojisteniB2B"
SOAP_NS = "http://schemas.xmlsoap.org/soap/envelope/" SOAP_NS = "http://schemas.xmlsoap.org/soap/envelope/"
NS_STAV = "http://xmlns.gemsystem.cz/stavPojisteniB2B" NS_STAV = "http://xmlns.gemsystem.cz/stavPojisteniB2B"
MYSQL_CFG = {
"host": os.getenv("MYSQL_HOST", "192.168.1.76"),
"port": int(os.getenv("MYSQL_PORT", "3307")),
"user": os.getenv("MYSQL_USER", "root"),
"password": os.getenv("MYSQL_PASSWORD", "Vlado9674+"),
"database": os.getenv("MYSQL_DB", "medevio"),
"cursorclass": DictCursor,
"autocommit": False,
}
# ======== HELPERS ======== # ======== HELPERS ========
def normalize_rc(rc: str) -> str: def normalize_rc(rc: str) -> str:
@@ -153,7 +157,7 @@ def save_stav_pojisteni(rc: str, k_datu: str, parsed: dict, response_xml: str) -
VALUES VALUES
(%(rc)s, %(k_datu)s, %(stav)s, %(kod_pojistovny)s, %(nazev_pojistovny)s, %(pojisteni_kod)s, %(stav_vyrizeni)s, %(response_xml)s) (%(rc)s, %(k_datu)s, %(stav)s, %(kod_pojistovny)s, %(nazev_pojistovny)s, %(pojisteni_kod)s, %(stav_vyrizeni)s, %(response_xml)s)
""" """
conn = pymysql.connect(**MYSQL_CFG) conn = get_mysql_connection()
try: try:
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute(sql, payload) cur.execute(sql, payload)