コード例 #1
0
ファイル: gmDrugView.py プロジェクト: weeksjm/gnumed
    def __init__(self, aDatabaseName=None):
        """
		Initialize the DrugView object with information supplied via
		the standard config file. The data should be grouped together
		in the group designated by the database name.
		"""

        if aDatabaseName == None:
            raise gmExceptions.ConstructorError, "No database name specified."

        # open configuration source
        # if we are not inside gnumed we won't get a definite answer on
        # who and where we are. in this case try to get config source
        # from main config file (see gmCfg on how the name of this file
        # is determined
        currWorkplace = gmPraxis.gmCurrentPraxisBranch().active_workplace
        if currWorkplace is None:
            # assume we are outside gnumed
            self.dbConfFile = _cfg.get(aDatabaseName, 'configfile')
        else:
            #
            self.dbConfFile, match = gmCfg.getDBParam(
                workplace=currWorkplace,
                option="DrugReferenceBrowser.%s.configfile" % aDatabaseName)

        _log.Log(gmLog.lInfo, "dbConfFile is [%s]" % str(self.dbConfFile))

        if self.dbConfFile is None:
            _log.Log(
                gmLog.lErr,
                "No config information on drug database [%s] found." %
                aDatabaseName)
            raise gmExceptions.ConstructorError, "No DrugDB config file specified."

        try:
            self.mDrugInterface = gmDrugObject.cDrug(
                queryCfgSource=self.dbConfFile)
        except:
            _log.LogException("Unhandled exception while opening config file",
                              sys.exc_info(),
                              verbose=0)
            raise gmExceptions.ConstructorError, "Couldn't initialize drug object for DB %s" % aDatabaseName

        self.__mFormatString = {}  # format strings
        self.__mGroupPos = {}  # query group on position x
        self.__mFormatType = {}  # format type
        self.__mHeading = {}  # the heading used (if any)
        self.__mUsedVars = {}  # parameters used from the query dict
        # get configuration from file
        self.__getFormatInfo()

        # initialize DrugIds
        self.mLastId = {}
        self.mCurrId = -1
コード例 #2
0
ファイル: gmDrugView.py プロジェクト: ncqgm/gnumed
	def __init__(self, aDatabaseName=None):
		"""
		Initialize the DrugView object with information supplied via
		the standard config file. The data should be grouped together
		in the group designated by the database name.
		"""

		if aDatabaseName == None:
			raise gmExceptions.ConstructorError,"No database name specified."

		# open configuration source
		# if we are not inside gnumed we won't get a definite answer on
		# who and where we are. in this case try to get config source 
		# from main config file (see gmCfg on how the name of this file
		# is determined
		currWorkplace = gmPraxis.gmCurrentPraxisBranch().active_workplace
		if currWorkplace is None:
			# assume we are outside gnumed
			self.dbConfFile = _cfg.get(aDatabaseName, 'configfile')
		else:
			# 
			self.dbConfFile, match = gmCfg.getDBParam(
				workplace=currWorkplace,
				option="DrugReferenceBrowser.%s.configfile" % aDatabaseName
			)

		_log.Log(gmLog.lInfo, "dbConfFile is [%s]" % str(self.dbConfFile))
			
		if self.dbConfFile is None:
			_log.Log(gmLog.lErr, "No config information on drug database [%s] found." % aDatabaseName)
			raise gmExceptions.ConstructorError,"No DrugDB config file specified."

		try:
			self.mDrugInterface = gmDrugObject.cDrug(queryCfgSource = self.dbConfFile)
		except:
			_log.LogException("Unhandled exception while opening config file", sys.exc_info(), verbose = 0)
			raise gmExceptions.ConstructorError,"Couldn't initialize drug object for DB %s" % aDatabaseName

		self.__mFormatString = {} 	# format strings
		self.__mGroupPos = {}		# query group on position x
		self.__mFormatType = {}		# format type
		self.__mHeading = {}		# the heading used (if any)
		self.__mUsedVars = {}		# parameters used from the query dict
		# get configuration from file
		self.__getFormatInfo()

		# initialize DrugIds
		self.mLastId = {}
		self.mCurrId = -1
コード例 #3
0
    def __init__(self,
                 parent,
                 id,
                 pos=wxDefaultPosition,
                 size=wxDefaultSize,
                 style=wx.TAB_TRAVERSAL):

        wx.Panel.__init__(self, parent, id, pos, size, style)

        # if we are not inside gnumed we won't get a definite answer on
        # who and where we are. in this case try to get config source
        # from main config file (see gmCfg on how the name of this file
        # is determined
        # this is necessary to enable stand alone use of the drug browser
        currworkplace = gmPraxis.gmCurrentPraxisBranch().active_workplace
        if currworkplace is None:
            # assume we are outside gnumed
            self.dbName = _cfg.get('DrugReferenceBrowser', 'drugDBname')
        else:
            self.dbName, match = gmCfg.getDBParam(
                currworkplace, option="DrugReferenceBrowser.drugDBName")

        if self.dbName is None:
            if __name__ == '__main__':
                title = _('Starting drug data browser')
                msg = _(
                    'Cannot start the drug data browser.\n\n'
                    'There is no drug database specified in the configuration.'
                )
                gmGuiHelpers.gm_show_error(msg, title)
            _log.Log(gmLog.lErr,
                     "No drug database specified. Aborting drug browser.")
            # FIXME: we shouldn't directly call Close() on the parent
            #			parent.Close()
            raise gmExceptions.ConstructorError, "No drug database specified"

# initialize interface to drug database.
        # this will fail if backend or config files are not available
        try:
            self.mDrugView = gmDrugView.DrugView(self.dbName)
        except Exception:
            _log.LogException("Unhandled exception during DrugView API init.",
                              sys.exc_info(),
                              verbose=0)
            raise gmExceptions.ConstructorError, "Couldn't initialize DrugView API"
#			return None

        self.mode = MODE_PRODUCT
        self.previousMode = MODE_PRODUCT
        self.printer = wx.HtmlEasyPrinting(
        )  #printer object to print html page
        self.mId = None
        self.drugProductInfo = None
        self.__mListCtrlItems = {
        }  # array holding data on every row in the list

        #-------------------------------------------------------------
        # These things build the physical window that you see when
        # the program boots. They each refer to a subroutine that
        # is listed below by the same name eg def Menus_Create(self)
        #-------------------------------------------------------------
        self.GuiElements_Init()  # add main gui elements
        self.inDisplay_PI = 0  # first we display a drug list, not product info
        self.GetDrugIssue()  # ?

        #--------------------------------------------------------------
        # handler declarations for DrugDisplay
        # note handlers for menu in Menus_Create()
        #--------------------------------------------------------------
        wx.EVT_BUTTON(self, ID_BUTTON_PRINT, self.OnPrint)
        wx.EVT_BUTTON(self, ID_BUTTON_DISPLAY, self.OnDisplay)
        wx.EVT_BUTTON(self, ID_BUTTON_PRESCRIBE, self.OnPrescribe)
        wx.EVT_LISTBOX_DCLICK(self, ID_LISTBOX_JUMPTO, self.OnJumpToDblClick)
        wx.EVT_LISTBOX(self, ID_LISTBOX_JUMPTO, self.OnJumpToSelected)
        wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL_DRUGCHOICE,
                                   self.OnDrugChoiceDblClick)
        wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYINDICATION,
                           self.OnSearchByIndication)
        wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYGENERIC,
                           self.OnSearchByGeneric)
        wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYPRODUCT,
                           self.OnSearchByProduct)
        wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYANY, self.OnSearchByAny)
        wx.EVT_TEXT(self, ID_COMBO_PRODUCT, self.OnProductKeyPressed)
        wx.EVT_COMBOBOX(self, ID_COMBO_PRODUCT, self.OnProductSelected)
        wx.EVT_BUTTON(self, wxID_OK, self.OnOk)
        wx.EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
        wx.EVT_BUTTON(self, ID_BUTTON_BOOKMARK, self.OnBookmark)
コード例 #4
0
ファイル: gmDrugDisplay.py プロジェクト: ncqgm/gnumed
	def __init__(self, parent, id, pos = wxDefaultPosition, 
				 size = wxDefaultSize, style = wx.TAB_TRAVERSAL):

		wx.Panel.__init__(self, parent, id, pos, size, style)

		# if we are not inside gnumed we won't get a definite answer on
		# who and where we are. in this case try to get config source 
		# from main config file (see gmCfg on how the name of this file
		# is determined
		# this is necessary to enable stand alone use of the drug browser
		currworkplace = gmPraxis.gmCurrentPraxisBranch().active_workplace
		if currworkplace is None:
			# assume we are outside gnumed
			self.dbName = _cfg.get('DrugReferenceBrowser', 'drugDBname')
		else:
			self.dbName, match = gmCfg.getDBParam(
				currworkplace,
				option="DrugReferenceBrowser.drugDBName"
			)

		if self.dbName is None:
			if __name__ == '__main__':
				title = _('Starting drug data browser')
				msg = _('Cannot start the drug data browser.\n\n'
						'There is no drug database specified in the configuration.')
				gmGuiHelpers.gm_show_error(msg, title)
			_log.Log(gmLog.lErr, "No drug database specified. Aborting drug browser.")
			# FIXME: we shouldn't directly call Close() on the parent
#			parent.Close()
			raise gmExceptions.ConstructorError, "No drug database specified"

                # initialize interface to drug database.
		# this will fail if backend or config files are not available
		try:    
			self.mDrugView=gmDrugView.DrugView(self.dbName)
		except:
			_log.LogException("Unhandled exception during DrugView API init.", sys.exc_info(), verbose = 0)
			raise gmExceptions.ConstructorError, "Couldn't initialize DrugView API"
#			return None

		self.mode = MODE_PRODUCT
		self.previousMode = MODE_PRODUCT
		self.printer = wx.HtmlEasyPrinting()		#printer object to print html page
		self.mId = None
		self.drugProductInfo = None            
		self.__mListCtrlItems = {}		# array holding data on every row in the list
        
		#-------------------------------------------------------------
		# These things build the physical window that you see when
		# the program boots. They each refer to a subroutine that
		# is listed below by the same name eg def Menus_Create(self)
		#-------------------------------------------------------------
		self.GuiElements_Init()	    # add main gui elements
		self.inDisplay_PI = 0	    # first we display a drug list, not product info
		self.GetDrugIssue() 	    # ?

		#--------------------------------------------------------------
		# handler declarations for DrugDisplay
		# note handlers for menu in Menus_Create()
		#--------------------------------------------------------------
		wx.EVT_BUTTON(self, ID_BUTTON_PRINT, self.OnPrint)
		wx.EVT_BUTTON(self, ID_BUTTON_DISPLAY, self.OnDisplay)
		wx.EVT_BUTTON(self, ID_BUTTON_PRESCRIBE, self.OnPrescribe)
		wx.EVT_LISTBOX_DCLICK(self, ID_LISTBOX_JUMPTO, self.OnJumpToDblClick)
		wx.EVT_LISTBOX(self, ID_LISTBOX_JUMPTO, self.OnJumpToSelected)
		wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL_DRUGCHOICE, self.OnDrugChoiceDblClick)
		wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYINDICATION, self.OnSearchByIndication)
		wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYGENERIC, self.OnSearchByGeneric)
		wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYPRODUCT, self.OnSearchByProduct)
		wx.EVT_RADIOBUTTON(self, ID_RADIOBUTTON_BYANY, self.OnSearchByAny)
		wx.EVT_TEXT(self, ID_COMBO_PRODUCT, self.OnProductKeyPressed)
		wx.EVT_COMBOBOX(self, ID_COMBO_PRODUCT, self.OnProductSelected)
		wx.EVT_BUTTON(self, wxID_OK, self.OnOk)
		wx.EVT_BUTTON(self, wxID_CANCEL, self.OnCancel)
		wx.EVT_BUTTON(self,ID_BUTTON_BOOKMARK, self.OnBookmark)