Smile 2775 package install logs ignore resource validation (#3381)

* Added log to the create() and valiForUpload() methods in the PackageInstallerSvcImpl class

* Added helper methods to extract URL from SearchParameter.Tested and fixed log entries.

* Changelog entry

* Update 3384-Package-Install-added-logs-for-resources-validation.yaml

Co-authored-by: Kai Liu <kliu@Kais-MacBook-Pro.local>
This commit is contained in:
kailiu-smile 2022-02-28 14:52:43 -05:00 committed by GitHub
parent bf04add6ef
commit 1bc6e0e3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View File

@ -115,6 +115,11 @@ public class SearchParameterUtil {
return getStringChild(theContext, theResource, "code");
}
@Nullable
public static String getURL(FhirContext theContext, IBaseResource theResource) {
return getStringChild(theContext, theResource, "url");
}
@Nullable
public static String getExpression(FhirContext theFhirContext, IBaseResource theResource) {
return getStringChild(theFhirContext, theResource, "expression");

View File

@ -0,0 +1,5 @@
---
type: add
issue: 3384
jira: SMILE-3517
title: "Added logs that identify the resource that failed the validation check during package installation, and describe the reason for the failure."

View File

@ -354,7 +354,9 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc {
theOutcome.incrementResourcesInstalled(myFhirContext.getResourceType(theResource));
}
}
}
else{
ourLog.warn("Failed to upload resource of type {} with ID {} - Error: Resource failed validation", theResource.fhirType(), theResource.getIdElement().getValue());
}
}
@ -398,22 +400,27 @@ public class PackageInstallerSvcImpl implements IPackageInstallerSvc {
String code = SearchParameterUtil.getCode(myFhirContext, theResource);
if (defaultString(code).startsWith("_")) {
ourLog.warn("Failed to validate resource of type {} with url {} - Error: Resource code starts with \"_\"", theResource.fhirType(), SearchParameterUtil.getURL(myFhirContext, theResource));
return false;
}
String expression = SearchParameterUtil.getExpression(myFhirContext, theResource);
if (isBlank(expression)) {
ourLog.warn("Failed to validate resource of type {} with url {} - Error: Resource expression is blank", theResource.fhirType(), SearchParameterUtil.getURL(myFhirContext, theResource));
return false;
}
if (SearchParameterUtil.getBaseAsStrings(myFhirContext, theResource).isEmpty()) {
ourLog.warn("Failed to validate resource of type {} with url {} - Error: Resource base is empty", theResource.fhirType(), SearchParameterUtil.getURL(myFhirContext, theResource));
return false;
}
}
List<IPrimitiveType> statusTypes = myFhirContext.newFhirPath().evaluate(theResource, "status", IPrimitiveType.class);
if (statusTypes.size() > 0) {
return statusTypes.get(0).getValueAsString().equals("active");
if (statusTypes.size() > 0 && !statusTypes.get(0).getValueAsString().equals("active")) {
ourLog.warn("Failed to validate resource of type {} with ID {} - Error: Resource status not equal to \"active\"", theResource.fhirType(), theResource.getIdElement().getValue());
return false;
}
return true;