Hi Sergio,
Thanks for the report, please find my comments below.
Hi,
I have the following observations regarding class DvOrdered:
- Method isNormal() checks only if normalRange contains current DvOrdered, but omits the situation where normalStatus is present.
One possibility is to change the method implementation to:
public boolean isNormal() {
return ((normalRange == null) ? false : getNormalRange().has(this)) ||
((normalStatus == null) ? false : normalStatus.getCodeString().equals(“N”));
}
Yes, the current isNormal() implementation isn’t complete according to the specification.
The pre-condition for this method is (normal_range != null || normal_status !=null). So I think the method shouldn’t just return false when both are null. Maybe should throw some kind of exception to indicate the pre-condition is not met.
- Method isSimple() checks only if otherReferenceRanges is null. It should also check if normalRange is null.
Yes, it will be fixed.
- The invariants Normal_status_validity and Normal_range_and_status_consistency are not warranted.
You could add a method like validateNormalStatus (see below) and call it in the constructor. To do this you should get a reference to a terminologyService. If you do this in the constructor, you’ll have to propagate it all the way down the hierarchy.
private void validateNormalStatus(CodePhrase status) {
if (status != null) {
if (terminologyService == null) {
throw new IllegalArgumentException(“null terminologyService”);
}
if (!terminologyService.codeSetForID(
“normal statuses”).hasCode(status)) {
throw new IllegalArgumentException(
"unknown code for normalStatus: " + status.getCodeString());
}
}
}
For normal range and status consistency, one possibility is to have a method like that below that should be called in the constructors of the concrete classes.
private void checkNormalRangeAndStatusConsistency(DvInterval normalRange) {
if ((normalRange != null) && (normalStatus() != null)) {
if (normalStatus.getCodeString().equals(“N”) ^ (normalRange.has(this)) {
throw new IllegalStateException(“normal status not consistent with normal range”);
}
}
}
These look alright. I will probably add a testcase for this.
These checks should also be done in the corresponding setters, unless you make the attributes final.
That’s right.
Cheers,
Rong