Skip to content

Commit

Permalink
Add Gonorrhea Support For Bulk Upload (#8300)
Browse files Browse the repository at this point in the history
* scafolding for Gonorrhea Bulk Upload

* update disease service tests

* add test to Test Result Row Test

* update function call
  • Loading branch information
bobbywells52 authored Dec 2, 2024
1 parent 1dc9b1c commit 00c7e06
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,18 @@ private boolean isHepatitisCResult() {
equipmentModelName.getValue(), testPerformedCode.getValue()));
}

private boolean isGonorrheaResult() {
if (equipmentModelName.getValue() == null || testPerformedCode.getValue() == null) {
return false;
}

return resultsUploaderCachingService
.getGonorrheaEquipmentModelAndTestPerformedCodeSet()
.contains(
ResultsUploaderCachingService.getKey(
equipmentModelName.getValue(), testPerformedCode.getValue()));
}

private List<FeedbackMessage> generateInvalidDataErrorMessages() {
String errorMessage =
"Invalid " + EQUIPMENT_MODEL_NAME + " and " + TEST_PERFORMED_CODE + " combination";
Expand Down Expand Up @@ -664,6 +676,14 @@ public List<FeedbackMessage> validateIndividualValues() {
List.of(gendersOfSexualPartners, pregnant, symptomaticForDisease)));
}

if (isGonorrheaResult()) {
errors.addAll(
validateRequiredFieldsForPositiveResult(
testResult,
DiseaseService.GONORRHEA_NAME,
List.of(gendersOfSexualPartners, pregnant, symptomaticForDisease)));
}

return errors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class CachingConfig {
"covidEquipmentModelAndTestPerformedCodeSet";
public static final String HEPATITIS_C_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET =
"hepatitisCEquipmentModelAndTestPerformedCodeSet";

public static final String GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET =
"gonorrheaEquipmentModelAndTestPerformedCodeSet";
public static final String HIV_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET =
"hivEquipmentModelAndTestPerformedCodeSet";
public static final String SYPHILIS_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET =
Expand All @@ -30,6 +33,7 @@ public CacheManager cacheManager() {
return new ConcurrentMapCacheManager(
COVID_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
HEPATITIS_C_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
HIV_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
SYPHILIS_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
DEVICE_MODEL_AND_TEST_PERFORMED_CODE_MAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class DiseaseService {
public static final String RSV_NAME = "RSV";
public static final String HIV_NAME = "HIV";
public static final String SYPHILIS_NAME = "Syphilis";
public static final String GONORRHEA_NAME = "Gonorrhea";

private final DiseaseCacheService diseaseCacheService;

Expand Down Expand Up @@ -65,6 +66,10 @@ public SupportedDisease hepatitisC() {
return getDiseaseByName(HEPATITIS_C_NAME);
}

public SupportedDisease gonorrhea() {
return getDiseaseByName(GONORRHEA_NAME);
}

public SupportedDisease rsv() {
return getDiseaseByName(RSV_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static gov.cdc.usds.simplereport.config.CachingConfig.ADDRESS_TIMEZONE_LOOKUP_MAP;
import static gov.cdc.usds.simplereport.config.CachingConfig.COVID_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET;
import static gov.cdc.usds.simplereport.config.CachingConfig.DEVICE_MODEL_AND_TEST_PERFORMED_CODE_MAP;
import static gov.cdc.usds.simplereport.config.CachingConfig.GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET;
import static gov.cdc.usds.simplereport.config.CachingConfig.HEPATITIS_C_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET;
import static gov.cdc.usds.simplereport.config.CachingConfig.HIV_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET;
import static gov.cdc.usds.simplereport.config.CachingConfig.SNOMED_TO_SPECIMEN_NAME_MAP;
Expand Down Expand Up @@ -170,6 +171,12 @@ public Set<String> getHepatitisCEquipmentModelAndTestPerformedCodeSet() {
return getDiseaseSpecificEquipmentModelAndTestPerformedCodeSet(DiseaseService.HEPATITIS_C_NAME);
}

@Cacheable(GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET)
public Set<String> getGonorrheaEquipmentModelAndTestPerformedCodeSet() {
log.info("generating gonorrheaEquipmentModelAndTestPerformedCodeSet cache");
return getDiseaseSpecificEquipmentModelAndTestPerformedCodeSet(DiseaseService.GONORRHEA_NAME);
}

@Scheduled(fixedRate = 1, timeUnit = TimeUnit.HOURS)
@Caching(
evict = {
Expand Down Expand Up @@ -202,6 +209,18 @@ public void cacheHepatitisCEquipmentModelAndTestPerformedCodeSet() {
getHepatitisCEquipmentModelAndTestPerformedCodeSet();
}

@Scheduled(fixedRate = 1, timeUnit = TimeUnit.HOURS)
@Caching(
evict = {
@CacheEvict(
value = GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
allEntries = true)
})
public void cacheGonorrheaEquipmentModelAndTestPerformedCodeSet() {
log.info("clear and generate gonorrheaEquipmentModelAndTestPerformedCodeSet cache");
getGonorrheaEquipmentModelAndTestPerformedCodeSet();
}

@Cacheable(SNOMED_TO_SPECIMEN_NAME_MAP)
public Map<String, String> getSNOMEDToSpecimenTypeNameMap() {
log.info("generating SNOMEDToSpecimenTypeNameMap cache");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ void getHepatitisC_successful() {
assertEquals(DiseaseService.HEPATITIS_C_NAME, hepC.getName());
}

@Test
void getGonorrhea_successful() {
SupportedDisease gonorrhea = _service.gonorrhea();
assertNotNull(gonorrhea);
assertEquals(DiseaseService.GONORRHEA_NAME, gonorrhea.getName());
}

@Test
void getByName_successful() {
SupportedDisease covidByName = _service.getDiseaseByName(COVID19_NAME);
Expand All @@ -86,7 +93,8 @@ void getSupportedDiseasesMap_successful() {
.containsEntry(_service.fluB().getInternalId(), _service.fluB())
.containsEntry(_service.rsv().getInternalId(), _service.rsv())
.containsEntry(_service.hiv().getInternalId(), _service.hiv())
.containsEntry(_service.hepatitisC().getInternalId(), _service.hepatitisC());
.containsEntry(_service.hepatitisC().getInternalId(), _service.hepatitisC())
.containsEntry(_service.gonorrhea().getInternalId(), _service.gonorrhea());
}

@Test
Expand All @@ -101,6 +109,7 @@ void getSupportedDiseasesList_successful() {
.contains(_service.fluB())
.contains(_service.rsv())
.contains(_service.hiv())
.contains(_service.gonorrhea())
.contains(_service.hepatitisC());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,37 @@ void validatePositiveHepatitisCRequiredAoeFields() {
"This is required because the row contains a positive Hepatitis C test result."));
}

@Test
void validatePositiveGonorrheaRequiredAoeFields() {
Map<String, String> missingGonorrheaRequiredAoeFields =
getPositiveResultRowMap("Gonorrhea Model", "5028-6");
missingGonorrheaRequiredAoeFields.put("pregnant", "");
missingGonorrheaRequiredAoeFields.put("genders_of_sexual_partners", "");
missingGonorrheaRequiredAoeFields.put("symptomatic_for_disease", "");

ResultsUploaderCachingService resultsUploaderCachingService =
mock(ResultsUploaderCachingService.class);
when(resultsUploaderCachingService.getModelAndTestPerformedCodeToDeviceMap())
.thenReturn(Map.of("gonorrhea model|5028-6", TestDataBuilder.createDeviceType()));
when(resultsUploaderCachingService.getGonorrheaEquipmentModelAndTestPerformedCodeSet())
.thenReturn(Set.of("gonorrhea model|5028-6"));

TestResultRow testResultRow =
new TestResultRow(
missingGonorrheaRequiredAoeFields,
resultsUploaderCachingService,
mock(FeatureFlagsConfig.class));

List<FeedbackMessage> actual = testResultRow.validateIndividualValues();

assertThat(actual).hasSize(3);
actual.forEach(
message ->
assertThat(message.getMessage())
.contains(
"This is required because the row contains a positive Gonorrhea test result."));
}

@NotNull
private Map<String, String> getPositiveResultRowMap(
String deviceModelName, String testPerformedCode) {
Expand Down

0 comments on commit 00c7e06

Please sign in to comment.