Skip to content

Commit

Permalink
update bulk upload code and tests for chlamydia
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbywells52 committed Dec 16, 2024
1 parent f939996 commit 4025449
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,18 @@ private boolean isGonorrheaResult() {
equipmentModelName.getValue(), testPerformedCode.getValue()));
}

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

return resultsUploaderCachingService
.getChlamydiaEquipmentModelAndTestPerformedCodeSet()
.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 @@ -684,6 +696,14 @@ public List<FeedbackMessage> validateIndividualValues() {
List.of(gendersOfSexualPartners, pregnant, symptomaticForDisease)));
}

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

return errors;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public class CachingConfig {

public static final String GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET =
"gonorrheaEquipmentModelAndTestPerformedCodeSet";

public static final String CHLAMYDIA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET =
"chlamydiaEquipmentModelAndTestPerformedCodeSet";
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 @@ -36,6 +39,7 @@ public CacheManager cacheManager() {
GONORRHEA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
HIV_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
SYPHILIS_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
CHLAMYDIA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
DEVICE_MODEL_AND_TEST_PERFORMED_CODE_MAP,
SPECIMEN_NAME_TO_SNOMED_MAP,
SNOMED_TO_SPECIMEN_NAME_MAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class DiseaseService {
public static final String HIV_NAME = "HIV";
public static final String SYPHILIS_NAME = "Syphilis";
public static final String GONORRHEA_NAME = "Gonorrhea";
public static final String CHLAMYDIA_NAME = "Chlamydia";

private final DiseaseCacheService diseaseCacheService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.cdc.usds.simplereport.service;

import static gov.cdc.usds.simplereport.config.CachingConfig.ADDRESS_TIMEZONE_LOOKUP_MAP;
import static gov.cdc.usds.simplereport.config.CachingConfig.CHLAMYDIA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET;
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;
Expand Down Expand Up @@ -177,6 +178,12 @@ public Set<String> getGonorrheaEquipmentModelAndTestPerformedCodeSet() {
return getDiseaseSpecificEquipmentModelAndTestPerformedCodeSet(DiseaseService.GONORRHEA_NAME);
}

@Cacheable(CHLAMYDIA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET)
public Set<String> getChlamydiaEquipmentModelAndTestPerformedCodeSet() {
log.info("generating chlamydiaEquipmentModelAndTestPerformedCodeSet cache");
return getDiseaseSpecificEquipmentModelAndTestPerformedCodeSet(DiseaseService.CHLAMYDIA_NAME);
}

@Scheduled(fixedRate = 1, timeUnit = TimeUnit.HOURS)
@Caching(
evict = {
Expand Down Expand Up @@ -221,6 +228,18 @@ public void cacheGonorrheaEquipmentModelAndTestPerformedCodeSet() {
getGonorrheaEquipmentModelAndTestPerformedCodeSet();
}

@Scheduled(fixedRate = 1, timeUnit = TimeUnit.HOURS)
@Caching(
evict = {
@CacheEvict(
value = CHLAMYDIA_EQUIPMENT_MODEL_AND_TEST_PERFORMED_CODE_SET,
allEntries = true)
})
public void cacheChlamydiaEquipmentModelAndTestPerformedCodeSet() {
log.info("clear and generate chlamydiaEquipmentModelAndTestPerformedCodeSet cache");
getChlamydiaEquipmentModelAndTestPerformedCodeSet();
}

@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 @@ -558,6 +558,37 @@ void validatePositiveGonorrheaRequiredAoeFields() {
"This is required because the row contains a positive Gonorrhea test result."));
}

@Test
void validatePositiveChlamydiaRequiredAoeFields() {
Map<String, String> missingChlamydiaRequiredAoeFields =
getPositiveResultRowMap("Chlamydia Model", "14298-1");
missingChlamydiaRequiredAoeFields.put("pregnant", "");
missingChlamydiaRequiredAoeFields.put("genders_of_sexual_partners", "");
missingChlamydiaRequiredAoeFields.put("symptomatic_for_disease", "");

ResultsUploaderCachingService resultsUploaderCachingService =
mock(ResultsUploaderCachingService.class);
when(resultsUploaderCachingService.getModelAndTestPerformedCodeToDeviceMap())
.thenReturn(Map.of("chlamydia model|14298-1", TestDataBuilder.createDeviceType()));
when(resultsUploaderCachingService.getChlamydiaEquipmentModelAndTestPerformedCodeSet())
.thenReturn(Set.of("chlamydia model|14298-1"));

TestResultRow testResultRow =
new TestResultRow(
missingChlamydiaRequiredAoeFields,
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 Chlamydia test result."));
}

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

0 comments on commit 4025449

Please sign in to comment.