From 3775ae6e28a15e6633a9d31d2c2a975812e8c6ca Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Tue, 7 Jan 2025 14:46:31 -0500 Subject: [PATCH] MAT-8080: When retrieving Code System data from VSAC, ignore the HCPCS Level 1 OID. --- .../service/FhirTerminologyService.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java b/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java index 38dc946..8d8ceb6 100644 --- a/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java +++ b/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java @@ -371,13 +371,6 @@ private void recursiveRetrieveCodeSystems( .forEach( entry -> { var codeSystem = (org.hl7.fhir.r4.model.CodeSystem) entry.getResource(); - String codeSystemValue = ""; - for (Identifier identifier : codeSystem.getIdentifier()) { - if (identifier.getValue() != null && !identifier.getValue().isEmpty()) { - codeSystemValue = identifier.getValue(); - break; - } - } codeSystemsPage.add( CodeSystem.builder() .id(codeSystem.getTitle() + codeSystem.getVersion()) @@ -386,7 +379,7 @@ private void recursiveRetrieveCodeSystems( .name(codeSystem.getName()) .version(codeSystem.getVersion()) .versionId(codeSystem.getMeta().getVersionId()) - .oid(codeSystemValue) + .oid(parseOidFromIdentifier(codeSystem.getIdentifier())) .lastUpdated(Instant.now()) .lastUpdatedUpstream(codeSystem.getMeta().getLastUpdated()) .build()); @@ -408,6 +401,24 @@ private void recursiveRetrieveCodeSystems( }); } + private String parseOidFromIdentifier(List identifiers) { + for (Identifier identifier : identifiers) { + if (identifier.getValue() != null && !identifier.getValue().isEmpty()) { + // HCPCS contains two OIDs, which VSAC returns as comma delimited String. + // MADiE is only concerned with the Level 2 OID ending in .285 as it + // CMS's custom codes. Level 1 is a duplicate of CPT, and + // users should be utilizing CPT directly. + if (StringUtils.equalsIgnoreCase( + StringUtils.deleteWhitespace(identifier.getValue()), + "urn:oid:2.16.840.1.113883.6.14,2.16.840.1.113883.6.285")) { + return "2.16.840.1.113883.6.285"; + } + return identifier.getValue(); + } + } + return ""; + } + // one to call only, one to mutate and build private Bundle retrieveCodeSystemsPage(UmlsUser umlsUser, Integer offset, Integer count) { IParser parser = fhirContext.newJsonParser();