Skip to content

Commit

Permalink
canonical json format generator complete closes #64
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed May 28, 2020
1 parent b96f2e6 commit 360e36a
Show file tree
Hide file tree
Showing 15 changed files with 4,574 additions and 1,389 deletions.
452 changes: 0 additions & 452 deletions Test_all_datatypes_en_20200527081426_1.json

This file was deleted.

466 changes: 0 additions & 466 deletions Test_all_datatypes_en_20200527082141_1.json

This file was deleted.

1 change: 0 additions & 1 deletion Test_all_datatypes_en_20200527082948_1.json

This file was deleted.

1 change: 0 additions & 1 deletion Test_all_datatypes_en_20200527095721_1.json

This file was deleted.

Large diffs are not rendered by default.

764 changes: 764 additions & 0 deletions Test_all_types_20200528040716_1.json

Large diffs are not rendered by default.

732 changes: 732 additions & 0 deletions Test_all_types_20200528042421_1.json

Large diffs are not rendered by default.

762 changes: 762 additions & 0 deletions Test_all_types_20200528042910_1.json

Large diffs are not rendered by default.

759 changes: 759 additions & 0 deletions Test_all_types_20200528043157_1.json

Large diffs are not rendered by default.

757 changes: 757 additions & 0 deletions Test_all_types_20200528043341_1.json

Large diffs are not rendered by default.

758 changes: 758 additions & 0 deletions Test_all_types_20200528043551_1.json

Large diffs are not rendered by default.

Binary file modified openEHR_OPT.jar
Binary file not shown.
14 changes: 10 additions & 4 deletions src/com/cabolabs/openehr/opt/Main.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class Main {
def generate = 'version'
if (args.size() > 4)
{
if (!['version', 'composition', 'version_committer', 'tagged', 'json'].contains(args[4]))
if (!['version', 'composition', 'version_committer', 'tagged', 'json_version', 'json_composition'].contains(args[4]))
{
println "result type should be 'version' or 'composition' or 'version_committer' or 'tagged' or 'json'"
println "result type should be one of 'version', 'composition', 'version_committer', 'tagged', 'json_version', 'json_composition'"
System.exit(0)
}

Expand Down Expand Up @@ -117,10 +117,16 @@ class Main {
igen = new XmlInstanceGeneratorTagged()
ins = igen.generateXMLVersionStringFromOPT(opt)
}
else if (generate == 'json')
else if (generate == 'json_version')
{
igen = new JsonInstanceCanonicalGenerator2()
ins = igen.generateJSONVersionStringFromOPT(opt)
ins = igen.generateJSONVersionStringFromOPT(opt, withParticipations, true)
ext = 'json'
}
else if (generate == 'json_composition')
{
igen = new JsonInstanceCanonicalGenerator2()
ins = igen.generateJSONCompositionStringFromOPT(opt, withParticipations, true)
ext = 'json'
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,24 @@ class JsonInstanceCanonicalGenerator2 {
]
}

private generate_DV_URI(ObjectNode o, String parent_arch_id)
{
AttributeNode a = o.parent
[
_type: 'DV_URI',
value: 'http://cabolabs.com' // TODO: consider the constraints to generate the URI
]
}

private generate_DV_EHR_URI(ObjectNode o, String parent_arch_id)
{
AttributeNode a = o.parent
[
_type: 'DV_EHR_URI',
value: 'ehr://cabolabs.com' // TODO: consider the constraints to generate the URI
]
}

/**
* /DATATYPES -----------------------------------------------------------------------------------------------
*/
Expand Down Expand Up @@ -1107,7 +1125,7 @@ class JsonInstanceCanonicalGenerator2 {
if (oa)
{
def items = processAttributeChildren(oa, parent_arch_id)
println "SECTION items"+ items
//println "SECTION items"+ items
mobj.items = items
}

Expand Down Expand Up @@ -1468,9 +1486,9 @@ class JsonInstanceCanonicalGenerator2 {

private generate_DV_INTERVAL__DV_COUNT(ObjectNode o, String parent_arch_id)
{
def mobj = [:]

mobj._type = 'DV_INTERVAL'
def mobj = [
_type: 'DV_INTERVAL<DV_COUNT>'
]

// Need to ask for the attributes explicitly since order matters for the XSD

Expand Down Expand Up @@ -1541,28 +1559,15 @@ class JsonInstanceCanonicalGenerator2 {

private generate_DV_INTERVAL__DV_QUANTITY(ObjectNode o, String parent_arch_id)
{
/*
<value xsi:type="DV_INTERVAL"><!-- note specific type is not valid here: DV_INERVAL<DV_COUNT> doesn't exists in the XSD -->
<lower xsi:type="DV_QUANTITY">
<magnitude>123.123</magnitude>
<units>mm[H20]</units>
</lower>
<upper xsi:type="DV_QUANTITY">
<magnitude>234.234</magnitude>
<units>mm[H20]</units>
</upper>
<lower_unbounded>false</lower_unbounded>
<upper_unbounded>false</upper_unbounded>
</value>
*/

def mobj = [:]
def mobj = [
_type: 'DV_INTERVAL<DV_QUANTITY>'
]

def lower = o.attributes.find { it.rmAttributeName == 'lower' }
mobj.lower = generate_DV_QUANTITY(lower.children[0], parent_arch_id)

def upper = o.attributes.find { it.rmAttributeName == 'upper' }
mobj.ipper = generate_DV_QUANTITY(upper.children[0], parent_arch_id)
mobj.upper = generate_DV_QUANTITY(upper.children[0], parent_arch_id)

// lower_unbounded and upper_unbounded are required
// for tagged DV_INTERVALs the only way to check this,
Expand Down Expand Up @@ -1618,13 +1623,15 @@ class JsonInstanceCanonicalGenerator2 {

private generate_DV_INTERVAL__DV_DATE_TIME(ObjectNode o, String parent_arch_id)
{
def mobj = [:]
def mobj = [
_type: 'DV_INTERVAL<DV_DATE_TIME>'
]

def lower = o.attributes.find { it.rmAttributeName == 'lower' }
mobj.lower = generate_attr_DV_DATE_TIME(lower.rmAttributeName)
mobj << generate_attr_DV_DATE_TIME(lower.rmAttributeName) // contains the attr name, that is why we use <<

def upper = o.attributes.find { it.rmAttributeName == 'upper' }
mobj.upper = generate_attr_DV_DATE_TIME(upper.rmAttributeName)
mobj << generate_attr_DV_DATE_TIME(upper.rmAttributeName)

// there are no constraints for date time to establish unbounded,
// so it is always unbounded for both limits.
Expand Down
1 change: 0 additions & 1 deletion test_all_datatypes_no_constraints_20200527083320_1.json

This file was deleted.

0 comments on commit 360e36a

Please sign in to comment.