[importer] Update gender for Imagen subjects based on the Quality Report
authorVincent Michel <vincent.michel@logilab.fr>
Wed, 03 Jul 2013 15:49:30 +0200
changeset 176 22404acb9b51
parent 175 fd9ddf194c6f
child 177 e5f2ee9a5b53
[importer] Update gender for Imagen subjects based on the Quality Report
importers/imagen.py
--- a/importers/imagen.py	Wed Jul 03 14:31:27 2013 +0200
+++ b/importers/imagen.py	Wed Jul 03 15:49:30 2013 +0200
@@ -1207,3 +1207,11 @@
                   {'e': eid, 'pa': pa})
     store.flush()
     store.commit()
+    # Update gender - Take gender from the QR
+    rset = rql('Any S, V WHERE SD is ScoreDef, SD category %(c)s, SD name %(n)s, SV definition SD, '
+               'SV measure M, M concerns S, SV text V',
+               {'n': 'Adolescent_Gender', 'c': 'qualityreport'})
+    for seid, g in rset:
+        if g.lower() in ('male', 'female'):
+            session.execute('SET X gender %(g)s WHERE X eid %(e)s', {'e': seid, 'g': g.lower()})
+    session.commit()