Skip to content

Commit

Permalink
Set rm_version from OPT in OpenEhrRmInstanceGenerator (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
J3173 authored Jan 28, 2025
1 parent 78ff09f commit b3b28ba
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ExampleJsonInstanceGenerator {
private final String language;
private final MetaModels models;
private OperationalTemplate archetype;
private String rmRelease;
private BmmModel bmm;
private AomProfile aomProfile;

Expand All @@ -56,7 +57,7 @@ public ExampleJsonInstanceGenerator(MetaModels models, String language) {

public Map<String, Object> generate(OperationalTemplate archetype) {
this.archetype = archetype;
String rmRelease = archetype.getRmRelease();
rmRelease = archetype.getRmRelease();
//rm release 1.0.4 and 1.1.0 supported. if other versions, switch to 1.1.0 automatically to support other archetypes
if(rmRelease == null ||
!(rmRelease.equalsIgnoreCase("1.0.4") || rmRelease.equalsIgnoreCase("1.1.0"))) {
Expand Down Expand Up @@ -505,4 +506,8 @@ protected String getLanguage() {
protected OperationalTemplate getArchetype() {
return archetype;
}

protected String getRmRelease() {
return rmRelease;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private Map<String, Object> constructArchetypeDetails(String archetypeIdValue) {
archetypeId.put(typePropertyName, "ARCHETYPE_ID");
archetypeId.put("value", archetypeIdValue);
archetypeDetails.put("archetype_id", archetypeId); //TODO: add template id?
archetypeDetails.put("rm_version", "1.0.4");
archetypeDetails.put("rm_version", generator.getRmRelease());
return archetypeDetails;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,45 @@ public void ordinal() throws Exception {
assertTrue(s.contains("{\"_type\":\"DV_ORDINAL\",\"value\":0,\"symbol\":{\"_type\":\"DV_CODED_TEXT\",\"value\":\"Absent\",\"defining_code\":{\"_type\":\"CODE_PHRASE\",\"terminology_id\":{\"_type\":\"TERMINOLOGY_ID\",\"value\":\"local\"},\"code_string\":\"at11\"}}}"));
}

@Test
public void rmRelease104() throws Exception {
// This archetype has rm_release=1.0.4
OperationalTemplate opt = createOPT("/com/nedap/archie/rules/evaluation/construct_archetype_slot.adls");
ExampleJsonInstanceGenerator structureGenerator = createExampleJsonInstanceGenerator();

Map<String, Object> structure = structureGenerator.generate(opt);
String json = serializeToJson(structure, false);
Observation observation = getArchieObjectMapper().readValue(json, Observation.class);

assertEquals("1.0.4", observation.getArchetypeDetails().getRmVersion());
}

@Test
public void rmRelease110() throws Exception {
// This archetype has rm_release=1.1.0
OperationalTemplate opt = createOPT("/com/nedap/archie/diff/openEHR-EHR-OBSERVATION.basic_annotations.v1.0.0.adls");
ExampleJsonInstanceGenerator structureGenerator = createExampleJsonInstanceGenerator();

Map<String, Object> structure = structureGenerator.generate(opt);
String json = serializeToJson(structure, false);
Observation observation = getArchieObjectMapper().readValue(json, Observation.class);

assertEquals("1.1.0", observation.getArchetypeDetails().getRmVersion());
}

@Test
public void rmReleaseFallback() throws Exception {
// This archetype has rm_release=1.0.2, which should fall back to 1.1.0
OperationalTemplate opt = createOPT("/adl2-tests/features/aom_structures/tuples/openEHR-EHR-OBSERVATION.ordinal_tuple.v1.0.0.adls");
ExampleJsonInstanceGenerator structureGenerator = createExampleJsonInstanceGenerator();

Map<String, Object> structure = structureGenerator.generate(opt);
String json = serializeToJson(structure, false);
Observation observation = getArchieObjectMapper().readValue(json, Observation.class);

assertEquals("1.1.0", observation.getArchetypeDetails().getRmVersion());
}

/**
* Tests all CKM examples with the Archie JSON Schema, that properly handles polymorphism
* This probably will go away once we have a proper solution
Expand Down

0 comments on commit b3b28ba

Please sign in to comment.