Skip to content

Commit

Permalink
Fix mismo configuration validation for existing Resources based on ol…
Browse files Browse the repository at this point in the history
…d MISMO versions
  • Loading branch information
HossamT committed Jan 15, 2025
1 parent adc53cf commit 6a40a7e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class SimpleDigestRunner implements DigestRunner {
public void digest(ConfigurationPayload configuration, String patient, String vaccines, DqDateFormat dateFormat, ADFWriter writer, Path output, Path temporaryDirectory) throws Exception {
logger.info("[REPORT] Initializing Local Report Engine");
logger.info("[PREPROCESS] Validating Configuration");
configurationPayloadValidator.validateConfigurationPayload(configuration);
configurationPayloadValidator.validateConfigurationPayload(configuration, true);
logger.info("[START] Processing Extract");
Path patientsFilePath = Paths.get(patient);
size = (int) Files.lines(patientsFilePath).parallel().count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public class ConfigurationPayloadValidator {
});
}

public void validateConfigurationPayload(ConfigurationPayload configurationPayload) throws InvalidConfigurationPayload {
public void validateConfigurationPayload(ConfigurationPayload configurationPayload, boolean validateMismoConfiguration) throws InvalidConfigurationPayload {
ArrayList<String> errors = new ArrayList<>();
errors.addAll(validateAgeGroups(configurationPayload.getAgeGroups(), true));
errors.addAll(validateDetections(configurationPayload.getDetections()));
errors.addAll(validateAsOfDate(configurationPayload.getAsOf()));
errors.addAll(validateVaxCodeAbstraction(configurationPayload.getVaxCodeAbstraction()));
errors.addAll(validateMismoPatientMatcherConfiguration(configurationPayload.getMismoPatientMatchingConfiguration()));
if(validateMismoConfiguration) {
errors.addAll(validateMismoPatientMatcherConfiguration(configurationPayload.getMismoPatientMatchingConfiguration()));
}
errors.addAll(validateComplexDetections(configurationPayload.getComplexDetections()));

if(!errors.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void check() throws Exception {
void checkADFs() throws Exception {
for(UserUploadedFile adf: adfMetaDataRepository.findAll()) {
try {
this.configurationService.validateConfigurationPayload(adf.getConfiguration());
this.configurationService.validateConfigurationPayload(adf.getConfiguration(), false);
} catch (InvalidConfigurationPayload invalidConfigurationPayload) {
throw new Exception("Invalid ADF (Configuration Payload) ID '" + adf.getId() +"' due to : " + invalidConfigurationPayload.getMessage());
}
Expand All @@ -45,7 +45,7 @@ void checkADFs() throws Exception {
void checkTemplates() throws Exception {
for(ReportTemplate template: templateRepository.findAll()) {
try {
this.configurationService.validateConfigurationPayload(template.getConfiguration());
this.configurationService.validateConfigurationPayload(template.getConfiguration(), false);
} catch (InvalidConfigurationPayload invalidConfigurationPayload) {
throw new Exception("Invalid Report Template (Configuration Payload) ID '" + template.getId() +"' due to : " + invalidConfigurationPayload.getMessage());
}
Expand All @@ -55,7 +55,7 @@ void checkTemplates() throws Exception {
void checkConfigurations() throws Exception {
for(DigestConfiguration configuration: configurationRepository.findAll()) {
try {
this.configurationService.validateConfigurationPayload(configuration.getPayload());
this.configurationService.validateConfigurationPayload(configuration.getPayload(), false);
} catch (InvalidConfigurationPayload invalidConfigurationPayload) {
throw new Exception("Invalid Digest Configuration ID '" + configuration.getId() +"' due to : " + invalidConfigurationPayload.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public OpAck<DigestConfiguration> create(
}
config.setLastUpdated(new Date());
try {
this.configService.validateConfigurationPayload(config.getPayload());
this.configService.validateConfigurationPayload(config.getPayload(), true);
this.configService.validateAgeGroups(config.getPayload().getAgeGroups(), false);
} catch (InvalidConfigurationPayload invalidConfigurationPayload) {
throw new OperationFailureException(invalidConfigurationPayload.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ UserUploadedFile create(String name, List<String> tags, String facility, String
if(!Strings.isNullOrEmpty(facility) && !facilityRepository.exists(facility)) {
throw new Exception("Facility Id '" + facility + "' does not exist");
}
this.configService.validateConfigurationPayload(file.getConfigurationPayload());
this.configService.validateConfigurationPayload(file.getConfigurationPayload(), false);
String uid = UUID.randomUUID().toString();
Path dir = Files.createDirectory(Paths.get(PATH+"/"+uid));
if (dir.toFile().exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public boolean compatible(ConfigurationPayload source, ConfigurationPayload targ
}

@Override
public void validateConfigurationPayload(ConfigurationPayload configurationPayload) throws InvalidConfigurationPayload {
this.configurationPayloadValidator.validateConfigurationPayload(configurationPayload);
public void validateConfigurationPayload(ConfigurationPayload configurationPayload, boolean validateMismoConfiguration) throws InvalidConfigurationPayload {
this.configurationPayloadValidator.validateConfigurationPayload(configurationPayload, validateMismoConfiguration);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface ConfigurationService {

boolean compatible(ConfigurationPayload source, ConfigurationPayload target);

void validateConfigurationPayload(ConfigurationPayload configurationPayload) throws InvalidConfigurationPayload;
void validateConfigurationPayload(ConfigurationPayload configurationPayload, boolean validateMismoConfiguration) throws InvalidConfigurationPayload;

void validateAgeGroups(List<Range> ageGroups, boolean allowEmptyGroupSameMinAndMax) throws InvalidConfigurationPayload;
}

0 comments on commit 6a40a7e

Please sign in to comment.