Skip to content
Snippets Groups Projects
Commit b653cfea authored by Carlos Vega's avatar Carlos Vega
Browse files

create provenance for finished visits (only if is_finished changes)

parent 89806f53
No related branches found
No related tags found
1 merge request!249More provenance #328
......@@ -206,8 +206,17 @@ class RedcapConnector(object):
status=Appointment.APPOINTMENT_STATUS_SCHEDULED)
for smasch_appointment in smasch_appointments:
smasch_appointment.mark_as_finished()
smasch_appointment.visit.is_finished = True
smasch_appointment.visit.save()
if smasch_appointment.visit.is_finished != True:
description = u'{} changed from "{}" to "{}"'.format('is_finished', smasch_appointment.visit.is_finished, True)
p = Provenance(modified_table=Visit._meta.db_table,
modified_table_id=smasch_appointment.visit.id,
modification_author=self.importer_user,
previous_value=smasch_appointment.visit.is_finished,
new_value=True,
modification_description=description,
modified_field='is_finished')
smasch_appointment.visit.is_finished = True
smasch_appointment.visit.save()
if visit.virus is not None or visit.virus_inconclusive:
if visit.visit_number == 1 and subject.virus_test_1 != visit.virus:
subject.virus_test_1 = visit.virus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment