diff --git a/CHANGELOG.md b/CHANGELOG.md index 2225636..d688cb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog +### v1.4.3-STU2.1 - 2023-04-26 + +* Race Literal Helper Methods + ### v1.4.2-STU2.1 - 2023-04-25 * Race Literal AlaskanNative typo fix diff --git a/src/main/java/edu/gatech/chai/VRDR/model/InputRaceAndEthnicity.java b/src/main/java/edu/gatech/chai/VRDR/model/InputRaceAndEthnicity.java index 13b82c2..178764b 100644 --- a/src/main/java/edu/gatech/chai/VRDR/model/InputRaceAndEthnicity.java +++ b/src/main/java/edu/gatech/chai/VRDR/model/InputRaceAndEthnicity.java @@ -1,5 +1,6 @@ package edu.gatech.chai.VRDR.model; +import edu.gatech.chai.VRDR.model.util.CodedRaceAndEthnicityUtil; import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; @@ -98,4 +99,131 @@ public String getValueCodeableConceptCodeForCoding(CodeableConcept codeableConce codeableConcept.getCodingFirstRep()); } + public String getHispanicMexicanCodedValue() { + return getValueCodeableConceptCodeForCoding(CodedRaceAndEthnicityUtil.hispanicMexicanCodeComponentCode); + } + + public String getHispanicPuertoRicanCodedValue() { + return getValueCodeableConceptCodeForCoding(CodedRaceAndEthnicityUtil.hispanicPuertoRicanCodeComponentCode); + } + + public String getHispanicCubeanCodedValue() { + return getValueCodeableConceptCodeForCoding(CodedRaceAndEthnicityUtil.hispanicCubanCodeComponentCode); + } + + public String getHispanicOtherCodedValue() { + return getValueCodeableConceptCodeForCoding(CodedRaceAndEthnicityUtil.hispanicOtherCodeComponentCode); + } + + public String getHispanicLiteralValue() { + return getStringValueForCode("HispanicLiteral"); + } + + public boolean getWhiteBooleanValue() { + return getBooleanValueForCode("White"); + } + + public boolean getBlackOrAfricanAmericanBooleanValue() { + return getBooleanValueForCode("BlackOrAfricanAmerican"); + } + + public boolean getAmericanIndianOrAlaskaNativeBooleanValue() { + return getBooleanValueForCode("AmericanIndianOrAlaskanNative"); + } + + public boolean getAsianIndianBooleanValue() { + return getBooleanValueForCode("AsianIndian"); + } + + public boolean getChineseBooleanValue() { + return getBooleanValueForCode("Chinese"); + } + + public boolean getFilipinoBooleanValue() { + return getBooleanValueForCode("Filipino"); + } + + public boolean getJapaneseBooleanValue() { + return getBooleanValueForCode("Japanese"); + } + + public boolean getKoreanBooleanValue() { + return getBooleanValueForCode("Korean"); + } + + public boolean getVietnameseBooleanValue() { + return getBooleanValueForCode("Vietnamese"); + } + + public boolean getOtherAsianBooleanValue() { + return getBooleanValueForCode("OtherAsian"); + } + + public boolean getNativeHawaiianBooleanValue() { + return getBooleanValueForCode("NativeHawaiian"); + } + + public boolean getGuamanianOrChamorroBooleanValue() { + return getBooleanValueForCode("GuamanianOrChamorro"); + } + + public boolean getSamoanBooleanValue() { + return getBooleanValueForCode("Samoan"); + } + + public boolean getOtherPacificIslanderBooleanValue() { + return getBooleanValueForCode("OtherPacificIslander"); + } + + public boolean getOtherRaceBooleanValue() { + return getBooleanValueForCode("OtherRace"); + } + + public String getFirstAmericanIndianOrAlaskaNativeLiteralValue() { + return getStringValueForCode("FirstAmericanIndianOrAlaskanNativeLiteral"); + } + + public String getSecondAmericanIndianOrAlaskaNativeLiteralValue() { + return getStringValueForCode("SecondAmericanIndianOrAlaskanNativeLiteral"); + } + + public String getFirstOtherAsianLiteralValue() { + return getStringValueForCode("FirstOtherAsianLiteral"); + } + + public String getSecondOtherAsianLiteralValue() { + return getStringValueForCode("SecondOtherAsianLiteral"); + } + + public String getFirstOtherPacificIslanderLiteralValue() { + return getStringValueForCode("FirstOtherPacificIslanderLiteral"); + } + + public String getSecondOtherPacificIslanderLiteralValue() { + return getStringValueForCode("SecondOtherPacificIslanderLiteral"); + } + + public String getFirstOtherRaceLiteralValue() { + return getStringValueForCode("FirstOtherRaceLiteral"); + } + + public String getSecondOtherRaceLiteralValue() { + return getStringValueForCode("SecondOtherRaceLiteral"); + } + + public boolean getBooleanValueForCode(String codeName) { + return getComponent().stream().filter(x -> + x.getCode().getCodingFirstRep().getCode().equals(codeName)) + .findFirst() + .orElse(new Observation.ObservationComponentComponent().setValue(new BooleanType(false))) + .getValueBooleanType().booleanValue(); + } + + public String getStringValueForCode(String codeName) { + return getComponent().stream().filter(x -> + x.getCode().getCodingFirstRep().getCode().equals(codeName)) + .findFirst() + .orElse(new Observation.ObservationComponentComponent()) + .getValueStringType().getValue(); + } } diff --git a/src/test/java/edu/gatech/VRDR/MessagingTest.java b/src/test/java/edu/gatech/VRDR/MessagingTest.java index f9c5f40..91fd7e4 100644 --- a/src/test/java/edu/gatech/VRDR/MessagingTest.java +++ b/src/test/java/edu/gatech/VRDR/MessagingTest.java @@ -11,9 +11,7 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.OperationOutcome; -import org.hl7.fhir.r4.model.StringType; +import org.hl7.fhir.r4.model.*; import java.util.ArrayList; import java.util.Arrays; @@ -849,6 +847,15 @@ public void testCreateSubmissionWithRaceLiterals() { CommonUtil.setUUID(inputRaceAndEthnicity); deathRecord.addResource(inputRaceAndEthnicity); + // test that bundle literals are readable + InputRaceAndEthnicity race = deathRecord.getInputRaceAndEthnicity().get(0); + assertTrue(race.getAmericanIndianOrAlaskaNativeBooleanValue()); + assertEquals("Apache", race.getFirstAmericanIndianOrAlaskaNativeLiteralValue()); + assertEquals("Lipan Apache", race.getSecondAmericanIndianOrAlaskaNativeLiteralValue()); + assertEquals("Y", race.getHispanicOtherCodedValue()); + assertFalse(race.getSamoanBooleanValue()); // should be false because it is not set + assertNull(race.getFirstOtherRaceLiteralValue()); // should be null because it is not set + // create a new submission message and add the death record to it DeathRecordSubmissionMessage submission = new DeathRecordSubmissionMessage(); submission.setDeathRecord(deathRecord);