Skip to content

Commit

Permalink
Merge branch 'develop' into MAT-7223/updateLogicForCheckingExistingCq…
Browse files Browse the repository at this point in the history
…lMetaData
  • Loading branch information
sb-prateekkeerthi authored May 22, 2024
2 parents da11964 + 799c1da commit 9393c2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/main/java/gov/cms/madie/terminology/service/VsacService.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public List<CqlCode> validateCodes(List<CqlCode> cqlCodes, UmlsUser umlsUser, St
String codeSystemVersion = buildCodeSystemVersion(cqlCode, codeSystemEntry.get());
String codeId = cqlCode.getCodeId();
if (codeId == null || TerminologyServiceUtil.sanitizeInput(codeId).isBlank()) {
log.debug("Code id is not available for code {}", cqlCode.getName());
log.info("Code id is not available for code {}", cqlCode.getName());
cqlCode.setValid(false);
cqlCode.setErrorMessage("Code Id is required");
} else if (!StringUtils.isBlank(codeSystemVersion)) {
Expand All @@ -143,15 +143,15 @@ public List<CqlCode> validateCodes(List<CqlCode> cqlCodes, UmlsUser umlsUser, St
}
} else {
// unidentified code system.
log.debug(
"No associated Code system found in code system entry json for {}",
cqlCode.getCodeSystem().getOid());
log.info(
"No associated Code system found in code system entry json for {}",
cqlCode.getCodeSystem().getOid());
cqlCode.getCodeSystem().setValid(false);
cqlCode.getCodeSystem().setErrorMessage("Invalid Code system");
}
} else {
// if oid/url is not provided in cql, then the code system is considered invalid.
log.debug("CodeSystem {} does not contain any URL", cqlCode.getCodeSystem().getName());
log.info("CodeSystem {} does not contain any URL", cqlCode.getCodeSystem().getName());
cqlCode.getCodeSystem().setValid(false);
cqlCode.getCodeSystem().setErrorMessage("Code system URL is required");
}
Expand Down Expand Up @@ -219,6 +219,7 @@ public UmlsUser verifyUmlsAccess(String harpId) {
}

private VsacCode validateCodeAgainstVsac(String codePath, UmlsUser umlsUser) {
log.info("codedPath is {}", codePath);
return terminologyWebClient.getCode(codePath, umlsUser.getApiKey());
}

Expand All @@ -237,7 +238,7 @@ private String buildCodeSystemVersion(CqlCode cqlCode, CodeSystemEntry codeSyste
String cqlCodeSystemVersion =
TerminologyServiceUtil.sanitizeInput(cqlCode.getCodeSystem().getVersion());
if (CollectionUtils.isEmpty(codeSystemEntryVersion)) {
log.debug(
log.info(
"CodeSystem {} does not have any known versions", cqlCode.getCodeSystem().getOid());
return cqlCodeSystemVersion;
} else {
Expand Down Expand Up @@ -280,11 +281,13 @@ private void buildVsacErrorMessage(CqlCode cqlCode, VsacCode vsacCode) {
&& StringUtils.isNumeric(vsacCode.getErrors().getResultSet().get(0).getErrCode())) {
int errorCode = Integer.parseInt(vsacCode.getErrors().getResultSet().get(0).getErrCode());
if (errorCode == 800 || errorCode == 801) {
log.info("Error code is 800, or 801 from VSAC. Error: {}", vsacCode.getErrors().getResultSet().get(0));
cqlCode.getCodeSystem().setValid(false);
cqlCode
.getCodeSystem()
.setErrorMessage(vsacCode.getErrors().getResultSet().get(0).getErrDesc());
} else if (errorCode == 802) {
log.info("Error code is 802 from VSAC. Error: {}", vsacCode.getErrors().getResultSet().get(0));
cqlCode.setValid(false);
cqlCode.setErrorMessage(vsacCode.getErrors().getResultSet().get(0).getErrDesc());
}
Expand All @@ -296,6 +299,7 @@ private void buildVsacErrorMessage(CqlCode cqlCode, VsacCode vsacCode) {
+ "If this error persists, please contact the Help Desk.");
} else {
cqlCode.setValid(false);
log.info("Error code is uncaught. General catch, Error: {} status: {}", vsacCode.getErrors().getResultSet().get(0), vsacCode.getStatus());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public String getCodeSystemsPage(Integer offset, Integer count, String apiKey) {
public String searchValueSets(String apiKey, Map<String, String> queryParams) {
if (queryParams.containsKey("url")) {
String urlValue = queryParams.get("url");
// if the value does not contain the vsac url we add it
if (!urlValue.startsWith("http://cts.nlm.nih.gov/fhir/ValueSet/")) {
urlValue = "http://cts.nlm.nih.gov/fhir/ValueSet/" + urlValue;
}
// if user didnt add htpp:// we do
if (!urlValue.startsWith("http://")) {
urlValue = "http://" + urlValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected URI getValueSetURI(
*/
public VsacCode getCode(String codePath, String apiKey) {
URI codeUri = TerminologyServiceUtil.buildRetrieveCodeUri(baseUrl, codePath);
log.debug("Retrieving vsacCode for codePath {}", codePath);
log.info("Retrieving vsacCode for codePath {}", codePath);
return terminologyClient
.get()
.uri(codeUri)
Expand All @@ -85,7 +85,7 @@ public VsacCode getCode(String codePath, String apiKey) {
|| clientResponse.statusCode().equals(HttpStatus.OK)) {
return clientResponse.bodyToMono(VsacCode.class);
} else {
log.debug("Received NON-OK response while retrieving codePath {}", codePath);
log.info("Received NON-OK response while retrieving codePath {}", codePath);
return clientResponse.createException().flatMap(Mono::error);
}
})
Expand Down

0 comments on commit 9393c2a

Please sign in to comment.