Skip to content

Commit

Permalink
Merge pull request #23 from nightingaleproject/22-add-race-helper-fun…
Browse files Browse the repository at this point in the history
…ctions-to-inputraceandethnicity-class

added race helper methods
  • Loading branch information
johnarleyburns authored Apr 26, 2023
2 parents 26961d7 + 60bf588 commit b3b0833
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
128 changes: 128 additions & 0 deletions src/main/java/edu/gatech/chai/VRDR/model/InputRaceAndEthnicity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
}
13 changes: 10 additions & 3 deletions src/test/java/edu/gatech/VRDR/MessagingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b3b0833

Please sign in to comment.