use of org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean in project OpenClinica by OpenClinica.
the class OdmExtractDAO method setOCSubjectDataAuditLogs.
protected void setOCSubjectDataAuditLogs(StudyBean study, OdmClinicalDataBean data, String studySubjectOids, HashMap<String, String> subOidPoses) {
this.setOCSubjectDataAuditsTypesExpected();
logger.debug("Begin to execute GetOCSubjectDataAuditsSql");
logger.debug("getOCSubjectDataAuditsSql= " + this.getOCSubjectDataAuditsSql(studySubjectOids));
ArrayList rows = select(this.getOCSubjectDataAuditsSql(studySubjectOids));
Iterator iter = rows.iterator();
while (iter.hasNext()) {
HashMap row = (HashMap) iter.next();
String studySubjectLabel = (String) row.get("study_subject_oid");
Integer auditId = (Integer) row.get("audit_id");
String type = (String) row.get("name");
Integer userId = (Integer) row.get("user_id");
Date auditDate = (Date) row.get("audit_date");
String auditReason = (String) row.get("reason_for_change");
String oldValue = (String) row.get("old_value");
String newValue = (String) row.get("new_value");
Integer typeId = (Integer) row.get("audit_log_event_type_id");
if (subOidPoses.containsKey(studySubjectLabel)) {
ExportSubjectDataBean sub = data.getExportSubjectData().get(Integer.parseInt(subOidPoses.get(studySubjectLabel)));
AuditLogBean auditLog = new AuditLogBean();
auditLog.setOid("AL_" + auditId);
auditLog.setUserId("USR_" + userId);
logger.debug("datatime=" + auditDate + " or " + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(auditDate));
auditLog.setDatetimeStamp(auditDate);
auditLog.setType(type);
auditLog.setReasonForChange(auditReason);
if (typeId == 3 || typeId == 6) {
if ("0".equals(newValue)) {
auditLog.setOldValue(Status.INVALID.getName());
} else {
auditLog.setNewValue(Status.getFromMap(Integer.parseInt(newValue)).getName());
}
if ("0".equals(oldValue)) {
auditLog.setOldValue(Status.INVALID.getName());
} else {
auditLog.setOldValue(Status.getFromMap(Integer.parseInt(oldValue)).getName());
}
} else {
auditLog.setNewValue(newValue);
auditLog.setOldValue(oldValue);
}
AuditLogsBean logs = sub.getAuditLogs();
if (logs.getEntityID() == null || logs.getEntityID().length() <= 0) {
logs.setEntityID(sub.getSubjectOID());
}
logs.getAuditLogs().add(auditLog);
sub.setAuditLogs(logs);
}
}
}
use of org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean in project OpenClinica by OpenClinica.
the class OdmExtractDAO method getClinicalData.
public void getClinicalData(StudyBean study, DatasetBean dataset, OdmClinicalDataBean data, String odmVersion, String studySubjectIds, String odmType) {
String dbName = CoreResources.getDBName();
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 = "";
HashMap<Integer, String> oidPoses = new HashMap<Integer, String>();
HashMap<Integer, String> idataOidPoses = new HashMap<Integer, String>();
// String studyIds = "";
// if (study.getParentStudyId() > 0) {
// studyIds += study.getId();
// } else {
// ArrayList<Integer> ids = (ArrayList<Integer>) (new
// StudyDAO(this.ds)).findAllSiteIdsByStudy(study);
// for (int i = 0; i < ids.size() - 1; ++i) {
// studyIds += ids.get(i) + ",";
// }
// studyIds += ids.get(ids.size() - 1);
// }
String studyIds = study.getId() + "";
int datasetItemStatusId = dataset.getDatasetItemStatus().getId();
String sql = dataset.getSQLStatement().split("order by")[0].trim();
sql = sql.split("study_event_definition_id in")[1];
String[] ss = sql.split("and item_id in");
String sedIds = ss[0];
String[] sss = ss[1].split("and");
String itemIds = sss[0];
String dateConstraint = "";
if ("postgres".equalsIgnoreCase(dbName)) {
dateConstraint = "and " + sss[1] + " and " + sss[2];
dateConstraint = dateConstraint.replace("date_created", "ss.enrollment_date");
} else if ("oracle".equalsIgnoreCase(dbName)) {
String[] os = (sss[1] + sss[2]).split("'");
dateConstraint = "and trunc(ss.enrollment_date) >= to_date('" + os[1] + "') and trunc(ss.enrollment_date) <= to_date('" + os[3] + "')";
}
logger.debug("Begin to GetSubjectEventFormSql");
if (odmVersion.startsWith("oc")) {
logger.debug("getOCSubjectEventFormSql=" + getOCSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
this.setSubjectEventFormDataTypesExpected(odmVersion);
ArrayList viewRows = select(getOCSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
Iterator iter = viewRows.iterator();
this.setDataWithOCAttributes(study, dataset, data, odmVersion, iter, oidPoses, odmType);
} else {
logger.debug("getSubjectEventFormSql=" + getSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
this.setSubjectEventFormDataTypesExpected();
ArrayList viewRows = select(getSubjectEventFormSqlSS(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
Iterator iter = viewRows.iterator();
// updated as well because this method came from here.
while (iter.hasNext()) {
JobTerminationMonitor.check();
HashMap row = (HashMap) iter.next();
String studySubjectLabel = (String) row.get("study_subject_oid");
String sedOID = (String) row.get("definition_oid");
Boolean studyEventRepeating = (Boolean) row.get("definition_repeating");
Integer sampleOrdinal = (Integer) row.get("sample_ordinal");
String cvOID = (String) row.get("crf_version_oid");
// ecId
Integer ecId = (Integer) row.get("event_crf_id");
CRFVersionBean cvBean = cvdao.findByOid(cvOID);
CRFBean cBean = (CRFBean) crfdao.findByPK(cvBean.getCrfId());
// should
// be unique;
String key = studySubjectLabel;
ExportSubjectDataBean sub = new ExportSubjectDataBean();
if (subprev.equals(studySubjectLabel)) {
int p = data.getExportSubjectData().size() - 1;
sub = data.getExportSubjectData().get(p);
} else {
subprev = studySubjectLabel;
sub.setSubjectOID(studySubjectLabel);
data.getExportSubjectData().add(sub);
seprev = "";
formprev = "";
igprev = "";
}
oidPos = data.getExportSubjectData().size() - 1 + "";
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;
se.setStudyEventOID(sedOID);
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);
ExportFormDataBean form = new ExportFormDataBean();
key += cvOID;
if (formprev.equals(key)) {
form = se.getExportFormData().get(se.getExportFormData().size() - 1);
} else {
formprev = key;
form.setFormOID(cBean.getOid());
se.getExportFormData().add(form);
igprev = "";
}
oidPos += "---" + (se.getExportFormData().size() - 1);
// ecId should be distinct
oidPoses.put(ecId, oidPos);
oidPos = "";
}
}
this.setEventGroupItemDataWithUnitTypesExpected();
logger.debug("Begin to GetEventGroupItemWithUnitSql");
ArrayList viewRows = select(getEventGroupItemWithUnitSql(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
logger.debug("getEventGroupItemWithUnitSql : " + getEventGroupItemWithUnitSql(studyIds, sedIds, itemIds, dateConstraint, datasetItemStatusId, studySubjectIds));
String idataIds = "";
if (viewRows.size() > 0) {
Iterator iter = viewRows.iterator();
ExportSubjectDataBean sub = new ExportSubjectDataBean();
ExportStudyEventDataBean se = new ExportStudyEventDataBean();
ExportFormDataBean form = new ExportFormDataBean();
int ecprev = -1;
igprev = "";
boolean goon = true;
String itprev = "";
// HashMap<String, String> nullValueMap =
// ClinicalDataUnit.getNullValueMap();
HashMap<String, String> nullValueCVs = this.getNullValueCVs(study);
HashSet<Integer> itemDataIds = new HashSet<Integer>();
String yearMonthFormat = StringUtil.parseDateFormat(ResourceBundleProvider.getFormatBundle(locale).getString("date_format_year_month"));
String yearFormat = StringUtil.parseDateFormat(ResourceBundleProvider.getFormatBundle(locale).getString("date_format_year"));
while (iter.hasNext()) {
JobTerminationMonitor.check();
HashMap row = (HashMap) iter.next();
Integer ecId = (Integer) row.get("event_crf_id");
Integer igId = (Integer) row.get("item_group_id");
String igOID = (String) row.get("item_group_oid");
String igName = (String) row.get("item_group_name");
Integer itId = (Integer) row.get("item_id");
String itOID = (String) row.get("item_oid");
Integer itDataOrdinal = (Integer) row.get("item_data_ordinal");
String itValue = (String) row.get("value");
Integer datatypeid = (Integer) row.get("item_data_type_id");
Integer idataId = (Integer) row.get("item_data_id");
String muOid = (String) row.get("mu_oid");
String key = "";
if (ecId != ecprev) {
logger.debug("Found ecId=" + ecId + " in subjectEventFormSql is:" + oidPoses.containsKey(ecId));
if (oidPoses.containsKey(ecId)) {
goon = true;
String[] poses = oidPoses.get(ecId).split("---");
sub = data.getExportSubjectData().get(Integer.valueOf(poses[0]));
se = sub.getExportStudyEventData().get(Integer.valueOf(poses[1]));
form = se.getExportFormData().get(Integer.valueOf(poses[2]));
} else {
goon = false;
}
ecprev = ecId;
}
if (goon) {
ImportItemGroupDataBean ig = new ImportItemGroupDataBean();
// key = ecId + igOID;
key = ecId + "-" + igId;
if (!igprev.equals(key) || !igpos.containsKey(key + itDataOrdinal)) {
igpos.put(key + itDataOrdinal, form.getItemGroupData().size());
igprev = key;
ig.setItemGroupOID(igOID + "");
ig.setItemGroupRepeatKey("ungrouped".equalsIgnoreCase(igName) ? "-1" : itDataOrdinal + "");
form.getItemGroupData().add(ig);
} else {
ig = form.getItemGroupData().get(igpos.get(key + itDataOrdinal));
}
String newpos = oidPoses.get(ecId) + "---" + igpos.get(key + itDataOrdinal);
// item should be distinct; but duplicated item data have
// been reported because "save" have been clicked twice.
// those duplicated item data have been arranged together by
// "distinct" because of their same
// ecId+igOID+itOID+itDataOrdinal (08-2008)
key = itId + "_" + itDataOrdinal + key;
if (!itprev.equals(key)) {
itprev = key;
ImportItemDataBean it = new ImportItemDataBean();
it.setItemOID(itOID);
it.setTransactionType("Insert");
String nullKey = study.getId() + "-" + se.getStudyEventOID() + "-" + form.getFormOID();
if (ClinicalDataUtil.isNull(itValue, nullKey, nullValueCVs)) {
// if
// (nullValueMap.containsKey(itValue.trim().toUpperCase()))
// {
// itValue =
// nullValueMap.get(itValue.trim().toUpperCase());
it.setIsNull("Yes");
String nullvalues = ClinicalDataUtil.presetNullValueStr(nullValueCVs.get(nullKey));
boolean hasValueWithNull = ClinicalDataUtil.isValueWithNull(itValue, nullvalues);
it.setHasValueWithNull(hasValueWithNull);
if (hasValueWithNull) {
it.setValue(itValue);
it.setReasonForNull(ClinicalDataUtil.getNullsInValue(itValue, nullvalues));
} else {
it.setReasonForNull(itValue.trim());
}
} else {
if (datatypeid == 9) {
try {
itValue = new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat(oc_df_string).parse(itValue));
} catch (Exception fe) {
logger.debug("Item -" + itOID + " value " + itValue + " might not be ODM date format yyyy-MM-dd.");
}
}
/*
* not be supported in openclinica-3.0.40.1
* else if (datatypeid == 10 && odmVersion.contains("1.3")) {
* if (StringUtil.isFormatDate(itValue, oc_df_string)) {
* try {
* itValue = new SimpleDateFormat("yyyy-MM-dd").format(new
* SimpleDateFormat(oc_df_string).parse(itValue));
* } catch (Exception e) {
* logger.info("Item -" + itOID + " value " + itValue +
* " might not be ODM partialDate format yyyy[-MM[-dd]].");
* }
* } else {
* if (StringUtil.isPartialYearMonth(itValue, yearMonthFormat)) {
* try {
* itValue = new SimpleDateFormat("yyyy-MM").format(new
* SimpleDateFormat(yearMonthFormat).parse(itValue));
* } catch (Exception e) {
* logger.info("Item -" + itOID + " value " + itValue +
* " might not be ODM partialDate format yyyy[-MM[-dd]].");
* }
* } else {
* try {
* itValue = new SimpleDateFormat("yyyy").format(new
* SimpleDateFormat(yearFormat).parse(itValue));
* } catch (Exception e) {
* logger.info("Item -" + itOID + " value " + itValue +
* " might not be ODM partialDate format yyyy[-MM[-dd]].");
* }
* }
* }
* }
*/
it.setValue(itValue);
}
if (muOid != null && muOid.length() > 0) {
ElementRefBean measurementUnitRef = new ElementRefBean();
measurementUnitRef.setElementDefOID(muOid);
it.setMeasurementUnitRef(measurementUnitRef);
}
ig.getItemData().add(it);
newpos += "---" + (ig.getItemData().size() - 1);
idataOidPoses.put(idataId, newpos);
}
idataIds += "'" + idataId + "', ";
}
}
}
idataIds = idataIds.length() > 0 ? idataIds.substring(0, idataIds.length() - 2) : idataIds;
if (idataIds.length() > 0 && itemIds.length() > 0) {
this.setErasedScoreItemDataValues(data, itemIds, idataIds, idataOidPoses, odmVersion);
} else {
logger.info("OdmExtractDAO.setScoreItemDataNullValues was not called because of empty item_data_ids or/and item_ids");
}
if (odmType != null && odmType.equalsIgnoreCase("clinical_data")) {
logger.debug("Do not create discrepancy notes");
} else if (odmVersion.startsWith("oc")) {
if (idataIds.length() > 0) {
setOCItemDataAuditLogs(study, data, idataIds, idataOidPoses);
setOCItemDataDNs(data, idataIds, idataOidPoses);
} else {
logger.info("OdmExtractDAO.setOCItemDataAuditLogs & setOCItemDataDNs weren't called because of empty idataIds");
}
}
}
use of org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method constructClinicalDataStudy.
private OdmClinicalDataBean constructClinicalDataStudy(List<StudySubject> studySubjs, Study study, List<StudyEvent> studyEvents, String formVersionOID) {
OdmClinicalDataBean odmClinicalDataBean = new OdmClinicalDataBean();
ExportSubjectDataBean expSubjectBean;
List<ExportSubjectDataBean> exportSubjDataBeanList = new ArrayList<ExportSubjectDataBean>();
for (StudySubject studySubj : studySubjs) {
studyEvents = (ArrayList<StudyEvent>) getStudySubjectDao().fetchListSEs(studySubj.getOcOid());
if (studyEvents != null) {
expSubjectBean = setExportSubjectDataBean(studySubj, study, studyEvents, formVersionOID);
exportSubjDataBeanList.add(expSubjectBean);
odmClinicalDataBean.setExportSubjectData(exportSubjDataBeanList);
odmClinicalDataBean.setStudyOID(study.getOc_oid());
}
}
return odmClinicalDataBean;
// return null;
}
use of org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean 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);
}
}
use of org.akaza.openclinica.bean.submit.crfdata.ExportSubjectDataBean 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;
}
Aggregations