use of org.akaza.openclinica.domain.datamap.ResolutionStatus in project OpenClinica by OpenClinica.
the class AbstractItemProcessor method closeItemDiscrepancyNotes.
protected void closeItemDiscrepancyNotes(SubmissionContainer container, ItemData itemData) {
ResourceBundleProvider.updateLocale(container.getLocale());
ResourceBundle resword = ResourceBundleProvider.getWordsBundle(container.getLocale());
// Notes & Discrepancies must be set to "closed" when event CRF is deleted
// parentDiscrepancyNoteList is the list of the parent DNs records only
List<DiscrepancyNote> parentDiscrepancyNoteList = discrepancyNoteDao.findParentNotesByItemData(itemData.getItemDataId());
for (DiscrepancyNote parentDiscrepancyNote : parentDiscrepancyNoteList) {
if (parentDiscrepancyNote.getResolutionStatus().getResolutionStatusId() != 4) {
// if the DN's resolution
// status is not set to
// Closed
String description = resword.getString("dn_auto-closed_description");
String detailedNotes = resword.getString("dn_auto_closed_item_detailed_notes");
// create new DN record , new DN Map record , also update the parent record
DiscrepancyNote dn = new DiscrepancyNote();
ResolutionStatus resStatus = resolutionStatusDao.findByResolutionStatusId(4);
dn.setStudy(container.getStudy());
dn.setEntityType("itemData");
dn.setDescription(description);
dn.setDetailedNotes(detailedNotes);
// set to parent DN Type Id
dn.setDiscrepancyNoteType(parentDiscrepancyNote.getDiscrepancyNoteType());
// set to closed
dn.setResolutionStatus(resStatus);
dn.setUserAccount(container.getUser());
dn.setUserAccountByOwnerId(container.getUser());
dn.setParentDiscrepancyNote(parentDiscrepancyNote);
dn.setDateCreated(new Date());
dn = discrepancyNoteDao.saveOrUpdate(dn);
// Create Mapping for new Discrepancy Note
DnItemDataMapId dnItemDataMapId = new DnItemDataMapId();
dnItemDataMapId.setDiscrepancyNoteId(dn.getDiscrepancyNoteId());
dnItemDataMapId.setItemDataId(itemData.getItemDataId());
dnItemDataMapId.setStudySubjectId(container.getSubject().getStudySubjectId());
dnItemDataMapId.setColumnName("value");
DnItemDataMap mapping = new DnItemDataMap();
mapping.setDnItemDataMapId(dnItemDataMapId);
mapping.setItemData(itemData);
mapping.setStudySubject(container.getSubject());
mapping.setActivated(false);
mapping.setDiscrepancyNote(dn);
dnItemDataMapDao.saveOrUpdate(mapping);
DiscrepancyNote itemParentNote = discrepancyNoteDao.findByDiscrepancyNoteId(dn.getParentDiscrepancyNote().getDiscrepancyNoteId());
itemParentNote.setResolutionStatus(resStatus);
itemParentNote.setUserAccount(container.getUser());
discrepancyNoteDao.saveOrUpdate(itemParentNote);
}
}
// Deactivate existing mappings for this ItemData
List<DnItemDataMap> existingMappings = dnItemDataMapDao.findByItemData(itemData.getItemDataId());
for (DnItemDataMap mapping : existingMappings) {
mapping.setActivated(false);
dnItemDataMapDao.saveOrUpdate(mapping);
}
}
Aggregations