/** * Returns true if at least one output parameter has a value. * * @return True if we have at least one output parameter value; */ private boolean hasSomeOrAllOutputParameterValues() { InstrumentType instrumentType = getInstrumentType(); if (instrumentType.isRepeatable()) { return haveSomeOrAllRepeatingOutputParameterValues(); } else { return haveSomeOrAllNonRepeatableOutputParameterValues(); } }
private List<InstrumentOutputParameter> getOutputParametersOriginallyMarkedForManualCapture() { List<InstrumentOutputParameter> result = new ArrayList<InstrumentOutputParameter>(); InstrumentType instrumentType = (InstrumentType) getModelObject(); List<InstrumentOutputParameter> outputParams = instrumentType.getOutputParameters(InstrumentParameterCaptureMethod.MANUAL); for (InstrumentOutputParameter param : outputParams) { if (!param.isManualCaptureAllowed()) { result.add(param); } } return result; }
private boolean haveSomeOrAllNonRepeatableOutputParameterValues() { InstrumentType instrumentType = getInstrumentType(); InstrumentRun instrumentRun = activeInstrumentRunService.getInstrumentRun(); for (InstrumentOutputParameter instrumentOutputParameter : instrumentType.getOutputParameters()) { InstrumentRunValue instrumentRunValue = instrumentRun.getInstrumentRunValue(instrumentOutputParameter); if (instrumentRunValue != null) { if (instrumentRunValue.getData(instrumentOutputParameter.getDataType()).getValue() != null) return true; } } return false; // No values found }
private boolean isEnableNextLink(WizardForm form) { InstrumentType instrumentType = activeInstrumentRunService.getInstrumentType(); if (instrumentType.isRepeatable()) { // minimum is having the expected count of repeatable measures int currentCount = activeInstrumentRunService.getInstrumentRun().getValidMeasureCount(); int expectedCount = instrumentType.getExpectedMeasureCount(activeInstrumentRunService.getParticipant()); boolean skipped = ((InstrumentOutputParameterPanel) get(getContentId())).isSkipMeasurement(); if (currentCount < expectedCount && !skipped) { return false; } else { return true; } } else { return true; } }
private boolean haveSomeOrAllRepeatingOutputParameterValues() { InstrumentType instrumentType = getInstrumentType(); InstrumentRun instrumentRun = activeInstrumentRunService.getInstrumentRun(); Participant participant = activeInstrumentRunService.getParticipant(); if (instrumentType.getExpectedMeasureCount(participant) == 0) return false; // No values for (Measure measure : instrumentRun.getMeasures()) { InstrumentRun measureInstrumentRun = measure.getInstrumentRun(); for (InstrumentOutputParameter instrumentOutputParameter : instrumentType.getOutputParameters()) { InstrumentRunValue instrumentRunValue = measureInstrumentRun.getInstrumentRunValue(instrumentOutputParameter); if (instrumentRunValue != null) { if (instrumentRunValue.getData(instrumentOutputParameter.getDataType()).getValue() != null) return true; } } } return false; // No values found }
public InstrumentWizardForm(String id, IModel<InstrumentType> instrumentTypeModel) { super(id, instrumentTypeModel); // Add Interrupt button. add(createInterrupt()); InstrumentType type = (InstrumentType) instrumentTypeModel.getObject(); log.debug("instrumentType={}", type.getName()); observedContraIndicationStep = new ObservedContraIndicationStep(getStepId()); askedContraIndicationStep = new AskedContraIndicationStep(getStepId()); instrumentSelectionStep = new InstrumentSelectionStep(getStepId(), instrumentTypeModel); noInstrumentAvailableStep = new NoInstrumentAvailableStep(getStepId()); inputParametersStep = new InputParametersStep(getStepId()); instrumentLaunchStep = new InstrumentLaunchStep(getStepId()); conclusionStep = new ConclusionStep(getStepId()); warningStep = new WarningsStep(getStepId()); outputParametersStep = new OutputParametersStep(getStepId(), conclusionStep, warningStep); warningStep.setNextStep(conclusionStep); warningStep.setPreviousStep(outputParametersStep); createModalAdministrationPanel(); // admin button AjaxLink link = new AjaxLink("adminLink") { private static final long serialVersionUID = 0L; @Override public void onClick(AjaxRequestTarget target) { adminWindow.setInterruptState(getInterruptLink().isEnabled()); if (getCancelLink() != null) adminWindow.setCancelState(getCancelLink().isEnabled()); adminWindow.show(target); } }; link.add( new AttributeModifier( "value", true, new StringResourceModel("Administration", this, null))); link.add(new AttributeAppender("class", new Model("ui-corner-all"), " ")); add(link); }
/** * Returns true if at least one interpretive parameter has a value. * * @return True if we have at least one interpretive parameter value. */ private boolean hasSomeOrAllInterpretiveParameterValues() { InstrumentType instrumentType = getInstrumentType(); InstrumentRun instrumentRun = activeInstrumentRunService.getInstrumentRun(); for (InterpretativeParameter interpretiveParameter : instrumentType.getInterpretativeParameters()) { InstrumentRunValue instrumentRunValue = instrumentRun.getInstrumentRunValue(interpretiveParameter); if (instrumentRunValue != null) { if (instrumentRunValue.getData(interpretiveParameter.getDataType()).getValue() != null) return true; } } for (InstrumentInputParameter instrumentInputParameter : instrumentType.getInputParameters(false)) { InstrumentRunValue instrumentRunValue = instrumentRun.getInstrumentRunValue(instrumentInputParameter); if (instrumentRunValue != null) { if (instrumentRunValue.getData(instrumentInputParameter.getDataType()).getValue() != null) return true; } } return false; }
/** * Determines the step to be displayed when resuming the stage. * * @return The step to resume to. */ private WizardStepPanel getStepWhenResuming() { WizardStepPanel resumingStartStep = null; List<Instrument> activeInstrumentsForCurrentWorkstation = instrumentService.getActiveInstrumentsAssignedToCurrentWorkstation( (InstrumentType) getModelObject()); if (activeInstrumentsForCurrentWorkstation.size() == 0 || activeInstrumentsForCurrentWorkstation.size() > 1) { // The user must select an instrument for the measure. return null; } InstrumentType instrumentType = getInstrumentType(); if (hasSomeOrAllOutputParameterValues()) { log.info("Has all output values."); if (getOutputParametersOriginallyMarkedForManualCapture().size() > 0) { log.info("Resume at outputParametersStep."); resumingStartStep = outputParametersStep; } else { log.info("Resume at instrumentLaunchStep."); resumingStartStep = instrumentLaunchStep; } } else { if (instrumentType.hasInterpretativeParameter() || instrumentType.hasInputParameter(false)) { if (hasSomeOrAllInterpretiveParameterValues()) { log.info("Resume at inputParametersStep."); resumingStartStep = inputParametersStep; } else { if (activeInstrumentRunService.hasContraindications(Contraindication.Type.OBSERVED)) { log.info("Resume at observedContraIndicationStep."); resumingStartStep = observedContraIndicationStep; } else if (activeInstrumentRunService.hasContraindications(Contraindication.Type.ASKED)) { log.info("Resume at askedContraIndicationStep."); resumingStartStep = askedContraIndicationStep; } else { log.info("Resume at inputParametersStep."); resumingStartStep = inputParametersStep; } } } else { if (activeInstrumentRunService.hasContraindications(Contraindication.Type.OBSERVED)) { log.info("Resume at observedContraIndicationStep."); resumingStartStep = observedContraIndicationStep; } else if (activeInstrumentRunService.hasContraindications(Contraindication.Type.ASKED)) { log.info("Resume at askedContraIndicationStep."); resumingStartStep = askedContraIndicationStep; } else { if (getOutputParametersOriginallyMarkedForManualCapture().size() > 0) { log.info("Resume at outputParametersStep."); resumingStartStep = outputParametersStep; } else { log.info("Resume at instrumentLaunchStep."); resumingStartStep = instrumentLaunchStep; } } } } log.info("Set resumingStartStep to [{}].", resumingStartStep); return resumingStartStep; }
public WizardStepPanel setUpWizardFlow(WizardStepPanel startStepWhenResuming) { boolean resuming = startStepWhenResuming != null; WizardStepPanel startStep = startStepWhenResuming; WizardStepPanel lastStep = null; List<Instrument> activeInstrumentsForCurrentWorkstation = instrumentService.getActiveInstrumentsForCurrentWorkstation(getInstrumentType()); log.debug("instruments.count={}", activeInstrumentsForCurrentWorkstation.size()); if (activeInstrumentsForCurrentWorkstation.size() == 0) { log.debug("activeInstrumentsForCurrentWorkstation.size() == 0"); startStep = noInstrumentAvailableStep; lastStep = startStep; } else if (activeInstrumentsForCurrentWorkstation.size() > 1) { log.debug("activeInstrumentsForCurrentWorkstation.size() > 1"); // Found too many instruments of the correct type. // Prompt the user to enter the instrument they will be using for this measure. if (startStep == null || startStep.equals(instrumentSelectionStep)) { startStep = instrumentSelectionStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(instrumentSelectionStep); } instrumentSelectionStep.setPreviousStep(lastStep); lastStep = instrumentSelectionStep; } instrumentSelected = true; } else { log.debug("activeInstrumentsForCurrentWorkstation.size() == 1"); // A single instrument of the correct type is associated with this workstation. if (resuming) { log.debug( "Resuming an InstrumentRun with the instrument type [" + getInstrumentType().getName() + "] and barcode [" + activeInstrumentsForCurrentWorkstation.get(0).getBarcode() + "]."); activeInstrumentRunService.setInstrument(activeInstrumentsForCurrentWorkstation.get(0)); } else { log.debug("Not resuming, instrumentSelected={}", instrumentSelected); if (!instrumentSelected) { log.debug( "Starting a new InstrumentRun with the instrument type [" + getInstrumentType().getName() + "] and barcode [" + activeInstrumentsForCurrentWorkstation.get(0).getBarcode() + "]."); activeInstrumentRunService.start( activeInterviewService.getParticipant(), activeInstrumentsForCurrentWorkstation.get(0), getInstrumentType()); instrumentSelected = true; } } } // are there observed contra-indications to display ? if (hasContraindications(Contraindication.Type.OBSERVED)) { if (startStep == null || startStep.equals(observedContraIndicationStep)) { startStep = observedContraIndicationStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(observedContraIndicationStep); } observedContraIndicationStep.setPreviousStep(lastStep); lastStep = observedContraIndicationStep; } } else { log.debug("No contraindications of type OBSERVED. Skipping step."); } // are there asked contra-indications to display ? if (hasContraindications(Contraindication.Type.ASKED)) { if (startStep == null || startStep.equals(askedContraIndicationStep)) { startStep = askedContraIndicationStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(askedContraIndicationStep); } askedContraIndicationStep.setPreviousStep(lastStep); lastStep = askedContraIndicationStep; } } else { log.debug("No contraindications of type ASKED. Skipping step."); } // are there input parameters with input source that requires user provisioning ? // or interpretative questions InstrumentType instrumentType = (InstrumentType) getModelObject(); log.debug( "instrumentInterpretativeParameters.count={}", instrumentType.getInterpretativeParameters().size()); log.debug("instrumentInputParameters.count={}", instrumentType.getInputParameters(false)); if (instrumentType.hasInterpretativeParameter() || instrumentType.hasInputParameter(false)) { if (startStep == null || startStep.equals(inputParametersStep)) { startStep = inputParametersStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(inputParametersStep); } inputParametersStep.setPreviousStep(lastStep); lastStep = inputParametersStep; } } // are there output parameters that are to be captured automatically from instrument (i.e. // requires instrument // launch) ? log.debug("instrument.isInteractive={}", instrumentType.isInteractive()); if (instrumentType.isInteractive()) { if (startStep == null || startStep.equals(instrumentLaunchStep)) { startStep = instrumentLaunchStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(instrumentLaunchStep); } instrumentLaunchStep.setPreviousStep(lastStep); lastStep = instrumentLaunchStep; } } // are there output parameters that are to be captured manually from instrument ? log.debug( "instrumentOutputParameters.MANUAL.count={}", instrumentType.getOutputParameters(InstrumentParameterCaptureMethod.MANUAL).size()); if (getOutputParametersOriginallyMarkedForManualCapture().size() > 0) { if (startStep == null || startStep.equals(outputParametersStep)) { startStep = outputParametersStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(outputParametersStep); } outputParametersStep.setPreviousStep(lastStep); lastStep = outputParametersStep; } } // validation: final step if (startStep == null) { startStep = conclusionStep; lastStep = startStep; } else { if (lastStep != null) { lastStep.setNextStep(conclusionStep); } conclusionStep.setPreviousStep(lastStep); lastStep = conclusionStep; } return startStep; }