-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
…assoctions
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cms.gov.madie.measure.config; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
|
||
import cms.gov.madie.measure.repositories.MeasureRepository; | ||
import gov.cms.madie.models.measure.Group; | ||
import gov.cms.madie.models.measure.Measure; | ||
import gov.cms.madie.models.measure.Stratification; | ||
import io.mongock.api.annotations.ChangeUnit; | ||
import io.mongock.api.annotations.Execution; | ||
import io.mongock.api.annotations.RollbackExecution; | ||
import lombok.Setter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@ChangeUnit(id = "update_stratification-assocation", order = "1", author = "madie_dev") | ||
@Slf4j | ||
public class UpdateStratificationAssociation { | ||
Check warning on line 19 in src/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java Codecov / codecov/patchsrc/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java#L18-L19
|
||
|
||
@Setter private List<Measure> tempMeasures; | ||
|
||
@Execution | ||
public void removeAssociationFromStratification(MeasureRepository measureRepository) { | ||
List<Measure> measures = measureRepository.findAllByModel("QDM v5.6"); | ||
if (CollectionUtils.isNotEmpty(measures)) { | ||
setTempMeasures(measures); | ||
measures.forEach( | ||
Check warning on line 28 in src/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java Codecov / codecov/patchsrc/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java#L27-L28
|
||
measure -> { | ||
if ("QDM v5.6".equals(measure.getModel())) { | ||
List<Group> groups = measure.getGroups(); | ||
if (CollectionUtils.isNotEmpty(groups)) { | ||
groups.forEach( | ||
group -> { | ||
List<Stratification> strats = group.getStratifications(); | ||
if (CollectionUtils.isNotEmpty((strats))) { | ||
strats.forEach( | ||
strat -> { | ||
log.info("Stratification...", strat); | ||
strat.setAssociation(null); | ||
}); | ||
Check warning on line 41 in src/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java Codecov / codecov/patchsrc/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java#L39-L41
|
||
} | ||
group.setStratifications(strats); | ||
}); | ||
measure.setGroups(groups); | ||
measureRepository.save(measure); | ||
Check warning on line 46 in src/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java Codecov / codecov/patchsrc/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java#L43-L46
|
||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
@RollbackExecution | ||
public void rollbackExecution(MeasureRepository measureRepository) { | ||
if (CollectionUtils.isNotEmpty(tempMeasures)) { | ||
tempMeasures.forEach( | ||
measure -> { | ||
measureRepository.save(measure); | ||
}); | ||
Check warning on line 59 in src/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java Codecov / codecov/patchsrc/main/java/cms/gov/madie/measure/config/UpdateStratificationAssociation.java#L58-L59
|
||
} | ||
} | ||
} |