3164 updating code review points (#3165)

* 3164 updating code review points

* 3164 updating code review points

Co-authored-by: leif stawnyczy <leifstawnyczy@leifs-MacBook-Pro.local>
This commit is contained in:
TipzCM 2021-11-12 15:13:42 -05:00 committed by GitHub
parent 1487e03037
commit 1478abac3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 5 deletions

View File

@ -1,5 +1,6 @@
---
type: fix
issue: 3153
jira: SMILE-3289
title: "Updated UnknownCodeSystemWarningValidationSupport to allow the throwing of warnings if
configured to do so."

View File

@ -161,6 +161,20 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
}
private Observation createObservationForUnknownCodeSystemTest() {
Observation obs = new Observation();
obs.getMeta().addProfile("http://sd");
obs.getText().setDivAsString("<div>Hello</div>");
obs.getText().setStatus(Narrative.NarrativeStatus.GENERATED);
obs.getCategoryFirstRep().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/observation-category").setCode("vital-signs");
obs.getCode().setText("hello");
obs.setSubject(new Reference("Patient/123"));
obs.addPerformer(new Reference("Practitioner/123"));
obs.setEffective(DateTimeType.now());
obs.setStatus(ObservationStatus.FINAL);
return obs;
}
/**
* By default, an unknown code system should fail validation
*/
@ -171,6 +185,32 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
createStructureDefWithBindingToUnknownCs();
Observation obs = createObservationForUnknownCodeSystemTest();
OperationOutcome oo;
String encoded;
// Valid code
obs.setValue(new Quantity().setSystem("http://cs").setCode("code1").setValue(123));
oo = validateAndReturnOutcome(obs);
encoded = encode(oo);
ourLog.info(encoded);
assertTrue(oo.getIssueFirstRep().getDiagnostics().contains("No issues detected during validation"));
// Invalid code
obs.setValue(new Quantity().setSystem("http://cs").setCode("code99").setValue(123));
oo = validateAndReturnOutcome(obs);
encoded = encode(oo);
ourLog.info(encoded);
assertTrue(oo.getIssueFirstRep().getDiagnostics().contains("No issues detected during validation"));
}
@Test
public void testValidateCodeInValueSetWithUnknownCodeSystem_Error() {
myUnknownCodeSystemWarningValidationSupport.setNonExistentCodeSystemSeverity(IValidationSupport.IssueSeverity.ERROR);
createStructureDefWithBindingToUnknownCs();
Observation obs = new Observation();
obs.getMeta().addProfile("http://sd");
obs.getText().setDivAsString("<div>Hello</div>");
@ -192,13 +232,15 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
ourLog.info(encoded);
assertTrue(oo.getIssueFirstRep().getDiagnostics().contains("No issues detected during validation"));
// Invalid code
obs.setValue(new Quantity().setSystem("http://cs").setCode("code99").setValue(123));
oo = validateAndReturnOutcome(obs);
encoded = encode(oo);
ourLog.info(encoded);
assertTrue(oo.getIssueFirstRep().getDiagnostics().contains("No issues detected during validation"));
assertTrue(oo.getIssueFirstRep()
.getDiagnostics().contains("The code provided (http://cs#code99) is not in the value set http://vs, and a code from this value set is required: Unknown code 'http://cs#code99' for in-memory expansion of ValueSet 'http://vs'")
);
}
public void createStructureDefWithBindingToUnknownCs() {

View File

@ -45,12 +45,15 @@ public class UnknownCodeSystemWarningValidationSupport extends BaseValidationSup
@Override
public CodeValidationResult validateCode(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, String theValueSetUrl) {
// filters out error/fatal
// NB: this is a secondary check. isCodeSystemSupported
// should prevent this from ever calling validate code here
// ... but should it ever get called, we'll return null
if (!canValidateCodeSystem(theValidationSupportContext, theCodeSystem)) {
return null;
}
CodeValidationResult result = new CodeValidationResult()
.setSeverity(myNonExistentCodeSystemSeverity); // will be warning or info
.setSeverity(myNonExistentCodeSystemSeverity); // will be warning or info (error/fatal filtered out above)
result.setMessage("No issues detected during validation");
@ -89,15 +92,22 @@ public class UnknownCodeSystemWarningValidationSupport extends BaseValidationSup
case ERROR:
case FATAL:
return false;
case WARNING:
case INFORMATION:
return true;
default:
ourLog.info("Unknown issue severity " + myNonExistentCodeSystemSeverity.name()
+ ". Treating as INFO/WARNING");
case WARNING:
case INFORMATION:
return true;
}
}
/**
* Determines if the code system can (and should) be validated.
* @param theValidationSupportContext
* @param theCodeSystem
* @return
*/
private boolean canValidateCodeSystem(ValidationSupportContext theValidationSupportContext,
String theCodeSystem) {
if (!allowNonExistentCodeSystems()) {