Skip to content

Commit

Permalink
Merge pull request #18 from PharmCat/dev
Browse files Browse the repository at this point in the history
make clin dat, write file, docs
  • Loading branch information
PharmCat committed Aug 3, 2023
2 parents 3cc58cb + 42b5d08 commit d5c48da
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ODMXMLTools"
uuid = "2456a17b-6ca2-4f51-9342-f0287e829718"
authors = ["PharmCat <[email protected]>"]
version = "0.6.2"
version = "0.6.3"

[deps]

Expand Down
16 changes: 14 additions & 2 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
ODMXMLTools.importxml
```

## Make node

### ODMXMLTools.mekenode!
```@docs
ODMXMLTools.mekenode!
```

### ODMXMLTools.makeclinicaldata!
```@docs
ODMXMLTools.makeclinicaldata!
```

## Build metadata

### ODMXMLTools.buildmetadata
Expand Down Expand Up @@ -221,7 +233,7 @@ ODMXMLTools.name
ODMXMLTools.sortelements!
```

### ODMXMLTools.writenode!
### ODMXMLTools.writenode
```@docs
ODMXMLTools.writenode!
ODMXMLTools.writenode
```
3 changes: 3 additions & 0 deletions src/ODMXMLTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module ODMXMLTools
import Base: show, findfirst, findall, push!, deleteat!, length

export importxml,

mekenode!,

findclinicaldata,
findstudy,
findstudymetadata,
Expand Down
34 changes: 34 additions & 0 deletions src/odmxml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ end
################################################################################
# MAKE NODE
################################################################################
"""
mekenode!(root::AbstractODMNode, nname::Symbol, attrs::Dict = Dict(); content = nothing, namespace = Symbol(""), checkname = false, checkni = false)
Make ODM node in root.
"""
function mekenode!(root::AbstractODMNode, nname::Symbol, attrs::Dict = Dict(); content = nothing, namespace = Symbol(""), checkname = false, checkni = false)
if checkname
if nname ODMNAMESPACE error("Name $nname not in ODMNAMESPACE!") end
Expand Down Expand Up @@ -1560,6 +1565,15 @@ function writenode(io::IO, node::AbstractODMNode, sp::Int)
println(io, "/>")
end
end
function writenode(file::String, node::AbstractODMNode; sp = 1)
f = open(file, "w")
try
writenode(f, node, sp)
finally
close(f)
end
nothing
end

##########################################################################
##
Expand Down Expand Up @@ -1635,4 +1649,24 @@ function sortelements!(node::AbstractODMNode, rec::Bool = true)
end
end
end
end


#####################################################################
## MAKE NODES
#####################################################################
"""
makeclinicaldata!(odm::ODMRoot, soid::String, moid::String)
Make ClinicalData in ODM.
"""
function makeclinicaldata!(odm::ODMRoot, soid::String, moid::String)
for i in odm.el
if isClinicalData(i)
if attribute(i, "StudyOID") == soid && attribute(i, "MetaDataVersionOID") == moid
error("ODM has ClinicalData with same StudyOID and MetaDataVersionOID")
end
end
end
mekenode!(odm, :ClinicalData, Dict(:StudyOID => soid, :MetaDataVersionOID => moid))
end
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ using Test
# Write
ODMXMLTools.writenode(io, odm)

@test_nowarn ODMXMLTools.writenode("test_file.xml", odm)

# SPSS
spssvallab = ODMXMLTools.spss_form_value_labels(mdb, "FORM_VD_1"; variable = :OID)
@test_nowarn show(io, spssvallab)
Expand Down Expand Up @@ -280,6 +282,10 @@ using Test
@test ODMXMLTools.name(cld) == :ClinicalData
cdel = ODMXMLTools.findelements(odm, :ClinicalData)
@test length(cdel) == 2

newcldat = ODMXMLTools.makeclinicaldata!(odm, "TestSOID", "TestMOID")
@test ODMXMLTools.isClinicalData(newcldat)

#@test ODMXMLTools.ischild(c[1], odm)
# Node information

Expand Down

2 comments on commit d5c48da

@PharmCat
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/88952

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.3 -m "<description of version>" d5c48da3802c8d4a70d63d2367b256fc51210b04
git push origin v0.6.3

Please sign in to comment.