Hi,
thanks again, no I haven’t modified the templates and due to the supplied needed archetypes: yes I think so (see code below - just to mention this: the debug print shows the correct values of the template). The exception I get is thrown in the Flattener.java (see below the stacktrace).
thanks!
[EXCEPTION]
org.openehr.am.template.FlatteningException: Unkown archetyped sub-type
at org.openehr.am.template.Flattener.flattenArchetyped(Flattener.java:174)
at org.openehr.am.template.Flattener.toFlattenedArchetype(Flattener.java:133)
at org.openehr.am.template.Flattener.toFlattenedArchetype(Flattener.java:119)
…
[\EXCEPTION]
Here’s the code:
[CODE]
Flattener flattener = new Flattener();
String ids = {
“openEHR-EHR-COMPOSITION.prescription.v1”,
“openEHR-EHR-INSTRUCTION.medication.v1”,
“openEHR-EHR-ITEM_TREE.medication.v1”,
“openEHR-EHR-ITEM_TREE.medication_mod.v1”,
“openEHR-EHR-SECTION.medications.v1”,
“openEHR-EHR-ITEM_TREE.medication_test_one.v1”,
“openEHR-EHR-ITEM_TREE.medication_test_three.v1”,
“openEHR-EHR-ITEM_TREE.medication_multiple_constraint_test.v1”,
“openEHR-EHR-ITEM_TREE.medication_multiple_constraint_test2.v1”,
“openEHR-EHR-SECTION.ad_hoc_heading.v1”,
“openEHR-EHR-SECTION.simple_section_name.v1”,
“openEHR-EHR-COMPOSITION.test.v1”,
“openEHR-EHR-EVALUATION.structured_summary.v1”,
“openEHR-EHR-EVALUATION.review_of_procedures.v1”,
“openEHR-EHR-ACTION.medication.v1”,
“openEHR-EHR-ITEM_TREE.medication.v1”,
“openEHR-EHR-ITEM_TREE.medication_quantity_test.v1”,
“openEHR-EHR-ITEM_TREE.medication_quantity_test2.v1”,
“openEHR-EHR-OBSERVATION.waist_hip.v2”,
“openEHR-EHR-OBSERVATION.lab_test.v1”,
“openEHR-EHR-OBSERVATION.heart_failure_stage.v2”,
“openEHR-EHR-EVALUATION.medication_review.v1”
};
archetypeMap = new HashMap<String, Archetype>();
for(String id : ids) {
Archetype archetype;
try {
archetype = loadArchetype(id + “.adl”);
archetypeMap.put(archetype.getArchetypeId().toString(), archetype);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
parser = new OETParser();
template = loadTemplate(“prescription.oet”);
System.out.println(template.getId());
Archetyped xy = template.getDefinition();
//this if is just for debugging → xy always is an instance of ArchetypedImpl
if(xy instanceof ArchetypedImpl){
System.out.println(“TRUE”);
Node test = xy.getDomNode().getAttributes().item(0);
System.out.println(xy.getArchetypeId() + "\n DESCRIPTION: " + xy.getDomNode().getLocalName() + " " + test.getLocalName() + " " + test.getNodeValue());
}
flattened = flattener.toFlattenedArchetype(template,
archetypeMap, templateMap);
} catch (FlatteningException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
[\CODE]
2012/2/20 Rong Chen <rong.acode@gmail.com>