[ANN] ODMXMLTools.jl: A simple tools for working with ODM-XML

ODMXMLTools.jl is a simple tool set for working with ODM-XML.

ODM-XML is a vendor-neutral, platform-independent format for exchanging and archiving clinical and translational research data, along with their associated metadata, administrative data, reference data, and audit information. ODM-XML facilitates the regulatory-compliant acquisition, archival and exchange of metadata and data. It has become the language of choice for representing case report form content in many electronic data capture (EDC) tools.

The ODM has been designed to be compliant with guidance and regulations published by the FDA for computer systems used in clinical studies.

See CDISK site for more information.


import Pkg; Pkg.add(url="https://github.com/PharmCat/ODMXMLTools.jl.git")

With ODMXMLTools.jl you can:

  • Import ODM xml file;
  • Get table of MetaDataVersion;
  • Find study elements;
  • Build MetaDataVersion (recursive resolve all includes in MetaDataVersion);
  • Get study list;
  • Get events table;
  • Get forms table;
  • Get ItemGroups table;
  • Get items table;
  • Get study subject information;
  • Get study information;
  • Get ClinicalData list;
  • Get data from ClinicalData in “long” format;

This package currently is not registered because I don’t know would it be in demand.

This package does not validate odm.xml file, but a structure validation procedure may be developed in the future.

This package is not for changing odm.xml file and not writing it.

This program comes with absolutely no warranty. No liability is accepted for any loss and risk to public health resulting from use of this software.


Made documentation page with example. Improved API. Made some work on validation and OCL (OpenClinica) form details list.

1 Like

New minor version released. More docs and minor changes. Some additional keywords.

See documents: Home · ODMXMLTools.jl

1 Like

Version 0.4.0 released.

There was changes in API to provide more consistent interface.

New feature included: checkdatavalues can help to check data inside ClinicalData part.

ODMXMLTools.jl is still package that can help to get information about ODM-XML files that used as export, transfer and archiving format for data collected in clinical and pre-clinical trials.

It is simple to load xml file:

using ODMXMLTools, DataFrames, CSV
odm = importxml(".//data//some-odm-xml.xml")

You can build completed metadata (with recurcive including all Include tags) for MetaDataVersion by StudyOID and MetaDataVersionOID. And then you can get listings for events, forms, groups and items:

mdb = buildmetadata(odm, "S1", "v1.0.0")
forms = formlist(mdb)
items = itemlist(mdb; optional = true)

You can also to get all data from all ClinicalData sections or by StudyOID and MetaDataVersionOID.

datadf = ODMXMLTools.clinicaldatatable(odm)

After a simple data management with DataFrames you can make CSV tables for each form and get SPSS code for value labels.

leftjoin!(datadf, items[!, ["OID", "SASFieldName"]]; on = "ItemOID" => "OID")
for f = 1:size(forms, 1)
    formds = subset(datadf, :FormOID => x -> x .== forms[f, "OID"])[!, [:SubjectKey, :StudyEventOID, :ItemGroupOID, :ItemGroupRepeatKey, :Value, :SASFieldName]]
    replace!(formds[!, :ItemGroupRepeatKey], "" => "1")
    unstfds = unstack(formds, [:SubjectKey, :StudyEventOID, :ItemGroupRepeatKey], :SASFieldName, :Value)

    CSV.write(joinpath(path, "csv", forms[f, :Name]*".csv"), unstfds)

    open(joinpath(path, "csv", forms[f, :Name]*".sps"), "w+") do io
        spslab = ODMXMLTools.spss_form_variable_labels(mdb, forms[f, "OID"]; variable = :SASFieldName, labels = :Comment)
        spsval = ODMXMLTools.spss_form_value_labels(mdb, forms[f, "OID"]; variable = :SASFieldName)
        print(io,"\xEF\xBB\xBF") # BOM
        println(io, "* Encoding: UTF-8.")
        println(io, spslab) 
        if length(spsval.v) > 0 
            println(io, spsval)
        println(io, "EXECUTE.")

It is very important to check your xml files before importing with XSD schema provided by CDISK. There is plan to make more validation checks inside ODMXMLTools, but this is not replace checks with XSD schema. As ODMXMLTools build on EzXML.jl - unfortunatly EzXML not provide checking with XSD. Maybe check with DTD will be included in ODMXMLTools later.

To get full information see Documentation. Also issues and PR wellcome!

An official version of ODM specificatoion document is available on the ODM page of the CDISC website http://www.cdisc.org/odm.