Source

pacient db / test.py

# -*- coding: utf-8 -*-
from PyQt4 import QtGui
import sys
from PyQt4 import QtCore
#TODO: setForwardOnly pt query cica e mult mai rapid
#TODO:setDisplayFormat la alea care afiseaza data ca sa nu mai fie prostii 
#TODO:citit 467-8

class Analize_widget(QtGui.QWidget):
    def __init__(self,parent,nume,unitateDeMasura=None):
        self.parent=parent
        QtGui.QWidget.__init__(self,self.parent)
        self.nume=nume
        self.unitate=unitateDeMasura
        self.analiza=QtGui.QLabel(self.nume)
        self.valoare=QtGui.QLineEdit()
        self.layout=QtGui.QHBoxLayout()
        self.layout.addWidget(self.analiza)
        if self.unitate:
            self.unit=QtGui.QLabel(self.unitate)
            self.layout.addWidget(self.unit)
        self.layout.addWidget(self.valoare)
        self.setLayout(self.layout)
        self.setObjectName(self.nume)
    def __float__(self):
        try:
            return float(self.valoare.text())
        except:
            return 0.0
    def forPrint(self):
        #greu de folosit: mai bine cu atribute
        a={'analiza':self.nume,'valoare':self.valoare.text(),'unitate':self.unitate}
        return a
    def __repr__(self):
        return self.valoare.text()
    def text(self):
        return self.valoare.text()
    def __str__(self):
	    return self.nume
    def baga(self,valoare):
        self.valoare.setText(valoare)
        
        
class Pagina_widget(QtGui.QWidget):
    def __init__(self,setu,parent=None):
      QtGui.QWidget.__init__(self,parent)
      self.biochimieSet={'ac uric':'mg/dL','albumina':'g/dL','creatinina':'mg/dL','uree':'mg/dL','calciu total':'mg/dL'}
      self.hemogramaSet={'leucocite':'mii/uL','hemoglobina':'g/dL','hematocrit':'%','plachete':'mii/uL',
      'bicarbonat':'mmol/L'}
      self.pipiSet={'colesterol':'mg/dL','trigliceride':'mg/dL','tgop':'UI/L',
      'hemoglobina glicozilata':'%','glicemie':'mg/dL'}
      self.widget=Analize_widget(self,categorie,unitate)
      self.widgets.append(self.widget)
      self.layout.addWidget(self.widget)
      self.setLayout(self.layout)
      self.layout=QtGui.QVBoxLayout()
      if setu=='biochimie':self.setu=self.biochimieSet
      elif setu=='hemograma':self.setu=self.hemogramaSet
      elif setu=='pipi':self.setu=self.pipiSet
      self.widgets=[]
      self.lungimeMaxima=0
      
      for categorie,unitate in self.biochimieSet.items():
          if len(categorie)>self.lungimeMaxima:
              self.lungimeMaxima=len(categorie)
          else:
              categorie=categorie+' '*(self.lungimeMaxima-len(categorie))
	
    def introdu(self,date):
       for data, widget in zip(date, self.widgets):
	 widget.baga(data)
    def da_valori(self):
      for item in self.widgets:
	    pass #need to deserialize ?
        

class Model(QtGui.QWidget):
    analiza_pa_pagina=6
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
      
      
if __name__=="__main__":
    app=QtGui.QApplication(sys.argv)
    #a=QtGui.QDialog()
    #b=Analize_widget(a,'ceva','ds')
    #lay=QtGui.QFormLayout()
    #lay.addRow(b)
    #a.setLayout(lay)
    a=Pagina_widget('biochimie')
#a.addWidget(b)
    a.show()
    sys.exit(app.exec_())

class Recomandari(QtGui.QTextEdit):
    def __init__(self,parent=None):
        QtGui.QTextEdit.__init__(self,parent)
    def contextMenuEvent(self,event):
        #self.meniu=QtGui.QMenu(self)
        self.meniu=self.createStandardContextMenu(event.pos())
        self.meniu.addSeparator()
        self.meniu.addAction("tipareste reteta &ketosteril")
        self.meniu.addAction("tipareste reteta A&DO")
        self.meniu.addAction("insera restrictia &proteica")
        self.meniu.exec_(event.globalPos())