We are currently working on the forum. For the short-term, all forum content will be in read-only format. We apologize for the interruption and look forward to collaborating with you shortly. All the best in your research!

OC Synchroniser - Creating report on user activity

Csaba.HalmagyiCsaba.Halmagyi Posts: 54 ✭✭
edited November 2015 in Extracting & Reporting
Dear Community,

I am currently working on an OpenClinica Synchroniser Extension that allows users to submit some data in an OC instance then synchronise it with another linked OC instance. The tool can be used to migrate studies/sites across OC instances without even touching the database or collect data on multiple laptops (with a local OC instance on them) and synchronise with a central OC instance (the mothership as we say).
It is able to map the crf fields (to create a map between the OIDs), import subjects, schedule event occurrences and import crf data as well using the OC webservices.

Furthermore, I would like to trigger the synchronisation based on user activities, for example when the user logs out or when the user session times out, etc.
Has anyone got any experience on how to run a report based on the events mentioned above?

Csaba Halmagyi
RDCIT - University of Cambridge,
Cambridge, United Kingdom


  • lindsay.stevenslindsay.stevens Posts: 404 ✭✭✭
    via Email
    An administrator can go to Tasks -> Admin -> Users -> Audit user activity,
    to view the log in / log out times. I'm not sure if session time out is
    recorded there though. This corresponds to the database table
    audit_user_login. If it is a single user instance you could poll the tomcat
    logs for request handling activity. Then assume session time out if the
    last request time stamp minus last login is greater than the session time
    out setting.

    Maybe it's too late but ODK Collect (+ XLSForm) has been a pretty good
    distributed offline data collection tool.
  • haenselhaensel Posts: 602 ✭✭✭

    I'm not sure if session time out is recorded there though.

    I think it is not reported (at least not at the gui).


  • haenselhaensel Posts: 602 ✭✭✭

    Furthermore, I would like to trigger the synchronisation based on user activities, for example when the user logs out or when the user session times out, etc.
    Has anyone got any experience on how to run a report based on the events mentioned above?

    Hi Csaba

    There is no such trigger mechanism build into OpenClinica. Hooking into the logout procedure should be straight forward. I'm not totally shure but I think there is no such event as 'session timeout'. The session validity status will be checked if necessary.
    Is a background job (like the one for the datasets) an option to you?

  • haenselhaensel Posts: 602 ✭✭✭
    Hi Csaba

    One further question. Do you want to use this synchronization tool as an offline data capture workaround?

  • Csaba.HalmagyiCsaba.Halmagyi Posts: 54 ✭✭

    Thank you for the responses.
    Christian: unfortunately a background job is not an option.

    The Synchroniser is a php application that can read an ODM XML (coming from the laptops or other OC instances) and can fetch the metadata(also an ODM XML) from the targeted OC instance's study (mothership). Then it identifies the events/forms/groups/items and creates a mapping table between the OIDs.
    Based on that mapping it will replace the OIDs in the first xml, imports the subjects (and/or retrieves their OID), schedules the event occurrences and creates the final import xml with the updated OIDs.

    The OC synchroniser can be used in several usecases.

    Usecase 1 (We would like to use the synchroniser as part of our staging):
    There is a "sandbox" OC where the users could create their studies and crfs, import their data and play with it. When they are happy with their data (no errors or invalid values, etc) they can extract it in ODM XML and this xml can be used by the synchroniser to transfer their studies to the final OC instance (the mothership).

    Usecase2 (Offline mode): Some of our colleagues cannot access our secured system so we can give them a laptop with a local OC on it. They can collect the data and extract it in ODM XML and we can synchronise the data back to our secured system. In this case I would like to run an export job when the user logs out so they don't have to run it manually.

    Usecase3 (Same studies (or sites) on different servers): You can create one study on the mothership and synchronise all data from different servers.
  • toskriptoskrip Posts: 279 ✭✭✭
    Hey Csaba,

    I had a plan to implement something similiar. But I was considering a little bit different approach for data syncing. Rather than having the sync triggered by user action, you may consider to implement scheduled job within your php application. E.g. to be executed every night with workflow that looks like this:

    - get all clinical data for study from mother instance (RESTfull URLs)
    - get all clinical data from child instance
    - transform ODM from child instance to use mother instance metadata (just OID mapping if they share the same study design)
    - make a checksum of mother ODM and checksum of child ODM to compare whether there is a change in data
    - if there was a change look for differences in order to create import ODM for mother instance, if no change end the job here
    - import the created ODM to mother instance (if there was a change in data), of course subject enrolment and event scheduling before if necessary.



  • Csaba.HalmagyiCsaba.Halmagyi Posts: 54 ✭✭
    Hi Tomas,

    My approach is similar:
    Source system: where the data comes from
    Target system: where the data goes to

    - get full odm xml (meta+clinical data) report from the source system
    - load the previous xml came from the source system (stored on the sync server)
    - use my ODMDiff class to determine the new subjects/values or changed values (basically compare the previous xml and the current one) and create a diff.xml
    - map diff.xml to the study meta on the target system to replace oids and create final.xml
    - use final.xml to create new subjects (if there is any), schedule events and import data


  • toskriptoskrip Posts: 279 ✭✭✭
    edited January 2016
    Looks good. The only worry that I would have is that if you perform diffs always only against previous source system ODM, you are risking that if somebody modifies data in the mother instance directly, you will be not able to catch it resulting to the situation where mother and child will be out of sync.

    I know that you can have business rule that says to data manager, to not touch data in mother instance... but you never know... users make mistakes. IMHO it is better to have foolproof strategy.

  • Csaba.HalmagyiCsaba.Halmagyi Posts: 54 ✭✭
    Hi Tomas,

    You are absolutely right, however we have a business rule in place saying "we sync from the source system(s) to the target system (mothership) only and there is no manual entry on the mothership". This comes in handy when all sites have got a laptop and sync their study (site) data back to our target system.
    The second upside is that with this concept you can do staging and rollbacks without affecting other studies (do a sync from one source, check data, if not happy=> rollback and do a sync again).
    At the end of the day we have one OC instance to use the datawarehousing scripts on.


Sign In or Register to comment.