Search in sources :

Example 1 with ODMcomplexTypeDefinitionFormData

use of org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormData in project OpenClinica by OpenClinica.

the class OdmController method getODM.

private ODM getODM(String studyOID, String subjectKey) {
    ODM odm = new ODM();
    String ssoid = subjectKey;
    if (ssoid == null) {
        return null;
    }
    FormLayoutDAO formLayoutDAO = new FormLayoutDAO(dataSource);
    StudyDAO studyDAO = new StudyDAO(dataSource);
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    ItemDataDAO itemDataDAO = new ItemDataDAO(dataSource);
    CRFDAO crfDAO = new CRFDAO(dataSource);
    List<ODMcomplexTypeDefinitionFormData> formDatas = new ArrayList<>();
    try {
        // Retrieve crfs for next event
        StudySubjectBean studySubjectBean = studySubjectDAO.findByOid(ssoid);
        ParticipantEventService participantEventService = new ParticipantEventService(dataSource);
        StudyEventBean nextEvent = participantEventService.getNextParticipantEvent(studySubjectBean);
        if (nextEvent != null) {
            logger.debug("Found event: " + nextEvent.getName() + " - ID: " + nextEvent.getId());
            List<EventCRFBean> eventCrfs = eventCRFDAO.findAllByStudyEvent(nextEvent);
            StudyBean study = studyDAO.findByOid(studyOID);
            if (!mayProceed(studyOID, studySubjectBean))
                return odm;
            List<EventDefinitionCRFBean> eventDefCrfs = participantEventService.getEventDefCrfsForStudyEvent(studySubjectBean, nextEvent);
            for (EventDefinitionCRFBean eventDefCrf : eventDefCrfs) {
                if (eventDefCrf.isParticipantForm()) {
                    EventCRFBean eventCRF = participantEventService.getExistingEventCRF(studySubjectBean, nextEvent, eventDefCrf);
                    boolean itemDataExists = false;
                    boolean validStatus = true;
                    FormLayoutBean formLayout = null;
                    if (eventCRF != null) {
                        if (eventCRF.getStatus().getId() != 1 && eventCRF.getStatus().getId() != 2)
                            validStatus = false;
                        if (itemDataDAO.findAllByEventCRFId(eventCRF.getId()).size() > 0)
                            itemDataExists = true;
                        formLayout = (FormLayoutBean) formLayoutDAO.findByPK(eventCRF.getFormLayoutId());
                    } else
                        formLayout = (FormLayoutBean) formLayoutDAO.findByPK(eventDefCrf.getDefaultVersionId());
                    if (validStatus) {
                        String formUrl = null;
                        if (!itemDataExists)
                            formUrl = createEnketoUrl(studyOID, formLayout, nextEvent, ssoid);
                        else
                            formUrl = createEditUrl(studyOID, formLayout, nextEvent, ssoid);
                        formDatas.add(getFormDataPerCrf(formLayout, nextEvent, eventCrfs, crfDAO, formUrl, itemDataExists));
                    }
                }
            }
            return createOdm(study, studySubjectBean, nextEvent, formDatas);
        } else {
            logger.debug("Unable to find next event for subject.");
        }
    } catch (Exception e) {
        logger.error(e.getMessage());
        logger.error(ExceptionUtils.getStackTrace(e));
    }
    return odm;
}
Also used : EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ParticipantEventService(org.akaza.openclinica.service.ParticipantEventService) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) ODMcomplexTypeDefinitionFormData(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormData) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) ODM(org.cdisc.ns.odm.v130.ODM) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 2 with ODMcomplexTypeDefinitionFormData

use of org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormData in project OpenClinica by OpenClinica.

the class OdmController method generateFormData.

private ODMcomplexTypeDefinitionFormData generateFormData(FormLayoutBean formLayout, StudyEventBean nextEvent, EventCRFBean eventCRFBean, CRFBean crfBean, String formUrl, boolean itemDataExists) {
    ODMcomplexTypeDefinitionFormData formData = new ODMcomplexTypeDefinitionFormData();
    formData.setFormOID(formLayout.getOid());
    formData.setFormName(crfBean.getName());
    formData.setVersionDescription(formLayout.getDescription());
    formData.setUrl(formUrl);
    if (eventCRFBean == null) {
        formData.setStatus("Not Started");
    } else {
        EventCrf eventCrf = eventCrfDao.findById(eventCRFBean.getId());
        if (!itemDataExists) {
            formData.setStatus("Not Started");
        } else {
            formData.setStatus(eventCRFBean.getStatus().getName());
        }
        if (eventCrf.getDateUpdated() != null) {
            // returns time as UTC
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
            formData.setStatusChangeTimeStamp(sdf.format(eventCrf.getDateUpdated()));
        }
    }
    return formData;
}
Also used : EventCrf(org.akaza.openclinica.domain.datamap.EventCrf) ODMcomplexTypeDefinitionFormData(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormData) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with ODMcomplexTypeDefinitionFormData

use of org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormData in project OpenClinica by OpenClinica.

the class OdmController method createOdm.

private ODM createOdm(StudyBean study, StudySubjectBean studySubjectBean, StudyEventBean nextEvent, List<ODMcomplexTypeDefinitionFormData> formDatas) {
    ODM odm = new ODM();
    ODMcomplexTypeDefinitionClinicalData clinicalData = generateClinicalData(study);
    ODMcomplexTypeDefinitionSubjectData subjectData = generateSubjectData(studySubjectBean);
    ODMcomplexTypeDefinitionStudyEventData studyEventData = generateStudyEventData(nextEvent);
    // Create the object graph
    studyEventData.getFormData().addAll(formDatas);
    subjectData.getStudyEventData().add(studyEventData);
    clinicalData.getSubjectData().add(subjectData);
    odm.getClinicalData().add(clinicalData);
    return odm;
}
Also used : ODMcomplexTypeDefinitionClinicalData(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionClinicalData) ODM(org.cdisc.ns.odm.v130.ODM) ODMcomplexTypeDefinitionSubjectData(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionSubjectData) ODMcomplexTypeDefinitionStudyEventData(org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionStudyEventData)

Aggregations

ODM (org.cdisc.ns.odm.v130.ODM)2 ODMcomplexTypeDefinitionFormData (org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionFormData)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)1 FormLayoutBean (org.akaza.openclinica.bean.submit.FormLayoutBean)1 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)1 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)1 FormLayoutDAO (org.akaza.openclinica.dao.submit.FormLayoutDAO)1 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)1 EventCrf (org.akaza.openclinica.domain.datamap.EventCrf)1 ParticipantEventService (org.akaza.openclinica.service.ParticipantEventService)1 ODMcomplexTypeDefinitionClinicalData (org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionClinicalData)1 ODMcomplexTypeDefinitionStudyEventData (org.cdisc.ns.odm.v130.ODMcomplexTypeDefinitionStudyEventData)1