Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add SiblingOrder when specialising the first element of an archetype #604

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions tools/src/main/java/com/nedap/archie/diff/LCSOrderingDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@

if(lcs.size() == 0) {
//If there's no empty LCS, it's not possible to add sibling markers
} else {
} else {
for (int i = 0; i < childNodeIds.size(); i++) {
String nodeId = childNodeIds.get(i);
if (!nodeIdLCS.contains(nodeId)) {
Expand Down Expand Up @@ -192,26 +192,25 @@
boolean onlyTheSameParentNodeId = false;
String firstNodeIdWithSameParent = null;

for(int j = i - 1; j>= 0; j--) {

for(int j = i - 1; j >= 0; j--) {
String otherNodeId = childNodeIds.get(j);
if(AOMUtils.getSpecializationDepthFromCode(nodeId) == childSpecializationDepth &&
if (AOMUtils.getSpecializationDepthFromCode(nodeId) == childSpecializationDepth &&
AOMUtils.codeExistsAtLevel(nodeId, childSpecializationDepth-1) &&
AOMUtils.codeAtLevel(otherNodeId, childSpecializationDepth-1).equals(AOMUtils.codeAtLevel(nodeId, childSpecializationDepth-1))) {
onlyTheSameParentNodeId = true;
firstNodeIdWithSameParent = otherNodeId;
} else {
if (onlyTheSameParentNodeId) {
CObject cObjectInResult = resultAttribute.getChild(nodeId);
SiblingOrder order = DiffUtil.findSiblingOrder(siblingOrders, firstNodeIdWithSameParent);
if(order != null) {
DiffUtil.addSiblingOrder(siblingOrders, order, cObjectInResult);
}
return true;
}
return false;
break;
}
}

if (onlyTheSameParentNodeId) {
CObject cObjectInResult = resultAttribute.getChild(nodeId);
SiblingOrder order = DiffUtil.findSiblingOrder(siblingOrders, firstNodeIdWithSameParent);
if(order != null) {
DiffUtil.addSiblingOrder(siblingOrders, order, cObjectInResult);

Check warning on line 211 in tools/src/main/java/com/nedap/archie/diff/LCSOrderingDiff.java

View check run for this annotation

Codecov / codecov/patch

tools/src/main/java/com/nedap/archie/diff/LCSOrderingDiff.java#L211

Added line #L211 was not covered by tests
}
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ public void redefinitionAtSamePlace() throws Exception {
diffTestUtil.test("openEHR-EHR-CLUSTER.order-parent.v1.0.0.adls","openEHR-EHR-CLUSTER.redefinition_at_same_place.v1.0.0.adls");
}

@Test
public void specialiseFirstElement() throws Exception {
diffTestUtil.test("openEHR-EHR-CLUSTER.order-parent.v1.0.0.adls","openEHR-EHR-CLUSTER.specialise_first_element.v1.0.0.adls");
}

//The two tricky edge cases in the flattener test are really not interesting here, as the Differentiator will never create such hard to do code
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ description
definition
CLUSTER[id1.1] matches { -- Lipid studies panel
items matches {
after [id3]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the flattener, specialised nodes will appear after their parent if there is no sibling order attacked to the specialised nodeId

CLUSTER[id3.1] matches { -- LDL
items matches {
ELEMENT[id2.1] matches { -- LDL cholesterol
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
archetype (adl_version=2.0.5; rm_release=1.0.2; generated)
openEHR-EHR-CLUSTER.specialise_first_element.v1.0.0

specialize
openEHR-EHR-CLUSTER.order-parent.v1.0.0

language
original_language = <[ISO_639-1::en]>

description
lifecycle_state = <"unmanaged">

definition
CLUSTER[id1.1] ∈ {
items ∈ {
ELEMENT[id2.1]
}
}

terminology
term_definitions = <
["en"] = <
["id1.1"] = <
text = <"cluster">
description = <"cluster">
>
["id0.1"] = <
text = <"item 5">
description = <"item 5">
>
["id0.2"] = <
text = <"item 6">
description = <"item 6">
>
["id0.3"] = <
text = <"item 7">
description = <"item 7">
>
["id0.4"] = <
text = <"item 8">
description = <"item 8">
>
>
>