Search in sources :

Example 1 with SubjectGroupDataBean

use of org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean in project OpenClinica by OpenClinica.

the class ClinicalDataReportBean method addNodeClinicalData.

public void addNodeClinicalData(boolean header, boolean footer) {
    String ODMVersion = this.getODMVersion();
    // when collecting data, only item with value has been collected.
    StringBuffer xml = this.getXmlOutput();
    String indent = this.getIndent();
    String nls = System.getProperty("line.separator");
    if (header) {
        xml.append(indent + "<ClinicalData StudyOID=\"" + StringEscapeUtils.escapeXml(clinicalData.getStudyOID()) + "\" MetaDataVersionOID=\"" + StringEscapeUtils.escapeXml(this.clinicalData.getMetaDataVersionOID()) + "\">");
        xml.append(nls);
    }
    ArrayList<ExportSubjectDataBean> subs = (ArrayList<ExportSubjectDataBean>) this.clinicalData.getExportSubjectData();
    for (ExportSubjectDataBean sub : subs) {
        xml.append(indent + indent + "<SubjectData SubjectKey=\"" + StringEscapeUtils.escapeXml(sub.getSubjectOID()));
        if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
            xml.append("\" OpenClinica:StudySubjectID=\"" + StringEscapeUtils.escapeXml(sub.getStudySubjectId()));
            String uniqueIdentifier = sub.getUniqueIdentifier();
            if (uniqueIdentifier != null && uniqueIdentifier.length() > 0) {
                xml.append("\" OpenClinica:UniqueIdentifier=\"" + StringEscapeUtils.escapeXml(uniqueIdentifier));
            }
            String status = sub.getStatus();
            if (status != null && status.length() > 0) {
                xml.append("\" OpenClinica:Status=\"" + StringEscapeUtils.escapeXml(status));
            }
            String secondaryId = sub.getSecondaryId();
            if (secondaryId != null && secondaryId.length() > 0) {
                xml.append("\"  OpenClinica:SecondaryID=\"" + StringEscapeUtils.escapeXml(secondaryId));
            }
            Integer year = sub.getYearOfBirth();
            if (year != null) {
                xml.append("\" OpenClinica:YearOfBirth=\"" + sub.getYearOfBirth());
            } else {
                if (sub.getDateOfBirth() != null) {
                    xml.append("\" OpenClinica:DateOfBirth=\"" + sub.getDateOfBirth());
                }
            }
            String gender = sub.getSubjectGender();
            if (gender != null && gender.length() > 0) {
                xml.append("\" OpenClinica:Sex=\"" + StringEscapeUtils.escapeXml(gender));
            }
            String enrollmentDate = sub.getEnrollmentDate();
            if (enrollmentDate != null && enrollmentDate.length() > 0) {
                xml.append("\" OpenClinica:EnrollmentDate=\"" + enrollmentDate);
            }
        }
        xml.append("\">");
        xml.append(nls);
        //
        ArrayList<ExportStudyEventDataBean> ses = (ArrayList<ExportStudyEventDataBean>) sub.getExportStudyEventData();
        for (ExportStudyEventDataBean se : ses) {
            xml.append(indent + indent + indent + "<StudyEventData StudyEventOID=\"" + StringEscapeUtils.escapeXml(se.getStudyEventOID()));
            if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
                String location = se.getLocation();
                if (location != null && location.length() > 0) {
                    xml.append("\" OpenClinica:StudyEventLocation=\"" + StringEscapeUtils.escapeXml(location));
                }
                String startDate = se.getStartDate();
                if (startDate != null && startDate.length() > 0) {
                    xml.append("\" OpenClinica:StartDate=\"" + startDate);
                }
                String endDate = se.getEndDate();
                if (endDate != null && endDate.length() > 0) {
                    xml.append("\" OpenClinica:EndDate=\"" + endDate);
                }
                String status = se.getStatus();
                if (status != null && status.length() > 0) {
                    xml.append("\" OpenClinica:Status=\"" + StringEscapeUtils.escapeXml(status));
                }
                if (se.getAgeAtEvent() != null) {
                    xml.append("\" OpenClinica:SubjectAgeAtEvent=\"" + se.getAgeAtEvent());
                }
            }
            xml.append("\"");
            if (!"-1".equals(se.getStudyEventRepeatKey())) {
                xml.append(" StudyEventRepeatKey=\"" + se.getStudyEventRepeatKey() + "\"");
            }
            xml.append(">");
            xml.append(nls);
            //
            ArrayList<ExportFormDataBean> forms = se.getExportFormData();
            for (ExportFormDataBean form : forms) {
                xml.append(indent + indent + indent + indent + "<FormData FormOID=\"" + StringEscapeUtils.escapeXml(form.getFormOID()));
                if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
                    String formLayout = form.getFormLayout();
                    if (!StringUtils.isEmpty(formLayout)) {
                        xml.append("\" OpenClinica:FormLayoutOID=\"" + StringEscapeUtils.escapeXml(formLayout));
                    }
                    String interviewerName = form.getInterviewerName();
                    if (interviewerName != null && interviewerName.length() > 0) {
                        xml.append("\" OpenClinica:InterviewerName=\"" + StringEscapeUtils.escapeXml(interviewerName));
                    }
                    if (form.getInterviewDate() != null && form.getInterviewDate().length() > 0) {
                        xml.append("\" OpenClinica:InterviewDate=\"" + form.getInterviewDate());
                    }
                    String status = form.getStatus();
                    if (status != null && status.length() > 0) {
                        xml.append("\" OpenClinica:Status=\"" + StringEscapeUtils.escapeXml(status));
                    }
                }
                xml.append("\">");
                xml.append(nls);
                //
                ArrayList<ImportItemGroupDataBean> igs = form.getItemGroupData();
                sortImportItemGroupDataBeanList(igs);
                for (ImportItemGroupDataBean ig : igs) {
                    xml.append(indent + indent + indent + indent + indent + "<ItemGroupData ItemGroupOID=\"" + StringEscapeUtils.escapeXml(ig.getItemGroupOID()) + "\" ");
                    if (!"-1".equals(ig.getItemGroupRepeatKey())) {
                        xml.append("ItemGroupRepeatKey=\"" + ig.getItemGroupRepeatKey() + "\" ");
                    }
                    if (ig.getItemData().get(0).isDeleted()) {
                        xml.append("OpenClinica:Removed=\"" + (ig.getItemData().get(0).isDeleted() ? "Yes" : "No") + "\" ");
                    }
                    xml.append("TransactionType=\"Insert\">");
                    xml.append(nls);
                    ArrayList<ImportItemDataBean> items = ig.getItemData();
                    sortImportItemDataBeanList(items);
                    for (ImportItemDataBean item : items) {
                        boolean printValue = true;
                        xml.append(indent + indent + indent + indent + indent + indent + "<ItemData ItemOID=\"" + StringEscapeUtils.escapeXml(item.getItemOID()) + "\" ");
                        if ("Yes".equals(item.getIsNull())) {
                            xml.append("IsNull=\"Yes\"");
                            if (!item.isHasValueWithNull()) {
                                printValue = false;
                            }
                            if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
                                xml.append(" OpenClinica:ReasonForNull=\"" + StringEscapeUtils.escapeXml(item.getReasonForNull()) + "\" ");
                                if (!printValue) {
                                    xml.append("/>");
                                    xml.append(nls);
                                }
                            }
                        }
                        if (printValue) {
                            Boolean hasElm = false;
                            xml.append("Value=\"" + StringEscapeUtils.escapeXml(item.getValue()) + "\"");
                            String muRefOid = item.getMeasurementUnitRef().getElementDefOID();
                            if (muRefOid != null && muRefOid.length() > 0) {
                                if (hasElm) {
                                } else {
                                    xml.append(">");
                                    xml.append(nls);
                                    hasElm = true;
                                }
                                xml.append(indent + indent + indent + indent + indent + indent + indent + "<MeasurementUnitRef MeasurementUnitOID=\"" + StringEscapeUtils.escapeXml(muRefOid) + "\"/>");
                                xml.append(nls);
                            }
                            if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
                                if (item.getAuditLogs() != null && item.getAuditLogs().getAuditLogs().size() > 0) {
                                    if (hasElm) {
                                    } else {
                                        xml.append(">");
                                        xml.append(nls);
                                        hasElm = true;
                                    }
                                    this.addAuditLogs(item.getAuditLogs(), indent + indent + indent + indent + indent + indent + indent, "item");
                                }
                                //
                                if (item.getDiscrepancyNotes() != null && item.getDiscrepancyNotes().getDiscrepancyNotes().size() > 0) {
                                    if (hasElm) {
                                    } else {
                                        xml.append(">");
                                        xml.append(nls);
                                        hasElm = true;
                                    }
                                    this.addDiscrepancyNotes(item.getDiscrepancyNotes(), indent + indent + indent + indent + indent + indent + indent);
                                }
                            }
                            if (hasElm) {
                                xml.append(indent + indent + indent + indent + indent + indent + "</ItemData>");
                                xml.append(nls);
                                hasElm = false;
                            } else {
                                xml.append("/>");
                                xml.append(nls);
                            }
                        }
                    }
                    xml.append(indent + indent + indent + indent + indent + "</ItemGroupData>");
                    xml.append(nls);
                }
                //
                if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
                    if (form.getAuditLogs() != null && form.getAuditLogs().getAuditLogs().size() > 0) {
                        this.addAuditLogs(form.getAuditLogs(), indent + indent + indent + indent + indent, "form");
                    }
                    //
                    if (form.getDiscrepancyNotes() != null && form.getDiscrepancyNotes().getDiscrepancyNotes().size() > 0) {
                        this.addDiscrepancyNotes(form.getDiscrepancyNotes(), indent + indent + indent + indent + indent);
                    }
                }
                xml.append(indent + indent + indent + indent + "</FormData>");
                xml.append(nls);
            }
            //
            if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
                if (se.getAuditLogs() != null && se.getAuditLogs().getAuditLogs().size() > 0) {
                    this.addAuditLogs(se.getAuditLogs(), indent + indent + indent + indent, "se");
                }
                //
                if (se.getDiscrepancyNotes() != null && se.getDiscrepancyNotes().getDiscrepancyNotes().size() > 0) {
                    this.addDiscrepancyNotes(se.getDiscrepancyNotes(), indent + indent + indent + indent);
                }
            }
            xml.append(indent + indent + indent + "</StudyEventData>");
            xml.append(nls);
        }
        if ("oc1.2".equalsIgnoreCase(ODMVersion) || "oc1.3".equalsIgnoreCase(ODMVersion)) {
            ArrayList<SubjectGroupDataBean> sgddata = (ArrayList<SubjectGroupDataBean>) sub.getSubjectGroupData();
            if (sgddata.size() > 0) {
                for (SubjectGroupDataBean sgd : sgddata) {
                    String cid = sgd.getStudyGroupClassId() != null ? "OpenClinica:StudyGroupClassID=\"" + StringEscapeUtils.escapeXml(sgd.getStudyGroupClassId()) + "\" " : "";
                    if (cid.length() > 0) {
                        String cn = sgd.getStudyGroupClassName() != null ? "OpenClinica:StudyGroupClassName=\"" + StringEscapeUtils.escapeXml(sgd.getStudyGroupClassName()) + "\" " : "";
                        String gn = sgd.getStudyGroupName() != null ? "OpenClinica:StudyGroupName=\"" + StringEscapeUtils.escapeXml(sgd.getStudyGroupName()) + "\" " : "";
                        xml.append(indent + indent + indent + "<OpenClinica:SubjectGroupData " + cid + cn + gn);
                    }
                    xml.append(" />");
                    xml.append(nls);
                }
            }
            //
            if (sub.getAuditLogs() != null && sub.getAuditLogs().getAuditLogs().size() > 0) {
                this.addAuditLogs(sub.getAuditLogs(), indent + indent + indent, "sub");
            }
            //
            if (sub.getDiscrepancyNotes() != null && sub.getDiscrepancyNotes().getDiscrepancyNotes().size() > 0) {
                this.addDiscrepancyNotes(sub.getDiscrepancyNotes(), indent + indent + indent);
            }
        }
        xml.append(indent + indent + "</SubjectData>");
        xml.append(nls);
    }
    if (footer) {
        xml.append(indent + "</ClinicalData>");
        xml.append(nls);
    }
}
Also used : ExportFormDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean) ImportItemGroupDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemGroupDataBean) ArrayList(java.util.ArrayList) ImportItemDataBean(org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean) ExportStudyEventDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean) SubjectGroupDataBean(org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean) ExportSubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean)

Example 2 with SubjectGroupDataBean

use of org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method setExportSubjectDataBean.

@SuppressWarnings("unchecked")
private ExportSubjectDataBean setExportSubjectDataBean(StudySubject studySubj, Study study, List<StudyEvent> studyEvents, String formVersionOID) {
    ExportSubjectDataBean exportSubjectDataBean = new ExportSubjectDataBean();
    if (subjectBelongsToStudy(study, studySubj)) {
        // exportSubjectDataBean.setAuditLogs(studySubj.getA)
        if (studySubj.getSubject().getDateOfBirth() != null)
            exportSubjectDataBean.setDateOfBirth(studySubj.getSubject().getDateOfBirth() + "");
        exportSubjectDataBean.setSubjectGender(studySubj.getSubject().getGender() + "");
        for (SubjectGroupMap subjGrpMap : studySubj.getSubjectGroupMaps()) {
            SubjectGroupDataBean subjGrpDataBean = new SubjectGroupDataBean();
            subjGrpDataBean.setStudyGroupClassId("SGC_" + subjGrpMap.getStudyGroupClass().getStudyGroupClassId());
            subjGrpDataBean.setStudyGroupClassName(subjGrpMap.getStudyGroup().getStudyGroupClass().getName());
            subjGrpDataBean.setStudyGroupName(subjGrpMap.getStudyGroup().getName());
            exportSubjectDataBean.getSubjectGroupData().add(subjGrpDataBean);
        }
        exportSubjectDataBean.setStudySubjectId(studySubj.getLabel());
        if (studySubj.getSubject().getUniqueIdentifier() != null)
            exportSubjectDataBean.setUniqueIdentifier(studySubj.getSubject().getUniqueIdentifier());
        exportSubjectDataBean.setSecondaryId(studySubj.getSecondaryLabel());
        exportSubjectDataBean.setStatus(studySubj.getStatus().toString());
        if (isCollectAudits())
            exportSubjectDataBean.setAuditLogs(fetchAuditLogs(studySubj.getStudySubjectId(), "study_subject", studySubj.getOcOid(), null));
        AuditLogsBean subjectGroupMapLogs = fetchAuditLogs(studySubj.getStudySubjectId(), "subject_group_map", studySubj.getOcOid(), null);
        AuditLogsBean subjectLogs = fetchAuditLogs(studySubj.getSubject().getSubjectId(), "subject", studySubj.getOcOid(), null);
        exportSubjectDataBean.getAuditLogs().getAuditLogs().addAll(subjectGroupMapLogs.getAuditLogs());
        exportSubjectDataBean.getAuditLogs().getAuditLogs().addAll(subjectLogs.getAuditLogs());
        Collections.sort(exportSubjectDataBean.getAuditLogs().getAuditLogs());
        if (isCollectDns())
            exportSubjectDataBean.setDiscrepancyNotes(fetchDiscrepancyNotes(studySubj));
        exportSubjectDataBean.setExportStudyEventData(setExportStudyEventDataBean(studySubj, studyEvents, formVersionOID));
        exportSubjectDataBean.setSubjectOID(studySubj.getOcOid());
        exportSubjectDataBean.setEnrollmentDate(studySubj.getEnrollmentDate() + "");
    }
    return exportSubjectDataBean;
}
Also used : SubjectGroupDataBean(org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean) SubjectGroupMap(org.akaza.openclinica.domain.datamap.SubjectGroupMap) AuditLogsBean(org.akaza.openclinica.bean.odmbeans.AuditLogsBean) ExportSubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean)

Example 3 with SubjectGroupDataBean

use of org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setDataWithOCAttributes.

protected void setDataWithOCAttributes(StudyBean study, DatasetBean dataset, OdmClinicalDataBean data, String odmVersion, Iterator iter, HashMap<Integer, String> oidPoses, String odmType) {
    String subprev = "";
    HashMap<String, Integer> sepos = new HashMap<String, Integer>();
    String seprev = "";
    String formprev = "";
    HashMap<String, Integer> igpos = new HashMap<String, Integer>();
    String igprev = "";
    String oidPos = "";
    StudyBean parentStudy = study.getParentStudyId() > 0 ? (StudyBean) new StudyDAO(this.ds).findByPK(study.getParentStudyId()) : study;
    setStudyParemeterConfig(parentStudy);
    HashSet<Integer> sgcIdSet = new HashSet<Integer>();
    HashMap<String, String> subOidPoses = new HashMap<String, String>();
    HashMap<String, String> evnOidPoses = new HashMap<String, String>();
    String studySubjectOids = "";
    String sedOids = "";
    String ecIds = "";
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        String studySubjectLabel = (String) row.get("study_subject_oid");
        // String label = (String) row.get("label");
        Integer sgcId = (Integer) row.get("sgc_id");
        String sgcName = (String) row.get("sgc_name");
        String sgName = (String) row.get("sg_name");
        String sedOID = (String) row.get("definition_oid");
        Boolean studyEventRepeating = (Boolean) row.get("definition_repeating");
        Integer sampleOrdinal = (Integer) row.get("sample_ordinal");
        Date startDate = (Date) row.get("date_start");
        String cvOID = (String) row.get("crf_version_oid");
        // ecId should
        Integer ecId = (Integer) row.get("event_crf_id");
        // be unique;
        Date dob = (Date) row.get("date_of_birth");
        CRFVersionBean cvBean = cvdao.findByOid(cvOID);
        CRFBean cBean = (CRFBean) crfdao.findByPK(cvBean.getCrfId());
        String key = studySubjectLabel;
        ExportSubjectDataBean sub = new ExportSubjectDataBean();
        if (subprev.equals(studySubjectLabel)) {
            int p = data.getExportSubjectData().size() - 1;
            sub = data.getExportSubjectData().get(p);
            // ------ add openclinica subject_group
            if (sgcId > 0) {
                int presize = sgcIdSet.size();
                sgcIdSet.add(sgcId);
                if (sgcIdSet.size() > presize) {
                    sgcIdSet.add(sgcId);
                    SubjectGroupDataBean sgd = new SubjectGroupDataBean();
                    sgd.setStudyGroupClassId("SGC_" + sgcId);
                    sgd.setStudyGroupClassName(sgcName);
                    sgd.setStudyGroupName(sgName);
                    sub.getSubjectGroupData().add(sgd);
                }
            }
        // ------ finish adding openclinica subject_group
        } else {
            subprev = studySubjectLabel;
            studySubjectOids += "'" + studySubjectLabel + "', ";
            sub.setSubjectOID(studySubjectLabel);
            // ----- add openclinica subject attributes
            sub.setStudySubjectId((String) row.get("label"));
            if (dataset.isShowSubjectUniqueIdentifier()) {
                sub.setUniqueIdentifier((String) row.get("unique_identifier"));
            }
            if (dataset.isShowSubjectSecondaryId()) {
                sub.setSecondaryId((String) row.get("secondary_label"));
            }
            if (dob != null) {
                if (dataset.isShowSubjectDob()) {
                    if (parentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
                        Calendar cal = Calendar.getInstance();
                        cal.setTime(dob);
                        int year = cal.get(Calendar.YEAR);
                        if (year > 0) {
                            sub.setYearOfBirth(year);
                        }
                    } else {
                        sub.setDateOfBirth(new SimpleDateFormat("yyyy-MM-dd").format(dob));
                    }
                }
            }
            if (dataset.isShowSubjectGender()) {
                sub.setSubjectGender((String) row.get("gender"));
            }
            if (dataset.isShowSubjectStatus()) {
                sub.setStatus(Status.get((Integer) row.get("status_id")).getName());
            }
            // ------ add openclinica subject_group
            if (sgcId > 0) {
                sgcIdSet.clear();
                sgcIdSet.add(sgcId);
                SubjectGroupDataBean sgd = new SubjectGroupDataBean();
                sgd.setStudyGroupClassId("SGC_" + sgcId);
                sgd.setStudyGroupClassName(sgcName);
                sgd.setStudyGroupName(sgName);
                sub.getSubjectGroupData().add(sgd);
            }
            // ------ finish adding openclinica subject_group
            data.getExportSubjectData().add(sub);
            seprev = "";
            formprev = "";
            igprev = "";
        }
        oidPos = data.getExportSubjectData().size() - 1 + "";
        subOidPoses.put(studySubjectLabel, oidPos);
        ExportStudyEventDataBean se = new ExportStudyEventDataBean();
        // key += sedOID + sampleOrdinal;
        key += sedOID;
        if (!seprev.equals(key) || !sepos.containsKey(key + sampleOrdinal)) {
            sepos.put(key + sampleOrdinal, sub.getExportStudyEventData().size());
            seprev = key;
            sedOids += "'" + sedOID + "', ";
            se.setStudyEventOID(sedOID);
            // ----- add openclinica study event attributes
            if (startDate != null && dataset.isShowSubjectAgeAtEvent() && dob != null) {
                se.setAgeAtEvent(Utils.getAge(dob, startDate));
            }
            if (dataset.isShowEventLocation()) {
                se.setLocation((String) row.get("se_location"));
            }
            if (dataset.isShowEventStart() && startDate != null) {
                if ((Boolean) row.get("start_time_flag") == Boolean.TRUE) {
                    se.setStartDate(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(startDate));
                } else {
                    se.setStartDate(new SimpleDateFormat("yyyy-MM-dd").format(startDate));
                }
            }
            Date endDate = (Date) row.get("date_end");
            if (dataset.isShowEventEnd() && endDate != null) {
                if ((Boolean) row.get("end_time_flag") == Boolean.TRUE) {
                    se.setEndDate(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(endDate));
                } else {
                    se.setEndDate(new SimpleDateFormat("yyyy-MM-dd").format(endDate));
                }
            }
            if (dataset.isShowEventStatus()) {
                se.setStatus(SubjectEventStatus.get((Integer) row.get("event_status_id")).getName());
            }
            // ----- finish adding study event attributes
            se.setStudyEventRepeatKey(studyEventRepeating ? sampleOrdinal + "" : "-1");
            sub.getExportStudyEventData().add(se);
            formprev = "";
            igprev = "";
        } else {
            se = sub.getExportStudyEventData().get(sepos.get(key + sampleOrdinal));
        }
        oidPos += "---" + (sub.getExportStudyEventData().size() - 1);
        evnOidPoses.put(key, oidPos);
        ExportFormDataBean form = new ExportFormDataBean();
        key += cvOID;
        if (formprev.equals(key)) {
            form = se.getExportFormData().get(se.getExportFormData().size() - 1);
        } else {
            formprev = key;
            ecIds += "'" + ecId + "', ";
            form.setFormOID(cBean.getOid());
            // ----- add openclinica crf attributes
            if (dataset.isShowCRFversion()) {
                form.setCrfVersion((String) row.get("crf_version"));
            }
            if (dataset.isShowCRFstatus()) {
                form.setStatus(this.getCrfVersionStatus(se.getStatus(), (Integer) row.get("cv_status_id"), (Integer) row.get("ec_status_id"), (Integer) row.get("validator_id")));
            }
            if (dataset.isShowCRFinterviewerName()) {
                form.setInterviewerName((String) row.get("interviewer_name"));
            }
            if (dataset.isShowCRFinterviewerDate()) {
                try {
                    form.setInterviewDate(new SimpleDateFormat("yyyy-MM-dd").format((Date) row.get("date_interviewed")));
                } catch (NullPointerException npe) {
                    logger.debug("caught NPE for interviewDate");
                // Comment it out for: 11592. For this exaction function, interviewDate should be kept as the
                // same as in database.
                // form.setInterviewDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
                }
            }
            // ----- finish adding crf attributes
            se.getExportFormData().add(form);
            igprev = "";
        }
        oidPos += "---" + (se.getExportFormData().size() - 1);
        // ecId should be distinct
        oidPoses.put(ecId, oidPos);
        oidPos = "";
    }
    studySubjectOids = studySubjectOids.length() > 0 ? studySubjectOids.substring(0, studySubjectOids.length() - 2).trim() : studySubjectOids;
    sedOids = sedOids.length() > 0 ? sedOids.substring(0, sedOids.length() - 2).trim() : sedOids;
    ecIds = ecIds.length() > 0 ? ecIds.substring(0, ecIds.length() - 2).trim() : ecIds;
    if (odmType != null && odmType.equalsIgnoreCase("clinical_data")) {
        logger.debug("No Audit logs or discrepancy Notes");
    } else {
        if (studySubjectOids.length() > 0) {
            this.setOCSubjectDataAuditLogs(parentStudy, data, studySubjectOids, subOidPoses);
            this.setOCEventDataAuditLogs(parentStudy, data, studySubjectOids, evnOidPoses);
            if (ecIds.length() > 0) {
                this.setOCFormDataAuditLogs(parentStudy, data, studySubjectOids, ecIds, oidPoses);
            } else {
                logger.debug("OdmExtractDAO.setOCFormDataAuditLogs wasn't called because of empty ecIds");
            }
            this.setOCSubjectDataDNs(data, studySubjectOids, subOidPoses);
            if (sedOids.length() > 0) {
                this.setOCEventDataDNs(data, sedOids, studySubjectOids, evnOidPoses);
            } else {
                logger.info("OdmExtractDAO.setOCEventDataDNs wasn't called because of empty sedOids");
            }
        } else {
            logger.debug("OdmExtractDAO methods(setOCSubjectDataAuditLogs,setOCEventDataAuditLogs,setOCFormDataAuditLogs," + "setOCSubjectDataDNs,setOCEventDataDNs) weren't called because of empty studySubjectOids");
        }
        if (ecIds.length() > 0) {
            this.setOCFormDataDNs(data, ecIds, oidPoses);
        } else {
            logger.debug("OdmExtractDAO.setOCFormDataDNs wasn't called because of empty ecIds");
        }
    }
}
Also used : ExportFormDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) Calendar(java.util.Calendar) Date(java.util.Date) ExportStudyEventDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectGroupDataBean(org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) ExportSubjectDataBean(org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet)

Aggregations

ExportSubjectDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean)3 SubjectGroupDataBean (org.akaza.openclinica.bean.submit.crfdata.SubjectGroupDataBean)3 ExportFormDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportFormDataBean)2 ExportStudyEventDataBean (org.akaza.openclinica.bean.submit.crfdata.ExportStudyEventDataBean)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 AuditLogsBean (org.akaza.openclinica.bean.odmbeans.AuditLogsBean)1 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)1 ImportItemDataBean (org.akaza.openclinica.bean.submit.crfdata.ImportItemDataBean)1 ImportItemGroupDataBean (org.akaza.openclinica.bean.submit.crfdata.ImportItemGroupDataBean)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 SubjectGroupMap (org.akaza.openclinica.domain.datamap.SubjectGroupMap)1