use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class ExpressionBeanService method getSSTimeZone.
public String getSSTimeZone() {
Integer subjectId = expressionBeanWrapper.getStudySubjectBeanId();
System.out.print(" subjectId " + subjectId + " : ");
if (subjectId == null)
return null;
StudySubjectBean ssBean = (StudySubjectBean) getStudySubjectDao().findByPK(subjectId);
return ssBean.getTime_zone().trim();
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class ExpressionService method getSSZoneId.
public String getSSZoneId() {
Integer subjectId = expressionWrapper.getStudySubjectId();
System.out.println(" subjectId " + subjectId + " : ");
if (subjectId == null)
return null;
StudySubjectBean ssBean = (StudySubjectBean) getStudySubjectDao().findByPK(subjectId);
return ssBean.getTime_zone().trim();
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class RandomizeService method getRandomizationCode.
// Rest Call to OCUI to get Randomization
public String getRandomizationCode(EventCRFBean eventCrfBean, List<StratificationFactorBean> stratificationFactorBeans, RuleSetBean ruleSet) throws JSONException {
StudySubjectDAO ssdao = new StudySubjectDAO<>(ds);
StudySubjectBean ssBean = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
// study subject oid
String identifier = ssBean.getOid();
StudyDAO sdao = new StudyDAO<>(ds);
StudyBean sBean = (StudyBean) sdao.findByPK(ssBean.getStudyId());
// site or study oid
String siteIdentifier = sBean.getOid();
// site or study name
String name = sBean.getName();
UserAccountDAO udao = new UserAccountDAO(ds);
int userId = 0;
if (eventCrfBean.getUpdaterId() == 0) {
userId = eventCrfBean.getOwnerId();
} else {
userId = eventCrfBean.getUpdaterId();
}
UserAccountBean uBean = (UserAccountBean) udao.findByPK(userId);
String user = uBean.getName();
// sBean should be parent study
// put randomization object in cache
StudyBean study = getParentStudy(sBean.getOid());
SeRandomizationDTO randomization = null;
try {
randomization = getCachedRandomizationDTOObject(study.getOid(), false);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String randomiseUrl = randomization.getUrl();
String username = randomization.getUsername();
String password = randomization.getPassword();
String timezone = "America/New_York";
// String randomiseUrl = "https://evaluation.sealedenvelope.com/redpill/seti2";
// String username = "oc";
// String password = "secret";
HttpHeaders headers = createHeaders(username, password);
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
// retrieve json object if Randomization exist ,otherwise return a null object
JSONObject jsonRandObject = retrieveARandomisation(randomiseUrl, ssBean, headers);
if (jsonRandObject != null) {
return (String) jsonRandObject.get("code");
} else {
// if Site identifier exists ,then update otherwise create new Site identifier
addOrUpdateASite(randomiseUrl, sBean, headers, timezone);
// send for Randomization
JSONObject jsonRandomisedObject = randomiseSubject(randomiseUrl, ssBean, sBean, headers, user, stratificationFactorBeans, eventCrfBean, ruleSet);
if (jsonRandomisedObject != null)
return (String) jsonRandomisedObject.get("code");
else
return "";
}
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class EventService method scheduleEvent.
public HashMap<String, String> scheduleEvent(UserAccountBean user, Date startDateTime, Date endDateTime, String location, String studyUniqueId, String siteUniqueId, String eventDefinitionOID, String studySubjectId) throws OpenClinicaSystemException {
// Business Validation
StudyBean study = getStudyDao().findByUniqueIdentifier(studyUniqueId);
int parentStudyId = study.getId();
if (siteUniqueId != null) {
study = getStudyDao().findSiteByUniqueIdentifier(studyUniqueId, siteUniqueId);
}
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionDao().findByOidAndStudy(eventDefinitionOID, study.getId(), parentStudyId);
StudySubjectBean studySubject = getStudySubjectDao().findByLabelAndStudy(studySubjectId, study);
Integer studyEventOrdinal = null;
if (canSubjectScheduleAnEvent(studyEventDefinition, studySubject)) {
StudyEventBean studyEvent = new StudyEventBean();
studyEvent.setStudyEventDefinitionId(studyEventDefinition.getId());
studyEvent.setStudySubjectId(studySubject.getId());
studyEvent.setLocation(location);
studyEvent.setDateStarted(startDateTime);
studyEvent.setDateEnded(endDateTime);
studyEvent.setOwner(user);
studyEvent.setStatus(Status.AVAILABLE);
studyEvent.setSubjectEventStatus(SubjectEventStatus.SCHEDULED);
studyEvent.setSampleOrdinal(getStudyEventDao().getMaxSampleOrdinal(studyEventDefinition, studySubject) + 1);
studyEvent = (StudyEventBean) getStudyEventDao().create(studyEvent, true);
studyEventOrdinal = studyEvent.getSampleOrdinal();
} else {
throw new OpenClinicaSystemException("Cannot schedule an event for this Subject");
}
HashMap<String, String> h = new HashMap<String, String>();
h.put("eventDefinitionOID", eventDefinitionOID);
h.put("studyEventOrdinal", studyEventOrdinal.toString());
h.put("studySubjectOID", studySubject.getOid());
return h;
}
use of org.akaza.openclinica.bean.managestudy.StudySubjectBean in project OpenClinica by OpenClinica.
the class DiscrepancyNoteUtil method getStudySubjectIdForDiscNote.
public int getStudySubjectIdForDiscNote(DiscrepancyNoteBean discrepancyNoteBean, DataSource dataSource, int studyId) {
if (discrepancyNoteBean == null)
return 0;
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
List<StudySubjectBean> studySubjectBeans = new ArrayList<StudySubjectBean>();
if ("subject".equalsIgnoreCase(discrepancyNoteBean.getEntityType())) {
studySubjectBeans = studySubjectDAO.findAllBySubjectId(discrepancyNoteBean.getEntityId());
for (StudySubjectBean bean : studySubjectBeans) {
if (bean.getStudyId() == studyId) {
return bean.getId();
} else {
if (((StudyBean) new StudyDAO(dataSource).findByPK(bean.getStudyId())).getParentStudyId() == studyId) {
return bean.getId();
}
}
}
} else if ("studySub".equalsIgnoreCase(discrepancyNoteBean.getEntityType())) {
return discrepancyNoteBean.getEntityId();
}
return 0;
}
Aggregations