Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- import hl7
- import hl7apy
- import sys
- from datetime import date, datetime, timedelta
- from mysql.connector import errorcode , Error
- def menu_inicial():
- print("HL7 Manager")
- print("---------------")
- print("1 - Registar")
- print("2 - Alterar")
- print("3 - Cancelar")
- print("0- Sair")
- def registo():
- nome_utente = input('Nome:')
- morada = input("Morada: ")
- telefone = input("Telefone: ")
- telefone = int(telefone)
- nome_medico = input("Medico: ")
- data = input("Data: ")
- hora = input("Hora: ")
- descricao = input("Descricao: ")
- regista_bd(nome_utente, morada , telefone , nome_medico , data, hora , descricao)
- return;
- def regista_bd(nome_utente, morada , telefone , nome_medico , data, hora , descricao):
- try:
- cnx = mysql.connector.connect(user='root',
- password='root',
- database='BDhospital')
- except mysql.connector.Error as err:
- if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
- print("Something is wrong with your user name or password")
- elif err.errno == errorcode.ER_BAD_DB_ERROR:
- print("Database does not exist")
- else:
- print(err)
- else:
- cursor = cnx.cursor()
- data = datetime.now()
- pedido = ("INSERT INTO pedido "
- "(utente_name, morada,telefone,nome_medico,data,hora,'0','obs',descricao,'relatorio') "
- "VALUES (%s, %s, %d, %s, %s, %s, %s,%s,%s)")
- cursor.execute(pedido)
- cnx.commit()
- print("done")
- cursor.close()
- cnx.close()
- return;
- def main():
- op=1
- while(op!=0):
- menu_inicial()
- op=input()
- if op==1 :
- registo()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement