OpenClinica User Manual/ImportingData

Importing data
It is sometimes useful to import data into OpenClinica. The data can be amended, discrepancy notes added, it is checked on import and can be referenced using rules.

Reasons why you shouldn't do it (mostly convenience)

 * 1) It is sometimes less work to consider non-OpenClinica data as a separate data stream, that is merged with data from OpenClinica at the end of the study (especially if it doesn't need to be amended in the OpenClinica interface).
 * 2) It is sometimes quicker to manually enter data than import data
 * 3) Depending on your regulatory regime, you may need to validate any manipulation of the data prior to it being imported
 * 4) Depending on the import method, data goes into the system as ‘Completed’, but a data manager user can still upload the same data over the top of the data. Altering the records to be ‘locked’ doesn't stop the data being overwritten.  May need sophisticated logic to avoid overwrites

Difficulties in using the standard import

 * 1) Import requires you to set up subjects and schedule visits before importing a file
 * 2) Import uses CDISC ODM XML files that can be challenging to create from Excel, CSV or whatever source you have
 * 3) Need to obtain OIDs for event and CRF when creating the CDISC ODM XML
 * 4) Import is dependent upon the subject's SubjectKey (StudySubjectOID), which varies from their standard Study Subject ID in a consistent way. However, if their Study Subject ID has changed, then SubjectKey will be dependent upon their initial incorrect Study Subject ID.  So you may have to have some mappings for subjects whose ID was entered wrongly

How to do it
OpenClinica.com has documentation on how you can import CDISC ODM format XML files.

Methods
The OpenClinica wiki includes a number of import tools that can be used to import data

Converting CSV to CDISC ODM XML using XSLT
One method of generating a CDISC ODM XML from a CSV file (Microsoft Excel can save in this format) is to use an XSLT parser such as Kernow to parse the CSV using a customised XSLT transform.

An example CSV file (with SubjectKeys: SS_S001 and SS_S002, ITEM_NAMES: I_APFIN_LBISOPROSTANES and I_APFIN_LBOXLDL):

The XSLT transform for import: This should create the following CDISC ODM XML file: Then import the file as per OpenClinica's Import Data documentation.

Limitations of this method

 * The transform to XML step only works correctly if there are no line breaks in the data (so no multi-line text fields).
 * XML characters in the input like will cause problems.
 * Changes to the template or a different transformation tool (such as http://servingxml.sourceforge.net/) may avoid these issues.
 * The XML is easiest to construct if all the data is for the same CRF in the same Event
 * Need to reorganise data to have correct fieldnames for column headers and subject names for first items in each row