use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.
private DiscrepancyNotesBean fetchDiscrepancyNotes(StudySubject studySubj) {
List<DnStudySubjectMap> dnMaps = studySubj.getDnStudySubjectMaps();
DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
dnNotesBean.setEntityID(studySubj.getOcOid());
DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
DiscrepancyNoteBean dnSubjBean = new DiscrepancyNoteBean();
ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
boolean addDN = true;
for (DnStudySubjectMap dnMap : dnMaps) {
DiscrepancyNote dn = dnMap.getDiscrepancyNote();
addDN = true;
fillDNObject(dnNoteBean, dnNotes, addDN, dn, dnMap.getDnStudySubjectMapId().getColumnName());
}
dnNotesBean.setDiscrepancyNotes(dnNotes);
List<DnSubjectMap> dnSubjMaps = studySubj.getSubject().getDnSubjectMaps();
ArrayList<DiscrepancyNoteBean> dnSubjs = new ArrayList<DiscrepancyNoteBean>();
for (DnSubjectMap dnMap : dnSubjMaps) {
DiscrepancyNote dn = dnMap.getDiscrepancyNote();
addDN = true;
fillDNObject(dnSubjBean, dnSubjs, addDN, dn, dnMap.getDnSubjectMapId().getColumnName());
}
for (DiscrepancyNoteBean dnSubjMap : dnSubjs) dnNotesBean.getDiscrepancyNotes().add(dnSubjMap);
return dnNotesBean;
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.
private DiscrepancyNotesBean fetchDiscrepancyNotes(EventCrf eventCrf) {
LOGGER.info("Fetching the discrepancy notes..");
List<DnEventCrfMap> dnEventCrfMaps = eventCrf.getDnEventCrfMaps();
DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
dnNotesBean.setEntityID(eventCrf.getCrfVersion().getCrf().getOcOid());
DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
boolean addDN = true;
for (DnEventCrfMap dnItemDataMap : dnEventCrfMaps) {
DiscrepancyNote dn = dnItemDataMap.getDiscrepancyNote();
addDN = true;
fillDNObject(dnNoteBean, dnNotes, addDN, dn, dnItemDataMap.getDnEventCrfMapId().getColumnName());
}
dnNotesBean.setDiscrepancyNotes(dnNotes);
return dnNotesBean;
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class QueryServiceImpl method updateParentQuery.
private void updateParentQuery(QueryServiceHelperBean helperBean) {
if (helperBean.getDn().getParentDiscrepancyNote() == null)
return;
DiscrepancyNote itemParentNote = discrepancyNoteDao.findByDiscrepancyNoteId(helperBean.getDn().getParentDiscrepancyNote().getDiscrepancyNoteId());
itemParentNote.setResolutionStatus(helperBean.getResStatus());
discrepancyNoteDao.saveOrUpdate(itemParentNote);
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class QueryServiceImpl method createQuery.
private DiscrepancyNote createQuery(QueryServiceHelperBean helperBean, QueryBean queryBean) throws Exception {
DiscrepancyNote dn = new DiscrepancyNote();
dn.setStudy(helperBean.getContainer().getStudy());
dn.setEntityType("itemData");
dn.setDescription("description");
dn.setDetailedNotes(queryBean.getComment());
dn.setDiscrepancyNoteType(new DiscrepancyNoteType(3));
String user = queryBean.getUser();
if (user == null) {
dn.setUserAccountByOwnerId(helperBean.getContainer().getUser());
} else {
UserAccount userAccountByOwnerId = userAccountDao.findByUserName(user);
dn.setUserAccountByOwnerId(userAccountByOwnerId);
}
setResolutionStatus(queryBean, dn);
String assignedTo = "";
if (queryBean.getComment().startsWith("Automatic query for:")) {
assignedTo = helperBean.getContainer().getUser().getUserName();
} else {
assignedTo = queryBean.getAssigned_to();
}
if (!StringUtils.isEmpty(assignedTo)) {
UserAccount userAccount = userAccountDao.findByUserName(assignedTo);
helperBean.setUserAccount(userAccount);
dn.setUserAccount(userAccount);
}
// create itemData when a query is created without an autosaved itemdata
if (helperBean.getItemData() == null) {
helperBean.setItemData(createBlankItemData(helperBean));
}
dn.setDateCreated(new Date());
return dn;
}
use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.
the class QueryServiceImpl method process.
@Override
public void process(QueryServiceHelperBean helperBean, SubmissionContainer container, Node itemNode, int itemOrdinal) throws Exception {
String node = itemNode.getTextContent();
if (StringUtils.isEmpty(node))
return;
helperBean.setContainer(container);
helperBean.setItemOrdinal(itemOrdinal);
helperBean.setItemNode(itemNode);
ItemData id = getItemData(helperBean);
if (id == null) {
helperBean.setItemData(createBlankItemData(helperBean));
} else {
helperBean.setItemData(id);
}
QueriesBean queries = null;
try {
ObjectMapper objectMapper = new ObjectMapper();
queries = objectMapper.readValue(node, QueriesBean.class);
} catch (IOException e) {
logger.error(e.getMessage());
throw e;
}
List<Integer> idList = new ArrayList();
List<QueryBean> qBeans = queries.getQueries();
QueryBean queryBean = null;
DiscrepancyNote childDN = null;
DiscrepancyNote parentDN = null;
List<DiscrepancyNote> childDns = null;
if (qBeans.size() > 0) {
for (QueryBean qBean : qBeans) {
idList.add(Integer.valueOf(qBean.getId()));
}
Collections.reverse(idList);
queryBean = qBeans.get(0);
parentDN = findQueryParent(helperBean);
if (parentDN == null) {
parentDN = createQuery(helperBean, queryBean);
parentDN = discrepancyNoteDao.saveOrUpdate(parentDN);
helperBean.setDn(parentDN);
saveQueryItemDatamap(helperBean);
}
childDns = findChildQueries(helperBean);
if (childDns.size() < qBeans.size()) {
// Enketo passes JSON "id" attribute for unsubmitted queries only
// if (StringUtils.isEmpty(queryBean.getId())){
childDN = createQuery(helperBean, queryBean);
childDN.setParentDiscrepancyNote(parentDN);
childDN = discrepancyNoteDao.saveOrUpdate(childDN);
parentDN.setUserAccount(childDN.getUserAccount());
setResolutionStatus(queryBean, parentDN);
parentDN.setUserAccountByOwnerId(helperBean.getContainer().getUser());
parentDN.setDetailedNotes(childDN.getDetailedNotes());
parentDN.setDiscrepancyNoteType(childDN.getDiscrepancyNoteType());
parentDN = discrepancyNoteDao.saveOrUpdate(parentDN);
helperBean.setDn(childDN);
saveQueryItemDatamap(helperBean);
handleEmailNotification(helperBean, queryBean);
}
}
}
Aggregations