use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ExtractBean method addStudyEventData.
// addStudySubjectData
/*
* public void addStudySubjectData(Integer studySubjectId, String
* studySubjectLabel, Date dateOfBirth, String gender, Integer
* subjectStatusId, Boolean dobCollected, String uniqueIdentifier, String
* subjectSecondaryLabel) { if (!subjectsAdded.containsKey(studySubjectId))
* { StudySubjectBean sub = new StudySubjectBean();
* sub.setId(studySubjectId.intValue()); sub.setLabel(studySubjectLabel);
*
* sub.setDateOfBirth(dateOfBirth); if (gender != null && gender.length() >
* 0) { sub.setGender(gender.charAt(0)); } else { sub.setGender(' '); }
* sub.setStatus(Status.get(subjectStatusId.intValue())); //
* sub.setSecondaryLabel(secondaryID);//????
* sub.setUniqueIdentifier(uniqueIdentifier);
* sub.setSecondaryLabel(subjectSecondaryLabel); //
* sub.setEnrollmentDate(enrollmentDate); // TODO need to find enrollment
* date, later, tbh subjects.add(sub); subjectsAdded.put(studySubjectId,
* Boolean.TRUE); } }
*/
/**
* @vbc 08/06/2008 NEW EXTRACT DATA IMPLEMENTATION Combines the two HashMaps
* into eventData entries - the data is already filtered for null
* values
*/
public void addStudyEventData() {
/**
* The two ArrayList are synchronized because they are extracted with
* "ORDER BY aitem_data_id"
*/
boolean isfnd = false;
// initialize
eventData = new HashMap();
for (int ik = 0; ik < aBASE_ITEMDATAID.size(); ik++) {
// get the item_group side
extractDataset_ITEMGROUPSIDE objgrp = (extractDataset_ITEMGROUPSIDE) hBASE_ITEMGROUPSIDE.get(ik);
extractDataset_EVENTSIDE objev = (extractDataset_EVENTSIDE) hBASE_EVENTSIDE.get(ik);
// sanity check - assume both are not null
Integer itemdataid = (Integer) aBASE_ITEMDATAID.get(ik);
Integer itemdataid_objgrp = objgrp.itemDataId;
Integer itemdataid_objev = objev.itemDataId;
if (itemdataid_objgrp.intValue() == itemdataid.intValue() && itemdataid_objev.intValue() == itemdataid.intValue()) {
// OK - add entries to the dataEvent
// initialize
StudyEventBean event = new StudyEventBean();
EventCRFBean eventCRF = new EventCRFBean();
//
// studyEventDefinitionName
event.setName(objev.studyEventDefinitionName);
// studyEventStart
event.setDateStarted(objev.studyEventDateStart);
// studyEventEnd
event.setDateEnded(objev.studyEventDateEnd);
// studyEventLocation
event.setLocation(objev.studyEventLoacation);
// sampleOrdinal
event.setSampleOrdinal(objev.sampleOrdinal.intValue());
// .
// intValue
// ()
// studyEventDefinitionId
event.setStudyEventDefinitionId(objev.studyEvenetDefinitionId.intValue());
// .
// intValue
// (
// )
// studySubjectId
event.setStudySubjectId(objev.studySubjectId.intValue());
// .
// intValue
// ()
// se
event.setStartTimeFlag(objev.studyEventStartTimeFlag.booleanValue());
// .
// getStartTimeFlag
// (
// )
// se
event.setEndTimeFlag(objev.studyEventEndTimeFlag.booleanValue());
// .
// getEndTimeFlag
// (
// )
// below needs to be added, tbh
// TODO - @vbc - validate this
// se
event.setStatus(Status.get(objev.studyEventStatusId.intValue()));
// .
// getStatus
// (
// )
// se
event.setSubjectEventStatus(SubjectEventStatus.get(objev.studyEventSubjectEventStatusId.intValue()));
// .
// getSubjectEventStatus
// (
// )
// @vbc 08/06/2008 NEW EXTRACT DATA IMPLEMENTATION
// the stage is set on setStatus - skip it
// event.setStage(se.getStage());
// se.getId()
event.setId(objev.studyEventId.intValue());
// end tbh, 03/08
// completionStatusId
eventCRF.setCompletionStatusId(objgrp.eventCrfCompletionStatusId);
// .
// intValue
// (
// )
// interviewerName
eventCRF.setInterviewerName(objgrp.interviewerName);
// dateCompleted
eventCRF.setDateCompleted(objgrp.eventCrfDateCompleted);
// dateValidateCompleted
eventCRF.setDateValidateCompleted(objgrp.eventCrfDateValidateCompleted);
eventCRF.setStatus(Status.get(objgrp.eventCrfStatusId));
// eventCRF.setCreatedDate();//same as interviewed date? NO
// dateInterviewedv
eventCRF.setDateInterviewed(objgrp.dateInterviewed);
// eventCRF.setStatus(status); //this is the one that we want,
// tbh
CRFVersionBean crfVersion = new CRFVersionBean();
// crfVersionName
crfVersion.setName(objgrp.crfVersionName);
// crfVersionStatusId
crfVersion.setStatus(Status.get(objgrp.crfVersionStatusId.intValue()));
// crfVersionStatusId
crfVersion.setStatusId(objgrp.crfVersionStatusId.intValue());
// .
// intValue
// (
// )
eventCRF.setCrfVersion(crfVersion);
ArrayList events = new ArrayList();
events.add(eventCRF);
// logger.info("///adding an event CRF..."
// + eventCRF.getInterviewerName());
// hmm, one to one relationship?
event.setEventCRFs(events);
// guard clause to see if it's in there already?
// not rly, the above is only used in auditlogging
// could fit in crf and crf version ids here, though
// FIXME def not one to one relationship, tbh, 03.08
String key = getStudyEventDataKey(/* studySubjectId.intValue() */
objev.studySubjectId.intValue(), /* studyEventDefinitionId.intValue() */
objev.studyEvenetDefinitionId.intValue(), /* sampleOrdinal.intValue()) */
objev.sampleOrdinal.intValue());
if (eventData == null) {
eventData = new HashMap();
}
StudyEventBean checkEvent = (StudyEventBean) eventData.get(key);
if (checkEvent == null) {
eventData.put(key, event);
// logger.info("###just CREATED key: " + key + " event: " +
// event.getName() + " int.name: " +
// eventCRF.getInterviewerName());
} else {
// OK - already saved
}
} else {
isfnd = true;
}
//
}
// for
// before return quick count
logger.debug("Number of entries in the eventData is:" + eventData.size());
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ExtractBean method getSEDCRFStatus.
// private String getSEDCRFName(int sedInd, int crfInd) {
// syncCRFIndex(sedInd, crfInd);
// return currentCRF.getName();
// }
// private String getSEDCRFVersionName(int h, int sedInd, int crfInd) {
// syncCRFIndex(sedInd, crfInd);
//
// StudyEventBean seb = getEvent(h, sedInd, crfInd);
//
// String returnMe = "";
// //ArrayList versions = currentCRF.getVersions();//returns zero results
// EventCRFBean eventCRF = null;
// if (seb.getEventCRFs().size() > 0) {
// logger.info("found getEventCRFs.size " + seb.getEventCRFs().size());
// for (int t = 0; t < seb.getEventCRFs().size(); t++) {
// eventCRF = (EventCRFBean) seb.getEventCRFs().get(t);
// returnMe = eventCRF.getCrfVersion().getName();
// //logger.info("found versions.size "+versions.size());
// //for (int s = 0; s < versions.size(); s++) {
// // CRFVersionBean version = (CRFVersionBean)versions.get(s);
// // if (version.getId()==eventCRF.getCRFVersionId()) {
// // returnMe = version.getName();
// //break;
// // }
// //}
// }
//
// }
// logger.info("returning the following for crf version name: " + returnMe);
// return returnMe;
// }
private String getSEDCRFStatus(int h, int sedInd, int crfInd) {
// BADS Flag
syncCRFIndex(sedInd, crfInd);
StudyEventBean seb = getEvent(h, sedInd, crfInd);
Status ecStatus = Status.AVAILABLE;
EventCRFBean eventCRF = null;
if (seb.getEventCRFs().size() > 0) {
eventCRF = (EventCRFBean) seb.getEventCRFs().get(0);
}
String crfVersionStatus = "";
SubjectEventStatus status = SubjectEventStatus.NOT_SCHEDULED;
CRFVersionBean crfv = new CRFVersionBean();
crfv.setStatus(Status.AVAILABLE);
// modified stage so that crfVersionStatus could be the same as what it
// shows in subject matrix - as required.
DataEntryStage stage = DataEntryStage.INVALID;
try {
stage = eventCRF.getStage();
ecStatus = eventCRF.getStatus();
// SubjectEventStatus.get(
status = seb.getSubjectEventStatus();
// eventCRF
// .getCompletionStatusId());
crfv = eventCRF.getCrfVersion();
} catch (NullPointerException e) {
logger.info("exception hit, status set to not scheduled");
}
// currentCRF.getStatus().getName();
//
logger.info("event crf stage: " + stage.getName() + ", event crf status: " + ecStatus.getName() + ", STATUS: " + status.getName() + " crf version: " + crfv.getStatus().getName() + " data entry stage: " + stage.getName());
if (stage.equals(DataEntryStage.INVALID) || ecStatus.equals(Status.INVALID)) {
stage = DataEntryStage.UNCOMPLETED;
}
crfVersionStatus = stage.getName();
if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
crfVersionStatus = DataEntryStage.LOCKED.getName();
} else if (status.equals(SubjectEventStatus.INVALID)) {
crfVersionStatus = DataEntryStage.LOCKED.getName();
} else if (!currentCRF.getStatus().equals(Status.AVAILABLE)) {
crfVersionStatus = DataEntryStage.LOCKED.getName();
} else if (!crfv.getStatus().equals(Status.AVAILABLE)) {
crfVersionStatus = DataEntryStage.LOCKED.getName();
}
logger.info("returning: " + crfVersionStatus);
return crfVersionStatus;
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean 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");
}
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class CRFVersionDAO method findByPK.
public EntityBean findByPK(int ID) {
CRFVersionBean eb = new CRFVersionBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), new Integer(ID));
String sql = digester.getQuery("findByPK");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (CRFVersionBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class CRFVersionDAO method findByFullName.
public EntityBean findByFullName(String version, String crfName) {
CRFVersionBean eb = new CRFVersionBean();
this.setTypesExpected();
HashMap variables = new HashMap();
variables.put(new Integer(1), version);
variables.put(new Integer(2), crfName);
String sql = digester.getQuery("findByFullName");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (CRFVersionBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
Aggregations