def pull_latest(study_name): export = study_export(study_name) if export is None: raise RuntimeError('error querying web service') converted = convert._convert_xform(export) xforms = [u.dump_xml(xf, True) for xf in converted['crfs']] for se in converted['study_events']: try: StudyEvent.objects.get(oid=se['oid']) # TODO: update if changed except StudyEvent.DoesNotExist: new_se = StudyEvent(oid=se['oid'], name=se['name'], study=Study.objects.get(identifier=study_name)) new_se.save() for xf in xforms: update_xform(xf) return converted['errors']
def submit(odm): logging.debug('converted to odm:\n%s' % u.dump_xml(odm, pretty=True)) conn = WSDL(settings.WEBSERVICE_URL) auth = (settings.OC_USER, settings.OC_PASS) conn.submit(auth, odm)
def onsubmit(xform, instance): odm = util.generate_submit_payload({ 'subject_id': 'SS_123456', 'event_ordinal': 99, }, instance) return HttpResponse(u.dump_xml(odm, pretty=True), 'text/xml')