Examples of ErrorWidget


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

            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));

        if (parameters.get(FIELD_DISCONTINUED_REASON_ANSWERS) != null){
            //setup a list of the reason concepts
            List<Concept> discReasons = new ArrayList<Concept>();
            String discAnswersString = (String) parameters.get(FIELD_DISCONTINUED_REASON_ANSWERS);
            String[] strDiscAnswers = discAnswersString.split(",");
            for (int i = 0; i < strDiscAnswers.length; i++){
                String thisAnswer = strDiscAnswers[i];
                Concept answer = HtmlFormEntryUtil.getConcept(thisAnswer, "discontinueReasonAnswers includes a value that is not a valid conceptId or concept UUID");
                  discReasons.add(answer);
            }

            if (parameters.get(FIELD_DISCONTINUED_REASON_ANSWER_LABELS) != null){
                // use the listed discontinueReasons, and use labels:
                String discLabelsString = parameters.get(FIELD_DISCONTINUED_REASON_ANSWER_LABELS);
                String[] strDiscAnswerLabels = discLabelsString.split(",");
                //a little validation:
                if (strDiscAnswerLabels.length != discReasons.size())
                    throw new RuntimeException("discontinueReasonAnswers and discontinueReasonAnswerLabels must contain the same number of members.");
                for (int i = 0; i < strDiscAnswerLabels.length; i ++ ){
                    discOptions.add(new Option( strDiscAnswerLabels[i], discReasons.get(i).getConceptId().toString(),false));
                    dof.addDiscontinuedReasonAnswer(new ObsFieldAnswer(strDiscAnswerLabels[i].trim(), discReasons.get(i)));
                }
            } else {
                // use the listed discontinueReasons, and use their ConceptNames.
                for (Concept c: discReasons){
                    discOptions.add(new Option( c.getBestName(Context.getLocale()).getName(), c.getConceptId().toString(),false));
                    dof.addDiscontinuedReasonAnswer(new ObsFieldAnswer(c.getBestName(Context.getLocale()).getName(), c));
                }
            }
        } else {
            //just use the conceptAnswers
            for (ConceptAnswer ca : discontineReasonConcept.getAnswers()){
                discOptions.add(new Option( ca.getAnswerConcept().getBestName(Context.getLocale()).getName(), ca.getAnswerConcept().getConceptId().toString(),false));
                dof.addDiscontinuedReasonAnswer(new ObsFieldAnswer(ca.getAnswerConcept().getBestName(Context.getLocale()).getName(), ca.getAnswerConcept()));
            }
        }
        if (discOptions.size() == 1)
            throw new IllegalArgumentException("discontinue reason Concept doesn't have any ConceptAnswers");

        discontinuedReasonWidget.setOptions(discOptions);
        context.registerWidget(discontinuedReasonWidget);
          context.registerErrorWidget(discontinuedReasonWidget, discontinuedReasonErrorWidget);
    }
   
    createAdditionalWidgets(context);
   
    if (context.getMode() != Mode.ENTER && context.getExistingOrders() != null) {
      // If VIEW, EDIT
      populateDrugOrderValuesFromDB(context, usingDurationField);
    }

        instructionsLabel = parameters.get(FIELD_INSTRUCTIONS_LABEL);
        if (instructionsLabel != null){
            instructionsWidget = new TextFieldWidget();
            if (existingOrder != null){
                instructionsWidget.setInitialValue(existingOrder.getInstructions());
            }
            instructionsErrorWidget = new ErrorWidget();
            context.registerWidget(instructionsWidget);
            context.registerErrorWidget(instructionsWidget, instructionsErrorWidget);
        }

        if (usingDurationField){
            orderDurationWidget = new TextFieldWidget(4);
            if (existingOrder != null && existingOrder.getAutoExpireDate() != null){
                //set duration from autoExpireDate in days
                Long autoDateMilis = existingOrder.getAutoExpireDate().getTime();
                Long startDateMilis = existingOrder.getStartDate().getTime();
                Long diffInMSec = autoDateMilis - startDateMilis;
                // Find date difference in days
                // (24 hours 60 minutes 60 seconds 1000 millisecond)
                Long diffOfDays = diffInMSec / (24 * 60 * 60 * 1000);
                orderDurationWidget.setInitialValue(String.valueOf(diffOfDays.intValue()));
            }
            orderDurationErrorWidget = new ErrorWidget();
            context.registerWidget(orderDurationWidget);
            context.registerErrorWidget(orderDurationWidget, orderDurationErrorWidget);
        }
        context.getSchema().addField(dof);
  }
View Full Code Here

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

   * @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--) {
            weekOptions.add(new Option(i + " " + mss.getMessage("DrugOrder.frequency.days") + "/"  + mss.getMessage("DrugOrder.frequency.week") , String.valueOf(i), false));
View Full Code Here

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

   * @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++) {
            freqOptions.add(new Option(i + "/" + mss.getMessage("DrugOrder.frequency.day"), String.valueOf(i), false));
View Full Code Here

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

    // Required attribute defaults to true if not specified
    required = ! "false".equalsIgnoreCase(attributes.get("required"));

    if (FIELD_PERSON_NAME.equalsIgnoreCase(field)) {
      nameWidget = new NameWidget();
      nameErrorWidget = new ErrorWidget();
      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;
            identifierLocationWidget.setInitialValue(defaultLocation);
View Full Code Here

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

      }
    } else {
      existingObs = context.removeExistingObs(concepts, answerConcept);
    }
   
    errorWidget = new ErrorWidget();
    context.registerWidget(errorWidget);
   
    if (parameters.containsKey("labelNameTag")) {
      if (parameters.get("labelNameTag").equals("default"))
        if (concepts != null)
View Full Code Here

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

        if (context.getCurrentObsGroupConcepts() != null && context.getCurrentObsGroupConcepts().size() > 0) {
            existingObs = context.getObsFromCurrentGroup(concept, answerConcept);
        } else {
            existingObs = context.removeExistingObs(concepts, answerConcept);
        }
        errorWidget = new ErrorWidget();
        context.registerWidget(errorWidget);
        //next, just setup all variables:
        if (parameters.containsKey("labelNameTag")) {
            if (parameters.get("labelNameTag").equals("default"))
                valueLabel = answerConcept.getBestName(Context.getLocale()).getName();
View Full Code Here

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

    private void createElement(FormEntryContext context, Map<String, String> parameters) {

        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();

        // setting the initial values
        String conceptId = Context.getAdministrationService().getGlobalProperty("concept.reasonExitedCare");
        Concept reasonExitConcept = Context.getConceptService().getConcept(conceptId);
        Concept initialAnswer = null;
View Full Code Here

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

   
    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));
       
        if (parameters.get(FIELD_DISCONTINUED_REASON_ANSWERS) != null){
View Full Code Here

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

        }
        if (DISPLAY_DROPDOWN.equals(display)) {
            personStubWidget = new PersonStubWidget();
            context.registerWidget(personStubWidget);
        }
        personErrorWidget = new ErrorWidget();

        labelText = parameters.get(FIELD_LABEL_TEXT);

        context.registerWidget(relationshipWidget);
        context.registerErrorWidget(personWidget, personErrorWidget);
View Full Code Here

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

 
  private void createDurationWidget(FormEntryContext context) {
    durationWidget = new NumberFieldWidget(0d, 9999999d, true);
    context.registerWidget(durationWidget);
   
    durationErrorWidget = new ErrorWidget();
    context.registerErrorWidget(durationWidget, durationErrorWidget);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.