-
Notifications
You must be signed in to change notification settings - Fork 160
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
Issue #694 - Perform syntax validation against ucum-units value set #1430
Conversation
Signed-off-by: Mike Schroeder <mschroed@us.ibm.com>
|
fail(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style consistency - we merge the catch line with the prior line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a second comment, to this approach, if they are individual tests, then they can succeed and fail independently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a code template and formatting rules for Eclipse here (near the bottom of the page):
https://github.com/IBM/FHIR/wiki/Style-Guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix style and break into individual testcases.
@@ -1260,6 +1261,8 @@ private String getSyntaxBasedValueSetValidationMethod(String valueSet, String fi | |||
String suffix = fieldType + (isRepeating ? "s" : ""); | |||
if (ALL_LANG_VALUE_SET_URL.equals(valueSet)) { | |||
return "checkLanguage" + suffix; | |||
} else if (UCUM_UNITS_VALUE_SET_URL.equals(valueSet)) { | |||
return "checkUcum" + suffix; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised it didn't hit Location as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you're referring to here - don't see any UCUM value sets used in the Location resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just surprised there were not any. It feels like a resource that can benefit from ucum consistency.
* @param elementName the element name | ||
* @throws IllegalStateException if the passed UCUM codeable concept is not valid | ||
*/ | ||
public static void checkUcumCodeableConcept(CodeableConcept ucumCodeableConcept, String elementName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be great to turn this on / and off like we've done with some other validation features.
That way we have an opportunity to still extract or tell someone how to extract bad data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed doing this more widely - something we'd address in issue #1421 - and making sure it applies to the UCUM and language syntax validation as well.
if (ucumCoding != null) { | ||
if (hasSystemAndCodeValues(ucumCoding)) { | ||
if (!UCUM_CODE_SYSTEM_URL.equals(ucumCoding.getSystem().getValue())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be refactored a little into one if statement and the else could be the checkUcumCode (it feels super nested) also ucumCoding.getSystem is this ever null on 355? maybe just combine this with 354 and 355
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need the if check on line 353 by itself b/c I don't want to return an exception if the coding is null. The if check on line 354 is just to verify that I have values for both system and code. If I don't, I can skip validating those fields separately since I know the coding is not valid without both system and code values. I can move the checkUcumCode to an else leg for the if check on line 355 (ucumCoding.getSystem will never be null here due to the checking in line above in the hasSystemAndCodeValues method)
if (ucumCodeableConcept.getCoding() != null) { | ||
for (Coding coding : ucumCodeableConcept.getCoding()) { | ||
if (coding != null) { | ||
try { | ||
checkUcumCoding(coding, elementName); | ||
return; | ||
} | ||
catch (IllegalStateException e) {} | ||
} | ||
} | ||
} | ||
throw new IllegalStateException(String.format("'%s' does not contain a Coding with a UCUM system of '%s' and a valid UCUM code", elementName, UCUM_CODE_SYSTEM_URL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the for loop succeeds and the coding is checked it can throw an illegalState? I don't think it should return elementName as part of the String.format, it's difficult to back track in the error to the actual failing element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we're just looking for one valid Coding. The checkUcumCoding method will return an IllegalStateException if a coding is not valid, so we want to just catch the exception and continue processing codings until we find a valid one, at which point we return from the method. If no valid codings are found we drop out of the loop and throw the IllegalStateException. For the error msg, do you suggest I just omit the CodeableConcept element name, or should I be providing something else there?
Looks good. Once the testcases are working, I'll approve it. |
Signed-off-by: Mike Schroeder <mschroed@us.ibm.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Mike Schroeder mschroed@us.ibm.com