Skip to content

Commit

Permalink
fixed parser serializer for demographic dtos
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed Mar 22, 2023
1 parent 749a3a0 commit 8e2106e
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 1.8.28
version = 1.8.29
group = com.cabolabs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ class OpenEhrJsonParserQuick {
}

def method = 'parse'+ type +'Dto'
this."$method"(map)
return this."$method"(map)
}

private PersonDto parsePERSONDto(Map map)
Expand Down Expand Up @@ -866,12 +866,11 @@ class OpenEhrJsonParserQuick {

if (!type)
{
throw new JsonParseException("_type required for PARTY_IDNETITY.details")
throw new JsonParseException("_type required for PARTY_IDENTITY.details")
}

def method = 'parse'+ type

this."$method"(map.details, pi)
pi.details = this."$method"(map.details, pi)
}

return pi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,24 @@ class OpenEhrJsonSerializer {
out.roles = []
a.roles.each { role ->

out.roles << this.serializeRole(role)
out.roles << this.serializeRoleDto(role)
}
}
}

private Map serializeRoleDto(Role r)
{
def out = [:]

out._type = 'ROLE'

this.fillParty(r, out)

//out.performer = this.serializePartyRef(r.performer)

return out
}

private void fillActor(Actor a, Map out)
{
this.fillParty(a, out)
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/json_schema/openehr_api_1.0.2_all.json
Original file line number Diff line number Diff line change
Expand Up @@ -5557,7 +5557,8 @@
"required": [
"archetype_node_id",
"archetype_details",
"name"
"name",
"identities"
],
"properties": {
"uid": {
Expand Down
109 changes: 103 additions & 6 deletions src/test/groovy/com/cabolabs/openehr/opt/ValidationFlowTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package com.cabolabs.openehr.opt
import groovy.util.GroovyTestCase
import com.cabolabs.testing.TestUtils
import static com.cabolabs.testing.TestUtils.PS as PS
import com.cabolabs.openehr.formats.OpenEhrJsonParser
import com.cabolabs.openehr.formats.OpenEhrJsonParserQuick
import com.cabolabs.openehr.formats.*
import com.cabolabs.openehr.validation.*
import com.cabolabs.openehr.opt.manager.*
import com.cabolabs.openehr.rm_1_0_2.ehr.Ehr
Expand All @@ -18,7 +17,6 @@ import com.cabolabs.openehr.rm_1_0_2.demographic.Group
import com.cabolabs.openehr.rm_1_0_2.demographic.Agent
import com.cabolabs.openehr.rm_1_0_2.data_types.text.DvText
import com.cabolabs.openehr.rm_1_0_2.support.identification.*

import com.cabolabs.openehr.dto_1_0_2.ehr.*
import com.cabolabs.openehr.dto_1_0_2.demographic.*

Expand Down Expand Up @@ -1147,7 +1145,39 @@ class ValidationFlowTest extends GroovyTestCase {
},
"rm_version": "1.0.2"
},
"archetype_node_id": "openEHR-DEMOGRAPHIC-ROLE.generic.v1"
"archetype_node_id": "openEHR-DEMOGRAPHIC-ROLE.generic.v1",
"identities": [
{
"_type": "PARTY_IDENTITY",
"name": {
"_type": "DV_TEXT",
"value": "identity"
},
"archetype_node_id": "at0004",
"details": {
"_type": "ITEM_TREE",
"name": {
"_type": "DV_TEXT",
"value": "tree"
},
"archetype_node_id": "at0005",
"items": [
{
"_type": "ELEMENT",
"name": {
"_type": "DV_TEXT",
"value": "name"
},
"archetype_node_id": "at0006",
"value": {
"_type": "DV_TEXT",
"value": "patient"
}
}
]
}
}
]
}
],
"identities": [
Expand Down Expand Up @@ -1256,7 +1286,39 @@ class ValidationFlowTest extends GroovyTestCase {
}
}
]
}
},
"identities": [
{
"_type": "PARTY_IDENTITY",
"name": {
"_type": "DV_TEXT",
"value": "identity"
},
"archetype_node_id": "at0004",
"details": {
"_type": "ITEM_TREE",
"name": {
"_type": "DV_TEXT",
"value": "tree"
},
"archetype_node_id": "at0005",
"items": [
{
"_type": "ELEMENT",
"name": {
"_type": "DV_TEXT",
"value": "name"
},
"archetype_node_id": "at0006",
"value": {
"_type": "DV_TEXT",
"value": "patient"
}
}
]
}
}
]
}
],
"identities": [
Expand Down Expand Up @@ -1313,6 +1375,9 @@ class ValidationFlowTest extends GroovyTestCase {
RmValidationReport report = validator.dovalidate(person, 'com.cabolabs.openehr_opt.namespaces.default')

assert !report.errors

def serializer = new OpenEhrJsonSerializer()
println serializer.serialize(person)
}

void test_generic_group_api_valid()
Expand Down Expand Up @@ -1410,7 +1475,39 @@ class ValidationFlowTest extends GroovyTestCase {
},
"rm_version": "1.0.2"
},
"archetype_node_id": "openEHR-DEMOGRAPHIC-ROLE.generic.v1"
"archetype_node_id": "openEHR-DEMOGRAPHIC-ROLE.generic.v1",
"identities": [
{
"_type": "PARTY_IDENTITY",
"name": {
"_type": "DV_TEXT",
"value": "identity"
},
"archetype_node_id": "at0004",
"details": {
"_type": "ITEM_TREE",
"name": {
"_type": "DV_TEXT",
"value": "tree"
},
"archetype_node_id": "at0005",
"items": [
{
"_type": "ELEMENT",
"name": {
"_type": "DV_TEXT",
"value": "name"
},
"archetype_node_id": "at0006",
"value": {
"_type": "DV_TEXT",
"value": "patient"
}
}
]
}
}
]
}
]
}
Expand Down

0 comments on commit 8e2106e

Please sign in to comment.