[importer] Update random_importer to support relations to Protocol entity types (related to #3370439)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Thu, 12 Dec 2013 11:08:55 +0100
changeset 643 17e951f21e26
parent 642 823f84c0a88b
child 644 66e70b99068c
[importer] Update random_importer to support relations to Protocol entity types (related to #3370439)
importers/random_import.py
--- a/importers/random_import.py	Mon Jan 20 13:21:29 2014 +0000
+++ b/importers/random_import.py	Thu Dec 12 11:08:55 2013 +0100
@@ -60,8 +60,12 @@
 def import_questionnaire(store, subject_eid, center_eid, study_eid,
                          questionnaire_eid, questions, label):
     date = random_date()
+    protocol = store.create_entity('Protocol', identifier=u'Demo questionnaire protocol',
+                                   start_datetime=date)
+    store.relate(protocol.eid, 'related_study', study_eid, subtype='Protocol')
     assessment = store.create_entity('Assessment', identifier=u'%s_%s' % (label, subject_eid),
-                                     datetime=date, protocol=u'Demo questionnaire')
+                                     datetime=date)
+    store.relate(assessment.eid, 'protocols', protocol.eid, subtype='Assessment')
     store.relate(assessment.eid, 'related_study', study_eid, subtype='Assessment')
     store.relate(center_eid, 'holds', assessment.eid)
     store.relate(subject_eid, 'concerned_by', assessment.eid)
@@ -81,8 +85,12 @@
 
 def import_genomic(store, subject_eid, center_eid, study_eid, platform=None):
     date = random_date()
+    protocol = store.create_entity('Protocol', identifier=u'Demo genomics protocol',
+                                   start_datetime=date)
+    store.relate(protocol.eid, 'related_study', study_eid, subtype='Protocol')
     assessment = store.create_entity('Assessment', identifier=u'genomics_%s' % subject_eid,
-                                     datetime=date, protocol=u'Demo genomics')
+                                     datetime=date)
+    store.relate(assessment.eid, 'protocols', protocol.eid, subtype='Assessment')
     store.relate(assessment.eid, 'related_study', study_eid, subjtype='Assessment')
     store.relate(center_eid, 'holds', assessment.eid)
     store.relate(subject_eid, 'concerned_by', assessment.eid)
@@ -96,8 +104,12 @@
 
 def import_anat_images(store, subject_eid, center_eid, study_eid, mri_1, mri_2):
     date = random_date()
+    protocol = store.create_entity('Protocol', identifier=u'Demo anat protocol',
+                                   start_datetime=date)
+    store.relate(protocol.eid, 'related_study', study_eid, subtype='Protocol')
     assessment = store.create_entity('Assessment', identifier=u'anat_%s' % subject_eid,
-                                     datetime=date, protocol=u'Demo anat')
+                                     datetime=date)
+    store.relate(assessment.eid, 'protocols', protocol.eid, subtype='Assessment')
     store.relate(assessment.eid, 'related_study', study_eid, subjtype='Assessment')
     store.relate(center_eid, 'holds', assessment.eid)
     store.relate(subject_eid, 'concerned_by', assessment.eid)
@@ -118,8 +130,12 @@
 
 def import_fmri_images(store, subject_eid, center_eid, study_eid, mri_1, mri_2):
     date = random_date()
+    protocol = store.create_entity('Protocol', identifier=u'Demo fmri protocol',
+                                   start_datetime=date)
+    store.relate(protocol.eid, 'related_study', study_eid, subtype='Protocol')
     assessment = store.create_entity('Assessment', identifier=u'fmri_%s' % subject_eid,
-                                     datetime=date, protocol=u'Demo fmri')
+                                     datetime=date)
+    store.relate(assessment.eid, 'protocols', protocol.eid, subtype='Assessment')
     store.relate(assessment.eid, 'related_study', study_eid, subjtype='Assessment')
     store.relate(center_eid, 'holds', assessment.eid)
     store.relate(subject_eid, 'concerned_by', assessment.eid)
@@ -140,8 +156,12 @@
 
 def import_constrat_images(store, subject_eid, center_eid, study_eid, mri_1, mri_2):
     date = random_date()
+    protocol = store.create_entity('Protocol', identifier=u'Demo c map protocol',
+                                   start_datetime=date)
+    store.relate(protocol.eid, 'related_study', study_eid, subtype='Protocol')
     assessment = store.create_entity('Assessment', identifier=u'cmap_%s' % subject_eid,
-                                     datetime=date, protocol=u'Demo c map')
+                                     datetime=date)
+    store.relate(assessment.eid, 'protocols', protocol.eid, subtype='Assessment')
     store.relate(assessment.eid, 'related_study', study_eid, subjtype='Assessment')
     store.relate(center_eid, 'holds', assessment.eid)
     store.relate(subject_eid, 'concerned_by', assessment.eid)