Exemplo n.º 1
0
	def done(self, button):
		global values
		global index
		global data_entered

		fields = test_field.get_gui_field_list()
		
		values['`id`'] = '0' # auto increment value
		values['`patient_id`'] = "'" + str(patient_id) + "'"

		for field in fields:
			obj =  builder.get_object(field)

			key = '`' + field + '`'			

			if obj == None:
				# calculation field
				values[key] = "'" + str(get_calculation_result(field)) + "'" # result of the calculation 
				continue

			object_type = obj.get_name()
			
			if object_type == 'GtkEntry':
				values[key] = "'" + get_gtkEntry_value(obj) + "'"
			elif object_type == 'GtkTextView':
				values[key] = "'" + get_gtkTextView_value(obj) + "'"
			elif object_type == 'GtkComboBoxText':
				values[key] = "'" + get_gtkComboBoxText_value(obj) + "'"

		# if there are preiously entered data do an update, else do an insert
		if data_entered is None:
			db.feed_test_data(db.validate(builder.get_object('title').get_text()), values)
		else:
			db.update_test_data(db.validate(builder.get_object('title').get_text()), values, data_entered['id'])

		# update the data entered field of main table
		db.update_data_entered(index)

		# close the window
		self.window.destroy()
Exemplo n.º 2
0
	def add_patient(self, button):
		# insert in to patient table
		patient = {}
		patient['`id`'] = '0'
		patient['`patient_id`'] = "'" + str(gui_patient_id.get_text()) + "'"
		patient['`name`'] = "'" + gui_name.get_text() + "'"
		patient['`requested_bd`'] = "'" + gui_requested_bd.get_text() + "'"
		patient['`sample_co`'] = "'" + gui_sample_co.get_text() + "'"
		patient['`billed_by`'] = "'MANUAL'"

		# feed data to patient table
		db.feed_test_data('patient', patient)

		# insert tests into main table
		for test in test_list_data:
			main = {}
			main['`id`'] = '0'
			main['`patient_id`'] = patient['`patient_id`']
			main['`test_id`'] = "'" + str(db.get_test_id(test[0])) + "'"

			# feed data to main table
			db.feed_test_data('main', main)