notebook
This commit is contained in:
78
Kontakty01.py
Normal file
78
Kontakty01.py
Normal file
@@ -0,0 +1,78 @@
|
||||
import firebirdsql,re
|
||||
|
||||
def get_connection():
|
||||
return firebirdsql.connect(
|
||||
host="192.168.1.4",
|
||||
port=3050,
|
||||
database=r"z:\medicus 3\data\medicus.fdb", # path must be valid on the server
|
||||
user="SYSDBA",
|
||||
password="masterkey",
|
||||
charset="WIN1250",
|
||||
)
|
||||
def get_registrovani(cur): #vrati list rodnych cisel registrovanych pacientu "registrovani"
|
||||
cur.execute("""
|
||||
select rodcis from registr join kar
|
||||
on registr.idpac=kar.idpac where
|
||||
kar.vyrazen!='A' and
|
||||
kar.rodcis is not null and
|
||||
idicp!=0 and
|
||||
datum_zruseni is null
|
||||
""")
|
||||
registrovani=[]
|
||||
for radek in cur.fetchall():
|
||||
registrovani.append(radek[0])
|
||||
return registrovani
|
||||
|
||||
def je_registrovany(con,rodcis):
|
||||
cur=conn.cursor()
|
||||
cur.execute("""
|
||||
select 1 from registr join kar
|
||||
on registr.idpac=kar.idpac where
|
||||
kar.vyrazen!='A' and
|
||||
kar.rodcis is not null and
|
||||
idicp!=0 and
|
||||
datum_zruseni is null
|
||||
and rodcis=%s
|
||||
limit 1
|
||||
""")
|
||||
cur.execute(sql, (rodcis,))
|
||||
return cur.fetchone() is not None
|
||||
|
||||
def strip_cz_prefix(num: str) -> str:
|
||||
# remove spaces and non-digits first
|
||||
n = re.sub(r"\D", "", num)
|
||||
|
||||
# strip +420, 00420 or 420 at start
|
||||
if n.startswith("00420"):
|
||||
return n[5:]
|
||||
elif n.startswith("420"):
|
||||
return n[3:]
|
||||
else:
|
||||
return n
|
||||
|
||||
def is_cz_mobile(num: str) -> bool:
|
||||
nmbr=strip_cz_prefix(num)
|
||||
MOBILE_PREFIXES = ("60", "72", "73", "77", "79")
|
||||
# now check length and prefix
|
||||
return len(nmbr) == 9 and nmbr[:2] in MOBILE_PREFIXES
|
||||
|
||||
def get_mobile(rodcis,conn):
|
||||
sql = f"""
|
||||
SELECT kar.prijmeni, kar.rodcis,
|
||||
karkontakt.poradi, karkontakt.kontakt
|
||||
FROM karkontakt join kar on kar.idpac=karkontakt.idpac
|
||||
where kar.rodcis={rodcis}
|
||||
"""
|
||||
cur=conn.cursor()
|
||||
mobil={}
|
||||
|
||||
|
||||
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
|
||||
|
||||
|
||||
# print(get_mobile("340415112",conn))
|
||||
print(is_cz_mobile("283893084"))
|
||||
Reference in New Issue
Block a user