Exemplo n.º 1
0
"""Test for concurrency detection to work.
"""
#============================================================
__version__ = "$Revision: 1.2 $"
__author__ = "Karsten Hilbert"
__license__ = "GPL"

import time, sys

from Gnumed.pycommon import gmPG
from Gnumed.business import gmClinNarrative, gmPerson, gmPersonSearch
#============================================================

db = gmPG.ConnectionPool()
pat = gmPersonSearch.ask_for_patient()
#gmPerson.set_active_patient(patient=pat)
emr = pat.emr
epi = emr.get_episodes()[0]

print "creating new narrative row"
note = emr.add_clin_narrative (
	note = 'testing concurrency detection: %s' % time.time(),
	episode = epi
)
print "primary key:", note['pk_narrative']
print "xmin before change:", note['xmin_clin_narrative']

print "waiting for narrative row (xmin) to change"
print "manually update the clin_narrative row with pk=<%s> in the database now" % note['pk_narrative']
cmd = "select xmin from clin_narrative where pk=%s"
while 1:
Exemplo n.º 2
0
    else:
        print "=> another error"
        print "error", err
        print "message", msg
    return


#============================================================
# main
#------------------------------------------------------------
if __name__ == '__main__':
    print "========================================="
    print "GNUmed concurrency detection torture test"
    print "========================================="
    loops = int(sys.argv[1])
    conn_pool = gmPG.ConnectionPool()
    print "Seeding pseudo-random number generator ..."
    random.seed()
    print "Initial random delay ..."
    wait_random(2000)

    print "Running torture loop %s times ..." % loops
    for loop in range(loops):
        print '.'
        narr = find_narr()
        mutate_narr(narr)

    print "Cleaning up ..."
    conn_pool.StopListeners()
    print "Done."
Exemplo n.º 3
0
in <ldt-datei>. All requests will belong to Laborata
Testwoman.
"""
    sys.exit()


print "accessing patient Laborata Testwoman"
# set encoding
gmPG.set_default_client_encoding('latin1')
# setup login defs
auth_data = gmLoginInfo.LoginInfo(user='******',
                                  passwd='any-doc',
                                  host='hherb.com',
                                  port=5432,
                                  database='gnumed')
backend = gmPG.ConnectionPool(login=auth_data)

pat_data = {'lastnames': 'Testwoman', 'firstnames': 'Laborata', 'gender': 'f'}
searcher = gmPersonSearch.cPatientSearcher_SQL()
pat_ids = searcher.get_patient_ids(search_dict=pat_data)

if len(pat_ids) == 0:
    print "cannot find Laborata Testwoman"
    sys.exit()
if len(pat_ids) > 1:
    print "more than one patient for Laborata Testwoman"
    sys.exit()

patid = pat_ids[0]
print "Laborata Testwoman has ID [%s]" % patid
pat = gmPerson.gmCurrentPatient(aPKey=patid)