Exemple #1
0
	def run_monitor():

		print("starting up backend notifications monitor")

		def monitoring_callback(*args, **kwargs):
			try:
				kwargs['originated_in_database']
				print('==> got notification from database "%s":' % kwargs['signal'])
			except KeyError:
				print('==> received signal from client: "%s"' % kwargs['signal'])
			del kwargs['signal']
			for key in kwargs.keys():
				print('    [%s]: %s' % (key, kwargs[key]))

		gmDispatcher.connect(receiver = monitoring_callback)

		listener = gmBackendListener(conn = gmPG2.get_raw_connection())
		print("listening for the following notifications:")
		print("1) unspecific:")
		for sig in listener.unspecific_notifications:
			print('   - %s' % sig)

		while True:
			pat = gmPersonSearch.ask_for_patient()
			if pat is None:
				break
			print("found patient", pat)
			gmPerson.set_active_patient(patient=pat)
			print("now waiting for notifications, hit <ENTER> to select another patient")
			raw_input()

		print("cleanup")
		listener.shutdown()

		print("shutting down backend notifications monitor")
Exemple #2
0
	def run_monitor():

		print("starting up backend notifications monitor")

		def monitoring_callback(*args, **kwargs):
			try:
				kwargs['originated_in_database']
				print('==> got notification from database "%s":' % kwargs['signal'])
			except KeyError:
				print('==> received signal from client: "%s"' % kwargs['signal'])
			del kwargs['signal']
			for key in kwargs.keys():
				print('    [%s]: %s' % (key, kwargs[key]))

		gmDispatcher.connect(receiver = monitoring_callback)

		listener = gmBackendListener(conn = gmPG2.get_raw_connection())
		print("listening for the following notifications:")
		print("1) unspecific:")
		for sig in listener.unspecific_notifications:
			print('   - %s' % sig)

		while True:
			pat = gmPersonSearch.ask_for_patient()
			if pat is None:
				break
			print("found patient", pat)
			gmPerson.set_active_patient(patient=pat)
			print("now waiting for notifications, hit <ENTER> to select another patient")
			raw_input()

		print("cleanup")
		listener.shutdown()

		print("shutting down backend notifications monitor")
Exemple #3
0
def run_importer():

	# map data from commandline
	try:
		date = sys.argv[idx_date]
		gsm = sys.argv[idx_gsm]
		sms = sys.argv[idx_sms]
		pk_patient, weight = sms.split(':::')
	except:
		return False

	# find patient by gsm
#	cmd1 = u"select dem.add_external_id_type(%(desc)s, %(org)s)"
#	args1 = {'desc': external_id_type, 'org': u'gmSMSImporter.py'}
#	cmd2 = u'select pk from dem.enum_ext_id_types where name = %(desc)s'
#	rows, idx = gmPG2.run_rw_queries (
#		queries = [
#			{'cmd': cmd1, 'args': args1},
#			{'cmd': cmd2, 'args': args1}
#		],
#		return_data = True
#	)
#	ext_id_pk = rows[0][0]

#	cmd = u"""
#select li2id.id_identity
#from dem.lnk_identity2ext_id li2id
#where
#	li2id.external_id = %(id)s and
#	fk_origin = %(src)s"""
#	args = {'id': gsm, 'src': ext_id_pk}

#	rows, idx = gmPG2.run_ro_queries (
#		queries = [{'cmd': cmd, 'args': args}],
#		return_data = True
#	)
#	if len(rows) == 0:
#		print "patient with GSM [%s] not found" % gsm
#		return False
#	pk_patient = rows[0][0]

	gmPerson.set_active_patient(patient = gmPerson.cPerson(aPK_obj = pk_patient))

	# ensure structure of EMR
	curr_pat = gmPerson.gmCurrentPatient()
	emr = curr_pat.get_emr()
	epi = emr.add_episode(episode_name = u'Gewichtsmonitoring', is_open = False)

	# and import our stuff
	narr = emr.add_clin_narrative (
		note = weight_template % (dt.datetime.now().strftime('%X'), weight),
		soap_cat = soap_cat,
		episode = epi
	)

	return True
Exemple #4
0
def run_importer():

    # map data from commandline
    try:
        date = sys.argv[idx_date]
        gsm = sys.argv[idx_gsm]
        sms = sys.argv[idx_sms]
        pk_patient, weight = sms.split(':::')
    except:
        return False

    # find patient by gsm
#	cmd1 = u"select dem.add_external_id_type(%(desc)s, %(org)s)"
#	args1 = {'desc': external_id_type, 'org': u'gmSMSImporter.py'}
#	cmd2 = u'select pk from dem.enum_ext_id_types where name = %(desc)s'
#	rows, idx = gmPG2.run_rw_queries (
#		queries = [
#			{'cmd': cmd1, 'args': args1},
#			{'cmd': cmd2, 'args': args1}
#		],
#		return_data = True
#	)
#	ext_id_pk = rows[0][0]

#	cmd = u"""
#select li2id.id_identity
#from dem.lnk_identity2ext_id li2id
#where
#	li2id.external_id = %(id)s and
#	fk_origin = %(src)s"""
#	args = {'id': gsm, 'src': ext_id_pk}

#	rows, idx = gmPG2.run_ro_queries (
#		queries = [{'cmd': cmd, 'args': args}],
#		return_data = True
#	)
#	if len(rows) == 0:
#		print "patient with GSM [%s] not found" % gsm
#		return False
#	pk_patient = rows[0][0]

    gmPerson.set_active_patient(patient=gmPerson.cPerson(aPK_obj=pk_patient))

    # ensure structure of EMR
    curr_pat = gmPerson.gmCurrentPatient()
    emr = curr_pat.emr
    epi = emr.add_episode(episode_name='Gewichtsmonitoring', is_open=False)

    # and import our stuff
    narr = emr.add_clin_narrative(note=weight_template %
                                  (dt.datetime.now().strftime('%X'), weight),
                                  soap_cat=soap_cat,
                                  episode=epi)

    return True
def set_active_patient(patient=None, forced_reload=False):

	# already active ?
	if isinstance(patient, gmPerson.gmCurrentPatient):
		return True

	if isinstance(patient, gmPerson.cPatient):
		if patient['is_deleted']:
			_log.error('patient is disabled, will not use as active patient: %s', patient)
			return False
	elif isinstance(patient, gmPerson.cPerson):
		if patient['is_deleted']:
			_log.error('patient is disabled, will not use as active patient: %s', patient)
			return False
		patient = patient.as_patient
	elif patient == -1:
		pass
	else:
		# maybe integer ?
		success, pk = gmTools.input2int(initial = patient, minval = 1)
		if not success:
			raise ValueError('<patient> must be either -1, >0, or a cPatient, cPerson or gmCurrentPatient instance, is: %s' % patient)
		# but also valid patient ID ?
		try:
			patient = gmPerson.cPatient(aPK_obj = pk)
		except Exception:
			_log.exception('error changing active patient to [%s]' % patient)
			return False

	if not _verify_staff_chart_access(patient = patient):
		return False

	success = gmPerson.set_active_patient(patient = patient, forced_reload = forced_reload)

	if not success:
		return False

	wx.CallAfter(_do_after_setting_active_patient, patient)
	return True
Exemple #6
0
def set_active_patient(patient=None, forced_reload=False):

	# already active ?
	if isinstance(patient, gmPerson.gmCurrentPatient):
		return True

	if isinstance(patient, gmPerson.cPatient):
		if patient['is_deleted']:
			_log.error('patient is disabled, will not use as active patient: %s', patient)
			return False
	elif isinstance(patient, gmPerson.cPerson):
		if patient['is_deleted']:
			_log.error('patient is disabled, will not use as active patient: %s', patient)
			return False
		patient = patient.as_patient
	elif patient == -1:
		pass
	else:
		# maybe integer ?
		success, pk = gmTools.input2int(initial = patient, minval = 1)
		if not success:
			raise ValueError('<patient> must be either -1, >0, or a cPatient, cPerson or gmCurrentPatient instance, is: %s' % patient)
		# but also valid patient ID ?
		try:
			patient = gmPerson.cPatient(aPK_obj = pk)
		except:
			_log.exception('error changing active patient to [%s]' % patient)
			return False

	if not _verify_staff_chart_access(patient = patient):
		return False

	success = gmPerson.set_active_patient(patient = patient, forced_reload = forced_reload)

	if not success:
		return False

	wx.CallAfter(_do_after_setting_active_patient, patient)
	return True
Exemple #7
0
#				return False
#		return True

#================================================================
# MAIN
#----------------------------------------------------------------
if __name__ == '__main__':
    _log.info("starting SOAP importer...")

    try:
        # obtain patient
        patient = gmPersonSearch.ask_for_patient()
        if patient is None:
            print "No patient. Exiting gracefully..."
            sys.exit(0)
        gmPerson.set_active_patient(patient=patient)

        # now import
        importer = cSOAPImporter()
        bundle = [{
            soap_bundle_SOAP_CAT_KEY: 's',
            soap_bundle_TYPES_KEY: ['Hx'],
            soap_bundle_TEXT_KEY: 'Test subjective narrative',
            soap_bundle_CLIN_CTX_KEY: {
                soap_bundle_EPISODE_ID_KEY: '1'
            }
        }, {
            soap_bundle_SOAP_CAT_KEY: 'o',
            soap_bundle_TYPES_KEY: ['Hx'],
            soap_bundle_TEXT_KEY: 'Test objective narrative',
            soap_bundle_CLIN_CTX_KEY: {
Exemple #8
0
                              beep=False)
            return False

        return True


#============================================================
# main
#------------------------------------------------------------
if __name__ == "__main__":

    if len(sys.argv) < 2:
        sys.exit()

    if sys.argv[1] != 'test':
        sys.exit()

    from Gnumed.pycommon import gmI18N
    from Gnumed.pycommon import gmDateTime
    gmI18N.activate_locale()
    gmI18N.install_domain()
    gmDateTime.init()

    from Gnumed.business import gmPerson

    gmPerson.set_active_patient(patient=gmPerson.cPerson(aPK_obj=12))

    arriba = cArriba()
    print(arriba)
    arriba.run(patient=gmPerson.gmCurrentPatient(), debug=True)
Exemple #9
0
		except:
			_log.exception('error accessing [%s]', self.pdf_result)
			gmDispatcher.send(signal = u'statustext', msg = _('No [arriba] result found in [%s].') % self.pdf_result, beep = False)
			return False

		return True
#============================================================
# main
#------------------------------------------------------------
if __name__ == "__main__":

	if len(sys.argv) < 2:
		sys.exit()

	if sys.argv[1] != 'test':
		sys.exit()

	from Gnumed.pycommon import gmI18N
	from Gnumed.pycommon import gmDateTime
	gmI18N.activate_locale()
	gmI18N.install_domain()
	gmDateTime.init()

	from Gnumed.business import gmPerson

	gmPerson.set_active_patient(patient = gmPerson.cPerson(aPK_obj = 12))

	arriba = cArriba()
	print arriba
	arriba.run(patient = gmPerson.gmCurrentPatient(), debug = True)
Exemple #10
0
	def test_fd_show_interactions():
		gmPerson.set_active_patient(patient = gmPerson.cPerson(aPK_obj = 12))
		fd = cFreeDiamsInterface()
		fd.patient = gmPerson.gmCurrentPatient()
		fd.check_interactions(substances = fd.patient.emr.get_current_medications())
Exemple #11
0
	def test_fd_switch_to():
		gmPerson.set_active_patient(patient = gmPerson.cPerson(aPK_obj = 12))
		fd = cFreeDiamsInterface()
		fd.patient = gmPerson.gmCurrentPatient()
#		fd.switch_to_frontend(blocking = True)
		fd.import_fd2gm_file_as_drugs(filename = sys.argv[2])
Exemple #12
0
	def test_fd_show_interactions():
		gmPerson.set_active_patient(patient = gmPerson.cPerson(aPK_obj = 12))
		fd = cFreeDiamsInterface()
		fd.patient = gmPerson.gmCurrentPatient()
		fd.check_interactions(substances = fd.patient.emr.get_current_medications(include_unapproved = True))
Exemple #13
0
	def test_fd_switch_to():
		gmPerson.set_active_patient(patient = gmPerson.cPerson(aPK_obj = 12))
		fd = cFreeDiamsInterface()
		fd.patient = gmPerson.gmCurrentPatient()
#		fd.switch_to_frontend(blocking = True)
		fd.import_fd2gm_file_as_drugs(filename = sys.argv[2])