# Error in CKM body_weight ADL2 form archetype **Category:** [Clinical](https://discourse.openehr.org/c/clinical/5) **Created:** 2023-09-21 15:38 UTC **Views:** 363 **Replies:** 8 **URL:** https://discourse.openehr.org/t/error-in-ckm-body-weight-adl2-form-archetype/4478 --- ## Post #1 by @thomas.beale We've just noticed that there is something strange in the body weight archetype, ADL2 version see the last item: ``` DV_QUANTITY[id29] matches { property matches {[at30]} [magnitude, units] matches { [{|0.0..1000.0|}, {"kg"}], [{|0.0..2000.0|}, {"[lb_av]"}], [{|0.0..1e+006.0|}, {"g"}] ``` That `1e+006.0` should just be `1000000.0`. Is this an Archie generation thing (@sebastian.garde )? It breaks other parsers that try to consume it, and can't be used in JSON either. --- ## Post #2 by @sebastian.garde Yes, this is Archie generated. @pieterbos, maybe there is a configuration for this? --- ## Post #3 by @pieterbos That is indeed an issue. The ADL 2 grammar does allow for exponent notation, but not in that format. From the ADL2 grammar: ```antlr INTEGER : DIGIT+ E_SUFFIX? ; REAL : DIGIT+ '.' DIGIT+ E_SUFFIX? ; fragment E_SUFFIX : [eE][+-]? DIGIT+ ; ``` This is the same form as is supported in json, and that should be `1.0e+6` or `1000000.0`. So the order of the fraction and the exponent segments appear to be reversed. The serialiation Archie uses is the Double::toString method in java. That has a clear specification, as in java 8:https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html#toString-double- or in java 17 https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Double.html#toString(double) That conforms exactly to the correct format. I would also not expect this to ever generate a 10E6, only a 10E7 and greater. So, either I am missing something, or this is a bug in the JVM used, or Archie is not used for this conversion. I checked the CKM, and that converts this correctly: ``` DV_QUANTITY[id9002] matches { property matches {[at9000]} -- Mass [magnitude, units] matches { [{|0.0..1000.0|}, {"kg"}], [{|0.0..2000.0|}, {"[lb_av]"}], [{|0.0..1000000.0|}, {"g"}] } } ``` From https://ckm.openehr.org/ckm/archetypes/1013.1.2960/adl , select adl 2 with the radio button at the bottom. The generated id code, id29, also suggests that Archie was not used in conversion, or that it was converted using very strange custom settings. Because id29 is likely to conflict with future codes in ADL 1.4, and id9002 is not. So @thomas.beale , how did you obtain this archetype? Could it be that this was converted using either the ADL workbench or the Better archetype designer? Those do not use Archie for conversion. --- ## Post #4 by @thomas.beale [quote="pieterbos, post:3, topic:4478"] So @thomas.beale , how did you obtain this archetype? Could it be that this was converted using either the ADL workbench or the Better archetype designer? Those do not use Archie for conversion. [/quote] I thought I had taken it from CKM, but now that I double check, I see that CKM is not causing this error, and it appears that it is the Workbench doing it, which I now need to investigate. Apologies for implying it was CKM, I got my files mixed up and thought it was. [quote="pieterbos, post:3, topic:4478"] The generated id code, id29, also suggests that Archie was not used in conversion, or that it was converted using very strange custom settings. Because id29 is likely to conflict with future codes in ADL 1.4, and id9002 is not. [/quote] I am thinking we should establish some soft rules for this kind of thing. --- ## Post #5 by @sebastian.garde [quote="thomas.beale, post:4, topic:4478"] I am thinking we should establish some soft rules for this kind of thing. [/quote] Wasn't the idea to use codes starting from 9000 for this purpose and keep a conversion log for consistency - this is what Archie(+CKM) is doing. --- ## Post #6 by @pieterbos [quote="sebastian.garde, post:5, topic:4478"] Wasn’t the idea to use codes starting from 9000 for this purpose and keep a conversion log for consistency - this is what Archie(+CKM) is doing. [/quote] That is indeed what Archie is doing. Both are necessary to make sure that further edits to the ADL 1.4 files result in ADL 2 archetypes that are compatible with the previous ADL 2 versions. It is of course possible and I think also a good idea to standardize the conversion log. It is not documented at the moment, other than the java file at https://github.com/openEHR/archie/blob/master/aom/src/main/java/com/nedap/archie/adl14/log/ADL2ConversionRunLog.java#L15 and https://github.com/openEHR/archie/blob/master/aom/src/main/java/com/nedap/archie/adl14/log/ADL2ConversionLog.java#L8 . The created codes map is keyed by path. The value sets - I think also by path where the converted encountered a place where a value set was missing. --- ## Post #7 by @thomas.beale [quote="sebastian.garde, post:5, topic:4478"] Wasn’t the idea to use codes starting from 9000 for this purpose and keep a conversion log for consistency - this is what Archie(+CKM) is doing. [/quote] I possibly would have chosen some other numeric starting point like id5000 for nodes that previously had no codes, because id9999 is documented as the special code for primitive nodes, that occasionally appears in an archetype. --- ## Post #8 by @pieterbos [quote="thomas.beale, post:7, topic:4478"] I possibly would have chosen some other numeric starting point like id5000 for nodes that previously had no codes, because id9999 is documented as the special code for primitive nodes, that occasionally appears in an archetype. [/quote] This is already in use, including the converted archetypes from the CKM, so it is tricky change. And the chance of needing 999 synthesized codes for a single archetype appears to be quite small. if that number is ever reached, we can easily change the range to continue at id8000 or even lower after id9998. --- ## Post #9 by @sebastian.garde [quote="pieterbos, post:8, topic:4478"] needing 999 synthesized codes for a single archetype [/quote] ...or put it that way: If you find the need to synthesize 999 codes, you may also have 5000 or 9000 or so existing normal codes in the archetype. We could augment the rule for the (let’s hope) theoretical case of exceeding 9000 normal codes and/or 999 synthesised codes. But then I think neither should continue before 10000 --- **Canonical:** https://discourse.openehr.org/t/error-in-ckm-body-weight-adl2-form-archetype/4478 **Original content:** https://discourse.openehr.org/t/error-in-ckm-body-weight-adl2-form-archetype/4478