Using adl-parser from jar-file

Hi,

I downloaded and tested the ADL-parser jar-file from

http://www.openehr.org/svn/ref_impl_java/TRUNK/docs/download.htm

I got the following error

Exception in thread “main” java.lang.NoClassDefFoundError: org/openehr/rm/support/measurement/SimpleMeasurementService
at se.acode.openehr.parser.ADLParser.(ADLParser.java:49)
at se.acode.openehr.parser.ADLParser.(ADLParser.java:56)
at Parsertest.main(Parsertest.java:24)

When I checked the reference model jar there was no SimpleMeasurementService class

Am I doing something wrong, or do I have to download the source and compile it myself to get working jar-files to use?

Regards

Olof Torgersson

Hi Olof,

The ADL-parser is using a component, which implemented a simple Measurement Service. http://www.openehr.org/svn/ref_impl_java/TRUNK/measure-serv/

The easiest way of getting started with the parser is to check out the source and build the jar with maven “mvn clean package”. Then you can find the jar called “adl-parser-1.0.5-SNAPSHOT-jar-with-dependencies.jar” in target sub directory. As the name implies, it includes all the dependencies required by the jar file and yon can actually start it from command line for some trivial parsing.

Let me know how it goes for you.

Cheers,
Rong

Thanks for your reply.

I’ll try to compile from the sources.

Regards

Olof

(As far as I can tell org.openehr.rm.support.measurement.SimpleMeasurementService is missing from
the pre-built jar-file openehr-rm-core-0.1-SNAPSHOT.jar. This is a bit confusing since it is required by the ADL-parser
that can be downloaded from the same site ( http://www.openehr.org/svn/ref_impl_java/TRUNK/docs/download.htm ))

29 sep 2008 kl. 14.12 skrev Rong Chen:

After realising that maven was actually already installed, building on Mac OS X was no problem, before that I spent some time trying to make it easy installing maven-plugins for netbeans etc.

I’ve tested the parser on the archetypes that come with Ocean Informatics’ Archetype Editor.

95 out of 134 archetypes failed to parse. Is this due to some kind of incompatibility?

Basically there seems to be 2 kinds of errors, the first a parse error:

ParseException for openEHR-EHR-ITEM_TREE.referral.v1.adl
ParseException: Encountered “"en"” at line 15, column 37.
Was expecting:
<V_CODE_PHRASE> …

se.acode.openehr.parser.ParseException: Encountered “"en"” at line 15, column 37.
Was expecting:
<V_CODE_PHRASE> …

at se.acode.openehr.parser.ADLParser.generateParseException(ADLParser.java:7216)
at se.acode.openehr.parser.ADLParser.jj_consume_token(ADLParser.java:7078)
at se.acode.openehr.parser.ADLParser.code_phrase(ADLParser.java:297)
at se.acode.openehr.parser.ADLParser.arch_description_item(ADLParser.java:616)
at se.acode.openehr.parser.ADLParser.arch_description(ADLParser.java:517)
at se.acode.openehr.parser.ADLParser.archetype(ADLParser.java:272)
at se.acode.openehr.parser.ADLParser.parse(ADLParser.java:101)
at tsts2.testFile(tsts2.java:112)
at tsts2.testDirectory(tsts2.java:162)
at tsts2.testDirectory(tsts2.java:159)
at tsts2.main(tsts2.java:66)

and the second another kind which is not caught by the parser

Another exption for openEHR-EHR-ITEM_TREE.patient_information.v1.adl
Exception: null or empty purpose
java.lang.IllegalArgumentException: null or empty purpose
at org.openehr.rm.common.resource.ResourceDescriptionItem.(ResourceDescriptionItem.java:48)
at se.acode.openehr.parser.ADLParser.arch_description_item(ADLParser.java:698)
at se.acode.openehr.parser.ADLParser.arch_description(ADLParser.java:517)
at se.acode.openehr.parser.ADLParser.archetype(ADLParser.java:272)
at se.acode.openehr.parser.ADLParser.parse(ADLParser.java:101)
at tsts2.testFile(tsts2.java:112)
at tsts2.testDirectory(tsts2.java:162)
at tsts2.testDirectory(tsts2.java:159)
at tsts2.main(tsts2.java:66)

Regards

Olof

30 sep 2008 kl. 08.37 skrev Rong Chen:

Dear Olof,

not sure what is included in the latest Archtype Editor - I would assume they are only test archetypes, which may indeed be a bit outdated - see comments inline.
You can get a recent set of archetypes via subversion…see at the very bottom of http://www.openehr.org/clinicalmodels/archetypes.html
Or you can download a zip file from the Beta openEHR Clinical Knowledge Manager at http://www.openehr.org/knowledge (Archetypes/Export Archetypes)

See more details on the errors inline

Best regards
Sebastian

Olof Torgersson wrote:

After realising that maven was actually already installed, building on Mac OS X was no problem, before that I spent some time trying to make it easy installing maven-plugins for netbeans etc.

I’ve tested the parser on the archetypes that come with Ocean Informatics’ Archetype Editor.

95 out of 134 archetypes failed to parse. Is this due to some kind of incompatibility?

Basically there seems to be 2 kinds of errors, the first a parse error:

ParseException for openEHR-EHR-ITEM_TREE.referral.v1.adl
ParseException: Encountered “"en"” at line 15, column 37.
Was expecting:
<V_CODE_PHRASE> …

se.acode.openehr.parser.ParseException: Encountered “"en"” at line 15, column 37.
Was expecting:
<V_CODE_PHRASE> …

at se.acode.openehr.parser.ADLParser.generateParseException(ADLParser.java:7216)
at se.acode.openehr.parser.ADLParser.jj_consume_token(ADLParser.java:7078)
at se.acode.openehr.parser.ADLParser.code_phrase(ADLParser.java:297)
at se.acode.openehr.parser.ADLParser.arch_description_item(ADLParser.java:616)
at se.acode.openehr.parser.ADLParser.arch_description(ADLParser.java:517)
at se.acode.openehr.parser.ADLParser.archetype(ADLParser.java:272)
at se.acode.openehr.parser.ADLParser.parse(ADLParser.java:101)
at tsts2.testFile(tsts2.java:112)
at tsts2.testDirectory(tsts2.java:162)
at tsts2.testDirectory(tsts2.java:159)
at tsts2.main(tsts2.java:66)

This is probably due to outdated specification of language in the archetype.
Opening the archetype and saving it, should update this to the “new” format and then should parse properly.

and the second another kind which is not caught by the parser

Another exption for openEHR-EHR-ITEM_TREE.patient_information.v1.adl
Exception: null or empty purpose
java.lang.IllegalArgumentException: null or empty purpose
at org.openehr.rm.common.resource.ResourceDescriptionItem.(ResourceDescriptionItem.java:48)
at se.acode.openehr.parser.ADLParser.arch_description_item(ADLParser.java:698)
at se.acode.openehr.parser.ADLParser.arch_description(ADLParser.java:517)
at se.acode.openehr.parser.ADLParser.archetype(ADLParser.java:272)
at se.acode.openehr.parser.ADLParser.parse(ADLParser.java:101)
at tsts2.testFile(tsts2.java:112)
at tsts2.testDirectory(tsts2.java:162)
at tsts2.testDirectory(tsts2.java:159)
at tsts2.main(tsts2.java:66)

This is because the ADL requires to have a purpose specified.
Most uptodate archetypes should have that now, but in case you REALLY need to parse an archetype that doesn’t have specified purpose, you could adapt the constructor of openehr-rm-core\src\main\java\org\openehr\rm\common\resource\ResourceDescriptionItem.java

if (StringUtils.isEmpty(purpose)) {
// throw new IllegalArgumentException(“null or empty purpose”);
System.out.println(“WARNING: Archetype parsed that has null or empty purpose…”);
}

(attachments)

oceanlogo.png

Date: Tue, 30 Sep 2008 16:09:11 +0200
From: Olof Torgersson <oloft@chalmers.se>
Subject: {Disarmed} Re: Using adl-parser from jar-file

95 out of 134 archetypes failed to parse. Is this due to some kind of
incompatibility?

I don't know if it is helpful but when I was importing archetypes on
mass using the java ADL parser I read each ADL file and made a little
change to get past some parsing errors. Essentially I did this:

String contents =
FileSystemUtil.getTextContents(file).replace("purpose = <\"\">",
"purpose = <\"test\">");
if (contents.contains("description\r\n\tdetail")) {
     contents = contents.replace("description\r\n\tdetail",
"description\r\noriginal_author = < [\"name\"] = <\"me\"> >\tdetail");

Not sure if I was using the same version you are now.

Greg

http://www.patientos.org

Date: Tue, 30 Sep 2008 16:09:11 +0200
From: Olof Torgersson <oloft@chalmers.se>
Subject: {Disarmed} Re: Using adl-parser from jar-file

95 out of 134 archetypes failed to parse. Is this due to some kind of
incompatibility?

I don’t know if it is helpful but when I was importing archetypes on
mass using the java ADL parser I read each ADL file and made a little
change to get past some parsing errors. Essentially I did this:

String contents =
FileSystemUtil.getTextContents(file).replace(“purpose = <"">”,
“purpose = <"test">”);
if (contents.contains(“description\r\n\tdetail”)) {
contents = contents.replace(“description\r\n\tdetail”,
“description\r\noriginal_author = < ["name"] = <"me"> >\tdetail”);

Hi Greg,

Thanks for this information. Do you still have to do this if you import latest archetypes from the knowledge repository?

Cheers,
Rong

Forward to the list.
/rong

Thanks for all the replies, now I know what the problem was.

One possibly stupid questio:

How do I check out the archetypes that can be viewed at

http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/?rev=0&sc=0

Regards

Olof

30 sep 2008 kl. 20.36 skrev Rong Chen:

Olof Torgersson wrote:

Thanks. Nice site.

regards

Olof

(The exported archetypes parsed ok except for the following, which threw an exception due to not having any purpose

openEHR-EHR-CLUSTER.change.v1.adl
openEHR-EHR-CLUSTER.delivery_of_infant.v1.adl
openEHR-EHR-CLUSTER.free_text.v1.adl
openEHR-EHR-CLUSTER.health_event-trauma.v1.adl
openEHR-EHR-CLUSTER.health_event.v1.adl
openEHR-EHR-CLUSTER.hydration.v1.adl
openEHR-EHR-CLUSTER.pupils.v1.adl
openEHR-EHR-ACTION.follow_up.v1.adl
openEHR-EHR-ACTION.procedure.v1.adl
openEHR-EHR-EVALUATION.check_list.v1.adl
openEHR-EHR-INSTRUCTION.follow_up.v1.adl
openEHR-EHR-INSTRUCTION.procedure.v1.adl
openEHR-EHR-OBSERVATION.faeces.v1.adl
openEHR-EHR-OBSERVATION.fundoscopic_examination.v1.adl
openEHR-EHR-OBSERVATION.infant_feeding.v1.adl
openEHR-EHR-OBSERVATION.operation_record.v1.adl
openEHR-EHR-OBSERVATION.story.v1.adl
openEHR-EHR-OBSERVATION.third_party_observation-hearing.v1.adl
openEHR-EHR-OBSERVATION.third_party_observation.v1.adl
openEHR-EHR-OBSERVATION.uterine_contractions.v1.adl
openEHR-EHR-SECTION.discharge_summary_outline.v1.adl
openEHR-EHR-ITEM_TREE.follow_up.v1.adl
openEHR-EHR-ITEM_TREE.intravenous_fluids.v1.adl

)

1 okt 2008 kl. 10.24 skrev Thomas Beale:

Message: 4
Date: Wed, 1 Oct 2008 09:45:38 +0200
From: Olof Torgersson <oloft@chalmers.se>
Subject: Re: Using adl-parser from jar-file
To: "List for the development team for the reference implementation of
       openEHR in Java language and technologies."
       <ref_impl_java@openehr.org>
Message-ID: <B44D82BE-6DD7-42FB-8FF5-28142403BE2B@chalmers.se>
Content-Type: text/plain; charset="iso-8859-1"

How do I check out the archetypes that can be viewed at

http://www.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/?rev=0&sc=0

Regards

Olof

svn co http://svn.openehr.org/knowledge/archetypes/dev/adl/test

I assume you are familiar with svn (windows binaries here for those
not: http://subversion.tigris.org/getting.html#windows)

obviously remove the suffix dev/adl/test if you want all archetypes

Greg