use of org.akaza.openclinica.domain.datamap.DiscrepancyNote 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);
}
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.
private DiscrepancyNotesBean fetchDiscrepancyNotes(StudyEvent studyEvent) {
List<DnStudyEventMap> dnMaps = studyEvent.getDnStudyEventMaps();
DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
dnNotesBean.setEntityID(studyEvent.getStudyEventDefinition().getOc_oid());
DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
boolean addDN = true;
for (DnStudyEventMap dnMap : dnMaps) {
DiscrepancyNote dn = dnMap.getDiscrepancyNote();
addDN = true;
fillDNObject(dnNoteBean, dnNotes, addDN, dn, dnMap.getDnStudyEventMapId().getColumnName());
}
dnNotesBean.setDiscrepancyNotes(dnNotes);
return dnNotesBean;
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.
private DiscrepancyNotesBean fetchDiscrepancyNotes(ItemData itemData) {
List<DnItemDataMap> dnItemDataMaps = itemData.getDnItemDataMaps();
DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
dnNotesBean.setEntityID(itemData.getItem().getOcOid());
if (isCollectDns()) {
DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
boolean addDN = true;
for (DnItemDataMap dnItemDataMap : dnItemDataMaps) {
DiscrepancyNote dn = dnItemDataMap.getDiscrepancyNote();
addDN = true;
fillDNObject(dnNoteBean, dnNotes, addDN, dn, null);
}
dnNotesBean.setDiscrepancyNotes(dnNotes);
}
return dnNotesBean;
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method fillDNObject.
private void fillDNObject(DiscrepancyNoteBean dnNoteBean, ArrayList<DiscrepancyNoteBean> dnNotes, boolean addDN, DiscrepancyNote dn, String columnName) {
if (dn.getParentDiscrepancyNote() != null) {
} else {
dnNoteBean = new DiscrepancyNoteBean();
dnNoteBean.setStatus(dn.getResolutionStatus().getName());
dnNoteBean.setNoteType(dn.getEntityType());
dnNoteBean.setOid("DN_" + dn.getDiscrepancyNoteId());
dnNoteBean.setNoteType(dn.getDiscrepancyNoteType().getName());
dnNoteBean.setDateUpdated(dn.getDateCreated());
dnNoteBean.setEntityName(columnName);
for (DiscrepancyNote childDN : dn.getChildDiscrepancyNotes()) {
ChildNoteBean childNoteBean = new ChildNoteBean();
childNoteBean.setOid("CDN_" + childDN.getDiscrepancyNoteId());
ElementRefBean userRef = new ElementRefBean();
childNoteBean.setDescription(childDN.getDescription());
childNoteBean.setStatus(childDN.getResolutionStatus().getName());
childNoteBean.setDetailedNote(childDN.getDetailedNotes());
childNoteBean.setDateCreated(childDN.getDateCreated());
if (childDN.getUserAccountByOwnerId() != null) {
childNoteBean.setOwnerUserName(childDN.getUserAccountByOwnerId().getUserName());
childNoteBean.setOwnerFirstName(childDN.getUserAccountByOwnerId().getFirstName());
childNoteBean.setOwnerLastName(childDN.getUserAccountByOwnerId().getLastName());
}
if (childDN.getUserAccount() != null) {
userRef.setElementDefOID("USR_" + childDN.getUserAccount().getUserId());
userRef.setUserName(childDN.getUserAccount().getUserName());
userRef.setFullName(childDN.getUserAccount().getFirstName() + " " + childDN.getUserAccount().getLastName());
} else {
userRef.setElementDefOID("");
userRef.setUserName("");
userRef.setFullName("");
}
childNoteBean.setUserRef(userRef);
dnNoteBean.getChildNotes().add(childNoteBean);
}
dnNoteBean.setNumberOfChildNotes(dnNoteBean.getChildNotes().size());
if (!dnNotes.contains(dnNoteBean)) {
dnNotes.add(dnNoteBean);
}
}
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class DiscrepancyNoteDao method findParentQueryByItemData.
public DiscrepancyNote findParentQueryByItemData(Integer itemDataId) {
Query q = getCurrentSession().createQuery(findParentQueryByItemDataQuery);
q.setParameter("itemDataId", itemDataId);
return (DiscrepancyNote) q.uniqueResult();
}
Aggregations