Skip to content

Commit

Permalink
Merge pull request #105 from MeasureAuthoringTool/feature/mat-7859-ad…
Browse files Browse the repository at this point in the history
…d-default-vs-status

MAT-7859: Guard against unexpected Value Set Status values by mapping them to UNKNOWN
  • Loading branch information
jkotanchik-SB authored Oct 29, 2024
2 parents 509c955 + a21d40e commit 24edc4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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

0 comments on commit 24edc4e

Please sign in to comment.