Skip to content

Commit

Permalink
fixes for ingen
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed Nov 17, 2023
1 parent a0a7d46 commit ba02134
Show file tree
Hide file tree
Showing 9 changed files with 854 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ String path = "vital_signs.xml"
File file = new File(getClass().getResource(path).toURI())
String xml = file.text
def parser = new OpenEhrXmlParser()
Composition c = (Composition)parser.parseXml(xml)
Composition c = (Composition)parser.parseLocatable(xml)
```

### Serialize a COMPOSITION to XML
Expand Down Expand Up @@ -249,7 +249,7 @@ report.errors.each { error ->
```groovy
String xml = ...
def parser = new OpenEhrXmlParser()
Composition c = (Composition)parser.parseXml(xml)
Composition c = (Composition)parser.parseLocatable(xml)
def serializer = new OpenEhrJsonSerializer()
String json = serializer.serialize(c)
```
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = 1.9.10
version = 1.9.11
group = com.cabolabs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class OpenEhrJsonParser {
return ehr
}

// FIXME: this should be parseLocatable
// used to parse compositions and other descendant from Locatable
// TODO: FOLDER and EHR_STATUS are above, we might need to use this one instead
Locatable parseJson(String json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ class OpenEhrJsonSerializer {
{
this.fillPartyDto(a, out)

def method

// optional
if (a.languages)
{
Expand Down Expand Up @@ -218,6 +220,8 @@ class OpenEhrJsonSerializer {
{
this.fillParty(a, out)

def method

// optional
if (a.languages)
{
Expand Down Expand Up @@ -674,8 +678,7 @@ class OpenEhrJsonSerializer {

out.system_id = a.system_id

String method
method = this.method(a.committer)
String method = this.method(a.committer)
out.committer = [_type: this.openEhrType(a.committer)] + this."$method"(a.committer)

out.time_committed = this.serializeDvDateTime(a.time_committed)
Expand All @@ -698,8 +701,7 @@ class OpenEhrJsonSerializer {
// AuditDetails fields
out.system_id = a.system_id

def method
method = this.method(a.committer)
def method = this.method(a.committer)
out.committer = [_type: this.openEhrType(a.committer)] + this."$method"(a.committer)

out.time_committed = this.serializeDvDateTime(a.time_committed)
Expand Down Expand Up @@ -911,9 +913,11 @@ class OpenEhrJsonSerializer {
{
this.fillEntry(o, out)

String method

if (o.protocol)
{
String method = this.method(o.protocol)
method = this.method(o.protocol)
out.protocol = [_type: this.openEhrType(o.protocol)] + this."$method"(o.protocol)

// TODO: check if this is needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class OpenEhrXmlParser {
catch (Exception e)
{
println e.message
throw new XmlParseException("Can't parse XML, check ${type} is a VERSION type. If you tried to parse a LOCATABLE, use the parseXml method", e)
throw new XmlParseException("Can't parse XML, check ${type} is a VERSION type. If you tried to parse a LOCATABLE, use the parseLocatable method", e)
}
return out
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/groovy/com/cabolabs/openehr/opt/Main.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class Main {
def destination_path = args[2]
verifyFolder(destination_path)

// TODO: separate xml/json from the composition/version in two params
def format = 'json'
def generate = 'locatable'

Expand Down Expand Up @@ -282,6 +281,7 @@ class Main {
printer.flush()
printer.close()
break
// TODO: trans FOLDER, EHR_STATUS, ACTOR, PARTY_RELATIONSHIP
case "composition":

String path = args[2] // composition
Expand All @@ -302,7 +302,7 @@ class Main {
// Parse XML
String xml = f.text
def parser = new OpenEhrXmlParser()
Composition c = (Composition)parser.parseXml(xml)
Composition c = (Composition)parser.parseLocatable(xml)

// debug
// out = JsonOutput.toJson(c)
Expand Down Expand Up @@ -457,7 +457,7 @@ class Main {
static validateXMLWithOPT(File xml)
{
def parser = new OpenEhrXmlParser()
def instance = parser.parseXml(xml.text) // should be a composition, if the file is a version it won't parse
def instance = parser.parseLocatable(xml.text) // xml should be a locatable
validateCompositionWithOPT(instance)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ class RmInstanceGenerator {
_denominator = 1
break
case 2: // percent
_numerator = (random_gen.nextFloat() * (num_hi - num_lo) + num_lo).round(1)
_numerator = (random_gen.nextFloat() * 100).round(1) // NOTE: for a percentage, 100 is the high value
_denominator = 100
break
case [3,4]: // fraction, integer_fraction
Expand Down
Loading

0 comments on commit ba02134

Please sign in to comment.