Since a move to OPT2 is taking longer than expected I tried using *.t.json files that Better’s Archetype Designer exports (using “Export Fileset”).
I wrote a BMM file that matches the AM used in *.t.json files but also followed the standard AM definitions where they are available. Code for deserializing *.t.json files was generated from the BMM file.
Here are some notes about the incompatibilities with the specifications. It would be great if AD could implement these fixes but the main goal of posting them here is for others who would like to avoid the headaches while parsing *.t.json files.
A similar discussion produced great results for OPT2 JSON and earned some praise for teamwork (ASSERTION in openehr_expression_104.bmm is not in accordance with the specifications - #41 by DavidIngram).
A good old regular expressions were used to process the original *.t.json files:
#1 Change property names to snake_case
#2 Add “rm_type_name” and “_type” to “Interval”
From:
"@type" : "C_REAL",
"constraint" : [ {
To:
"@type": "C_REAL",
"rm_type_name": "Real",
"constraint": [ {
"@type": "Interval<Real>",
When there are more constraints, we cannot fix them automatically. Editing the original *.t.json is required by adding type to the second constraint.
Found in:
- Antenatal - first visit.t.json
- Heart Failure Clinic First Visit Summary.t.json
"@type" : "C_INTEGER",
"rmTypeName" : "Integer",
"occurrences" : "1..1",
"constraint" : [ {
"lower" : 1,
"upper" : 1,
"lowerIncluded" : true,
"upperIncluded" : true,
"lowerUnbounded" : false,
"upperUnbounded" : false
}, {
"@type": "Interval<Integer>", <= this line was added manually
"lower" : 2,
"upper" : 2,
"lowerIncluded" : true,
"upperIncluded" : true,
"lowerUnbounded" : false,
"upperUnbounded" : false
} ]
#3 Add “rm_type_name” to “C_STRING”, “C_TERMINOLOGY_CODE”,…
From:
"@type": "C_STRING",
"constraint": [
To:
"@type": "C_STRING",
"rm_type_name": "String",
"constraint": [
#4 Add “rm_type_name” and “terminology_id” to “C_TERMINOLOGY_CODE”
Some “C_TERMINOLOGY_CODE” properties are incomplete.
From:
"@type" : "C_TERMINOLOGY_CODE",
"constraint" : [ "at0115" ]
To:
"@type": "C_TERMINOLOGY_CODE",
"rm_type_name": "CODE_PHRASE",
"terminology_id": {
"value": "local"
},
"constraint" : [ "at0115" ]
#5 Add proper “Multiplicity_interval” for the “occurrences” property
From:
"@type": "C_COMPLEX_OBJECT",
"rmTypeName": "ELEMENT",
"occurrences": "0..0",
To:
"@type": "C_COMPLEX_OBJECT",
"rm_type_name": "ELEMENT",
"occurrences": {
"_type": "Multiplicity_interval",
"lower_unbounded": false,
"upper_unbounded": false,
"lower_included": true,
"upper_included": true,
"lower": 0,
"upper": 0
},
#6 Extract “terminology_id” from the “value” property in “C_TERMINOLOGY_CODE”
From:
"terminologyId": {
"value": "local"
},
To:
"terminologyId": "local",
#7 Extract “lifecycle_state” from the “code_string” property in “RESOURCE_DESCRIPTION” (inside “TEMPLATE”)
From:
"lifecycleState": {
"codeString": "unmanaged"
},
To:
"lifecycleState": "local",
#8 Add “EXPR_” prefix to operator types
From:
"@type" : "BINARY_OPERATOR",
To:
"@type" : "EXPR_BINARY_OPERATOR",
#9 Add “_def” suffix to the “operator” property inside “BINARY_OPERATOR” and fix its type
From:
"operator": "matches",
To:
"operator_def": {
"_type": "OPERATOR_DEF_BUILTIN",
"identifier": "matches"
},