protected static String calculateDoseCohort()

in clns-acuity-admin/acuity-core/src/main/java/com/acuity/visualisations/web/service/wizard/study/StudySetupSubjectGroupService.java [224:285]


    protected static String calculateDoseCohort(SubjectGroupDosing subjectGroupDosing) {
        if (CollectionUtils.isEmpty(subjectGroupDosing.getSchedule())) {
            return null;
        }

        StringBuilder sb = new StringBuilder();

        Boolean repeat = null;

        for (SubjectGroupDosingSchedule schedule : subjectGroupDosing.getSchedule()) {
            if (repeat != null) {
                if (repeat == schedule.isRepeat()) {
                    sb.append("; ");
                } else {
                    sb.append(" | ");
                }
            }

            if (schedule.isRepeat() && (repeat == null || repeat != schedule.isRepeat())) {
                sb.append("Cycle: ");
            }
            if (schedule.isDosing()) {
                sb.append("On ");
            } else {
                sb.append("Off ");
            }

            String optionalSeparator = "";
            if (schedule.getDuration() != null && schedule.getDuration() > 0) {
                sb.append(schedule.getDuration());
                if (!isEmpty(schedule.getDurationUnit())) {
                    sb.append(" ").append(schedule.getDurationUnit().toHumanString(schedule.getDuration()));
                }
                optionalSeparator = ", ";
            }

            if (schedule.isDosing()) {
                if (schedule.getDose() != null && schedule.getDose() > 0) {
                    sb.append(optionalSeparator).append(new DecimalFormat("#.###").format(schedule.getDose()));
                    if (!isEmpty(schedule.getDoseUnit())) {
                        sb.append(schedule.getDoseUnit());
                    }
                    optionalSeparator = ", ";
                }

                if ("Unknown".equals(schedule.getFrequencyTerm())) {
                    sb.append(optionalSeparator).append("Unknown frequency");
                } else if ("Other".equals(schedule.getFrequencyTerm()) || isEmpty(schedule.getFrequencyTerm())) {
                    sb.append(optionalSeparator)
                            .append(schedule.getFrequency() != null && schedule.getFrequency() > 0 ? schedule.getFrequency() : "?")
                            .append("-per-")
                            .append(!isEmpty(schedule.getFrequencyUnit()) ? schedule.getFrequencyUnit().toLowerCase() : "?");
                } else {
                    sb.append(optionalSeparator).append(schedule.getFrequencyTerm());
                }
            }


            repeat = schedule.isRepeat();
        }
        return sb.toString();
    }