Skip to content
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

MAT-7859: Guard against unexpected Value Set Status values by mapping them to UNKNOWN #105

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import gov.cms.madie.terminology.service.MappingService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.r4.model.Identifier;
Expand Down Expand Up @@ -55,8 +56,7 @@ protected ValueSet setFhirMainAttributes(
fhirValueSet.setName(vsacDescribedValueSet.getDisplayName());
fhirValueSet.setTitle(vsacDescribedValueSet.getDisplayName());
fhirValueSet.setVersion(vsacDescribedValueSet.getVersion());
fhirValueSet.setStatus(
PublicationStatus.fromCode(vsacDescribedValueSet.getStatus().toLowerCase()));
fhirValueSet.setStatus(mapVsacValueSetStatusToFhir(vsacDescribedValueSet.getStatus()));
fhirValueSet.setDate(vsacDescribedValueSet.getRevisionDate().toGregorianCalendar().getTime());
fhirValueSet.setPublisher(vsacDescribedValueSet.getSource());
// ??
Expand All @@ -65,6 +65,14 @@ protected ValueSet setFhirMainAttributes(
return fhirValueSet;
}

private PublicationStatus mapVsacValueSetStatusToFhir(String vsacStatus) {
try {
return PublicationStatus.fromCode(vsacStatus.toLowerCase());
} catch (FHIRException | NullPointerException e) {
return PublicationStatus.UNKNOWN;
}
}

protected void addFhirValueSetComposeComponent(
List<Concept> vsacConceptList, ValueSet fhirValueSet) {
ValueSetComposeComponent fhirValueSetComposeComponent = new ValueSetComposeComponent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import org.hl7.fhir.r4.model.Enumerations;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent;
import org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent;
Expand Down Expand Up @@ -143,6 +144,14 @@ public void testSetFhirMainAttributes() {
assertEquals(vs.getDate(), today);
}

@Test
public void testMapMainAttributesUnknownStatus() {
ValueSet vs = new ValueSet();
describedValueSet.setStatus("Not Maintained");
vs = mapper.setFhirMainAttributes(vs, describedValueSet, TEST);
assertEquals(Enumerations.PublicationStatus.UNKNOWN.getDisplay(), vs.getStatus().getDisplay());
}

@Test
public void testGetVsacCodeMap() {

Expand Down
Loading