Package org.openmrs.module.htmlformentry.widget

Examples of org.openmrs.module.htmlformentry.widget.DropdownWidget


            CheckboxWidget cb = new CheckboxWidget();
            cb.setLabel(displayText);
            cb.setValue(drugsUsedAsKey.get(0).getDrugId().toString());
            drugWidget = cb;
        } else {
            DropdownWidget dw = new DropdownWidget();
            dw.setOptions(options);
            drugWidget = dw;
        }
        context.registerWidget(drugWidget);
        drugErrorWidget = new ErrorWidget();
        context.registerErrorWidget(drugWidget, drugErrorWidget);

    //start date
    startDateWidget = new DateWidget();
        startDateErrorWidget = new ErrorWidget();
        context.registerWidget(startDateWidget);
        context.registerErrorWidget(startDateWidget, startDateErrorWidget);

        if (!hideDoseAndFrequency){
        // dose validation by drug is done in validateSubmission()
        doseWidget = new NumberFieldWidget(0d, 9999999d, true);
        //set default value (maybe temporarily)
        String defaultDoseStr = parameters.get(CONFIG_DEFAULT_DOSE);
        if (!StringUtils.isEmpty(defaultDoseStr)){
            try {
                defaultDose = Double.valueOf(defaultDoseStr);
                doseWidget.setInitialValue(defaultDose);
            } catch (Exception ex){
                    throw new RuntimeException("optional attribute 'defaultDose' must be numeric or empty.");
            }
        }

        doseErrorWidget = new ErrorWidget();
        context.registerWidget(doseWidget);
        context.registerErrorWidget(doseWidget, doseErrorWidget);

        createFrequencyWidget(context, mss);

        createFrequencyWeekWidget(context, mss);
        }

        if (!usingDurationField){
        discontinuedDateWidget = new DateWidget();
        discontinuedDateErrorWidget = new ErrorWidget();
        context.registerWidget(discontinuedDateWidget);
        context.registerErrorWidget(discontinuedDateWidget, discontinuedDateErrorWidget);
        }
    if (parameters.get(FIELD_DISCONTINUED_REASON) != null){
        String discReasonConceptStr = (String) parameters.get(FIELD_DISCONTINUED_REASON);
        Concept discontineReasonConcept = HtmlFormEntryUtil.getConcept(discReasonConceptStr);
        if (discontineReasonConcept == null)
            throw new IllegalArgumentException("discontinuedReasonConceptId is not set to a valid conceptId or concept UUID");
        dof.setDiscontinuedReasonQuestion(discontineReasonConcept);

        discontinuedReasonWidget = new DropdownWidget();
        discontinuedReasonErrorWidget = new ErrorWidget();

        List<Option> discOptions = new ArrayList<Option>();
        discOptions.add(new Option("", "", false));
View Full Code Here


   *
   * @param context
   * @param mss
   */
  protected void createFrequencyWeekWidget(FormEntryContext context, MessageSourceService mss) {
      frequencyWeekWidget = new DropdownWidget();
      frequencyWeekErrorWidget = new ErrorWidget();
      // fill frequency drop down lists (ENTER, EDIT)
      List<Option> weekOptions = new ArrayList<Option>();
      if (context.getMode() != Mode.VIEW ) {
        for (int i = 7; i >= 1; i--) {
View Full Code Here

   *
   * @param context
   * @param mss
   */
  protected void createFrequencyWidget(FormEntryContext context, MessageSourceService mss) {
      frequencyWidget = new DropdownWidget();
      frequencyErrorWidget = new ErrorWidget();
      // fill frequency drop down lists (ENTER, EDIT)
      List<Option> freqOptions = new ArrayList<Option>();
      if (context.getMode() != Mode.VIEW ) {
        for (int i = 1; i <= 10; i++) {
View Full Code Here

      createWidgets(context, nameWidget, nameErrorWidget,
          existingPatient != null && existingPatient.getPersonName() != null ? existingPatient.getPersonName() : null);
    }
    else if (FIELD_GENDER.equalsIgnoreCase(field)) {
      MessageSourceService msg = Context.getMessageSourceService();
      genderWidget = new DropdownWidget();
      genderErrorWidget = new ErrorWidget();
      genderWidget.addOption(new Option(msg.getMessage("Patient.gender.male"), "M", false));
      genderWidget.addOption(new Option(msg.getMessage("Patient.gender.female"), "F", false));
      createWidgets(context, genderWidget, genderErrorWidget, existingPatient != null ? existingPatient.getGender() : null);
    }
    else if (FIELD_AGE.equalsIgnoreCase(field)) {
      ageWidget = new NumberFieldWidget(0d, 200d, false);
      ageErrorWidget = new ErrorWidget();
      createWidgets(context, ageWidget, ageErrorWidget, existingPatient != null ? existingPatient.getAge() : null);
    }
    else if (FIELD_BIRTH_DATE.equalsIgnoreCase(field)) {
      birthDateWidget = new DateWidget();
      birthDateErrorWidget = new ErrorWidget();
      createWidgets(context, birthDateWidget, birthDateErrorWidget, existingPatient != null ? existingPatient.getBirthdate() : null);
    }
    else if (FIELD_BIRTH_DATE_OR_AGE.equalsIgnoreCase(field)) {
      ageWidget = new NumberFieldWidget(0d, 200d, false);
      ageErrorWidget = new ErrorWidget();
      createWidgets(context, ageWidget, ageErrorWidget, existingPatient != null ? existingPatient.getAge() : null);

      birthDateWidget = new DateWidget();
      birthDateErrorWidget = new ErrorWidget();
      createWidgets(context, birthDateWidget, birthDateErrorWidget, existingPatient != null ? existingPatient.getBirthdate() : null);

    }
    else if (FIELD_IDENTIFIER.equalsIgnoreCase(field)) {

      PatientIdentifierType idType = HtmlFormEntryUtil.getPatientIdentifierType(attributes.get("identifierTypeId"));
     
      identifierTypeValueWidget = new TextFieldWidget();
      identifierTypeValueErrorWidget = new ErrorWidget();
      String initialValue = null;
      if (existingPatient != null) {
        if (idType == null) {
          if (existingPatient.getPatientIdentifier() != null) {
            initialValue = existingPatient.getPatientIdentifier().getIdentifier();
          }
        } else {
          if (existingPatient.getPatientIdentifier(idType) != null) {
            initialValue = existingPatient.getPatientIdentifier(idType).getIdentifier();
          }
        }
      }
      createWidgets(context, identifierTypeValueWidget, identifierTypeValueErrorWidget, initialValue);

      if (idType != null) {
        identifierTypeWidget = new HiddenFieldWidget();
        createWidgets(context, identifierTypeWidget, null, idType.getId().toString());
      }
      else {
        identifierTypeWidget = new DropdownWidget();
        List<PatientIdentifierType> patientIdentifierTypes = HtmlFormEntryUtil.getPatientIdentifierTypes();

        for (PatientIdentifierType patientIdentifierType : patientIdentifierTypes) {
          ((DropdownWidget) identifierTypeWidget).addOption(new Option(patientIdentifierType.getName(), patientIdentifierType
              .getPatientIdentifierTypeId().toString(), false));
        }

        createWidgets(context, identifierTypeWidget, null,
            existingPatient != null && existingPatient.getPatientIdentifier() != null ? existingPatient.getPatientIdentifier()
                .getIdentifierType().getId() : null);
      }
    }
    else if (FIELD_IDENTIFIER_LOCATION.equalsIgnoreCase(field)) {
      identifierLocationWidget = new DropdownWidget();
      identifierLocationErrorWidget = new ErrorWidget();

            Location defaultLocation = existingPatient != null
          && existingPatient.getPatientIdentifier() != null ? existingPatient.getPatientIdentifier().getLocation() : null;
      defaultLocation = defaultLocation == null ? context.getDefaultLocation() : defaultLocation;
View Full Code Here

    prepareWidgets(context, parameters);
  }


    private Widget buildDropdownWidget(Integer size){
        Widget dropdownWidget = new DropdownWidget(size);
        if(size==1 || !required){
            // show an empty option when size =1, even if required =true
            ((DropdownWidget) dropdownWidget).addOption(new Option());
        }
        return dropdownWidget;
View Full Code Here

        }

                // configure the special obs type that allows selection of a location (the location_id PK is stored as the valueText)
        if (isLocationObs) {

                    valueWidget = new DropdownWidget();
                    // if "answerLocationTags" attribute is present try to get locations by tags
                    List<Location> locationList = HtmlFormEntryUtil.getLocationsByTags(HtmlFormEntryConstants.ANSWER_LOCATION_TAGS, parameters);
                    if ((locationList == null) ||
                            (locationList != null && locationList.size()<1)){
                        // if no locations by tags are found then get all locations
                        locationList = Context.getLocationService().getAllLocations();
                    }

                    for (Location location : locationList) {
                            String label = HtmlFormEntryUtil.format(location);
                            Option option = new Option(label, location.getId().toString(), location.getId().toString().equals(initialValue));
                            locationOptions.add(option);
                       }
                    Collections.sort(locationOptions, new OptionComparator());

                    // if initialValueIsSet=false, no initial/default location, hence this shows the 'select input' field as first option
                    boolean initialValueIsSet = !(initialValue == null);
                    ((DropdownWidget)valueWidget).addOption(new Option(Context.getMessageSourceService().getMessage("htmlformentry.chooseALocation"),"",!initialValueIsSet));
                    if (!locationOptions.isEmpty()) {
                        for(Option option: locationOptions)
                            ((DropdownWidget)valueWidget).addOption(option);
                    }

        } else if ("person".equals(parameters.get("style"))) {
         
          List<PersonStub> options = new ArrayList<PersonStub>();
                    List<Option> personOptions = new ArrayList<Option>();
         
          // If specific persons are specified, display only those persons in order
          String personsParam = (String) parameters.get("persons");
          if (personsParam != null) {
            for (String s : personsParam.split(",")) {
              Person p = HtmlFormEntryUtil.getPerson(s);
              if (p == null) {
                throw new RuntimeException("Cannot find Person: " + s);
              }
              options.add(new PersonStub(p));
            }
          }
         
          // Only if specific person ids are not passed in do we get by user Role
          if (options.isEmpty()) {
           
            List<PersonStub> users = new ArrayList<PersonStub>();
           
            // If the "role" attribute is passed in, limit to users with this role
            if (parameters.get("role") != null) {
              Role role = Context.getUserService().getRole((String) parameters.get("role"));
              if (role == null) {
                throw new RuntimeException("Cannot find role: " + parameters.get("role"));
              } else {
                users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(role.getRole());
              }
            }

            // Otherwise, limit to users with the default OpenMRS PROVIDER role,
            else {
              String defaultRole = OpenmrsConstants.PROVIDER_ROLE;
              Role role = Context.getUserService().getRole(defaultRole);
              if (role != null) {
                users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(role.getRole());
              }
              // If this role isn't used, default to all Users
              if (users.isEmpty()) {
                users = Context.getService(HtmlFormEntryService.class).getUsersAsPersonStubs(null);
              }
            }
            options.addAll(users);
            //              sortOptions = true;
          }

          valueWidget = new PersonStubWidget(options);

        } else {
          if (textAnswers.size() == 0) {
            Integer rows = null;
            Integer cols = null;
            try {
              rows = Integer.valueOf(parameters.get("rows"));
            }
            catch (Exception ex) {}
            try {
              cols = Integer.valueOf(parameters.get("cols"));
            }
            catch (Exception ex) {}
            if (rows != null || cols != null || "textarea".equals(parameters.get("style"))) {
              valueWidget = new TextFieldWidget(rows, cols);
            } else {
              Integer textFieldSize = null;
              try {
                                textFieldSize = Integer.valueOf(parameters.get("size"));
              }
              catch (Exception ex) {}
              valueWidget = new TextFieldWidget(textFieldSize);
            }
                        ((TextFieldWidget) valueWidget).setPlaceholder(parameters.get("placeholder"));
                    } else {
            if ("radio".equals(parameters.get("style"))) {
              valueWidget = new RadioButtonsWidget();
              if (answerSeparator != null) {
                ((RadioButtonsWidget) valueWidget).setAnswerSeparator(answerSeparator);
                            }
            } else { // dropdown
              valueWidget =buildDropdownWidget(size);
            }
            // need to make sure we have the initialValue too
            String lookFor = existingObs == null ? null : existingObs.getValueText();
            for (int i = 0; i < textAnswers.size(); ++i) {
              String s = textAnswers.get(i);
              if (lookFor != null && lookFor.equals(s))
                lookFor = null;
              String label = null;
              if (answerLabels != null && i < answerLabels.size()) {
                label = answerLabels.get(i);
              } else {
                label = s;
              }
              ((SingleOptionWidget) valueWidget).addOption(new Option(label, s, false));
            }
            // if lookFor is still non-null, we need to add it directly
            // as an option:
            if (lookFor != null)
              ((SingleOptionWidget) valueWidget).addOption(new Option(lookFor, lookFor, true));
          }
        }

        if (initialValue != null) {
          if (isLocationObs) {
            Location l = HtmlFormEntryUtil.getLocation(initialValue, context);
            if (l == null) {
              throw new RuntimeException("Cannot find Location: " + initialValue);
            }
            valueWidget.setInitialValue(l);
          } else if ("person".equals(parameters.get("style"))) {
            Person p = HtmlFormEntryUtil.getPerson(initialValue);
            if (p == null) {
              throw new RuntimeException("Cannot find Person: " + initialValue);
            }
            valueWidget.setInitialValue(new PersonStub(p));
          } else {
            valueWidget.setInitialValue(initialValue);
          }
        }
      } else if (concept.getDatatype().isCoded()) {
        if (parameters.get("answerConceptIds") != null) {
          try {
            for (StringTokenizer st = new StringTokenizer(parameters.get("answerConceptIds"), ","); st
                    .hasMoreTokens();) {
              Concept c = HtmlFormEntryUtil.getConcept(st.nextToken());
              if (c == null)
                throw new RuntimeException("Cannot find concept " + st.nextToken());
              conceptAnswers.add(c);
            }
          }
          catch (Exception ex) {
            throw new RuntimeException("Error in answer list for concept " + concept.getConceptId() + " ("
                    + ex.toString() + "): " + conceptAnswers);
          }
        } else if (parameters.get("answerClasses") != null && !"autocomplete".equals(parameters.get("style"))) {
          try {
            for (StringTokenizer st = new StringTokenizer(parameters.get("answerClasses"), ","); st
                    .hasMoreTokens();) {
              String className = st.nextToken().trim();
              ConceptClass cc = Context.getConceptService().getConceptClassByName(className);
              if (cc == null) {
                throw new RuntimeException("Cannot find concept class " + className);
              }
              conceptAnswers.addAll(Context.getConceptService().getConceptsByClass(cc));
            }
            Collections.sort(conceptAnswers, conceptNameComparator);
          }
          catch (Exception ex) {
            throw new RuntimeException("Error in answer class list for concept " + concept.getConceptId() + " ("
                    + ex.toString() + "): " + conceptAnswers);
          }
        }
       
        if (answerConcept != null) {
          // if there's also an answer concept specified, this is a single
          // checkbox
          answerLabel = parameters.get("answerLabel");
          if (answerLabel == null) {
            String answerCode = parameters.get("answerCode");
            if (answerCode != null) {
              answerLabel = context.getTranslator().translate(userLocaleStr, answerCode);
            } else {
              answerLabel = answerConcept.getBestName(Context.getLocale()).getName();
            }
          }
          valueWidget = new CheckboxWidget(answerLabel, answerConcept.getConceptId().toString());
          if (existingObsList != null && !existingObsList.isEmpty()) {
            for (int i = 0; i < existingObsList.size(); i++) {
              ((DynamicAutocompleteWidget)valueWidget).addInitialValue(existingObsList.get(i).getValueCoded());
            }
          } else if (existingObs != null) {
            valueWidget.setInitialValue(existingObs.getValueCoded());
          } else if (defaultValue != null && Mode.ENTER.equals(context.getMode())) {
            Concept initialValue = HtmlFormEntryUtil.getConcept(defaultValue);
            if (initialValue == null) {
              throw new IllegalArgumentException("Invalid default value. Cannot find concept: " + defaultValue);
            }
            if (!answerConcept.equals(initialValue)) {
              throw new IllegalArgumentException("Invalid default value: " + defaultValue
                      + ". The only allowed answer is: " + answerConcept.getId());
            }
            valueWidget.setInitialValue(initialValue);
          }
        } else if ("true".equals(parameters.get("multiple"))) {
          // if this is a select-multi, we need a group of checkboxes
          throw new RuntimeException("Multi-select coded questions are not yet implemented");
        } else {
          // allow selecting one of multiple possible coded values
         
          // if no answers are specified explicitly (by conceptAnswers or conceptClasses), get them from concept.answers.
          if (!parameters.containsKey("answerConceptIds") && !parameters.containsKey("answerClasses") && !parameters.containsKey("answerDrugs")) {
            conceptAnswers = new ArrayList<Concept>();
            for (ConceptAnswer ca : concept.getAnswers(false)) {
              conceptAnswers.add(ca.getAnswerConcept());
            }
            Collections.sort(conceptAnswers, conceptNameComparator);
          }
         
          if ("autocomplete".equals(parameters.get("style"))) {
            List<ConceptClass> cptClasses = new ArrayList<ConceptClass>();
            if (parameters.get("answerClasses") != null) {
              for (StringTokenizer st = new StringTokenizer(parameters.get("answerClasses"), ","); st
                      .hasMoreTokens();) {
                String className = st.nextToken().trim();
                ConceptClass cc = Context.getConceptService().getConceptClassByName(className);
                cptClasses.add(cc);
              }
            }
            if ((conceptAnswers == null || conceptAnswers.isEmpty())
                    && (cptClasses == null || cptClasses.isEmpty())) {
              throw new RuntimeException(
                      "style \"autocomplete\" but there are no possible answers. Looked for answerConcepts and answerClasses attributes, and answers for concept "
                              + concept.getConceptId());
            }
            if ("true".equals(parameters.get("selectMulti"))) {
              valueWidget = new DynamicAutocompleteWidget(conceptAnswers, cptClasses);
                        }
                        else {
                valueWidget = new ConceptSearchAutocompleteWidget(conceptAnswers, cptClasses);
                        }
                    } else if (parameters.get("answerDrugs") != null) {
                        // we support searching through all drugs via AJAX
                        RemoteJsonAutocompleteWidget widget = new RemoteJsonAutocompleteWidget("/" + WebConstants.WEBAPP_NAME + "/module/htmlformentry/drugSearch.form");
                        widget.setValueTemplate("Drug:{{id}}");
                        if (parameters.get("displayTemplate") != null) {
                            widget.setDisplayTemplate(parameters.get("displayTemplate"));
                        } else {
                            widget.setDisplayTemplate("{{name}}");
                        }
                        if (existingObs != null && existingObs.getValueDrug() != null) {
                            widget.setInitialValue(new Option(existingObs.getValueDrug().getName(), existingObs.getValueDrug().getDrugId().toString(), true));
                        }
                        valueWidget = widget;

                    } else {
                  // Show Radio Buttons if specified, otherwise default to Drop
            // Down
            boolean isRadio = "radio".equals(parameters.get("style"));
            if (isRadio) {
              valueWidget = new RadioButtonsWidget();
              if (answerSeparator != null) {
                ((RadioButtonsWidget) valueWidget).setAnswerSeparator(answerSeparator);
                            }
            } else {
              valueWidget = buildDropdownWidget(size);
            }
            for (int i = 0; i < conceptAnswers.size(); ++i) {
              Concept c = conceptAnswers.get(i);
              String label = null;
              if (answerLabels != null && i < answerLabels.size()) {
                label = answerLabels.get(i);
              } else {
                label = c.getBestName(Context.getLocale()).getName();
              }
              ((SingleOptionWidget) valueWidget).addOption(new Option(label, c.getConceptId().toString(),
                      false));
            }
          }
          if (existingObsList != null && !existingObsList.isEmpty()) {
            for (int i = 0; i < existingObsList.size(); i++) {
              ((DynamicAutocompleteWidget)valueWidget).addInitialValue(existingObsList.get(i).getValueCoded());
            }
          }
          if (existingObs != null) {
                        if (existingObs.getValueDrug() != null) {
                            valueWidget.setInitialValue(existingObs.getValueDrug());
                        } else {
                            valueWidget.setInitialValue(existingObs.getValueCoded());
                        }
                    } else if (defaultValue != null && Mode.ENTER.equals(context.getMode())) {
            Concept initialValue = HtmlFormEntryUtil.getConcept(defaultValue);
            if (initialValue == null) {
              throw new IllegalArgumentException("Invalid default value. Cannot find concept: " + defaultValue);
            }
           
            if (!conceptAnswers.contains(initialValue)) {
              String allowedIds = "";
              for (Concept conceptAnswer : conceptAnswers) {
                allowedIds += conceptAnswer.getId() + ", ";
              }
              allowedIds = allowedIds.substring(0, allowedIds.length() - 2);
              throw new IllegalArgumentException("Invalid default value: " + defaultValue
                      + ". The only allowed answers are: " + allowedIds);
            }
            valueWidget.setInitialValue(initialValue);
          }
        }
      } else if (concept.getDatatype().isBoolean()) {
        String noStr = parameters.get("noLabel");
        if (StringUtils.isEmpty(noStr)) {
          noStr = context.getTranslator().translate(userLocaleStr, "general.no");
        }
        String yesStr = parameters.get("yesLabel");
        if (StringUtils.isEmpty(yesStr)) {
          yesStr = context.getTranslator().translate(userLocaleStr, "general.yes");
        }
       
        if ("checkbox".equals(parameters.get("style"))) {
          if (parameters.get("toggle") != null) {
            ToggleWidget toggleWidget = new ToggleWidget(parameters.get("toggle"));
            valueWidget = new CheckboxWidget(valueLabel, parameters.get("value") != null ? parameters.get("value") : "true", toggleWidget.getTargetId(), toggleWidget.isToggleDim());
          } else {
            valueWidget = new CheckboxWidget(valueLabel, parameters.get("value") != null ? parameters.get("value") : "true", parameters.get("toggle"));
          }
          valueLabel = "";
        } else if ("no_yes".equals(parameters.get("style"))) {
          valueWidget = new RadioButtonsWidget();
          ((RadioButtonsWidget) valueWidget).addOption(new Option(noStr, "false", false));
          ((RadioButtonsWidget) valueWidget).addOption(new Option(yesStr, "true", false));
        } else if ("yes_no".equals(parameters.get("style"))) {
          valueWidget = new RadioButtonsWidget();
          ((RadioButtonsWidget) valueWidget).addOption(new Option(yesStr, "true", false));
          ((RadioButtonsWidget) valueWidget).addOption(new Option(noStr, "false", false));
        } else if ("no_yes_dropdown".equals(parameters.get("style"))) {
          valueWidget = new DropdownWidget();
          ((DropdownWidget) valueWidget).addOption(new Option());
          ((DropdownWidget) valueWidget).addOption(new Option(noStr, "false", false));
          ((DropdownWidget) valueWidget).addOption(new Option(yesStr, "true", false));
        } else if ("yes_no_dropdown".equals(parameters.get("style"))) {
          valueWidget = new DropdownWidget();
          ((DropdownWidget) valueWidget).addOption(new Option());
          ((DropdownWidget) valueWidget).addOption(new Option(yesStr, "true", false));
          ((DropdownWidget) valueWidget).addOption(new Option(noStr, "false", false));
        } else {
          throw new RuntimeException("Boolean with style = " + parameters.get("style")
View Full Code Here

            conceptLabels = Arrays.asList(parameters.get("conceptLabels").split(","));
        }
        if ("radio".equals(parameters.get("style"))) {
            valueWidget = new RadioButtonsWidget();
        } else { // dropdown
            valueWidget = new DropdownWidget();
            ((DropdownWidget) valueWidget).addOption(new Option());
        }
        for (int i = 0; i < concepts.size(); ++i) {
            Concept c = concepts.get(i);
            String label = null;
View Full Code Here

        Patient patient = context.getExistingPatient();

        dateWidget = new DateWidget();
        dateErrorWidget = new ErrorWidget();

        reasonForExitWidget = new DropdownWidget();
        reasonForExitErrorWidget = new ErrorWidget();

        causeOfDeathWidget = new DropdownWidget();
        causeOfDeathErrorWidget = new ErrorWidget();

        otherReasonWidget = new TextFieldWidget();
        otherReasonErrorWidget = new ErrorWidget();
View Full Code Here

      Entry<String, ProgramWorkflowState> state = states.entrySet().iterator().next();
      widget = new CheckboxWidget(state.getKey(), state.getValue().getUuid());
    } else {
      SingleOptionWidget singleOption;
      if (tagParams.getType().equals("dropdown")) {
        singleOption = new DropdownWidget();
        singleOption.addOption(new Option("", "", false));
      } else {
        singleOption = new RadioButtonsWidget();
      }
     
View Full Code Here

        possibleRegimens.add(rs);
      } else {
        throw new IllegalArgumentException("standardRegimen tag can't find regimen code " + regCode + " found in regimenCodes attribute in global property " + STANDARD_REGIMEN_GLOBAL_PROPERTY);
      }
    } 
    DropdownWidget dw = new DropdownWidget();
        dw.setOptions(options);
        regWidget = dw;
        context.registerWidget(regWidget);
        regErrorWidget = new ErrorWidget();
        context.registerErrorWidget(regWidget, regErrorWidget);
       
        //start date
        startDateWidget = new DateWidget();
        startDateErrorWidget = new ErrorWidget();
        context.registerWidget(startDateWidget);
        context.registerErrorWidget(startDateWidget, startDateErrorWidget);
       
        //end date
        discontinuedDateWidget = new DateWidget();
    discontinuedDateErrorWidget = new ErrorWidget();
    context.registerWidget(discontinuedDateWidget);
    context.registerErrorWidget(discontinuedDateWidget, discontinuedDateErrorWidget);
   
    //discontinue reasons
    if (parameters.get(FIELD_DISCONTINUED_REASON) != null){
        String discReasonConceptStr = (String) parameters.get(FIELD_DISCONTINUED_REASON);
        Concept discontineReasonConcept = HtmlFormEntryUtil.getConcept(discReasonConceptStr);
        if (discontineReasonConcept == null)
            throw new IllegalArgumentException("discontinuedReasonConceptId is not set to a valid conceptId or concept UUID");
        srf.setDiscontinuedReasonQuestion(discontineReasonConcept);
       
        discontinuedReasonWidget = new DropdownWidget();
        discontinuedReasonErrorWidget = new ErrorWidget();
       
        List<Option> discOptions = new ArrayList<Option>();
        discOptions.add(new Option("", "", false));
       
View Full Code Here

TOP

Related Classes of org.openmrs.module.htmlformentry.widget.DropdownWidget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.