Example usage for com.google.gwt.user.client.ui CheckBox setValue

List of usage examples for com.google.gwt.user.client.ui CheckBox setValue

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui CheckBox setValue.

Prototype

@Override
public void setValue(Boolean value) 

Source Link

Document

Checks or unchecks the check box.

Usage

From source file:org.freemedsoftware.gwt.client.screen.PatientForm.java

License:Open Source License

public PatientForm() {
    final VerticalPanel verticalPanel = new VerticalPanel();
    verticalPanel.setWidth("100%");
    initWidget(verticalPanel);/*from w  ww.  ja v a 2s. c  o m*/

    final CheckBox tabView = new CheckBox(_("Tab View"));
    tabView.setValue(true);

    verticalPanel.add(tabView);

    final TabPanel tabPanel = new TabPanel();
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            // TODO Auto-generated method stub
            if (event.getSelectedItem() == 0)
                title.setFocus(true);
            if (event.getSelectedItem() == 2)
                preferredContact.setFocus(true);
            if (event.getSelectedItem() == 3)
                martialStatus.setFocus(true);
            if (event.getSelectedItem() == 4)
                primaryFacility.setFocus(true);
        }
    });
    verticalPanel.add(tabPanel);

    final VerticalPanel nonTabViewContainer = new VerticalPanel();
    nonTabViewContainer.setWidth("100%");
    nonTabViewContainer.setVisible(false);
    verticalPanel.add(nonTabViewContainer);

    final FlexTable demographicsTable = new FlexTable();
    demographicsTable.setWidth("100%");
    tabPanel.add(demographicsTable, _("Demographics"));

    final Label titleLabel = new Label(_("Title"));
    demographicsTable.setWidget(0, 0, titleLabel);

    /*
    wTitle = new CustomListBox();
    demographicsTable.setWidget(0, 1, wTitle);
    wTitle.addItem("[Choose title]", "");
    wTitle.addItem("Mr");
    wTitle.addItem("Mrs");
    wTitle.addItem("Ms");
    wTitle.addItem("Dr");
    wTitle.addItem("Fr");
    wTitle.setVisibleItemCount(1);
    */
    title = new CustomRadioButtonGroup("title");
    title.setWidth("30%");
    demographicsTable.setWidget(0, 1, title);
    title.addItem("Mr");
    title.addItem("Mrs");
    title.addItem("Ms");
    title.addItem("Dr");
    title.addItem("Fr");

    final Label lastNameLabel = new Label(_("Last Name"));
    demographicsTable.setWidget(1, 0, lastNameLabel);

    wLastName = new TextBox();
    demographicsTable.setWidget(1, 1, wLastName);
    wLastName.setTabIndex(1);
    wLastName.setFocus(true);
    wLastName.setWidth("100%");
    wLastName.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label firstNameLabel = new Label(_("First Name"));
    demographicsTable.setWidget(2, 0, firstNameLabel);

    wFirstName = new TextBox();
    demographicsTable.setWidget(2, 1, wFirstName);
    wFirstName.setTabIndex(2);
    wFirstName.setWidth("100%");
    wFirstName.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label middleNameLabel = new Label(_("Middle Name"));
    demographicsTable.setWidget(3, 0, middleNameLabel);

    wMiddleName = new TextBox();
    demographicsTable.setWidget(3, 1, wMiddleName);
    wMiddleName.setTabIndex(3);
    wMiddleName.setWidth("100%");
    wMiddleName.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label suffixLabel = new Label(_("Suffix"));
    demographicsTable.setWidget(4, 0, suffixLabel);

    /*
    wSuffix = new CustomListBox();
    demographicsTable.setWidget(4, 1, wSuffix);
    wSuffix.setTabIndex(4);
    wSuffix.addItem("[No Suffix]", "");
    wSuffix.addItem("Sr");
    wSuffix.addItem("Jr");
    wSuffix.addItem("II");
    wSuffix.addItem("III");
    wSuffix.addItem("IV");
    wSuffix.setVisibleItemCount(1);
    */

    suffix = new CustomRadioButtonGroup("suffix");
    suffix.setWidth("30%");
    demographicsTable.setWidget(4, 1, suffix);
    suffix.addItem("Sr");
    suffix.addItem("Jr");
    suffix.addItem("II");
    suffix.addItem("III");
    suffix.addItem("IV");

    final Label genderLabel = new Label(_("Gender"));
    demographicsTable.setWidget(5, 0, genderLabel);

    /*
    wGender = new CustomListBox();
    demographicsTable.setWidget(5, 1, wGender);
    wGender.setTabIndex(5);
    wGender.addItem("[Choose Value]", "");
    wGender.addItem("Male", "m");
    wGender.addItem("Female", "f");
    wGender.addItem("Transgendered", "t");
    wGender.setVisibleItemCount(1);
    */

    gender = new CustomRadioButtonGroup("gender");
    gender.setWidth("30%");
    demographicsTable.setWidget(5, 1, gender);
    gender.addItem(_("Male"), "m");
    gender.addItem(_("Female"), "f");
    gender.addItem(_("Transgendered"), "t");

    final Label dateOfBirthLabel = new Label(_("Date of Birth"));
    demographicsTable.setWidget(6, 0, dateOfBirthLabel);

    wDob = new CustomDatePicker();
    demographicsTable.setWidget(6, 1, wDob);
    // wDob.setTabIndex(6);

    addressContainer = new PatientAddresses();
    addressContainer.setWidth("100%");
    tabPanel.add(addressContainer, _("Address"));

    final FlexTable contactTable = new FlexTable();
    contactTable.setWidth("100%");
    tabPanel.add(contactTable, _("Contact"));

    final Label preferredContactLabel = new Label(_("Preferred Contact"));
    contactTable.setWidget(0, 0, preferredContactLabel);

    preferredContact = new CustomListBox();
    preferredContact.addItem(_("Home"), "home");
    preferredContact.addItem(_("Work"), "work");
    preferredContact.addItem(_("Mobile"), "mobile");
    preferredContact.addItem(_("Email"), "email");
    preferredContact.setVisibleItemCount(1);
    contactTable.setWidget(0, 1, preferredContact);

    final Label homePhoneLabel = new Label(_("Home Phone"));
    contactTable.setWidget(1, 0, homePhoneLabel);

    final Label workPhoneLabel = new Label(_("Work Phone"));
    contactTable.setWidget(2, 0, workPhoneLabel);

    final Label faxPhoneLabel = new Label(_("Fax Phone"));
    contactTable.setWidget(3, 0, faxPhoneLabel);

    final Label mobilePhoneLabel = new Label(_("Mobile Phone"));
    contactTable.setWidget(4, 0, mobilePhoneLabel);

    final Label emailAddressLabel = new Label(_("Email Address"));
    contactTable.setWidget(5, 0, emailAddressLabel);

    phoneHome = new TextBox();
    contactTable.setWidget(1, 1, phoneHome);
    phoneHome.setWidth("100%");

    phoneWork = new TextBox();
    contactTable.setWidget(2, 1, phoneWork);
    phoneWork.setWidth("100%");

    phoneFax = new TextBox();
    contactTable.setWidget(3, 1, phoneFax);
    phoneFax.setWidth("100%");

    phoneMobile = new TextBox();
    contactTable.setWidget(4, 1, phoneMobile);
    phoneMobile.setWidth("100%");

    emailAddress = new TextBox();
    contactTable.setWidget(5, 1, emailAddress);
    emailAddress.setWidth("100%");

    //creating personal tab
    final FlexTable personalTable = new FlexTable();
    personalTable.setWidth("100%");
    tabPanel.add(personalTable, _("Personal"));

    final Label martialStatusLabel = new Label(_("Marital Status"));
    personalTable.setWidget(0, 0, martialStatusLabel);

    martialStatus = new CustomRadioButtonGroup("martialStatus");
    martialStatus.addItem(_("Single"), "single");
    martialStatus.addItem(_("Married"), "married");
    martialStatus.addItem(_("Divorced"), "divorced");
    martialStatus.addItem(_("Separated"), "separated");
    martialStatus.addItem(_("Widowed"), "widowed");
    //      martialStatus.setVisibleItemCount(1);
    personalTable.setWidget(0, 1, martialStatus);

    final Label employmentStatusLabel = new Label(_("Employment Status"));
    personalTable.setWidget(1, 0, employmentStatusLabel);

    employmentStatus = new CustomListBox();
    employmentStatus.addItem(_("Yes"), "y");
    employmentStatus.addItem(_("No"), "n");
    employmentStatus.addItem(_("Part Time"), "p");
    employmentStatus.addItem(_("Self"), "s");
    employmentStatus.addItem(_("Retired"), "r");
    employmentStatus.addItem(_("Military"), "m");
    employmentStatus.addItem(_("Unknown"), "u");
    employmentStatus.setVisibleItemCount(1);
    personalTable.setWidget(1, 1, employmentStatus);

    final Label patientStatusLabel = new Label(_("Patient Status"));
    personalTable.setWidget(2, 0, patientStatusLabel);

    final Label patientStatusValueLabel = new Label(_("None"));
    personalTable.setWidget(2, 1, patientStatusValueLabel);

    final Label socialSecurityNumberLabel = new Label(_("Social Security Number"));
    personalTable.setWidget(3, 0, socialSecurityNumberLabel);

    socialSecurityNumber = new TextBox();
    personalTable.setWidget(3, 1, socialSecurityNumber);
    socialSecurityNumber.setWidth("100%");
    socialSecurityNumber.addKeyUpHandler(new KeyUpHandler() {
        @Override
        public void onKeyUp(KeyUpEvent arg0) {
            generatePracticeId();
        }

    });

    final Label raceLabel = new Label(_("Race"));
    personalTable.setWidget(4, 0, raceLabel);

    race = new CustomListBox();
    race.addItem(_("Unknown race"), "7");
    race.addItem(_("Hispanic, white"), "1");
    race.addItem(_("Hispanic, black"), "2");
    race.addItem(_("American Indian or Alaska Native"), "3");
    race.addItem(_("Black, not of Hispanic origin"), "4");
    race.addItem(_("Asian or Pacific Islander"), "5");
    race.addItem(_("White, not of Hispanic origin"), "6");
    race.setVisibleItemCount(1);
    personalTable.setWidget(4, 1, race);

    final Label religionLabel = new Label(_("Religion"));
    personalTable.setWidget(5, 0, religionLabel);

    religion = new CustomListBox();
    religion.addItem(_("Unknown/No preference"), "29");
    religion.addItem(_("Catholic"), "0");
    religion.addItem(_("Jewish"), "1");
    religion.addItem(_("Eastern Orthodox"), "2");
    religion.addItem(_("Baptist"), "3");
    religion.addItem(_("Methodist"), "4");
    religion.addItem(_("Lutheran"), "5");
    religion.addItem(_("Presbyterian"), "6");
    religion.addItem(_("United Church of God"), "7");
    religion.addItem(_("Episcopalian"), "8");
    religion.addItem(_("Adventist"), "9");
    religion.addItem(_("Assembly of God"), "10");
    religion.addItem(_("Brethren"), "11");
    religion.addItem(_("Christian Scientist"), "12");
    religion.addItem(_("Church of Christ"), "13");
    religion.addItem(_("Church of God"), "14");
    religion.addItem(_("Disciples of Christ"), "15");
    religion.addItem(_("Evangelical Covenant"), "16");
    religion.addItem(_("Friends"), "17");
    religion.addItem(_("Jehovah's Witness"), "18");
    religion.addItem(_("Latter-Day Saints"), "19");
    religion.addItem(_("Islam"), "20");
    religion.addItem(_("Nazarene"), "21");
    religion.addItem(_("Other"), "22");
    religion.addItem(_("Pentecostal"), "23");
    religion.addItem(_("Protestant, Other"), "24");
    religion.addItem(_("Protestant, No Denomination"), "25");
    religion.addItem(_("Reformed"), "26");
    religion.addItem(_("Salvation Army"), "27");
    religion.addItem(_("Unitarian; Universalist"), "28");
    religion.addItem(_("Native American"), "30");
    religion.addItem(_("Buddhist"), "31");
    religion.setVisibleItemCount(1);
    personalTable.setWidget(5, 1, religion);

    final Label languageLabel = new Label(_("Language"));
    personalTable.setWidget(6, 0, languageLabel);
    languages = new CustomListBox();
    personalTable.setWidget(6, 1, languages);
    loadLanguages();

    final Label driverLicenceLabel = new Label(_("Driver's License (No State)"));
    personalTable.setWidget(7, 0, driverLicenceLabel);

    driverLicence = new TextBox();
    personalTable.setWidget(7, 1, driverLicence);
    driverLicence.setWidth("100%");

    final Label typeofBillingLabel = new Label(_("Type of Billing"));
    personalTable.setWidget(8, 0, typeofBillingLabel);

    typeofBilling = new CustomListBox();
    typeofBilling.addItem(_("NONE SELECTED"), "");
    typeofBilling.addItem(_("Monthly Billing On Account"), "mon");
    typeofBilling.addItem(_("Statement Billing"), "sta");
    typeofBilling.addItem(_("Charge Card Billing"), "chg");
    typeofBilling.setVisibleItemCount(1);
    personalTable.setWidget(8, 1, typeofBilling);

    final Label monthlyBudgetAmountLabel = new Label(_("Monthly Budget Amount"));
    personalTable.setWidget(9, 0, monthlyBudgetAmountLabel);

    monthlyBudgetAmount = new TextBox();
    personalTable.setWidget(9, 1, monthlyBudgetAmount);
    monthlyBudgetAmount.setWidth("100%");

    final Label patientPracticeIdLabel = new Label(_("Patient Practice ID"));
    personalTable.setWidget(10, 0, patientPracticeIdLabel);

    patientPracticeID = new TextBox();
    personalTable.setWidget(10, 1, patientPracticeID);
    patientPracticeID.setTabIndex(7);
    patientPracticeID.setWidth("100%");

    //creating Medical tab
    final FlexTable medicalTable = new FlexTable();
    medicalTable.setWidth("100%");
    tabPanel.add(medicalTable, _("Medical"));

    //      final Label bloodTypeLabel = new Label("Blood Type");
    //      medicalTable.setWidget(0, 0, bloodTypeLabel);
    //
    //      bloodType = new CustomListBox();
    //      bloodType.addItem("-","");
    //      bloodType.addItem("O","O");
    //      bloodType.addItem("O+","O+");
    //      bloodType.addItem("O-","O-");
    //      bloodType.addItem("A","A");
    //      bloodType.addItem("A+","A+");
    //      bloodType.addItem("A-","A-");
    //      bloodType.addItem("B","B");
    //      bloodType.addItem("B+","B+");
    //      bloodType.addItem("B-","B-");
    //      bloodType.addItem("AB","AB");
    //      bloodType.addItem("AB+","AB+");
    //      bloodType.addItem("AB-","AB-");
    //      bloodType.setVisibleItemCount(1);
    //      medicalTable.setWidget(0, 1, bloodType);

    final Label primaryFacilityLabel = new Label(_("Primary Facility"));
    medicalTable.setWidget(0, 0, primaryFacilityLabel);

    primaryFacility = new SupportModuleWidget("FacilityModule");
    medicalTable.setWidget(0, 1, primaryFacility);
    primaryFacility.setWidth("100%");

    final Label preferredPharmacyLabel = new Label(_("Preferred Pharmacy"));
    medicalTable.setWidget(1, 0, preferredPharmacyLabel);

    preferredPharmacy = new SupportModuleWidget("Pharmacy");
    medicalTable.setWidget(1, 1, preferredPharmacy);
    preferredPharmacy.setWidth("100%");

    final Label inHouseDoctorLabel = new Label(_("In House Doctor"));
    medicalTable.setWidget(2, 0, inHouseDoctorLabel);

    inHouseDoctor = new ProviderWidget();

    medicalTable.setWidget(2, 1, inHouseDoctor);
    inHouseDoctor.setWidth("100%");

    final Label referringDoctorLabel = new Label(_("Referring Doctor"));
    medicalTable.setWidget(3, 0, referringDoctorLabel);

    referringDoctor = new ProviderWidget();
    medicalTable.setWidget(3, 1, referringDoctor);
    referringDoctor.setWidth("100%");

    final Label primaryCarePhysicianLabel = new Label(_("Primary Care Physician"));
    medicalTable.setWidget(4, 0, primaryCarePhysicianLabel);

    primaryCarePhysician = new ProviderWidget();
    medicalTable.setWidget(4, 1, primaryCarePhysician);
    primaryCarePhysician.setWidth("100%");

    final Label numberofOtherPhysiciansLabel = new Label(_("Number of Other Physicians"));
    medicalTable.setWidget(5, 0, numberofOtherPhysiciansLabel);

    numberofOtherPhysicians = new CustomListBox();
    numberofOtherPhysicians.addItem("0", "0");
    numberofOtherPhysicians.addItem("1", "1");
    numberofOtherPhysicians.addItem("2", "2");
    numberofOtherPhysicians.addItem("3", "3");
    numberofOtherPhysicians.addItem("4", "4");
    numberofOtherPhysicians.setVisibleItemCount(1);
    medicalTable.setWidget(5, 1, numberofOtherPhysicians);

    numberofOtherPhysicians.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            // TODO Auto-generated method stub
            int selectedCount = Integer
                    .parseInt(numberofOtherPhysicians.getValue(numberofOtherPhysicians.getSelectedIndex()));
            updateOtherPhysiciansBoxes(selectedCount);
        }

    });

    otherPhysician1Label = new Label(_("Physician 1"));
    medicalTable.setWidget(6, 0, otherPhysician1Label);
    otherPhysician1 = new ProviderWidget();
    medicalTable.setWidget(6, 1, otherPhysician1);

    otherPhysician2Label = new Label(_("Physician 2"));
    medicalTable.setWidget(7, 0, otherPhysician2Label);
    otherPhysician2 = new ProviderWidget();
    medicalTable.setWidget(7, 1, otherPhysician2);

    otherPhysician3Label = new Label(_("Physician 3"));
    medicalTable.setWidget(8, 0, otherPhysician3Label);
    otherPhysician3 = new ProviderWidget();
    medicalTable.setWidget(8, 1, otherPhysician3);

    otherPhysician4Label = new Label(_("Physician 4"));
    medicalTable.setWidget(9, 0, otherPhysician4Label);
    otherPhysician4 = new ProviderWidget();
    medicalTable.setWidget(9, 1, otherPhysician4);

    updateOtherPhysiciansBoxes(0);

    // Select first tab "demographics" as active tag
    tabPanel.selectTab(0);

    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    verticalPanel.add(horizontalPanel);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setCellHorizontalAlignment(horizontalPanel, HasHorizontalAlignment.ALIGN_CENTER);
    //      horizontalPanel.setWidth("100%");

    submitButton = new CustomButton(_("Commit"), AppConstants.ICON_ADD);
    horizontalPanel.add(submitButton);
    submitButton.addClickHandler(new ClickHandler() {
        @SuppressWarnings({ "rawtypes", "unchecked" })
        @Override
        public void onClick(ClickEvent evt) {
            //            submitButton.setEnabled(false);
            if (validateForm()) {
                if (patientId == null || patientId == 0) {
                    List params = new ArrayList();
                    HashMap<String, String> criteria = new HashMap<String, String>();
                    criteria.put("ptlname", (String) wLastName.getText());
                    criteria.put("ptfname", (String) wFirstName.getText());
                    criteria.put("ptdob", (String) wDob.getStoredValue());
                    params.add(criteria);

                    Util.callApiMethod("PatientInterface", "GetDuplicatePatients", params,
                            new CustomRequestCallback() {

                                @Override
                                public void onError() {
                                    //                     submitButton.setEnabled(true);
                                }

                                @Override
                                public void jsonifiedData(Object data) {
                                    HashMap<String, String> result = (HashMap<String, String>) data;
                                    if (result == null || result.size() == 0)
                                        commitChanges();
                                    else {
                                        String msg = _(
                                                "This patient is already in the system. Do you want to continue adding?");
                                        Util.confirm(msg, new Command() {

                                            @Override
                                            public void execute() {
                                                commitChanges();
                                            }
                                        }, null);
                                    }
                                }
                            }, "HashMap<String,String>");

                } else
                    commitChanges();
            }
        }
    });

    CustomButton cancelButton = new CustomButton(_("Cancel"), AppConstants.ICON_CANCEL);
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            // TODO Auto-generated method stub
            try {
                closeScreen();
            } catch (Exception e) {
            }

            if (patientId != 0)
                spawnPatientScreen(patientId);
        }
    });
    horizontalPanel.add(cancelButton);

    if (CurrentState.isActionAllowed(CoveragesModuleName, AppConstants.SHOW)) {
        patientCoverages = new PatientCoverages();
        patientCoverages.setWidth("100%");
        tabPanel.add(patientCoverages, _("Coverages"));
    }
    if (CurrentState.isActionAllowed(AuthorizationsModuleName, AppConstants.SHOW)) {
        patientAuthorizations = new PatientAuthorizations();
        patientAuthorizations.setWidth("100%");
        tabPanel.add(patientAuthorizations, _("Authorizations"));
    }

    tabView.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
            if (arg0.getValue()) {
                tabPanel.clear();
                //Adding Demographics
                tabPanel.add(demographicsTable, _("Demographics"));
                //Adding Address
                tabPanel.add(addressContainer, _("Address"));
                //Adding Contact
                tabPanel.add(contactTable, _("Contact"));
                //Adding Personal
                tabPanel.add(personalTable, _("Personal"));
                //Adding Medical
                tabPanel.add(medicalTable, _("Medical"));
                //Adding Coverages
                tabPanel.add(patientCoverages, _("Coverages"));
                //Adding Authorizations
                tabPanel.add(patientAuthorizations, _("Authorizations"));

                nonTabViewContainer.setVisible(false);
                tabPanel.setVisible(true);
                tabPanel.selectTab(0);
            } else {
                nonTabViewContainer.clear();
                //Adding Demographics
                Label label = new Label(_("Demographics"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(demographicsTable);
                demographicsTable.setWidth("100%");

                //Adding Address
                label = new Label(_("Address"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(addressContainer);
                addressContainer.setWidth("100%");

                //Adding Contact
                label = new Label(_("Contact"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(contactTable);
                contactTable.setWidth("100%");

                //Adding Personal
                label = new Label(_("Personal"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(personalTable);
                personalTable.setWidth("100%");

                //Adding Medical
                label = new Label(_("Medical"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(medicalTable);
                medicalTable.setWidth("100%");

                //Adding Coverages
                label = new Label(_("Coverages"));
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(patientCoverages);
                patientCoverages.setWidth("100%");

                //Adding Authorizations
                label = new Label("Authorizations");
                label.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
                nonTabViewContainer.add(label);
                nonTabViewContainer.add(patientAuthorizations);
                patientAuthorizations.setWidth("100%");

                tabPanel.setVisible(false);
                nonTabViewContainer.setVisible(true);
            }

        }

    });

    Util.setFocus(title);
}

From source file:org.freemedsoftware.gwt.client.screen.PatientsGroupScreen.java

License:Open Source License

public PatientsGroupScreen() {
    super(ModuleName);
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    initWidget(horizontalPanel);//  w  w  w  .  java 2s.  c  om
    horizontalPanel.setSize("100%", "100%");

    final VerticalPanel verticalPanel = new VerticalPanel();
    horizontalPanel.add(verticalPanel);
    verticalPanel.setSize("100%", "100%");
    tabPanel = new TabPanel();
    tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> event) {
            // TODO Auto-generated method stub
            if (event.getSelectedItem() == 1)
                groupName.setFocus(true);
        }
    });

    verticalPanel.add(tabPanel);

    /*
     * final Label callInLabel = new Label("Call-in Patient Management.");
     * verticalPanelMenu.add(callInLabel);
     * callInLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
     */

    final HorizontalPanel menuButtonsPanel = new HorizontalPanel();
    menuButtonsPanel.setSpacing(1);
    if (canDelete || canWrite || canBook) {
        final CustomButton selectAllButton = new CustomButton(_("Select All"), AppConstants.ICON_SELECT_ALL);
        menuButtonsPanel.add(selectAllButton);
        selectAllButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent wvt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(true);
                    patientGroupTable.selectionAdd(checkboxStack.get(t).toString());
                    // }
                }
            }
        });
    }

    if (canDelete || canWrite || canBook) {
        final CustomButton selectNoneButton = new CustomButton(_("Select None"), AppConstants.ICON_SELECT_NONE);
        menuButtonsPanel.add(selectNoneButton);
        selectNoneButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                Iterator<CheckBox> iter = checkboxStack.keySet().iterator();
                while (iter.hasNext()) {
                    CheckBox t = iter.next();
                    t.setValue(false);
                    patientGroupTable.selectionRemove(checkboxStack.get(t).toString());
                }
            }
        });
    }

    if (canBook) {
        final CustomButton bookButton = new CustomButton(_("Book"), AppConstants.ICON_BOOK_APP);
        menuButtonsPanel.add(bookButton);
        bookButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (patientGroupTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry."));
                else {
                    List<String> slectedItems = patientGroupTable.getSelected();
                    SchedulerScreen schedulerScreen = SchedulerScreen.getInstance();
                    EventData eventData = schedulerScreen.getSchedulerWidget().getNewExternalDataEvent();
                    eventData.setPatientId(Integer.parseInt(slectedItems.get(0)));
                    eventData.setResourceType(AppConstants.APPOINTMENT_TYPE_GROUP);
                    schedulerScreen.getSchedulerWidget().setExternalDataEvent(eventData);
                    Util.spawnTab(AppConstants.SCHEDULER, schedulerScreen);
                }
            }
        });
    }

    if (canModify) {
        final CustomButton modifyButton = new CustomButton("Modify", AppConstants.ICON_MODIFY);
        menuButtonsPanel.add(modifyButton);
        modifyButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (patientGroupTable.getSelectedCount() < 1)
                    Window.alert(_("Please select an entry."));
                else if (patientGroupTable.getSelectedCount() > 1)
                    Window.alert(_("You can modify only a single entry at a time."));
                else {
                    List<String> slectedItems = patientGroupTable.getSelected();
                    Iterator<String> itr = slectedItems.iterator();// Get all
                    // selected
                    // items
                    // from
                    // custom
                    // table
                    tabPanel.selectTab(1);
                    groupName.setFocus(true);
                    btnAdd.setText(_("Modify"));
                    selectedEntryId = Integer.parseInt(itr.next());
                    modifyEntry(selectedEntryId);
                }
            }
        });
    }

    if (canDelete) {
        final CustomButton deleteButton = new CustomButton(_("Delete"), AppConstants.ICON_DELETE);
        menuButtonsPanel.add(deleteButton);
        deleteButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent evt) {
                if (patientGroupTable.getSelectedCount() < 1)
                    Window.alert(_("Please select at least one entry."));
                else if (Window.confirm(_("Are you sure you want to delete these item(s)?"))) {
                    List<String> slectedItems = patientGroupTable.getSelected();
                    Iterator<String> itr = slectedItems.iterator();// Get all
                    // selected
                    // items
                    // from
                    // custom
                    // table
                    while (itr.hasNext())
                        deleteEntry(Integer.parseInt(itr.next()));// delete
                    // messages
                    // one by
                    // one
                    populate();
                }
            }
        });
    }

    verticalPanelMenu.add(menuButtonsPanel);
    patientGroupTable = new CustomTable();
    verticalPanelMenu.add(patientGroupTable);
    patientGroupTable.setAllowSelection(false);
    patientGroupTable.setSize("100%", "100%");
    // //what for is this used???To work on this
    patientGroupTable.setIndexName("id");
    // ///
    if (canBook || canDelete)
        patientGroupTable.addColumn(_("Selected"), "selected");

    patientGroupTable.addColumn(_("Group Name"), "groupname");
    patientGroupTable.addColumn(_("Group Facility"), "groupfacility");
    patientGroupTable.addColumn(_("Group Frequency (in days)"), "groupfrequency");
    patientGroupTable.addColumn(_("Group Length (min)"), "grouplength");

    patientGroupTable.setTableRowClickHandler(new TableRowClickHandler() {
        @Override
        public void handleRowClick(HashMap<String, String> data, int col) {
            try {
                if (col != 0)
                    showGroupInfo(Integer.parseInt(data.get("id")));
            } catch (Exception e) {
                GWT.log("Caught exception: ", e);
            }
        }
    });

    patientGroupTable.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {
        public Widget setColumn(String columnName, HashMap<String, String> data) {
            Integer id = Integer.parseInt(data.get("id"));
            if (columnName.compareTo("selected") == 0) {
                CheckBox c = new CheckBox();
                c.addClickHandler(getPatientGroupScreen());
                checkboxStack.put(c, id);
                return c;
            } else {
                return (Widget) null;
            }
        }
    });

    tabPanel.add(verticalPanelMenu, _("Menu"));
    if (canWrite)
        tabPanel.add(createEntryTabBar(), _("Entry"));

    // tabPanel.add(new VerticalPanel(),"Entry");
    tabPanel.selectTab(0);
    // createEntryTabBar();

    // patientGroupTable.formatTable(5);
    // patientGroupTable.getFlexTable().setWidth("100%");

    // //////
    populate();
}

From source file:org.freemedsoftware.gwt.client.screen.PreferencesScreen.java

License:Open Source License

protected void createNavigatonOptions() {
    // preparing Navigation tab
    navigationsVerticalPanel.clear();/* w ww .j  a  va 2 s .  c om*/
    navigationsFlexTable = new FlexTable();
    navigationsCheckboxes.clear();
    navigationsFlexTable.addStyleName("cw-FlexTable");

    final HashMap<String, HashMap<String, Integer>> leftNavCategories = CurrentState.getLeftNavigationOptions();
    Iterator<String> itrCats = leftNavCategories.keySet().iterator();
    int i = 0;
    while (itrCats.hasNext()) {
        final String categoryName = itrCats.next();
        Label navLabel = new Label(categoryName);
        navLabel.setStyleName(AppConstants.STYLE_LABEL_LARGE_BOLD);
        navigationsFlexTable.setWidget(i++, 0, navLabel);
        final HashMap<String, Integer> leftNavOpts = leftNavCategories.get(categoryName);
        Iterator<String> itr = leftNavOpts.keySet().iterator();
        while (itr.hasNext()) {
            final String Option = itr.next();
            final Integer OptionVal = leftNavOpts.get(Option);
            navigationsFlexTable.setHTML(i, 0, Option);
            final CheckBox checkBox = new CheckBox();
            if (OptionVal == 1)
                checkBox.setValue(true);
            else
                checkBox.setValue(false);
            checkBox.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent arg0) {
                    isNavigatioMenuChanged = true;
                    if (checkBox.getValue()) {
                        leftNavOpts.put(Option, 1);
                    } else {
                        leftNavOpts.put(Option, 0);
                    }
                }
            });
            navigationsFlexTable.setWidget(i, 1, checkBox);
            navigationsCheckboxes.put(Option, checkBox);
            i++;
        }
    }
    navigationsVerticalPanel.add(navigationsFlexTable);

}

From source file:org.freemedsoftware.gwt.client.screen.UserManagementScreen.java

License:Open Source License

public void reselectGroups() {
    //Reselecting the checkboxes so that onclick could be fired and required checkboxes can be checked by default.
    Iterator<Integer> itr = aclGroupsCheckBoxesMap.keySet().iterator();
    while (itr.hasNext()) {
        Integer key = itr.next();
        CheckBox checkBox = aclGroupsCheckBoxesMap.get(key);
        if (checkBox.getValue()) {
            JsonUtil.debug("reselectGroups:" + key);
            checkBox.setValue(false);
            checkBox.setValue(true, true);
        }/*from w w  w  .j a v a 2 s.  c o  m*/
    } //End while
}

From source file:org.freemedsoftware.gwt.client.screen.UserManagementScreen.java

License:Open Source License

public void clearForm() {
    tbUsername.setText("");
    tbPassword.setEnabled(true);//from ww w . j a v a  2s  . co m
    tbPassword.setText("");
    tbPasswordverify.setEnabled(true);
    tbPasswordverify.setText("");
    tbUserFirstName.setText("");
    tbUserLastName.setText("");
    tbUserMiddleName.setText("");
    tbUserTitle.setWidgetValue("");
    changePasswordLink.setVisible(false);
    tbDescription.setText("");
    lbUserType.setWidgetValue("null");
    lbActualPhysician.clear();
    addUserButton.setText("Add User");
    userId = null;
    deleteUserButton.setVisible(false);
    copyButton.setVisible(false);
    aclSelectedGroupsIdsList.clear();
    lbActualPhysician.setVisible(false);
    Iterator<Integer> itr = aclGroupsCheckBoxesMap.keySet().iterator();
    while (itr.hasNext()) {
        Integer key = itr.next();
        CheckBox checkBox = aclGroupsCheckBoxesMap.get(key);
        checkBox.setValue(false);
    }

    itr = facilitiesCheckBoxesMap.keySet().iterator();
    while (itr.hasNext()) {
        Integer key = itr.next();
        CheckBox checkBox = facilitiesCheckBoxesMap.get(key);
        checkBox.setValue(false);
    }

    Iterator<String> itr2 = allAclPermissionsMap.keySet().iterator();
    while (itr2.hasNext()) {
        String key = itr2.next();
        CheckBox checkBox = allAclPermissionsMap.get(key);
        checkBox.setValue(false);
    }

    showEnhancedPermssions(false);
    selectedPermissionsMap.clear();
    blockedPermissionsMap.clear();
    allowedPermissionsMap.clear();

    tbUsername.setFocus(true);

    if (!canWrite && canModify)
        tabPanel.remove(addUserVPanel);
}

From source file:org.freemedsoftware.gwt.client.screen.UserManagementScreen.java

License:Open Source License

public void getUserDetails(final Integer userId) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // Do nothing
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        // Use JSON-RPC to retrieve the data
        String[] params = { JsonUtil.jsonify(userId) };

        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.UserInterface.GetRecord", params)));
        try {/*  w  ww  .  j  av a2s. c o m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    GWT.log(request.toString(), ex);
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {
                    if (response.getStatusCode() == 200) {
                        HashMap<String, String> data = (HashMap<String, String>) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                        if (data != null) {
                            tbUsername.setText(data.get("username"));
                            tbDescription.setText(data.get("userdescrip"));
                            tbUserFirstName.setText(data.get("userfname"));
                            tbUserLastName.setText(data.get("userlname"));
                            tbUserMiddleName.setText(data.get("usermname"));
                            tbUserTitle.setWidgetValue(data.get("usertitle"));
                            lbUserType.setWidgetValue(data.get("usertype"));
                            if (data.get("usertype") != null && data.get("usertype").equalsIgnoreCase("phy")) {
                                lbActualPhysician.setValue(Integer.parseInt(data.get("userrealphy")));
                                lbActualPhysician.setVisible(true);
                            }

                            if (data.get("userfac") != null && data.get("userfac").length() > 0) {
                                String[] userFacilities = data.get("userfac").split(",");
                                for (int i = 0; i < userFacilities.length; i++) {
                                    Integer id = Integer.parseInt(userFacilities[i]);
                                    CheckBox checkBox = facilitiesCheckBoxesMap.get(id);
                                    if (checkBox != null)
                                        checkBox.setValue(true);
                                }
                            }

                            addUserButton.setText(_("Modify User"));
                            changePasswordLink.setVisible(true);
                            tbPassword.setEnabled(false);
                            tbPasswordverify.setEnabled(false);
                            deleteUserButton.setVisible(true);
                            copyButton.setVisible(true);
                        }
                    }
                }
            });
        } catch (RequestException e) {
            // nothing here right now
        }
    } else if (Util.getProgramMode() == ProgramMode.NORMAL) {
        // Use GWT-RPC to retrieve the data
        // TODO: Create that stuff
    }

}

From source file:org.freemedsoftware.gwt.client.screen.UserManagementScreen.java

License:Open Source License

public void getUserGroup(final Integer userId) {
    aclSelectedGroupsIdsList.clear();//from  w  w  w. jav  a 2s . com
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // Do nothing
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        // Use JSON-RPC to retrieve the data
        String[] params = { JsonUtil.jsonify(userId) };

        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.ACL.GetUserGroups", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    GWT.log(request.toString(), ex);
                }

                public void onResponseReceived(Request request, Response response) {
                    if (response.getStatusCode() == 200) {
                        String[] data = (String[]) JsonUtil
                                .shoehornJson(JSONParser.parseStrict(response.getText()), "String[]");
                        if (data != null) {
                            Integer groupId = null;
                            for (int i = 0; i < data.length; i++) {
                                groupId = Integer.parseInt(data[i]);
                                CheckBox checkBox = aclGroupsCheckBoxesMap.get(groupId);
                                checkBox.setValue(true);
                                aclSelectedGroupsIdsList.add(groupId);
                            }
                        }
                    }
                }
            });
        } catch (RequestException e) {
            // nothing here right now
        }
    } else if (Util.getProgramMode() == ProgramMode.NORMAL) {
        // Use GWT-RPC to retrieve the data
        // TODO: Create that stuff
    }

}

From source file:org.freemedsoftware.gwt.client.widget.EncounterWidget.java

License:Open Source License

@SuppressWarnings("unchecked")
private void createExamTab() {
    examPanel.setSpacing(10);/*w  ww  .  j  a v  a  2  s  .c  om*/
    FlexTable examTable = new FlexTable();
    boolean isBillables = false;
    final String textWidth = "" + (int) (Window.getClientWidth() / 3);
    final String radWidth = "" + (int) (Window.getClientWidth() / 6);
    final String labelWidth = "" + (int) (Window.getClientWidth() / 5);
    int find_maxbillables = 0;
    try {
        find_maxbillables = Integer.parseInt(CurrentState.getSystemConfig("max_billable"));
    } catch (Exception ex) {
    }
    final int maxbillables = find_maxbillables;
    HashMap<String, HashMap<String, String>> billMap = null;
    if (templateValuesMap.get("pnotestbillable") != null
            && !templateValuesMap.get("pnotestbillable").equals("")) {
        isBillables = true;
        billMap = (HashMap<String, HashMap<String, String>>) JsonUtil.shoehornJson(
                JSONParser.parseStrict(templateValuesMap.get("pnotestbillable")),
                "HashMap<String,HashMap<String,String>>");
    } else if (templateValuesMap.get("pnotesbillable") != null
            && !templateValuesMap.get("pnotesbillable").equals("")) {
        isBillables = true;
        billMap = (HashMap<String, HashMap<String, String>>) JsonUtil.shoehornJson(
                JSONParser.parseStrict(templateValuesMap.get("pnotesbillable")),
                "HashMap<String,HashMap<String,String>>");
    }
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam"))
        loopCountMax = sectionsFieldMap.get("Sections#Exam").size();
    else if (sectionsFieldMap.containsKey("Sections") && !sectionsFieldMap.containsKey("Sections#Exam"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Exam");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("Head"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbHeadExam = new Label("Head");
            lbHeadExam.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbHeadExam);
            //headfTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(rightPanel);
            examPanel.add(hp);
            hp.setCellWidth(rightPanel, "100%");
            Label lbfreeform = new Label("Free Form Entry");
            lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

            tbHeadFreeForm = new TextArea();
            tbHeadFreeForm.setWidth(textWidth);
            HorizontalPanel freeHp = new HorizontalPanel();
            freeHp.setWidth("80%");
            freeHp.setSpacing(2);
            freeHp.add(lbfreeform);
            freeHp.add(tbHeadFreeForm);
            freeHp.setCellWidth(tbHeadFreeForm, "80%");
            rightPanel.add(freeHp);
            if (templateValuesMap.containsKey("pnotespeheadfreecmnt")) {
                tbHeadFreeForm.setText(templateValuesMap.get("pnotespeheadfreecmnt"));
            } else if (templateValuesMap.containsKey("pnotestpeheadfreecmnt")) {
                tbHeadFreeForm.setText(templateValuesMap.get("pnotestpeheadfreecmnt"));
            }

            VerticalPanel billPanel = new VerticalPanel();
            billPanel.setWidth("100%");
            billPanel.setSpacing(2);
            final BillInfoWidget biw = new BillInfoWidget();
            final CheckBox cbHeadExBill = new CheckBox("Procedure");
            cbHeadExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            billPanel.add(cbHeadExBill);
            billPanel.add(biw);
            cbHeadExBill.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbHeadExBill.getValue()) {
                        if (maxbillables == billingFieldsWidgetsMap.size()) {
                            Window.alert("Only " + maxbillables + " procedures can be created...");
                            cbHeadExBill.setValue(false);
                        } else {
                            billingFieldsWidgetsMap.put("pnotespehead", biw);
                            biw.setVisible(true);
                        }
                    } else {
                        billingFieldsWidgetsMap.remove("pnotespehead");
                        biw.setVisible(false);
                    }
                }
            });
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespehead")) {
                    HashMap<String, String> m = billMap.get("pnotespehead");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespehead", biw);
                    cbHeadExBill.setValue(true);

                }
            }
        }
        if ((secList != null && secList.get(i).equals("Eyes"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {

            int eyeRowCount = 0;
            Label lbEyes = new Label("Eyes");
            lbEyes.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbEyes);
            final FlexTable eyeTable = new FlexTable();
            eyeTable.getElement().getStyle().setMarginLeft(30, Unit.PX);

            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(eyeTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int eyesLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#Eyes"))
                eyesLoopCountMax = sectionsFieldMap.get("Sections#Exam#Eyes").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Eyes"))
                eyesLoopCountMax = 0;
            else
                eyesLoopCountMax = 1;
            List<String> eyesSecList = sectionsFieldMap.get("Sections#Exam#Eyes");
            for (int j = 0; j < eyesLoopCountMax; j++) {

                if ((eyesSecList != null && eyesSecList.get(j).equals("Conjunctivae_lids_pupils & irises"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbCLPI = new CheckBox("Conjunctivae, lids, pupils & irises");
                    cbCLPI.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radClpi = new CustomRadioButtonGroup("clpi");

                    tbClpi = new TextArea();
                    tbClpi.setEnabled(false);
                    tbClpi.setVisible(false);
                    tbClpi.setWidth(textWidth);
                    radClpi.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbClpi.setVisible(false);
                            cbCLPI.setValue(true, true);
                        }
                    });
                    radClpi.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbClpi.setVisible(true);
                            cbCLPI.setValue(true, true);
                        }
                    });
                    radClpi.setEnable(false);
                    cbCLPI.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbCLPI.getValue()) {
                                radClpi.setEnable(true);
                                tbClpi.setEnabled(true);
                            } else {
                                radClpi.setEnable(false);
                                tbClpi.setEnabled(false);
                            }
                        }

                    });
                    eyeTable.setWidget(eyeRowCount, 0, cbCLPI);
                    eyeTable.setWidget(eyeRowCount, 1, radClpi);
                    eyeTable.setWidget(eyeRowCount + 1, 0, tbClpi);
                    eyeTable.getFlexCellFormatter().setColSpan(eyeRowCount + 1, 0, 2);
                    eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 0, labelWidth);
                    eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 1, radWidth);

                    eyeRowCount = eyeRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeeyeclpistatus")) {
                        radClpi.setWidgetValue(templateValuesMap.get("pnotespeeyeclpistatus"), true);
                        tbClpi.setText(templateValuesMap.get("pnotespeeyeclpicmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeeyeclpistatus")) {
                        radClpi.setWidgetValue(templateValuesMap.get("pnotestpeeyeclpistatus"), true);
                        tbClpi.setText(templateValuesMap.get("pnotestpeeyeclpicmnt"));
                    }
                }

                if ((eyesSecList != null && eyesSecList.get(j).equals("Fundi"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    Label lbFundi = new Label("Fundi:");
                    lbFundi.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    eyeTable.setWidget(eyeRowCount, 0, lbFundi);
                    eyeRowCount++;

                    int fundiLoopCountMax = 0;
                    if (sectionsFieldMap.containsKey("Sections")
                            && sectionsFieldMap.containsKey("Sections#Exam#Eyes#Fundi"))
                        fundiLoopCountMax = sectionsFieldMap.get("Sections#Exam#Eyes#Fundi").size();
                    else if (sectionsFieldMap.containsKey("Sections")
                            && !sectionsFieldMap.containsKey("Sections#Exam#Eyes#Fundi"))
                        fundiLoopCountMax = 0;
                    else
                        fundiLoopCountMax = 1;
                    List<String> fundiSecList = sectionsFieldMap.get("Sections#Exam#Eyes#Fundi");
                    for (int k = 0; k < fundiLoopCountMax; k++) {

                        if ((fundiSecList != null && fundiSecList.get(k).equals("Disc edges sharp"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbDiscEdgeSharp = new CheckBox("Disc edges sharp");
                            cbDiscEdgeSharp.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbDiscEdgeSharp.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radDiscEdgeSharp = new CustomRadioButtonGroup("des");
                            tbDiscEdgeSharp = new TextArea();
                            tbDiscEdgeSharp.setWidth(textWidth);
                            tbDiscEdgeSharp.setVisible(false);
                            radDiscEdgeSharp.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbDiscEdgeSharp.setVisible(false);
                                    cbDiscEdgeSharp.setValue(true, true);

                                }
                            });
                            radDiscEdgeSharp.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbDiscEdgeSharp.setVisible(true);
                                    cbDiscEdgeSharp.setValue(true, true);
                                }
                            });
                            radDiscEdgeSharp.setEnable(false);
                            tbDiscEdgeSharp.setEnabled(false);
                            cbDiscEdgeSharp.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbDiscEdgeSharp.getValue()) {
                                        radDiscEdgeSharp.setEnable(true);
                                        tbDiscEdgeSharp.setEnabled(true);
                                    } else {
                                        radDiscEdgeSharp.setEnable(false);
                                        tbDiscEdgeSharp.setEnabled(false);
                                    }
                                }

                            });
                            eyeTable.setWidget(eyeRowCount, 0, cbDiscEdgeSharp);
                            eyeTable.setWidget(eyeRowCount, 1, radDiscEdgeSharp);
                            eyeTable.setWidget(eyeRowCount + 1, 0, tbDiscEdgeSharp);
                            eyeTable.getFlexCellFormatter().setColSpan(eyeRowCount + 1, 0, 2);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 0, labelWidth);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 1, radWidth);
                            eyeRowCount = eyeRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespeeyedesstatus")) {
                                radDiscEdgeSharp.setWidgetValue(templateValuesMap.get("pnotespeeyedesstatus"),
                                        true);
                                tbDiscEdgeSharp.setText(templateValuesMap.get("pnotespeeyedescmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpeeyedesstatus")) {
                                radDiscEdgeSharp.setWidgetValue(templateValuesMap.get("pnotestpeeyedesstatus"),
                                        true);
                                tbDiscEdgeSharp.setText(templateValuesMap.get("pnotestpeeyedescmnt"));
                            }
                        }
                        if ((fundiSecList != null && fundiSecList.get(k).equals("Venous pulses seen"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbVenPul = new CheckBox("Venous pulses seen");
                            cbVenPul.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbVenPul.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radVenPul = new CustomRadioButtonGroup("vps");
                            tbVenPul = new TextArea();
                            tbVenPul.setWidth(textWidth);
                            tbVenPul.setVisible(false);
                            radVenPul.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbVenPul.setVisible(false);
                                    cbVenPul.setValue(true, true);
                                }
                            });
                            radVenPul.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbVenPul.setVisible(true);
                                    cbVenPul.setValue(true, true);
                                }
                            });
                            radVenPul.setEnable(false);
                            tbVenPul.setEnabled(false);
                            cbVenPul.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbVenPul.getValue()) {
                                        radVenPul.setEnable(true);
                                        tbVenPul.setEnabled(true);
                                    } else {
                                        radVenPul.setEnable(false);
                                        tbVenPul.setEnabled(false);
                                    }
                                }

                            });
                            eyeTable.setWidget(eyeRowCount, 0, cbVenPul);
                            eyeTable.setWidget(eyeRowCount, 1, radVenPul);
                            eyeTable.setWidget(eyeRowCount + 1, 0, tbVenPul);
                            eyeTable.getFlexCellFormatter().setColSpan(eyeRowCount + 1, 0, 2);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 0, labelWidth);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 1, radWidth);
                            eyeRowCount = eyeRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespeeyevpsstatus")) {
                                radVenPul.setWidgetValue(templateValuesMap.get("pnotespeeyevpsstatus"), true);
                                tbVenPul.setText(templateValuesMap.get("pnotespeeyevpscmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpeeyevpsstatus")) {
                                radVenPul.setWidgetValue(templateValuesMap.get("pnotestpeeyevpsstatus"), true);
                                tbVenPul.setText(templateValuesMap.get("pnotestpeeyevpscmnt"));
                            }
                        }

                        if ((fundiSecList != null && fundiSecList.get(k).equals("A-V nicking"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbAVNicking = new CheckBox("A-V nicking");
                            cbAVNicking.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbAVNicking.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radAVNicking = new CustomRadioButtonGroup("avn");
                            tbAVNicking = new TextArea();
                            tbAVNicking.setVisible(false);
                            tbAVNicking.setWidth(textWidth);
                            radAVNicking.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbAVNicking.setVisible(false);
                                    cbAVNicking.setValue(true, true);
                                }
                            });
                            radAVNicking.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbAVNicking.setVisible(true);
                                    cbAVNicking.setValue(true, true);
                                }
                            });
                            radAVNicking.setEnable(false);
                            tbAVNicking.setEnabled(false);
                            cbAVNicking.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbAVNicking.getValue()) {
                                        radAVNicking.setEnable(true);
                                        tbAVNicking.setEnabled(true);
                                    } else {
                                        radAVNicking.setEnable(false);
                                        tbAVNicking.setEnabled(false);
                                    }
                                }

                            });
                            eyeTable.setWidget(eyeRowCount, 0, cbAVNicking);
                            eyeTable.setWidget(eyeRowCount, 1, radAVNicking);
                            eyeTable.setWidget(eyeRowCount + 1, 0, tbAVNicking);
                            eyeTable.getFlexCellFormatter().setColSpan(eyeRowCount + 1, 0, 2);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 0, labelWidth);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 1, radWidth);
                            eyeRowCount = eyeRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespeeyeavnstatus")) {
                                radAVNicking.setWidgetValue(templateValuesMap.get("pnotespeeyeavnstatus"),
                                        true);
                                tbAVNicking.setText(templateValuesMap.get("pnotespeeyeavncmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpeeyeavnstatus")) {
                                radAVNicking.setWidgetValue(templateValuesMap.get("pnotestpeeyeavnstatus"),
                                        true);
                                tbAVNicking.setText(templateValuesMap.get("pnotestpeeyeavncmnt"));
                            }
                        }

                        if ((fundiSecList != null && fundiSecList.get(k).equals("Hemorrhages"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbHemorrhages = new CheckBox("Hemorrhages");
                            cbHemorrhages.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbHemorrhages.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radHemorrhages = new CustomRadioButtonGroup("hom");
                            tbHemorrhages = new TextArea();
                            tbHemorrhages.setVisible(false);
                            tbHemorrhages.setWidth(textWidth);
                            radHemorrhages.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbHemorrhages.setVisible(false);
                                    cbHemorrhages.setValue(true, true);
                                }
                            });
                            radHemorrhages.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbHemorrhages.setVisible(true);
                                    cbHemorrhages.setValue(true, true);
                                }
                            });
                            radHemorrhages.setEnable(false);
                            tbHemorrhages.setEnabled(false);
                            cbHemorrhages.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbHemorrhages.getValue()) {
                                        radHemorrhages.setEnable(true);
                                        tbHemorrhages.setEnabled(true);
                                    } else {
                                        radHemorrhages.setEnable(false);
                                        tbHemorrhages.setEnabled(false);
                                    }
                                }

                            });
                            eyeTable.setWidget(eyeRowCount, 0, cbHemorrhages);
                            eyeTable.setWidget(eyeRowCount, 1, radHemorrhages);
                            eyeTable.setWidget(eyeRowCount + 1, 0, tbHemorrhages);
                            eyeTable.getFlexCellFormatter().setColSpan(eyeRowCount + 1, 0, 2);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 0, labelWidth);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 1, radWidth);
                            eyeRowCount = eyeRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespeeyehemstatus")) {
                                radHemorrhages.setWidgetValue(templateValuesMap.get("pnotespeeyehemstatus"),
                                        true);
                                tbHemorrhages.setText(templateValuesMap.get("pnotespeeyehemcmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpeeyehemstatus")) {
                                radHemorrhages.setWidgetValue(templateValuesMap.get("pnotestpeeyehemstatus"),
                                        true);
                                tbHemorrhages.setText(templateValuesMap.get("pnotestpeeyehemcmnt"));
                            }
                        }

                        if ((fundiSecList != null && fundiSecList.get(k).equals("Exudates"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbExudates = new CheckBox("Exudates");
                            cbExudates.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbExudates.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radExudates = new CustomRadioButtonGroup("exu");
                            tbExudates = new TextArea();
                            tbExudates.setVisible(false);
                            tbExudates.setWidth(textWidth);
                            radExudates.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbExudates.setVisible(false);
                                    cbExudates.setValue(true, true);
                                }
                            });
                            radExudates.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbExudates.setVisible(true);
                                    cbExudates.setValue(true, true);
                                }
                            });
                            radExudates.setEnable(false);
                            tbExudates.setEnabled(false);
                            cbExudates.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbExudates.getValue()) {
                                        radExudates.setEnable(true);
                                        tbExudates.setEnabled(true);
                                    } else {
                                        radExudates.setEnable(false);
                                        tbExudates.setEnabled(false);
                                    }
                                }

                            });
                            eyeTable.setWidget(eyeRowCount, 0, cbExudates);
                            eyeTable.setWidget(eyeRowCount, 1, radExudates);
                            eyeTable.setWidget(eyeRowCount + 1, 0, tbExudates);
                            eyeTable.getFlexCellFormatter().setColSpan(eyeRowCount + 1, 0, 2);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 0, labelWidth);
                            eyeTable.getFlexCellFormatter().setWidth(eyeRowCount, 1, radWidth);
                            eyeRowCount = eyeRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespeeyeexustatus")) {
                                radExudates.setWidgetValue(templateValuesMap.get("pnotespeeyeexustatus"), true);
                                tbExudates.setText(templateValuesMap.get("pnotespeeyeexucmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpeeyeexustatus")) {
                                radExudates.setWidgetValue(templateValuesMap.get("pnotestpeeyeexustatus"),
                                        true);
                                tbExudates.setText(templateValuesMap.get("pnotestpeeyeexucmnt"));
                            }
                        }
                    }
                }

                if ((eyesSecList != null && eyesSecList.get(j).equals("Cup:disc ratio"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbCupDiscRatio = new CheckBox("Cup:disc ratio");
                    cbCupDiscRatio.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    tbCupDiscRatio = new TextBox();
                    eyeTable.setWidget(eyeRowCount, 0, cbCupDiscRatio);
                    eyeTable.setWidget(eyeRowCount, 1, tbCupDiscRatio);
                    eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    eyeTable.getFlexCellFormatter().setVerticalAlignment(eyeRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    eyeRowCount++;
                    tbCupDiscRatio.setEnabled(false);
                    cbCupDiscRatio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbCupDiscRatio.getValue()) {
                                tbCupDiscRatio.setEnabled(true);
                            } else {
                                tbCupDiscRatio.setEnabled(false);
                            }
                        }

                    });
                    if (templateValuesMap.containsKey("pnotespeeyecupdiscratio")) {
                        tbCupDiscRatio.setText(templateValuesMap.get("pnotespeeyecupdiscratio"));
                        cbCupDiscRatio.setValue(true, true);
                    } else if (templateValuesMap.containsKey("pnotestpeeyecupdiscratio")) {
                        tbCupDiscRatio.setText(templateValuesMap.get("pnotestpeeyecupdiscratio"));
                        cbCupDiscRatio.setValue(true, true);
                    }
                }
                if ((eyesSecList != null && eyesSecList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (eyesSecList != null && eyesSecList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbEyeFreeForm = new TextArea();
                    tbEyeFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbEyeFreeForm);
                    freeHp.setCellWidth(tbEyeFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespeeyefreecmnt")) {
                        tbEyeFreeForm.setText(templateValuesMap.get("pnotespeeyefreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeeyefreecmnt")) {
                        tbEyeFreeForm.setText(templateValuesMap.get("pnotestpeeyefreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setWidth("100%");
                billPanel.setSpacing(2);
                rightPanel.add(billPanel);
                cbEyesExBill = new CheckBox("Procedure");
                cbEyesExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                // examTable.setWidget(row, 2, cbEyesExBill);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbEyesExBill);
                billPanel.add(biw);
                // examPanel.add(billPanel);
                // examTable.setWidget(row, 6, biw);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespeeyes")) {
                    HashMap<String, String> m = billMap.get("pnotespeeyes");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespeeyes", biw);
                    cbEyesExBill.setValue(true);
                }

                cbEyesExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbEyesExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbEyesExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespeeyes", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespeeyes");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("ENT"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int entRowCount = 0;
            Label lbEnt = new Label("ENT");
            lbEnt.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbEnt);
            final FlexTable entTable = new FlexTable();
            entTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(entTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);
            int entLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#ENT"))
                entLoopCountMax = sectionsFieldMap.get("Sections#Exam#ENT").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#ENT"))
                entLoopCountMax = 0;
            else
                entLoopCountMax = 1;
            List<String> entSecList = sectionsFieldMap.get("Sections#Exam#ENT");
            for (int j = 0; j < entLoopCountMax; j++) {
                if ((entSecList != null && entSecList.get(j).equals("External canals_TMs"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbExtCanTms = new CheckBox("External canals, TMs");
                    cbExtCanTms.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radExtCanTms = new CustomRadioButtonGroup("et");
                    tbExtCanTms = new TextArea();
                    tbExtCanTms.setVisible(false);
                    tbExtCanTms.setWidth(textWidth);
                    radExtCanTms.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbExtCanTms.setVisible(false);
                            cbExtCanTms.setValue(true, true);
                        }
                    });
                    radExtCanTms.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbExtCanTms.setVisible(true);
                            cbExtCanTms.setValue(true, true);

                        }
                    });
                    radExtCanTms.setEnable(false);
                    tbExtCanTms.setEnabled(false);
                    cbExtCanTms.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbExtCanTms.getValue()) {
                                radExtCanTms.setEnable(true);
                                tbExtCanTms.setEnabled(true);
                            } else {
                                radExtCanTms.setEnable(false);
                                tbExtCanTms.setEnabled(false);
                            }
                        }

                    });
                    entTable.setWidget(entRowCount, 0, cbExtCanTms);
                    entTable.setWidget(entRowCount, 1, radExtCanTms);
                    entTable.setWidget(entRowCount + 1, 0, tbExtCanTms);
                    entTable.getFlexCellFormatter().setColSpan(entRowCount + 1, 0, 2);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 0, labelWidth);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 1, radWidth);
                    entRowCount = entRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeentectstatus")) {
                        radExtCanTms.setWidgetValue(templateValuesMap.get("pnotespeentectstatus"), true);
                        tbExtCanTms.setText(templateValuesMap.get("pnotespeentectcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeentectstatus")) {
                        radExtCanTms.setWidgetValue(templateValuesMap.get("pnotestpeentectstatus"), true);
                        tbExtCanTms.setText(templateValuesMap.get("pnotestpeentectcmnt"));
                    }
                }

                if ((entSecList != null && entSecList.get(j).equals("Nasal mucosa_septum"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbNMS = new CheckBox("Nasal mucosa, septum");
                    cbNMS.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radNMS = new CustomRadioButtonGroup("nms");
                    tbNMS = new TextArea();
                    tbNMS.setVisible(false);
                    tbNMS.setWidth(textWidth);
                    radNMS.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbNMS.setVisible(false);
                            cbNMS.setValue(true, true);
                        }
                    });
                    radNMS.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbNMS.setVisible(true);
                            cbNMS.setValue(true, true);
                        }
                    });
                    radNMS.setEnable(false);
                    tbNMS.setEnabled(false);
                    cbNMS.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbNMS.getValue()) {
                                radNMS.setEnable(true);
                                tbNMS.setEnabled(true);
                            } else {
                                radNMS.setEnable(false);
                                tbNMS.setEnabled(false);
                            }
                        }

                    });
                    entTable.setWidget(entRowCount, 0, cbNMS);
                    entTable.setWidget(entRowCount, 1, radNMS);
                    entTable.setWidget(entRowCount + 1, 0, tbNMS);
                    entTable.getFlexCellFormatter().setColSpan(entRowCount + 1, 0, 2);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 0, labelWidth);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 1, radWidth);
                    entRowCount = entRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeentnmsstatus")) {
                        radNMS.setWidgetValue(templateValuesMap.get("pnotespeentnmsstatus"), true);
                        tbNMS.setText(templateValuesMap.get("pnotespeentnmscmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeentnmsstatus")) {
                        radNMS.setWidgetValue(templateValuesMap.get("pnotestpeentnmsstatus"), true);
                        tbNMS.setText(templateValuesMap.get("pnotestpeentnmscmnt"));
                    }
                }

                if ((entSecList != null && entSecList.get(j).equals("Lips_gums_teeth"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbLGT = new CheckBox("Lips, gums, teeth");
                    cbLGT.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radLGT = new CustomRadioButtonGroup("lgt");
                    tbLGT = new TextArea();
                    tbLGT.setVisible(false);
                    tbLGT.setWidth(textWidth);
                    radLGT.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbLGT.setVisible(false);
                            cbLGT.setValue(true, true);
                        }
                    });
                    radLGT.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbLGT.setVisible(true);
                            cbLGT.setValue(true, true);
                        }
                    });
                    radLGT.setEnable(false);
                    tbLGT.setEnabled(false);
                    cbLGT.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbLGT.getValue()) {
                                radLGT.setEnable(true);
                                tbLGT.setEnabled(true);
                            } else {
                                radLGT.setEnable(false);
                                tbLGT.setEnabled(false);
                            }
                        }

                    });
                    entTable.setWidget(entRowCount, 0, cbLGT);
                    entTable.setWidget(entRowCount, 1, radLGT);
                    entTable.setWidget(entRowCount + 1, 0, tbLGT);
                    entTable.getFlexCellFormatter().setColSpan(entRowCount + 1, 0, 2);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 0, labelWidth);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 1, radWidth);
                    entRowCount = entRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeentlgtstatus")) {
                        radLGT.setWidgetValue(templateValuesMap.get("pnotespeentlgtstatus"), true);
                        tbLGT.setText(templateValuesMap.get("pnotespeentlgtcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeentlgtstatus")) {
                        radLGT.setWidgetValue(templateValuesMap.get("pnotestpeentlgtstatus"), true);
                        tbLGT.setText(templateValuesMap.get("pnotestpeentlgtcmnt"));
                    }
                }

                if ((entSecList != null && entSecList.get(j).equals("Oropharynx_mucosa_salivary glands"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbOMS = new CheckBox("Oropharynx, mucosa, salivary glands");
                    cbOMS.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radOMS = new CustomRadioButtonGroup("oms");
                    tbOMS = new TextArea();
                    tbOMS.setVisible(false);
                    tbOMS.setWidth(textWidth);
                    radOMS.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbOMS.setVisible(false);
                            cbOMS.setValue(true, true);
                        }
                    });
                    radOMS.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbOMS.setVisible(true);
                            cbOMS.setValue(true, true);
                        }
                    });
                    radOMS.setEnable(false);
                    tbOMS.setEnabled(false);
                    cbOMS.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbOMS.getValue()) {
                                radOMS.setEnable(true);
                                tbOMS.setEnabled(true);
                            } else {
                                radOMS.setEnable(false);
                                tbOMS.setEnabled(false);
                            }
                        }

                    });
                    entTable.setWidget(entRowCount, 0, cbOMS);
                    entTable.setWidget(entRowCount, 1, radOMS);
                    entTable.setWidget(entRowCount + 1, 0, tbOMS);
                    entTable.getFlexCellFormatter().setColSpan(entRowCount + 1, 0, 2);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 0, labelWidth);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 1, radWidth);
                    entRowCount = entRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeentomsgstatus")) {
                        radOMS.setWidgetValue(templateValuesMap.get("pnotespeentomsgstatus"), true);
                        tbOMS.setText(templateValuesMap.get("pnotespeentomsgcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeentomsgstatus")) {
                        radOMS.setWidgetValue(templateValuesMap.get("pnotestpeentomsgstatus"), true);
                        tbOMS.setText(templateValuesMap.get("pnotestpeentomsgcmnt"));
                    }
                }

                if ((entSecList != null
                        && entSecList.get(j).equals("Hard/soft palate_tongue_tonsils_posterior pharynx"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbHTTP = new CheckBox("Hard/soft palate, tongue, tonsils, posterior pharynx");
                    cbHTTP.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radHTTP = new CustomRadioButtonGroup("http");
                    tbHTTP = new TextArea();
                    tbHTTP.setVisible(false);
                    tbHTTP.setWidth(textWidth);
                    radHTTP.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbHTTP.setVisible(false);
                            cbHTTP.setValue(true, true);
                        }
                    });
                    radHTTP.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbHTTP.setVisible(true);
                            cbHTTP.setValue(true, true);
                        }
                    });
                    radHTTP.setEnable(false);
                    tbHTTP.setEnabled(false);
                    cbHTTP.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbHTTP.getValue()) {
                                radHTTP.setEnable(true);
                                tbHTTP.setEnabled(true);
                            } else {
                                radHTTP.setEnable(false);
                                tbHTTP.setEnabled(false);
                            }
                        }

                    });
                    entTable.setWidget(entRowCount, 0, cbHTTP);
                    entTable.setWidget(entRowCount, 1, radHTTP);
                    entTable.setWidget(entRowCount + 1, 0, tbHTTP);
                    entTable.getFlexCellFormatter().setColSpan(entRowCount + 1, 0, 2);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 0, labelWidth);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 1, radWidth);
                    entRowCount = entRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeenthttpstatus")) {
                        radHTTP.setWidgetValue(templateValuesMap.get("pnotespeenthttpstatus"), true);
                        tbHTTP.setText(templateValuesMap.get("pnotespeenthttpcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeenthttpstatus")) {
                        radHTTP.setWidgetValue(templateValuesMap.get("pnotestpeenthttpstatus"), true);
                        tbHTTP.setText(templateValuesMap.get("pnotestpeenthttpcmnt"));
                    }
                }

                if ((entSecList != null && entSecList.get(j).equals("Thyroid"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbThyroid = new CheckBox("Thyroid");
                    cbThyroid.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radThyroid = new CustomRadioButtonGroup("thy");
                    tbThyroid = new TextArea();
                    tbThyroid.setVisible(false);
                    tbThyroid.setWidth(textWidth);
                    radThyroid.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbThyroid.setVisible(false);
                            cbThyroid.setValue(true, true);
                        }
                    });
                    radThyroid.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbThyroid.setVisible(true);
                            cbThyroid.setValue(true, true);
                        }
                    });
                    radThyroid.setEnable(false);
                    tbThyroid.setEnabled(false);
                    cbThyroid.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbThyroid.getValue()) {
                                radThyroid.setEnable(true);
                                tbThyroid.setEnabled(true);
                            } else {
                                radThyroid.setEnable(false);
                                tbThyroid.setEnabled(false);
                            }
                        }

                    });
                    entTable.setWidget(entRowCount, 0, cbThyroid);
                    entTable.setWidget(entRowCount, 1, radThyroid);
                    entTable.setWidget(entRowCount + 1, 0, tbThyroid);
                    entTable.getFlexCellFormatter().setColSpan(entRowCount + 1, 0, 2);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setVerticalAlignment(entRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 0, labelWidth);
                    entTable.getFlexCellFormatter().setWidth(entRowCount, 1, radWidth);
                    entRowCount = entRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeentthyrostatus")) {
                        radThyroid.setWidgetValue(templateValuesMap.get("pnotespeentthyrostatus"), true);
                        tbThyroid.setText(templateValuesMap.get("pnotespeentthyrocmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeentthyrostatus")) {
                        radThyroid.setWidgetValue(templateValuesMap.get("pnotestpeentthyrostatus"), true);
                        tbThyroid.setText(templateValuesMap.get("pnotestpeentthyrocmnt"));
                    }
                }

                if ((entSecList != null && entSecList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (entSecList != null && entSecList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbEntFreeForm = new TextArea();
                    tbEntFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbEntFreeForm);
                    freeHp.setCellWidth(tbEntFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespeentfreecmnt")) {
                        tbEntFreeForm.setText(templateValuesMap.get("pnotespeentfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeentfreecmnt")) {
                        tbEntFreeForm.setText(templateValuesMap.get("pnotestpeentfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbEntExBill = new CheckBox("Procedure");
                cbEntExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                rightPanel.add(billPanel);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbEntExBill);
                billPanel.add(biw);
                // examPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespeent")) {
                    HashMap<String, String> m = billMap.get("pnotespeent");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespeent", biw);
                    cbEntExBill.setValue(true);

                }
                cbEntExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbEntExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbEntExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespeent", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespeent");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Neck"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int neckRowCount = 0;
            Label lbEntExam = new Label("Neck");
            lbEntExam.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbEntExam);
            final FlexTable neckTable = new FlexTable();
            neckTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(neckTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);
            int neckLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#Neck"))
                neckLoopCountMax = sectionsFieldMap.get("Sections#Exam#Neck").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Neck"))
                neckLoopCountMax = 0;
            else
                neckLoopCountMax = 1;
            List<String> neckSecList = sectionsFieldMap.get("Sections#Exam#Neck");
            for (int j = 0; j < neckLoopCountMax; j++) {

                if ((neckSecList != null && neckSecList.get(j).equals("Neck (note bruit_JVD)"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbNeck = new CheckBox("Neck (note bruit, JVD)");
                    cbNeck.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radNeck = new CustomRadioButtonGroup("neckexam");
                    tbNeckExam = new TextArea();
                    tbNeckExam.setVisible(false);
                    tbNeckExam.setWidth(textWidth);
                    radNeck.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbNeckExam.setVisible(false);
                            cbNeck.setValue(true, true);
                        }
                    });
                    radNeck.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbNeckExam.setVisible(true);
                            cbNeck.setValue(true, true);
                        }
                    });
                    radNeck.setEnable(false);
                    tbNeckExam.setEnabled(false);
                    cbNeck.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbNeck.getValue()) {
                                radNeck.setEnable(true);
                                tbNeckExam.setEnabled(true);
                            } else {
                                radNeck.setEnable(false);
                                tbNeckExam.setEnabled(false);
                            }
                        }

                    });
                    neckTable.setWidget(neckRowCount, 0, cbNeck);
                    neckTable.setWidget(neckRowCount, 1, radNeck);
                    neckTable.setWidget(neckRowCount + 1, 0, tbNeckExam);
                    neckTable.getFlexCellFormatter().setColSpan(neckRowCount + 1, 0, 2);
                    neckTable.getFlexCellFormatter().setVerticalAlignment(neckRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    neckTable.getFlexCellFormatter().setVerticalAlignment(neckRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    neckTable.getFlexCellFormatter().setWidth(neckRowCount, 0, labelWidth);
                    neckTable.getFlexCellFormatter().setWidth(neckRowCount, 1, radWidth);
                    neckRowCount = neckRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeneckbrjvdstatus")) {
                        radNeck.setWidgetValue(templateValuesMap.get("pnotespeneckbrjvdstatus"), true);
                        tbNeckExam.setText(templateValuesMap.get("pnotespeneckbrjvdcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneckbrjvdstatus")) {
                        radNeck.setWidgetValue(templateValuesMap.get("pnotestpeneckbrjvdstatus"), true);
                        tbNeckExam.setText(templateValuesMap.get("pnotestpeneckbrjvdcmnt"));
                    }
                }

                if ((neckSecList != null && neckSecList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (neckSecList != null && neckSecList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbNeckFreeForm = new TextArea();
                    tbNeckFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbNeckFreeForm);
                    freeHp.setCellWidth(tbNeckFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespeneckfreecmnt")) {
                        tbNeckFreeForm.setText(templateValuesMap.get("pnotespeneckfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneckfreecmnt")) {
                        tbNeckFreeForm.setText(templateValuesMap.get("pnotestpeneckfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbNeckExBill = new CheckBox("Procedure");
                cbNeckExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbNeckExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespeneck")) {
                    HashMap<String, String> m = billMap.get("pnotespeneck");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespeneck", biw);
                    cbNeckExBill.setValue(true);

                }
                cbNeckExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbNeckExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbNeckExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespeneck", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespeneck");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Breast"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int breastRowCount = 0;
            Label lbBreastExam = new Label("Breast");
            lbBreastExam.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbBreastExam);
            final FlexTable breastTable = new FlexTable();
            breastTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(breastTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int breastLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections")
                    && sectionsFieldMap.containsKey("Sections#Exam#Breast"))
                breastLoopCountMax = sectionsFieldMap.get("Sections#Exam#Breast").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Breast"))
                breastLoopCountMax = 0;
            else
                breastLoopCountMax = 1;
            List<String> breastSecList = sectionsFieldMap.get("Sections#Exam#Breast");
            for (int j = 0; j < breastLoopCountMax; j++) {

                if ((breastSecList != null
                        && breastSecList.get(j).equals("Breasts (note dimpling_discharge_mass)"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbBreast = new CheckBox("Breasts (note dimpling, discharge, mass)");
                    cbBreast.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radBreast = new CustomRadioButtonGroup("breastexam");
                    tbBreastExam = new TextArea();
                    tbBreastExam.setVisible(false);
                    tbBreastExam.setWidth(textWidth);
                    radBreast.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbBreastExam.setVisible(false);
                            cbBreast.setValue(true, true);
                        }
                    });
                    radBreast.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbBreastExam.setVisible(true);
                            cbBreast.setValue(true, true);
                        }
                    });
                    radBreast.setEnable(false);
                    tbBreastExam.setEnabled(false);
                    cbBreast.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbBreast.getValue()) {
                                radBreast.setEnable(true);
                                tbBreastExam.setEnabled(true);
                            } else {
                                radBreast.setEnable(false);
                                tbBreastExam.setEnabled(false);
                            }
                        }

                    });
                    breastTable.setWidget(breastRowCount, 0, cbBreast);
                    breastTable.setWidget(breastRowCount, 1, radBreast);
                    breastTable.setWidget(breastRowCount + 1, 0, tbBreastExam);
                    breastTable.getFlexCellFormatter().setColSpan(breastRowCount + 1, 0, 2);
                    breastTable.getFlexCellFormatter().setVerticalAlignment(breastRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    breastTable.getFlexCellFormatter().setVerticalAlignment(breastRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    breastTable.getFlexCellFormatter().setWidth(breastRowCount, 0, labelWidth);
                    breastTable.getFlexCellFormatter().setWidth(breastRowCount, 1, radWidth);
                    breastRowCount++;
                    if (templateValuesMap.containsKey("pnotespebrstddmstatus")) {
                        radBreast.setWidgetValue(templateValuesMap.get("pnotespebrstddmstatus"), true);
                        tbBreastExam.setText(templateValuesMap.get("pnotespebrstddmcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpebrstddmstatus")) {
                        radBreast.setWidgetValue(templateValuesMap.get("pnotestpebrstddmstatus"), true);
                        tbBreastExam.setText(templateValuesMap.get("pnotestpebrstddmcmnt"));
                    }
                }
                if ((breastSecList != null && breastSecList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (breastSecList != null && breastSecList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbBreastFreeForm = new TextArea();
                    tbBreastFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbBreastFreeForm);
                    freeHp.setCellWidth(tbBreastFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespebrstfreecmnt")) {
                        tbBreastFreeForm.setText(templateValuesMap.get("pnotespebrstfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpebrstfreecmnt")) {
                        tbBreastFreeForm.setText(templateValuesMap.get("pnotestpebrstfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbBreastExBill = new CheckBox("Procedure");
                cbBreastExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbBreastExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespechestbreast")) {
                    HashMap<String, String> m = billMap.get("pnotespechestbreast");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespechestbreast", biw);
                    cbBreastExBill.setValue(true);

                }
                cbBreastExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbBreastExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbBreastExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespechestbreast", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespechestbreast");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Resp"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int respRowCount = 0;
            Label lbRespExam = new Label("Resp");
            lbRespExam.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbRespExam);
            final FlexTable respTable = new FlexTable();
            respTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(respTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);
            int respLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#Resp"))
                respLoopCountMax = sectionsFieldMap.get("Sections#Exam#Resp").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Resp"))
                respLoopCountMax = 0;
            else
                respLoopCountMax = 1;
            List<String> respSecList = sectionsFieldMap.get("Sections#Exam#Resp");
            for (int j = 0; j < respLoopCountMax; j++) {

                if ((respSecList != null && respSecList.get(j).equals("Respiratory effort"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbRespEff = new CheckBox("Respiratory effort (note use of accessory muscles)");
                    cbRespEff.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radRespEff = new CustomRadioButtonGroup("respeff");
                    tbRespEff = new TextArea();
                    tbRespEff.setVisible(false);
                    tbRespEff.setWidth(textWidth);
                    radRespEff.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbRespEff.setVisible(false);
                            cbRespEff.setValue(true, true);
                        }
                    });
                    radRespEff.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbRespEff.setVisible(true);
                            cbRespEff.setValue(true, true);
                        }
                    });
                    radRespEff.setEnable(false);
                    tbRespEff.setEnabled(false);
                    cbRespEff.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbRespEff.getValue()) {
                                radRespEff.setEnable(true);
                                tbRespEff.setEnabled(true);
                            } else {
                                radRespEff.setEnable(false);
                                tbRespEff.setEnabled(false);
                            }
                        }

                    });
                    respTable.setWidget(respRowCount, 0, cbRespEff);
                    respTable.setWidget(respRowCount, 1, radRespEff);
                    respTable.setWidget(respRowCount + 1, 0, tbRespEff);
                    respTable.getFlexCellFormatter().setColSpan(respRowCount + 1, 0, 2);
                    respTable.getFlexCellFormatter().setVerticalAlignment(respRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    respTable.getFlexCellFormatter().setVerticalAlignment(respRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    respTable.getFlexCellFormatter().setWidth(respRowCount, 0, labelWidth);
                    respTable.getFlexCellFormatter().setWidth(respRowCount, 1, radWidth);
                    respRowCount = respRowCount + 2;

                    if (templateValuesMap.containsKey("pnotesperespeffstatus")) {
                        radRespEff.setWidgetValue(templateValuesMap.get("pnotesperespeffstatus"), true);
                        tbRespEff.setText(templateValuesMap.get("pnotesperespeffcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestperespeffstatus")) {
                        radRespEff.setWidgetValue(templateValuesMap.get("pnotestperespeffstatus"), true);
                        tbRespEff.setText(templateValuesMap.get("pnotestperespeffcmnt"));
                    }
                }

                if ((respSecList != null && respSecList.get(j).equals("Lung percussion & auscultation"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbLPA = new CheckBox("Lung percussion & auscultation");
                    cbLPA.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radLPA = new CustomRadioButtonGroup("lunper");
                    tbLPA = new TextArea();
                    tbLPA.setVisible(false);
                    tbLPA.setWidth(textWidth);
                    radLPA.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbLPA.setVisible(false);
                            cbLPA.setValue(true, true);
                        }
                    });
                    radLPA.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbLPA.setVisible(true);
                            cbLPA.setValue(true, true);
                        }
                    });
                    radLPA.setEnable(false);
                    tbLPA.setEnabled(false);
                    cbLPA.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbLPA.getValue()) {
                                radLPA.setEnable(true);
                                tbLPA.setEnabled(true);
                            } else {
                                radLPA.setEnable(false);
                                tbLPA.setEnabled(false);
                            }
                        }

                    });
                    respTable.setWidget(respRowCount, 0, cbLPA);
                    respTable.setWidget(respRowCount, 1, radLPA);
                    respTable.setWidget(respRowCount + 1, 0, tbLPA);
                    respTable.getFlexCellFormatter().setColSpan(respRowCount + 1, 0, 2);
                    respTable.getFlexCellFormatter().setVerticalAlignment(respRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    respTable.getFlexCellFormatter().setVerticalAlignment(respRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    respTable.getFlexCellFormatter().setWidth(respRowCount, 0, labelWidth);
                    respTable.getFlexCellFormatter().setWidth(respRowCount, 1, radWidth);
                    respRowCount = respRowCount + 2;
                    if (templateValuesMap.containsKey("pnotesperesplungstatus")) {
                        radLPA.setWidgetValue(templateValuesMap.get("pnotesperesplungstatus"), true);
                        tbLPA.setText(templateValuesMap.get("pnotesperesplungcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestperesplungstatus")) {
                        radLPA.setWidgetValue(templateValuesMap.get("pnotestperesplungstatus"), true);
                        tbLPA.setText(templateValuesMap.get("pnotestperesplungcmnt"));
                    }
                }
                if ((respSecList != null && respSecList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (respSecList != null && respSecList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbRespFreeForm = new TextArea();
                    tbRespFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbRespFreeForm);
                    freeHp.setCellWidth(tbRespFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotesperespfreecmnt")) {
                        tbRespFreeForm.setText(templateValuesMap.get("pnotesperespfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestperespfreecmnt")) {
                        tbRespFreeForm.setText(templateValuesMap.get("pnotestperespfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbRespExBill = new CheckBox("Procedure");
                cbRespExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbRespExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotesperesp")) {
                    HashMap<String, String> m = billMap.get("pnotesperesp");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotesperesp", biw);
                    cbRespExBill.setValue(true);

                }
                cbRespExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbRespExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbRespExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotesperesp", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotesperesp");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("CV"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int cvRowCount = 0;
            Label lbCV = new Label("CV");
            lbCV.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbCV);
            final FlexTable cvTable = new FlexTable();
            cvTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(cvTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int cvLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#CV"))
                cvLoopCountMax = sectionsFieldMap.get("Sections#Exam#CV").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#CV"))
                cvLoopCountMax = 0;
            else
                cvLoopCountMax = 1;
            List<String> cvList = sectionsFieldMap.get("Sections#Exam#CV");
            for (int j = 0; j < cvLoopCountMax; j++) {
                if ((cvList != null && cvList.get(j).equals("Auscultation"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    Label lbExtCanTms = new Label("Auscultation:");
                    lbExtCanTms.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    cvTable.setWidget(cvRowCount, 0, lbExtCanTms);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvRowCount++;
                    int auscultationLoopCountMax = 0;
                    if (sectionsFieldMap.containsKey("Sections")
                            && sectionsFieldMap.containsKey("Sections#Exam#CV#Auscultation"))
                        auscultationLoopCountMax = sectionsFieldMap.get("Sections#Exam#CV#Auscultation").size();
                    else if (sectionsFieldMap.containsKey("Sections")
                            && !sectionsFieldMap.containsKey("Sections#Exam#CV#Auscultation"))
                        auscultationLoopCountMax = 0;
                    else
                        auscultationLoopCountMax = 1;
                    List<String> auscultationSecList = sectionsFieldMap.get("Sections#Exam#CV#Auscultation");
                    for (int k = 0; k < auscultationLoopCountMax; k++) {

                        if ((auscultationSecList != null && auscultationSecList.get(k).equals("Regular rhythm"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbRegRyth = new CheckBox("Regular rhythm");
                            cbRegRyth.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbRegRyth.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radRegRyth = new CustomRadioButtonGroup("regrhy");
                            tbRegRyth = new TextArea();
                            tbRegRyth.setVisible(false);
                            tbRegRyth.setWidth(textWidth);
                            radRegRyth.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbRegRyth.setVisible(false);
                                    cbRegRyth.setValue(true, true);
                                }
                            });
                            radRegRyth.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbRegRyth.setVisible(true);
                                    cbRegRyth.setValue(true, true);

                                }
                            });
                            radRegRyth.setEnable(false);
                            tbRegRyth.setEnabled(false);
                            cbRegRyth.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbRegRyth.getValue()) {
                                        radRegRyth.setEnable(true);
                                        tbRegRyth.setEnabled(true);
                                    } else {
                                        radRegRyth.setEnable(false);
                                        tbRegRyth.setEnabled(false);
                                    }
                                }

                            });
                            cvTable.setWidget(cvRowCount, 0, cbRegRyth);
                            cvTable.setWidget(cvRowCount, 1, radRegRyth);
                            cvTable.setWidget(cvRowCount + 1, 0, tbRegRyth);
                            cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                            cvRowCount = cvRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespecvregrhystatus")) {
                                radRegRyth.setWidgetValue(templateValuesMap.get("pnotespecvregrhystatus"),
                                        true);
                                tbRegRyth.setText(templateValuesMap.get("pnotespecvregrhycmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpecvregrhystatus")) {
                                radRegRyth.setWidgetValue(templateValuesMap.get("pnotestpecvregrhystatus"),
                                        true);
                                tbRegRyth.setText(templateValuesMap.get("pnotestpecvregrhycmnt"));
                            }
                        }
                        if ((auscultationSecList != null && auscultationSecList.get(k).equals("S1 constant"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbS1Cons = new CheckBox("S1 constant");
                            cbS1Cons.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbS1Cons.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radS1Cons = new CustomRadioButtonGroup("s1cons");
                            tbS1Cons = new TextArea();
                            tbS1Cons.setVisible(false);
                            tbS1Cons.setWidth(textWidth);
                            radS1Cons.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbS1Cons.setVisible(false);
                                    cbS1Cons.setValue(true, true);
                                }
                            });
                            radS1Cons.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbS1Cons.setVisible(true);
                                    cbS1Cons.setValue(true, true);
                                }
                            });
                            radS1Cons.setEnable(false);
                            tbS1Cons.setEnabled(false);
                            cbS1Cons.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbS1Cons.getValue()) {
                                        radS1Cons.setEnable(true);
                                        tbS1Cons.setEnabled(true);
                                    } else {
                                        radS1Cons.setEnable(false);
                                        tbS1Cons.setEnabled(false);
                                    }
                                }

                            });
                            cvTable.setWidget(cvRowCount, 0, cbS1Cons);
                            cvTable.setWidget(cvRowCount, 1, radS1Cons);
                            cvTable.setWidget(cvRowCount + 1, 0, tbS1Cons);
                            cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                            cvRowCount = cvRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespecvs1consstatus")) {
                                radS1Cons.setWidgetValue(templateValuesMap.get("pnotespecvs1consstatus"), true);
                                tbS1Cons.setText(templateValuesMap.get("pnotespecvs1conscmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpecvs1consstatus")) {
                                radS1Cons.setWidgetValue(templateValuesMap.get("pnotestpecvs1consstatus"),
                                        true);
                                tbS1Cons.setText(templateValuesMap.get("pnotestpecvs1conscmnt"));
                            }
                        }

                        if ((auscultationSecList != null
                                && auscultationSecList.get(k).equals("S2 physiologic split"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbS2PhysSplit = new CheckBox("S2 physiologic split");
                            cbS2PhysSplit.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbS2PhysSplit.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radPhysSplit = new CustomRadioButtonGroup("s2phy");
                            tbPhysSplit = new TextArea();
                            tbPhysSplit.setVisible(false);
                            tbPhysSplit.setWidth(textWidth);
                            radPhysSplit.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbPhysSplit.setVisible(false);
                                    cbS2PhysSplit.setValue(true, true);
                                }
                            });
                            radPhysSplit.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbPhysSplit.setVisible(true);
                                    cbS2PhysSplit.setValue(true, true);
                                }
                            });
                            radPhysSplit.setEnable(false);
                            tbPhysSplit.setEnabled(false);
                            cbS2PhysSplit.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbS2PhysSplit.getValue()) {
                                        radPhysSplit.setEnable(true);
                                        tbPhysSplit.setEnabled(true);
                                    } else {
                                        radPhysSplit.setEnable(false);
                                        tbPhysSplit.setEnabled(false);
                                    }
                                }

                            });
                            cvTable.setWidget(cvRowCount, 0, cbS2PhysSplit);
                            cvTable.setWidget(cvRowCount, 1, radPhysSplit);
                            cvTable.setWidget(cvRowCount + 1, 0, tbPhysSplit);
                            cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                            cvRowCount = cvRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespecvs2physplstatus")) {
                                radPhysSplit.setWidgetValue(templateValuesMap.get("pnotespecvs2physplstatus"),
                                        true);
                                tbPhysSplit.setText(templateValuesMap.get("pnotespecvs2physplcmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpecvs2physplstatus")) {
                                radPhysSplit.setWidgetValue(templateValuesMap.get("pnotestpecvs2physplstatus"),
                                        true);
                                tbPhysSplit.setText(templateValuesMap.get("pnotestpecvs2physplcmnt"));
                            }
                        }

                        if ((auscultationSecList != null
                                && auscultationSecList.get(k).equals("Murmur (describe)"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbMurmur = new CheckBox("Murmur (describe)");
                            cbMurmur.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbMurmur.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radMurmur = new CustomRadioButtonGroup("murmur");
                            tbMurmur = new TextArea();
                            tbMurmur.setVisible(false);
                            tbMurmur.setWidth(textWidth);
                            radMurmur.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbMurmur.setVisible(false);
                                    cbMurmur.setValue(true, true);
                                }
                            });
                            radMurmur.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbMurmur.setVisible(true);
                                    cbMurmur.setValue(true, true);
                                }
                            });
                            radMurmur.setEnable(false);
                            tbMurmur.setEnabled(false);
                            cbMurmur.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbMurmur.getValue()) {
                                        radMurmur.setEnable(true);
                                        tbMurmur.setEnabled(true);
                                    } else {
                                        radMurmur.setEnable(false);
                                        tbMurmur.setEnabled(false);
                                    }
                                }

                            });
                            cvTable.setWidget(cvRowCount, 0, cbMurmur);
                            cvTable.setWidget(cvRowCount, 1, radMurmur);
                            cvTable.setWidget(cvRowCount + 1, 0, tbMurmur);
                            cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                            cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                            cvRowCount = cvRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespecvmurstatus")) {
                                radMurmur.setWidgetValue(templateValuesMap.get("pnotespecvmurstatus"), true);
                                tbMurmur.setText(templateValuesMap.get("pnotespecvmurcmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpecvmurstatus")) {
                                radMurmur.setWidgetValue(templateValuesMap.get("pnotestpecvmurstatus"), true);
                                tbMurmur.setText(templateValuesMap.get("pnotestpecvmurcmnt"));
                            }
                        }
                    }
                }

                if ((cvList != null && cvList.get(j).equals("Palpation of heart"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbPalHrt = new CheckBox("Palpation of heart");
                    cbPalHrt.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radPalHrt = new CustomRadioButtonGroup("palhrt");
                    tbPalHrt = new TextArea();
                    tbPalHrt.setVisible(false);
                    tbPalHrt.setWidth(textWidth);
                    radPalHrt.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbPalHrt.setVisible(false);
                            cbPalHrt.setValue(true, true);
                        }
                    });
                    radPalHrt.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbPalHrt.setVisible(true);
                            cbPalHrt.setValue(true, true);
                        }
                    });
                    radPalHrt.setEnable(false);
                    tbPalHrt.setEnabled(false);
                    cbPalHrt.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbPalHrt.getValue()) {
                                radPalHrt.setEnable(true);
                                tbPalHrt.setEnabled(true);
                            } else {
                                radPalHrt.setEnable(false);
                                tbPalHrt.setEnabled(false);
                            }
                        }

                    });
                    cvTable.setWidget(cvRowCount, 0, cbPalHrt);
                    cvTable.setWidget(cvRowCount, 1, radPalHrt);
                    cvTable.setWidget(cvRowCount + 1, 0, tbPalHrt);
                    cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                    cvRowCount = cvRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespecvpalhrtstatus")) {
                        radPalHrt.setWidgetValue(templateValuesMap.get("pnotespecvpalhrtstatus"), true);
                        tbPalHrt.setText(templateValuesMap.get("pnotespecvpalhrtcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpecvpalhrtstatus")) {
                        radPalHrt.setWidgetValue(templateValuesMap.get("pnotestpecvpalhrtstatus"), true);
                        tbPalHrt.setText(templateValuesMap.get("pnotestpecvpalhrtcmnt"));
                    }
                }

                if ((cvList != null && cvList.get(j).equals("Abdominal aorta"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbAbAorta = new CheckBox("Abdominal aorta");
                    cbAbAorta.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radAbAorta = new CustomRadioButtonGroup("abdaor");
                    tbAbAorta = new TextArea();
                    tbAbAorta.setVisible(false);
                    tbAbAorta.setWidth(textWidth);
                    radAbAorta.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbAbAorta.setVisible(false);
                            cbAbAorta.setValue(true, true);
                        }
                    });
                    radAbAorta.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbAbAorta.setVisible(true);
                            cbAbAorta.setValue(true, true);
                        }
                    });
                    radAbAorta.setEnable(false);
                    tbAbAorta.setEnabled(false);
                    cbAbAorta.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbAbAorta.getValue()) {
                                radAbAorta.setEnable(true);
                                tbAbAorta.setEnabled(true);
                            } else {
                                radAbAorta.setEnable(false);
                                tbAbAorta.setEnabled(false);
                            }
                        }

                    });
                    cvTable.setWidget(cvRowCount, 0, cbAbAorta);
                    cvTable.setWidget(cvRowCount, 1, radAbAorta);
                    cvTable.setWidget(cvRowCount + 1, 0, tbAbAorta);
                    cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                    cvRowCount = cvRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespecvabdaorstatus")) {
                        radAbAorta.setWidgetValue(templateValuesMap.get("pnotespecvabdaorstatus"), true);
                        tbAbAorta.setText(templateValuesMap.get("pnotespecvabdaorcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpecvabdaorstatus")) {
                        radAbAorta.setWidgetValue(templateValuesMap.get("pnotestpecvabdaorstatus"), true);
                        tbAbAorta.setText(templateValuesMap.get("pnotestpecvabdaorcmnt"));
                    }
                }

                if ((cvList != null && cvList.get(j).equals("Femoral arteries"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbFemArt = new CheckBox("Femoral arteries");
                    cbFemArt.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radFemArt = new CustomRadioButtonGroup("femart");
                    tbFemArt = new TextArea();
                    tbFemArt.setVisible(false);
                    tbFemArt.setWidth(textWidth);
                    radFemArt.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbFemArt.setVisible(false);
                            cbFemArt.setValue(true, true);
                        }
                    });
                    radFemArt.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbFemArt.setVisible(true);
                            cbFemArt.setValue(true, true);
                        }
                    });
                    radFemArt.setEnable(false);
                    tbFemArt.setEnabled(false);
                    cbFemArt.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbFemArt.getValue()) {
                                radFemArt.setEnable(true);
                                tbFemArt.setEnabled(true);
                            } else {
                                radFemArt.setEnable(false);
                                tbFemArt.setEnabled(false);
                            }
                        }

                    });
                    cvTable.setWidget(cvRowCount, 0, cbFemArt);
                    cvTable.setWidget(cvRowCount, 1, radFemArt);
                    cvTable.setWidget(cvRowCount + 1, 0, tbFemArt);
                    cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                    cvRowCount = cvRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespecvfemartstatus")) {
                        radFemArt.setWidgetValue(templateValuesMap.get("pnotespecvfemartstatus"), true);
                        tbFemArt.setText(templateValuesMap.get("pnotespecvfemartcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpecvfemartstatus")) {
                        radFemArt.setWidgetValue(templateValuesMap.get("pnotestpecvfemartstatus"), true);
                        tbFemArt.setText(templateValuesMap.get("pnotestpecvfemartcmnt"));
                    }
                }

                if ((cvList != null && cvList.get(j).equals("Pedal pulses"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbPedalPulses = new CheckBox("Pedal pulses");
                    cbPedalPulses.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radPedalPulses = new CustomRadioButtonGroup("pedpul");
                    tbPedalPulses = new TextArea();
                    tbPedalPulses.setVisible(false);
                    tbPedalPulses.setWidth(textWidth);
                    radPedalPulses.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbPedalPulses.setVisible(false);
                            cbPedalPulses.setValue(true, true);
                        }
                    });
                    radPedalPulses.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbPedalPulses.setVisible(true);
                            cbPedalPulses.setValue(true, true);
                        }
                    });
                    radPedalPulses.setEnable(false);
                    tbPedalPulses.setEnabled(false);
                    cbPedalPulses.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbPedalPulses.getValue()) {
                                radPedalPulses.setEnable(true);
                                tbPedalPulses.setEnabled(true);
                            } else {
                                radPedalPulses.setEnable(false);
                                tbPedalPulses.setEnabled(false);
                            }
                        }

                    });
                    cvTable.setWidget(cvRowCount, 0, cbPedalPulses);
                    cvTable.setWidget(cvRowCount, 1, radPedalPulses);
                    cvTable.setWidget(cvRowCount + 1, 0, tbPedalPulses);
                    cvTable.getFlexCellFormatter().setColSpan(cvRowCount + 1, 0, 2);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setVerticalAlignment(cvRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 0, labelWidth);
                    cvTable.getFlexCellFormatter().setWidth(cvRowCount, 1, radWidth);
                    cvRowCount = cvRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespecvpedpulstatus")) {
                        radPedalPulses.setWidgetValue(templateValuesMap.get("pnotespecvpedpulstatus"), true);
                        tbPedalPulses.setText(templateValuesMap.get("pnotespecvpadpulcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpecvpedpulstatus")) {
                        radPedalPulses.setWidgetValue(templateValuesMap.get("pnotestpecvpedpulstatus"), true);
                        tbPedalPulses.setText(templateValuesMap.get("pnotestpecvpadpulcmnt"));
                    }
                }
                if ((cvList != null && cvList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (cvList != null && cvList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbCVFreeForm = new TextArea();
                    tbCVFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbCVFreeForm);
                    freeHp.setCellWidth(tbCVFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespecvfreecmnt")) {
                        tbCVFreeForm.setText(templateValuesMap.get("pnotespecvfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpecvfreecmnt")) {
                        tbCVFreeForm.setText(templateValuesMap.get("pnotestpecvfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbCVExBill = new CheckBox("Procedure");
                cbCVExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbCVExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespecv")) {
                    HashMap<String, String> m = billMap.get("pnotespecv");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespecv", biw);
                    cbCVExBill.setValue(true);

                }
                cbCVExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbCVExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbCVExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespecv", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespecv");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("GI"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int giRowCount = 0;
            Label lbGI = new Label("GI");
            lbGI.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbGI);
            final FlexTable giTable = new FlexTable();
            giTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(giTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int giLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#GI"))
                giLoopCountMax = sectionsFieldMap.get("Sections#Exam#GI").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#GI"))
                giLoopCountMax = 0;
            else
                giLoopCountMax = 1;
            List<String> giList = sectionsFieldMap.get("Sections#Exam#GI");
            for (int j = 0; j < giLoopCountMax; j++) {
                if ((giList != null && giList.get(j).equals("Abdomen"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    Label lbAbd = new Label("Abdomen:");
                    lbAbd.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    giTable.setWidget(giRowCount, 0, lbAbd);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    giRowCount++;
                    int abdLoopCountMax = 0;
                    if (sectionsFieldMap.containsKey("Sections")
                            && sectionsFieldMap.containsKey("Sections#Exam#GI#Abdomen"))
                        abdLoopCountMax = sectionsFieldMap.get("Sections#Exam#GI#Abdomen").size();
                    else if (sectionsFieldMap.containsKey("Sections")
                            && !sectionsFieldMap.containsKey("Sections#Exam#GI#Abdomen"))
                        abdLoopCountMax = 0;
                    else
                        abdLoopCountMax = 1;
                    List<String> abdSecList = sectionsFieldMap.get("Sections#Exam#GI#Abdomen");

                    for (int k = 0; k < abdLoopCountMax; k++) {

                        if ((abdSecList != null && abdSecList.get(k).equals("Scars"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbScars = new CheckBox("Scars");
                            cbScars.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbScars.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radScars = new CustomRadioButtonGroup("scars");
                            tbScars = new TextArea();
                            tbScars.setVisible(false);
                            tbScars.setWidth(textWidth);
                            radScars.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbScars.setVisible(false);
                                    cbScars.setValue(true, true);
                                }
                            });
                            radScars.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbScars.setVisible(true);
                                    cbScars.setValue(true, true);
                                }
                            });
                            radScars.setEnable(false);
                            tbScars.setEnabled(false);
                            cbScars.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbScars.getValue()) {
                                        radScars.setEnable(true);
                                        tbScars.setEnabled(true);
                                    } else {
                                        radScars.setEnable(false);
                                        tbScars.setEnabled(false);
                                    }
                                }

                            });
                            giTable.setWidget(giRowCount, 0, cbScars);
                            giTable.setWidget(giRowCount, 1, radScars);
                            giTable.setWidget(giRowCount + 1, 0, tbScars);
                            giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                            giRowCount = giRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespegiscarsstatus")) {
                                radScars.setWidgetValue(templateValuesMap.get("pnotespegiscarsstatus"), true);
                                tbScars.setText(templateValuesMap.get("pnotespegiscarscmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpegiscarsstatus")) {
                                radScars.setWidgetValue(templateValuesMap.get("pnotestpegiscarsstatus"), true);
                                tbScars.setText(templateValuesMap.get("pnotestpegiscarscmnt"));
                            }
                        }
                        if ((abdSecList != null && abdSecList.get(k).equals("Bruit"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbBruit = new CheckBox("Bruit");
                            cbBruit.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbBruit.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radBruit = new CustomRadioButtonGroup("bruit");
                            tbBruit = new TextArea();
                            tbBruit.setVisible(false);
                            tbBruit.setWidth(textWidth);
                            radBruit.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbBruit.setVisible(false);
                                    cbBruit.setValue(true, true);
                                }
                            });
                            radBruit.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbBruit.setVisible(true);
                                    cbBruit.setValue(true, true);
                                }
                            });
                            radBruit.setEnable(false);
                            tbBruit.setEnabled(false);
                            cbBruit.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbBruit.getValue()) {
                                        radBruit.setEnable(true);
                                        tbBruit.setEnabled(true);
                                    } else {
                                        radBruit.setEnable(false);
                                        tbBruit.setEnabled(false);
                                    }
                                }

                            });
                            giTable.setWidget(giRowCount, 0, cbBruit);
                            giTable.setWidget(giRowCount, 1, radBruit);
                            giTable.setWidget(giRowCount + 1, 0, tbBruit);
                            giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                            giRowCount = giRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespegibruitstatus")) {
                                radBruit.setWidgetValue(templateValuesMap.get("pnotespegibruitstatus"), true);
                                tbBruit.setText(templateValuesMap.get("pnotespegibruitcmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpegibruitstatus")) {
                                radBruit.setWidgetValue(templateValuesMap.get("pnotestpegibruitstatus"), true);
                                tbBruit.setText(templateValuesMap.get("pnotestpegibruitcmnt"));
                            }
                        }

                        if ((abdSecList != null && abdSecList.get(k).equals("Mass"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbMassExam = new CheckBox("Mass");
                            cbMassExam.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbMassExam.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radMass = new CustomRadioButtonGroup("mass");
                            tbMass = new TextArea();
                            tbMass.setVisible(false);
                            tbMass.setWidth(textWidth);
                            radMass.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbMass.setVisible(false);
                                    cbMassExam.setValue(true, true);
                                }
                            });
                            radMass.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbMass.setVisible(true);
                                    cbMassExam.setValue(true, true);
                                }
                            });
                            radMass.setEnable(false);
                            tbMass.setEnabled(false);
                            cbMassExam.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbMassExam.getValue()) {
                                        radMass.setEnable(true);
                                        tbMass.setEnabled(true);
                                    } else {
                                        radMass.setEnable(false);
                                        tbMass.setEnabled(false);
                                    }
                                }

                            });
                            giTable.setWidget(giRowCount, 0, cbMassExam);
                            giTable.setWidget(giRowCount, 1, radMass);
                            giTable.setWidget(giRowCount + 1, 0, tbMass);
                            giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                            giRowCount = giRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespegimassstatus")) {
                                radMass.setWidgetValue(templateValuesMap.get("pnotespegimassstatus"), true);
                                tbMass.setText(templateValuesMap.get("pnotespegimasscmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpegimassstatus")) {
                                radMass.setWidgetValue(templateValuesMap.get("pnotestpegimassstatus"), true);
                                tbMass.setText(templateValuesMap.get("pnotestpegimasscmnt"));
                            }
                        }

                        if ((abdSecList != null && abdSecList.get(k).equals("Tenderness"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbTenderness = new CheckBox("Tenderness");
                            cbTenderness.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbTenderness.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radTenderness = new CustomRadioButtonGroup("tender");
                            tbTenderness = new TextArea();
                            tbTenderness.setVisible(false);
                            tbTenderness.setWidth(textWidth);
                            radTenderness.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbTenderness.setVisible(false);
                                    cbTenderness.setValue(true, true);
                                }
                            });
                            radTenderness.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbTenderness.setVisible(true);
                                    cbTenderness.setValue(true, true);
                                }
                            });
                            radTenderness.setEnable(false);
                            tbTenderness.setEnabled(false);
                            cbTenderness.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbTenderness.getValue()) {
                                        radTenderness.setEnable(true);
                                        tbTenderness.setEnabled(true);
                                    } else {
                                        radTenderness.setEnable(false);
                                        tbTenderness.setEnabled(false);
                                    }
                                }

                            });
                            giTable.setWidget(giRowCount, 0, cbTenderness);
                            giTable.setWidget(giRowCount, 1, radTenderness);
                            giTable.setWidget(giRowCount + 1, 0, tbTenderness);
                            giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                            giRowCount = giRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespegitendstatus")) {
                                radTenderness.setWidgetValue(templateValuesMap.get("pnotespegitendstatus"),
                                        true);
                                tbTenderness.setText(templateValuesMap.get("pnotespegitendcmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpegitendstatus")) {
                                radTenderness.setWidgetValue(templateValuesMap.get("pnotestpegitendstatus"),
                                        true);
                                tbTenderness.setText(templateValuesMap.get("pnotestpegitendcmnt"));
                            }
                        }
                        if ((abdSecList != null && abdSecList.get(k).equals("Hepatomegaly"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbHepatomegaly = new CheckBox("Hepatomegaly");
                            cbHepatomegaly.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbHepatomegaly.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radHepatomegaly = new CustomRadioButtonGroup("hepat");
                            tbHepatomegaly = new TextArea();
                            tbHepatomegaly.setVisible(false);
                            tbHepatomegaly.setWidth(textWidth);
                            radHepatomegaly.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbHepatomegaly.setVisible(false);
                                    cbHepatomegaly.setValue(true, true);
                                }
                            });
                            radHepatomegaly.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbHepatomegaly.setVisible(true);
                                    cbHepatomegaly.setValue(true, true);
                                }
                            });
                            radHepatomegaly.setEnable(false);
                            tbHepatomegaly.setEnabled(false);
                            cbHepatomegaly.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbHepatomegaly.getValue()) {
                                        radHepatomegaly.setEnable(true);
                                        tbHepatomegaly.setEnabled(true);
                                    } else {
                                        radHepatomegaly.setEnable(false);
                                        tbHepatomegaly.setEnabled(false);
                                    }
                                }

                            });
                            giTable.setWidget(giRowCount, 0, cbHepatomegaly);
                            giTable.setWidget(giRowCount, 1, radHepatomegaly);
                            giTable.setWidget(giRowCount + 1, 0, tbHepatomegaly);
                            giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                            giRowCount = giRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespegiheptstatus")) {
                                radHepatomegaly.setWidgetValue(templateValuesMap.get("pnotespegiheptstatus"),
                                        true);
                                tbHepatomegaly.setText(templateValuesMap.get("pnotespegiheptcmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpegiheptstatus")) {
                                radHepatomegaly.setWidgetValue(templateValuesMap.get("pnotestpegiheptstatus"),
                                        true);
                                tbHepatomegaly.setText(templateValuesMap.get("pnotestpegiheptcmnt"));
                            }
                        }
                        if ((abdSecList != null && abdSecList.get(k).equals("Splenomegaly"))
                                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES
                                        && currTemplate.equals(""))) {
                            cbSplenomegaly = new CheckBox("Splenomegaly");
                            cbSplenomegaly.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbSplenomegaly.getElement().getStyle().setMarginLeft(50, Unit.PX);
                            radSplenomegaly = new CustomRadioButtonGroup("splen");
                            tbSplenomegaly = new TextArea();
                            tbSplenomegaly.setVisible(false);
                            tbSplenomegaly.setWidth(textWidth);
                            radSplenomegaly.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbSplenomegaly.setVisible(false);
                                    cbSplenomegaly.setValue(true, true);
                                }
                            });
                            radSplenomegaly.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbSplenomegaly.setVisible(true);
                                    cbSplenomegaly.setValue(true, true);
                                }
                            });
                            radSplenomegaly.setEnable(false);
                            tbSplenomegaly.setEnabled(false);
                            cbSplenomegaly.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbSplenomegaly.getValue()) {
                                        radSplenomegaly.setEnable(true);
                                        tbSplenomegaly.setEnabled(true);
                                    } else {
                                        radSplenomegaly.setEnable(false);
                                        tbSplenomegaly.setEnabled(false);
                                    }
                                }
                            });
                            giTable.setWidget(giRowCount, 0, cbSplenomegaly);
                            giTable.setWidget(giRowCount, 1, radSplenomegaly);
                            giTable.setWidget(giRowCount + 1, 0, tbSplenomegaly);
                            giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                                    HasVerticalAlignment.ALIGN_TOP);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                            giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                            giRowCount = giRowCount + 2;
                            if (templateValuesMap.containsKey("pnotespegisplenstatus")) {
                                radSplenomegaly.setWidgetValue(templateValuesMap.get("pnotespegisplenstatus"),
                                        true);
                                tbSplenomegaly.setText(templateValuesMap.get("pnotespegisplencmnt"));
                            } else if (templateValuesMap.containsKey("pnotestpegisplenstatus")) {
                                radSplenomegaly.setWidgetValue(templateValuesMap.get("pnotestpegisplenstatus"),
                                        true);
                                tbSplenomegaly.setText(templateValuesMap.get("pnotestpegisplencmnt"));
                            }
                        }
                    }
                }

                if ((giList != null && giList.get(j).equals("Anus_perineum_rectum_sphincter tone"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbAPRS = new CheckBox("Anus, perineum, rectum, sphincter tone");
                    cbAPRS.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radAPRS = new CustomRadioButtonGroup("aprst");
                    tbAPRS = new TextArea();
                    tbAPRS.setVisible(false);
                    tbAPRS.setWidth(textWidth);
                    radAPRS.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbAPRS.setVisible(false);
                            cbAPRS.setValue(true, true);
                        }
                    });
                    radAPRS.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbAPRS.setVisible(true);
                            cbAPRS.setValue(true, true);
                        }
                    });
                    radAPRS.setEnable(false);
                    tbAPRS.setEnabled(false);
                    cbAPRS.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbAPRS.getValue()) {
                                radAPRS.setEnable(true);
                                tbAPRS.setEnabled(true);
                            } else {
                                radAPRS.setEnable(false);
                                tbAPRS.setEnabled(false);
                            }
                        }
                    });
                    giTable.setWidget(giRowCount, 0, cbAPRS);
                    giTable.setWidget(giRowCount, 1, radAPRS);
                    giTable.setWidget(giRowCount + 1, 0, tbAPRS);
                    giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                    giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                    giRowCount = giRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespegiaprsstatus")) {
                        radAPRS.setWidgetValue(templateValuesMap.get("pnotespegiaprsstatus"), true);
                        tbAPRS.setText(templateValuesMap.get("pnotespegiaprscmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpegiaprsstatus")) {
                        radAPRS.setWidgetValue(templateValuesMap.get("pnotestpegiaprsstatus"), true);
                        tbAPRS.setText(templateValuesMap.get("pnotestpegiaprscmnt"));
                    }
                }

                if ((giList != null && giList.get(j).equals("Bowel sounds"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbBowSnd = new CheckBox("Bowel sounds:");
                    cbBowSnd.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radBowSnd = new CustomRadioButtonGroup("bowsnd");
                    tbBowSnd = new TextArea();
                    tbBowSnd.setVisible(false);
                    tbBowSnd.setWidth(textWidth);
                    radBowSnd.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbBowSnd.setVisible(false);
                            cbBowSnd.setValue(true, true);
                        }
                    });
                    radBowSnd.addItem("High", "2", new Command() {
                        @Override
                        public void execute() {

                            tbBowSnd.setVisible(true);
                            cbBowSnd.setValue(true, true);
                        }
                    });
                    radBowSnd.addItem("Low", "3", new Command() {
                        @Override
                        public void execute() {

                            tbBowSnd.setVisible(true);
                            cbBowSnd.setValue(true, true);
                        }
                    });
                    radBowSnd.addItem("Absent", "4", new Command() {
                        @Override
                        public void execute() {

                            tbBowSnd.setVisible(true);
                            cbBowSnd.setValue(true, true);
                        }
                    });
                    radBowSnd.setEnable(false);
                    tbBowSnd.setEnabled(false);
                    cbBowSnd.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbBowSnd.getValue()) {
                                radBowSnd.setEnable(true);
                                tbBowSnd.setEnabled(true);
                            } else {
                                radBowSnd.setEnable(false);
                                tbBowSnd.setEnabled(false);
                            }
                        }
                    });
                    giTable.setWidget(giRowCount, 0, cbBowSnd);
                    giTable.setWidget(giRowCount, 1, radBowSnd);
                    giTable.setWidget(giRowCount + 1, 0, tbBowSnd);
                    giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                    giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                    giRowCount = giRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespegibowsndstatus")) {
                        radBowSnd.setWidgetValue(templateValuesMap.get("pnotespegibowsndstatus"), true);
                        tbBowSnd.setText(templateValuesMap.get("pnotespegibowsndcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpegibowsndstatus")) {
                        radBowSnd.setWidgetValue(templateValuesMap.get("pnotestpegibowsndstatus"), true);
                        tbBowSnd.setText(templateValuesMap.get("pnotestpegibowsndcmnt"));
                    }
                }

                if ((giList != null && giList.get(j).equals("Stool"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbStool = new CheckBox("Stool:");
                    cbStool.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radStool = new CustomRadioButtonGroup("stool");
                    tbStool = new TextArea();
                    tbStool.setVisible(false);
                    tbStool.setWidth(textWidth);
                    radStool.addItem("Heme positive", "1", new Command() {
                        @Override
                        public void execute() {

                            tbStool.setVisible(false);
                            cbStool.setValue(true, true);
                        }
                    });
                    radStool.addItem("Heme negative", "2", new Command() {
                        @Override
                        public void execute() {

                            tbStool.setVisible(true);
                            cbStool.setValue(true, true);
                        }
                    });
                    radStool.setEnable(false);
                    tbStool.setEnabled(false);
                    cbStool.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbStool.getValue()) {
                                radStool.setEnable(true);
                                tbStool.setEnabled(true);
                            } else {
                                radStool.setEnable(false);
                                tbStool.setEnabled(false);
                            }
                        }
                    });
                    giTable.setWidget(giRowCount, 0, cbStool);
                    giTable.setWidget(giRowCount, 1, radStool);
                    giTable.setWidget(giRowCount + 1, 0, tbStool);
                    giTable.getFlexCellFormatter().setColSpan(giRowCount + 1, 0, 2);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    giTable.getFlexCellFormatter().setVerticalAlignment(giRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    giTable.getFlexCellFormatter().setWidth(giRowCount, 0, labelWidth);
                    giTable.getFlexCellFormatter().setWidth(giRowCount, 1, radWidth);
                    giRowCount = giRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespegistoolstatus")) {
                        radStool.setWidgetValue(templateValuesMap.get("pnotespegistoolstatus"), true);
                        tbStool.setText(templateValuesMap.get("pnotespegistoolcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpegistoolstatus")) {
                        radStool.setWidgetValue(templateValuesMap.get("pnotestpegistoolstatus"), true);
                        tbStool.setText(templateValuesMap.get("pnotestpegistoolcmnt"));
                    }
                }
                if ((giList != null && giList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (giList != null && giList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbGIFreeForm = new TextArea();
                    tbGIFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbGIFreeForm);
                    freeHp.setCellWidth(tbGIFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespegifreecmnt")) {
                        tbGIFreeForm.setText(templateValuesMap.get("pnotespegifreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpegifreecmnt")) {
                        tbGIFreeForm.setText(templateValuesMap.get("pnotestpegifreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbGIExBill = new CheckBox("Procedure");
                cbGIExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbGIExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespegiabd")) {
                    HashMap<String, String> m = billMap.get("pnotespegiabd");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespegiabd", biw);
                    cbGIExBill.setValue(true);

                }
                cbGIExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbGIExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbGIExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespegiabd", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespegiabd");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("GU"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int guRowCount = 0;
            Label lbGU = new Label("GU");
            lbGU.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbGU);
            final FlexTable guTable = new FlexTable();
            guTable.setWidth("100%");
            guTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(guTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int guLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#GU"))
                guLoopCountMax = sectionsFieldMap.get("Sections#Exam#GU").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#GU"))
                guLoopCountMax = 0;
            else
                guLoopCountMax = 1;
            List<String> guList = sectionsFieldMap.get("Sections#Exam#GU");
            for (int j = 0; j < guLoopCountMax; j++) {
                if ((guList != null && guList.get(j).equals("Gender"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    Label lbGender = new Label("Gender:");
                    lbGender.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radGender = new CustomRadioButtonGroup("gender");
                    radPenis = new CustomRadioButtonGroup("penis");
                    tbPenis = new TextArea();
                    tbPenis.setVisible(false);
                    tbPenis.setWidth(textWidth);

                    radTestes = new CustomRadioButtonGroup("testes");
                    tbTestes = new TextArea();
                    tbTestes.setVisible(false);
                    tbTestes.setWidth(textWidth);

                    radProstate = new CustomRadioButtonGroup("prostate");
                    tbProstate = new TextArea();
                    tbProstate.setVisible(false);
                    tbProstate.setWidth(textWidth);

                    radExtGen = new CustomRadioButtonGroup("extgen");
                    tbExtGen = new TextArea();
                    tbExtGen.setVisible(false);
                    tbExtGen.setWidth(textWidth);

                    radCervix = new CustomRadioButtonGroup("cervix");
                    tbCervix = new TextArea();
                    tbCervix.setVisible(false);
                    tbCervix.setWidth(textWidth);

                    radUteAdn = new CustomRadioButtonGroup("uteradn");
                    tbUteAdn = new TextArea();
                    tbUteAdn.setVisible(false);
                    tbUteAdn.setWidth(textWidth);
                    final int r1 = guRowCount;
                    radGender.addItem("Male", "1", new Command() {
                        @Override
                        public void execute() {
                            cbPenis = new CheckBox("Penis");
                            cbPenis.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbPenis.getElement().getStyle().setMarginLeft(50, Unit.PX);

                            final int r11 = r1 + 1;
                            radPenis.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbPenis.setVisible(false);
                                    cbPenis.setValue(true, true);
                                }
                            });
                            radPenis.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbPenis.setVisible(true);
                                    cbPenis.setValue(true, true);
                                }
                            });
                            radPenis.setEnable(false);
                            tbPenis.setEnabled(false);
                            cbPenis.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbPenis.getValue()) {
                                        radPenis.setEnable(true);
                                        tbPenis.setEnabled(true);
                                    } else {
                                        radPenis.setEnable(false);
                                        tbPenis.setEnabled(false);
                                    }
                                }
                            });
                            guTable.setWidget(r11, 0, cbPenis);
                            guTable.setWidget(r11, 1, radPenis);
                            guTable.setWidget(r11 + 1, 0, tbPenis);
                            guTable.getFlexCellFormatter().setColSpan(r11 + 1, 0, 2);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r11, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r11, 1,
                                    HasVerticalAlignment.ALIGN_TOP);

                            cbTestes = new CheckBox("Testes");
                            cbTestes.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbTestes.getElement().getStyle().setMarginLeft(50, Unit.PX);

                            final int r12 = r1 + 4;
                            radTestes.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbTestes.setVisible(false);
                                    cbTestes.setValue(true, true);
                                }
                            });
                            radTestes.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbTestes.setVisible(true);
                                    cbTestes.setValue(true, true);
                                }
                            });
                            radTestes.setEnable(false);
                            tbTestes.setEnabled(false);
                            cbTestes.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbTestes.getValue()) {
                                        radTestes.setEnable(true);
                                        tbTestes.setEnabled(true);
                                    } else {
                                        radTestes.setEnable(false);
                                        tbTestes.setEnabled(false);
                                    }
                                }
                            });
                            guTable.setWidget(r12, 0, cbTestes);
                            guTable.setWidget(r12, 1, radTestes);
                            guTable.setWidget(r12 + 1, 0, tbTestes);
                            guTable.getFlexCellFormatter().setColSpan(r12 + 1, 0, 2);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r12, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r12, 1,
                                    HasVerticalAlignment.ALIGN_TOP);

                            cbProstate = new CheckBox("Prostate");
                            cbProstate.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbProstate.getElement().getStyle().setMarginLeft(50, Unit.PX);

                            final int r13 = r1 + 6;
                            radProstate.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbProstate.setVisible(false);
                                    cbProstate.setValue(true, true);
                                }
                            });
                            radProstate.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbProstate.setVisible(true);
                                    cbProstate.setValue(true, true);
                                }
                            });
                            radProstate.setEnable(false);
                            tbProstate.setEnabled(false);
                            cbProstate.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbProstate.getValue()) {
                                        radProstate.setEnable(true);
                                        tbProstate.setEnabled(true);
                                    } else {
                                        radProstate.setEnable(false);
                                        tbProstate.setEnabled(false);
                                    }
                                }
                            });
                            guTable.setWidget(r13, 0, cbProstate);
                            guTable.setWidget(r13, 1, radProstate);
                            guTable.setWidget(r13 + 1, 0, tbProstate);
                            guTable.getFlexCellFormatter().setColSpan(r13 + 1, 0, 2);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r13, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r13, 1,
                                    HasVerticalAlignment.ALIGN_TOP);

                        }
                    });
                    radGender.addItem("Female", "2", new Command() {
                        @Override
                        public void execute() {
                            cbExtGen = new CheckBox("External genitalia");
                            cbExtGen.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbExtGen.getElement().getStyle().setMarginLeft(50, Unit.PX);

                            final int r14 = r1 + 1;
                            radExtGen.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbExtGen.setVisible(false);
                                    cbExtGen.setValue(true, true);
                                }
                            });
                            radExtGen.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {
                                    tbExtGen.setVisible(true);
                                    cbExtGen.setValue(true, true);
                                }
                            });
                            radExtGen.setEnable(false);
                            tbExtGen.setEnabled(false);
                            cbExtGen.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbExtGen.getValue()) {
                                        radExtGen.setEnable(true);
                                        tbExtGen.setEnabled(true);
                                    } else {
                                        radExtGen.setEnable(false);
                                        tbExtGen.setEnabled(false);
                                    }
                                }
                            });
                            guTable.setWidget(r14, 0, cbExtGen);
                            guTable.setWidget(r14, 1, radExtGen);
                            guTable.setWidget(r14 + 1, 0, tbExtGen);
                            guTable.getFlexCellFormatter().setColSpan(r14 + 1, 0, 2);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r14, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r14, 1,
                                    HasVerticalAlignment.ALIGN_TOP);

                            cbCervix = new CheckBox("Cervix");
                            cbCervix.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbCervix.getElement().getStyle().setMarginLeft(50, Unit.PX);

                            final int r15 = r1 + 4;
                            radCervix.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbCervix.setVisible(false);
                                    cbCervix.setValue(true, true);
                                }
                            });
                            radCervix.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbCervix.setVisible(true);
                                    cbCervix.setValue(true, true);
                                }
                            });
                            radCervix.setEnable(false);
                            tbCervix.setEnabled(false);
                            cbCervix.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbCervix.getValue()) {
                                        radCervix.setEnable(true);
                                        tbCervix.setEnabled(true);
                                    } else {
                                        radCervix.setEnable(false);
                                        tbCervix.setEnabled(false);
                                    }
                                }
                            });
                            guTable.setWidget(r15, 0, cbCervix);
                            guTable.setWidget(r15, 1, radCervix);
                            guTable.setWidget(r15 + 1, 0, tbCervix);
                            guTable.getFlexCellFormatter().setColSpan(r15 + 1, 0, 2);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r15, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r15, 1,
                                    HasVerticalAlignment.ALIGN_TOP);

                            cbUteAdn = new CheckBox("Uterus/adnexa");
                            cbUteAdn.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                            cbUteAdn.getElement().getStyle().setMarginLeft(50, Unit.PX);

                            final int r16 = r1 + 6;
                            radUteAdn.addItem("Normal", "1", new Command() {
                                @Override
                                public void execute() {
                                    tbUteAdn.setVisible(false);
                                    cbUteAdn.setValue(true, true);
                                }
                            });
                            radUteAdn.addItem("Abnormal", "2", new Command() {
                                @Override
                                public void execute() {

                                    tbUteAdn.setVisible(true);
                                    cbUteAdn.setValue(true, true);
                                }
                            });
                            radUteAdn.setEnable(false);
                            tbUteAdn.setEnabled(false);
                            cbUteAdn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                                @Override
                                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                                    if (cbUteAdn.getValue()) {
                                        radUteAdn.setEnable(true);
                                        tbUteAdn.setEnabled(true);
                                    } else {
                                        radUteAdn.setEnable(false);
                                        tbUteAdn.setEnabled(false);
                                    }
                                }
                            });
                            guTable.setWidget(r16, 0, cbUteAdn);
                            guTable.setWidget(r16, 1, radUteAdn);
                            guTable.setWidget(r16 + 1, 0, tbUteAdn);
                            guTable.getFlexCellFormatter().setColSpan(r16 + 1, 0, 2);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r16, 0,
                                    HasVerticalAlignment.ALIGN_TOP);
                            guTable.getFlexCellFormatter().setVerticalAlignment(r16, 1,
                                    HasVerticalAlignment.ALIGN_TOP);

                        }
                    });
                    guTable.setWidget(guRowCount, 0, lbGender);
                    guTable.setWidget(guRowCount, 1, radGender);
                    guTable.getFlexCellFormatter().setVerticalAlignment(guRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    guTable.getFlexCellFormatter().setVerticalAlignment(guRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    guTable.getFlexCellFormatter().setWidth(guRowCount, 0, labelWidth);
                    guTable.getFlexCellFormatter().setWidth(guRowCount, 1, radWidth);
                    guTable.getFlexCellFormatter().setVerticalAlignment(guRowCount, 2,
                            HasVerticalAlignment.ALIGN_TOP);
                    guRowCount++;
                    if (templateValuesMap.containsKey("pnotespegugender")) {
                        if (templateValuesMap.get("pnotespegugender").equals("Male")) {
                            radGender.setWidgetValue("1", true);
                            if (templateValuesMap.containsKey("pnotespegupenisstatus")) {
                                radPenis.setWidgetValue(templateValuesMap.get("pnotespegupenisstatus"), true);
                                tbPenis.setText(templateValuesMap.get("pnotespegupeniscmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotespegutestesstatus")) {
                                radTestes.setWidgetValue(templateValuesMap.get("pnotespegutestesstatus"), true);
                                tbTestes.setText(templateValuesMap.get("pnotespegutestescmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotespeguproststatus")) {
                                radProstate.setWidgetValue(templateValuesMap.get("pnotespeguproststatus"),
                                        true);
                                tbProstate.setText(templateValuesMap.get("pnotespeguprostcmnt"));
                            }
                        } else if (templateValuesMap.get("pnotespegugender").equals("Female")) {
                            radGender.setWidgetValue("2", true);
                            if (templateValuesMap.containsKey("pnotespeguextgenstatus")) {
                                radExtGen.setWidgetValue(templateValuesMap.get("pnotespeguextgenstatus"), true);
                                tbExtGen.setText(templateValuesMap.get("pnotespeguextgencmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotespegucervixstatus")) {
                                radCervix.setWidgetValue(templateValuesMap.get("pnotespegucervixstatus"), true);
                                tbCervix.setText(templateValuesMap.get("pnotespegucervixcmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotespeguutadnstatus")) {
                                radUteAdn.setWidgetValue(templateValuesMap.get("pnotespeguutadnstatus"), true);
                                tbUteAdn.setText(templateValuesMap.get("pnotespeguutadncmnt"));
                            }
                        }
                    } else if (templateValuesMap.containsKey("pnotestpegugender")) {
                        if (templateValuesMap.get("pnotestpegugender").equals("Male")) {
                            radGender.setWidgetValue("1", true);
                            if (templateValuesMap.containsKey("pnotestpegupenisstatus")) {
                                radPenis.setWidgetValue(templateValuesMap.get("pnotestpegupenisstatus"), true);
                                tbPenis.setText(templateValuesMap.get("pnotestpegupeniscmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotestpegutestesstatus")) {
                                radTestes.setWidgetValue(templateValuesMap.get("pnotestpegutestesstatus"),
                                        true);
                                tbTestes.setText(templateValuesMap.get("pnotestpegutestescmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotestpeguproststatus")) {
                                radProstate.setWidgetValue(templateValuesMap.get("pnotestpeguproststatus"),
                                        true);
                                tbProstate.setText(templateValuesMap.get("pnotestpeguprostcmnt"));
                            }
                        } else if (templateValuesMap.get("pnotestpegugender").equals("Female")) {
                            radGender.setWidgetValue("2", true);
                            if (templateValuesMap.containsKey("pnotestpeguextgenstatus")) {
                                radExtGen.setWidgetValue(templateValuesMap.get("pnotestpeguextgenstatus"),
                                        true);
                                tbExtGen.setText(templateValuesMap.get("pnotestpeguextgencmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotestpegucervixstatus")) {
                                radCervix.setWidgetValue(templateValuesMap.get("pnotestpegucervixstatus"),
                                        true);
                                tbCervix.setText(templateValuesMap.get("pnotestpegucervixcmnt"));
                            }
                            if (templateValuesMap.containsKey("pnotestpeguutadnstatus")) {
                                radUteAdn.setWidgetValue(templateValuesMap.get("pnotestpeguutadnstatus"), true);
                                tbUteAdn.setText(templateValuesMap.get("pnotestpeguutadncmnt"));
                            }
                        }
                    }
                }
                if ((guList != null && guList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (guList != null && guList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbGUFreeForm = new TextArea();
                    tbGUFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbGUFreeForm);
                    freeHp.setCellWidth(tbGUFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespegufreecmnt")) {
                        tbGUFreeForm.setText(templateValuesMap.get("pnotespegufreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpegufreecmnt")) {
                        tbGUFreeForm.setText(templateValuesMap.get("pnotestpegufreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbGUExBill = new CheckBox("Procedure");
                cbGUExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbGUExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespegu")) {
                    HashMap<String, String> m = billMap.get("pnotespegu");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespegu", biw);
                    cbGUExBill.setValue(true);

                }
                cbGUExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbGUExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbGUExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespegu", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespegu");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Lymphatics"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int lympRowCount = 0;
            Label lbLymphatics = new Label("Lymphatics");
            lbLymphatics.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbLymphatics);
            final FlexTable lymphaticsTable = new FlexTable();
            lymphaticsTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(lymphaticsTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int lymphaticsLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections")
                    && sectionsFieldMap.containsKey("Sections#Exam#Lymphatics"))
                lymphaticsLoopCountMax = sectionsFieldMap.get("Sections#Exam#Lymphatics").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Lymphatics"))
                lymphaticsLoopCountMax = 0;
            else
                lymphaticsLoopCountMax = 1;
            List<String> lymphaticsList = sectionsFieldMap.get("Sections#Exam#Lymphatics");
            for (int j = 0; j < lymphaticsLoopCountMax; j++) {
                if ((lymphaticsList != null && lymphaticsList.get(j).equals("Lymph nodes"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbLympNode = new CheckBox("Lymph nodes");
                    cbLympNode.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radLympNode = new CustomRadioButtonGroup("lymnds");
                    tbLympNode = new TextArea();
                    tbLympNode.setVisible(false);
                    tbLympNode.setWidth(textWidth);
                    radLympNode.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbLympNode.setVisible(false);
                            cbLympNode.setValue(true, true);
                        }
                    });
                    radLympNode.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbLympNode.setVisible(true);
                            cbLympNode.setValue(true, true);
                        }
                    });
                    radLympNode.setEnable(false);
                    tbLympNode.setEnabled(false);
                    cbLympNode.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbLympNode.getValue()) {
                                radLympNode.setEnable(true);
                                tbLympNode.setEnabled(true);
                            } else {
                                radLympNode.setEnable(false);
                                tbLympNode.setEnabled(false);
                            }
                        }
                    });
                    lymphaticsTable.setWidget(lympRowCount, 0, cbLympNode);
                    lymphaticsTable.setWidget(lympRowCount, 1, radLympNode);
                    lymphaticsTable.setWidget(lympRowCount + 1, 0, tbLympNode);
                    lymphaticsTable.getFlexCellFormatter().setColSpan(lympRowCount + 1, 0, 2);
                    lymphaticsTable.getFlexCellFormatter().setVerticalAlignment(lympRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    lymphaticsTable.getFlexCellFormatter().setVerticalAlignment(lympRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    lymphaticsTable.getFlexCellFormatter().setWidth(lympRowCount, 0, labelWidth);
                    lymphaticsTable.getFlexCellFormatter().setWidth(lympRowCount, 1, radWidth);
                    lympRowCount = lympRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespelympnodesstatus")) {
                        radLympNode.setWidgetValue(templateValuesMap.get("pnotespelympnodesstatus"), true);
                        tbLympNode.setText(templateValuesMap.get("pnotespelympnodescmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpelympnodesstatus")) {
                        radLympNode.setWidgetValue(templateValuesMap.get("pnotestpelympnodesstatus"), true);
                        tbLympNode.setText(templateValuesMap.get("pnotestpelympnodescmnt"));
                    }
                }
                if ((lymphaticsList != null && lymphaticsList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (lymphaticsList != null && lymphaticsList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbLympFreeForm = new TextArea();
                    tbLympFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbLympFreeForm);
                    freeHp.setCellWidth(tbLympFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespelympfreecmnt")) {
                        tbLympFreeForm.setText(templateValuesMap.get("pnotespelympfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpelympfreecmnt")) {
                        tbLympFreeForm.setText(templateValuesMap.get("pnotestpelympfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbLympExBill = new CheckBox("Procedure");
                cbLympExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbLympExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespelymph")) {
                    HashMap<String, String> m = billMap.get("pnotespelymph");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespelymph", biw);
                    cbLympExBill.setValue(true);

                }
                cbLympExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbLympExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbLympExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespelymph", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespelymph");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Skin"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int skinRowCount = 0;
            Label lbSkin = new Label("Skin");
            lbSkin.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbSkin);
            final FlexTable skinTable = new FlexTable();
            skinTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(skinTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);
            int skinLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#Skin"))
                skinLoopCountMax = sectionsFieldMap.get("Sections#Exam#Skin").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Skin"))
                skinLoopCountMax = 0;
            else
                skinLoopCountMax = 1;
            List<String> skinList = sectionsFieldMap.get("Sections#Exam#Skin");
            for (int j = 0; j < skinLoopCountMax; j++) {
                if ((skinList != null && skinList.get(j).equals("Skin & SQ tissue"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbSkinSQTissue = new CheckBox("Skin & SQ tissue (describe any rash)");
                    cbSkinSQTissue.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radSkinSQTissue = new CustomRadioButtonGroup("sksq");
                    tbSkinSQTissue = new TextArea();
                    tbSkinSQTissue.setVisible(false);
                    tbSkinSQTissue.setWidth(textWidth);
                    radSkinSQTissue.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbSkinSQTissue.setVisible(false);
                            cbSkinSQTissue.setValue(true, true);
                        }
                    });
                    radSkinSQTissue.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbSkinSQTissue.setVisible(true);
                            cbSkinSQTissue.setValue(true, true);
                        }
                    });
                    radSkinSQTissue.setEnable(false);
                    tbSkinSQTissue.setEnabled(false);
                    cbSkinSQTissue.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbSkinSQTissue.getValue()) {
                                radSkinSQTissue.setEnable(true);
                                tbSkinSQTissue.setEnabled(true);
                            } else {
                                radSkinSQTissue.setEnable(false);
                                tbSkinSQTissue.setEnabled(false);
                            }
                        }
                    });
                    skinTable.setWidget(skinRowCount, 0, cbSkinSQTissue);
                    skinTable.setWidget(skinRowCount, 1, radSkinSQTissue);
                    skinTable.setWidget(skinRowCount + 1, 0, tbSkinSQTissue);
                    skinTable.getFlexCellFormatter().setColSpan(skinRowCount + 1, 0, 2);
                    skinTable.getFlexCellFormatter().setVerticalAlignment(skinRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    skinTable.getFlexCellFormatter().setVerticalAlignment(skinRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    skinTable.getFlexCellFormatter().setWidth(skinRowCount, 0, labelWidth);
                    skinTable.getFlexCellFormatter().setWidth(skinRowCount, 1, radWidth);
                    skinRowCount = skinRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeskintissuestatus")) {
                        radSkinSQTissue.setWidgetValue(templateValuesMap.get("pnotespeskintissuestatus"), true);
                        tbSkinSQTissue.setText(templateValuesMap.get("pnotespeskintissuecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeskintissuestatus")) {
                        radSkinSQTissue.setWidgetValue(templateValuesMap.get("pnotestpeskintissuestatus"),
                                true);
                        tbSkinSQTissue.setText(templateValuesMap.get("pnotestpeskintissuecmnt"));
                    }
                }

                if ((skinList != null && skinList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (skinList != null && skinList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbSkinFreeForm = new TextArea();
                    tbSkinFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbSkinFreeForm);
                    freeHp.setCellWidth(tbSkinFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespeskinfreecmnt")) {
                        tbSkinFreeForm.setText(templateValuesMap.get("pnotespeskinfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeskinfreecmnt")) {
                        tbSkinFreeForm.setText(templateValuesMap.get("pnotestpeskinfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbSkinExBill = new CheckBox("Procedure");
                cbSkinExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbSkinExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespeskin")) {
                    HashMap<String, String> m = billMap.get("pnotespeskin");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespeskin", biw);
                    cbSkinExBill.setValue(true);

                }
                cbSkinExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbSkinExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbSkinExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespeskin", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespeskin");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("MS"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int msRowCount = 0;
            Label lbMS = new Label("MS");
            lbMS.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbMS);
            final FlexTable msTable = new FlexTable();
            msTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(msTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);
            int msLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#MS"))
                msLoopCountMax = sectionsFieldMap.get("Sections#Exam#MS").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#MS"))
                msLoopCountMax = 0;
            else
                msLoopCountMax = 1;
            List<String> msList = sectionsFieldMap.get("Sections#Exam#MS");
            for (int j = 0; j < msLoopCountMax; j++) {
                if ((msList != null && msList.get(j).equals("Gait & station"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbGaitStat = new CheckBox("Gait & station");
                    cbGaitStat.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radGaitStat = new CustomRadioButtonGroup("gaitsec");
                    tbGaitStat = new TextArea();
                    tbGaitStat.setVisible(false);
                    tbGaitStat.setWidth(textWidth);
                    radGaitStat.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbGaitStat.setVisible(false);
                            cbGaitStat.setValue(true, true);
                        }
                    });
                    radGaitStat.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbGaitStat.setVisible(true);
                            cbGaitStat.setValue(true, true);
                        }
                    });
                    radGaitStat.setEnable(false);
                    tbGaitStat.setEnabled(false);
                    cbGaitStat.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbGaitStat.getValue()) {
                                radGaitStat.setEnable(true);
                                tbGaitStat.setEnabled(true);
                            } else {
                                radGaitStat.setEnable(false);
                                tbGaitStat.setEnabled(false);
                            }
                        }
                    });
                    msTable.setWidget(msRowCount, 0, cbGaitStat);
                    msTable.setWidget(msRowCount, 1, radGaitStat);
                    msTable.setWidget(msRowCount + 1, 0, tbGaitStat);
                    msTable.getFlexCellFormatter().setColSpan(msRowCount + 1, 0, 2);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 0, labelWidth);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 1, radWidth);
                    msRowCount = msRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespemsgaitststatus")) {
                        radGaitStat.setWidgetValue(templateValuesMap.get("pnotespemsgaitststatus"), true);
                        tbGaitStat.setText(templateValuesMap.get("pnotespemsgaitstcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpemsgaitststatus")) {
                        radGaitStat.setWidgetValue(templateValuesMap.get("pnotestpemsgaitststatus"), true);
                        tbGaitStat.setText(templateValuesMap.get("pnotestpemsgaitstcmnt"));
                    }
                }

                if ((msList != null && msList.get(j).equals("Digits_nails"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbDigitsNails = new CheckBox("Digits, nails");
                    cbDigitsNails.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radDigitsNails = new CustomRadioButtonGroup("dignails");
                    tbDigitsNails = new TextArea();
                    tbDigitsNails.setVisible(false);
                    tbDigitsNails.setWidth(textWidth);
                    radDigitsNails.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbDigitsNails.setVisible(false);
                            cbDigitsNails.setValue(true, true);
                        }
                    });
                    radDigitsNails.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbDigitsNails.setVisible(true);
                            cbDigitsNails.setValue(true, true);
                        }
                    });
                    radDigitsNails.setEnable(false);
                    tbDigitsNails.setEnabled(false);
                    cbDigitsNails.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbDigitsNails.getValue()) {
                                radDigitsNails.setEnable(true);
                                tbDigitsNails.setEnabled(true);
                            } else {
                                radDigitsNails.setEnable(false);
                                tbDigitsNails.setEnabled(false);
                            }
                        }
                    });
                    msTable.setWidget(msRowCount, 0, cbDigitsNails);
                    msTable.setWidget(msRowCount, 1, radDigitsNails);
                    msTable.setWidget(msRowCount + 1, 0, tbDigitsNails);
                    msTable.getFlexCellFormatter().setColSpan(msRowCount + 1, 0, 2);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 0, labelWidth);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 1, radWidth);
                    msRowCount = msRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespemsdignlsstatus")) {
                        radDigitsNails.setWidgetValue(templateValuesMap.get("pnotespemsdignlsstatus"), true);
                        tbDigitsNails.setText(templateValuesMap.get("pnotespemsdignlscmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpemsdignlsstatus")) {
                        radDigitsNails.setWidgetValue(templateValuesMap.get("pnotestpemsdignlsstatus"), true);
                        tbDigitsNails.setText(templateValuesMap.get("pnotestpemsdignlscmnt"));
                    }
                }

                if ((msList != null && msList.get(j).equals("ROM_stability"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbRomStability = new CheckBox("ROM, stability");
                    cbRomStability.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radRomStability = new CustomRadioButtonGroup("romstab");
                    tbRomStability = new TextArea();
                    tbRomStability.setVisible(false);
                    tbRomStability.setWidth(textWidth);
                    radRomStability.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbRomStability.setVisible(false);
                            cbRomStability.setValue(true, true);
                        }
                    });
                    radRomStability.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbRomStability.setVisible(true);
                            cbRomStability.setValue(true, true);
                        }
                    });
                    radRomStability.setEnable(false);
                    tbRomStability.setEnabled(false);
                    cbRomStability.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbRomStability.getValue()) {
                                radRomStability.setEnable(true);
                                tbRomStability.setEnabled(true);
                            } else {
                                radRomStability.setEnable(false);
                                tbRomStability.setEnabled(false);
                            }
                        }
                    });
                    msTable.setWidget(msRowCount, 0, cbRomStability);
                    msTable.setWidget(msRowCount, 1, radRomStability);
                    msTable.setWidget(msRowCount + 1, 0, tbRomStability);
                    msTable.getFlexCellFormatter().setColSpan(msRowCount + 1, 0, 2);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 0, labelWidth);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 1, radWidth);
                    msRowCount = msRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespemsromstbstatus")) {
                        radRomStability.setWidgetValue(templateValuesMap.get("pnotespemsromstbstatus"), true);
                        tbRomStability.setText(templateValuesMap.get("pnotespemsromstbcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpemsromstbstatus")) {
                        radRomStability.setWidgetValue(templateValuesMap.get("pnotestpemsromstbstatus"), true);
                        tbRomStability.setText(templateValuesMap.get("pnotestpemsromstbcmnt"));
                    }
                }

                if ((msList != null && msList.get(j).equals("Joints_bones_muscles"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbJntBnsMusc = new CheckBox("Joints, bones, muscles");
                    cbJntBnsMusc.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radJntBnsMusc = new CustomRadioButtonGroup("jbm");
                    tbJntBnsMusc = new TextArea();
                    tbJntBnsMusc.setVisible(false);
                    tbJntBnsMusc.setWidth(textWidth);
                    radJntBnsMusc.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbJntBnsMusc.setVisible(false);
                            cbJntBnsMusc.setValue(true, true);
                        }
                    });
                    radJntBnsMusc.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbJntBnsMusc.setVisible(true);
                            cbJntBnsMusc.setValue(true, true);
                        }
                    });
                    radJntBnsMusc.setEnable(false);
                    tbJntBnsMusc.setEnabled(false);
                    cbJntBnsMusc.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbJntBnsMusc.getValue()) {
                                radJntBnsMusc.setEnable(true);
                                tbJntBnsMusc.setEnabled(true);
                            } else {
                                radJntBnsMusc.setEnable(false);
                                tbJntBnsMusc.setEnabled(false);
                            }
                        }
                    });
                    msTable.setWidget(msRowCount, 0, cbJntBnsMusc);
                    msTable.setWidget(msRowCount, 1, radJntBnsMusc);
                    msTable.setWidget(msRowCount + 1, 0, tbJntBnsMusc);
                    msTable.getFlexCellFormatter().setColSpan(msRowCount + 1, 0, 2);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 0, labelWidth);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 1, radWidth);
                    msRowCount = msRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespemsjntbnsmusstatus")) {
                        radJntBnsMusc.setWidgetValue(templateValuesMap.get("pnotespemsjntbnsmusstatus"), true);
                        tbJntBnsMusc.setText(templateValuesMap.get("pnotespemsjntbnsmuscmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpemsjntbnsmusstatus")) {
                        radJntBnsMusc.setWidgetValue(templateValuesMap.get("pnotestpemsjntbnsmusstatus"), true);
                        tbJntBnsMusc.setText(templateValuesMap.get("pnotestpemsjntbnsmuscmnt"));
                    }
                }

                if ((msList != null && msList.get(j).equals("Muscle strength & tone"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbMuscStrg = new CheckBox("Muscle strength & tone");
                    cbMuscStrg.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radMuscStrg = new CustomRadioButtonGroup("musstrtone");
                    tbMuscStrg = new TextArea();
                    tbMuscStrg.setVisible(false);
                    tbMuscStrg.setWidth(textWidth);
                    radMuscStrg.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbMuscStrg.setVisible(false);
                            cbMuscStrg.setValue(true, true);
                        }
                    });
                    radMuscStrg.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbMuscStrg.setVisible(true);
                            cbMuscStrg.setValue(true, true);
                        }
                    });
                    radMuscStrg.setEnable(false);
                    tbMuscStrg.setEnabled(false);
                    cbMuscStrg.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbMuscStrg.getValue()) {
                                radMuscStrg.setEnable(true);
                                tbMuscStrg.setEnabled(true);
                            } else {
                                radMuscStrg.setEnable(false);
                                tbMuscStrg.setEnabled(false);
                            }
                        }
                    });
                    msTable.setWidget(msRowCount, 0, cbMuscStrg);
                    msTable.setWidget(msRowCount, 1, radMuscStrg);
                    msTable.setWidget(msRowCount + 1, 0, tbMuscStrg);
                    msTable.getFlexCellFormatter().setColSpan(msRowCount + 1, 0, 2);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setVerticalAlignment(msRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 0, labelWidth);
                    msTable.getFlexCellFormatter().setWidth(msRowCount, 1, radWidth);
                    msRowCount = msRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespemsmusstrtnstatus")) {
                        radMuscStrg.setWidgetValue(templateValuesMap.get("pnotespemsmusstrtnstatus"), true);
                        tbMuscStrg.setText(templateValuesMap.get("pnotespemsmusstrtncmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpemsmusstrtnstatus")) {
                        radMuscStrg.setWidgetValue(templateValuesMap.get("pnotestpemsmusstrtnstatus"), true);
                        tbMuscStrg.setText(templateValuesMap.get("pnotestpemsmusstrtncmnt"));
                    }
                }

                if ((msList != null && msList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (msList != null && msList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbMSFreeForm = new TextArea();
                    tbMSFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbMSFreeForm);
                    freeHp.setCellWidth(tbMSFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespemsfreecmnt")) {
                        tbMSFreeForm.setText(templateValuesMap.get("pnotespemsfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpemsfreecmnt")) {
                        tbMSFreeForm.setText(templateValuesMap.get("pnotestpemsfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbMSExBill = new CheckBox("Procedure");
                cbMSExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbMSExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespems")) {
                    HashMap<String, String> m = billMap.get("pnotespems");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespems", biw);
                    cbMSExBill.setValue(true);

                }
                cbMSExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbMSExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbMSExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespems", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespems");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Neuro"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int neuroRowCount = 0;
            Label lbNeuro = new Label("Neuro");
            lbNeuro.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbNeuro);
            final FlexTable neuroTable = new FlexTable();
            neuroTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(neuroTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);
            int neuroLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#Neuro"))
                neuroLoopCountMax = sectionsFieldMap.get("Sections#Exam#Neuro").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Neuro"))
                neuroLoopCountMax = 0;
            else
                neuroLoopCountMax = 1;
            List<String> neuroList = sectionsFieldMap.get("Sections#Exam#Neuro");
            for (int j = 0; j < neuroLoopCountMax; j++) {
                if ((neuroList != null && neuroList.get(j).equals("Cranial nerves (note deficits)"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbCranNerves = new CheckBox("Cranial nerves (note deficits)");
                    cbCranNerves.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radCranNerves = new CustomRadioButtonGroup("cranner");
                    tbCranNerves = new TextArea();
                    tbCranNerves.setVisible(false);
                    tbCranNerves.setWidth(textWidth);
                    radCranNerves.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbCranNerves.setVisible(false);
                            cbCranNerves.setValue(true, true);
                        }
                    });
                    radCranNerves.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbCranNerves.setVisible(true);
                            cbCranNerves.setValue(true, true);
                        }
                    });
                    radCranNerves.setEnable(false);
                    tbCranNerves.setEnabled(false);
                    cbCranNerves.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbCranNerves.getValue()) {
                                radCranNerves.setEnable(true);
                                tbCranNerves.setEnabled(true);
                            } else {
                                radCranNerves.setEnable(false);
                                tbCranNerves.setEnabled(false);
                            }
                        }
                    });
                    neuroTable.setWidget(neuroRowCount, 0, cbCranNerves);
                    neuroTable.setWidget(neuroRowCount, 1, radCranNerves);
                    neuroTable.setWidget(neuroRowCount + 1, 0, tbCranNerves);
                    neuroTable.getFlexCellFormatter().setColSpan(neuroRowCount + 1, 0, 2);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 0, labelWidth);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 1, radWidth);
                    neuroRowCount = neuroRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeneurocrnervstatus")) {
                        radCranNerves.setWidgetValue(templateValuesMap.get("pnotespeneurocrnervstatus"), true);
                        tbCranNerves.setText(templateValuesMap.get("pnotespeneurocrnervcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneurocrnervstatus")) {
                        radCranNerves.setWidgetValue(templateValuesMap.get("pnotestpeneurocrnervstatus"), true);
                        tbCranNerves.setText(templateValuesMap.get("pnotestpeneurocrnervcmnt"));
                    }
                }

                if ((neuroList != null && neuroList.get(j).equals("DTRs"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbDTRs = new CheckBox("DTRs");
                    cbDTRs.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radDTRs = new CustomRadioButtonGroup("dtrs");
                    tbDTRs = new TextArea();
                    tbDTRs.setVisible(false);
                    tbDTRs.setWidth(textWidth);
                    radDTRs.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbDTRs.setVisible(false);
                            cbDTRs.setValue(true, true);
                        }
                    });
                    radDTRs.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbDTRs.setVisible(true);
                            cbDTRs.setValue(true, true);
                        }
                    });
                    radDTRs.setEnable(false);
                    tbDTRs.setEnabled(false);
                    cbDTRs.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbDTRs.getValue()) {
                                radDTRs.setEnable(true);
                                tbDTRs.setEnabled(true);
                            } else {
                                radDTRs.setEnable(false);
                                tbDTRs.setEnabled(false);
                            }
                        }
                    });
                    neuroTable.setWidget(neuroRowCount, 0, cbDTRs);
                    neuroTable.setWidget(neuroRowCount, 1, radDTRs);
                    neuroTable.setWidget(neuroRowCount + 1, 0, tbDTRs);
                    neuroTable.getFlexCellFormatter().setColSpan(neuroRowCount + 1, 0, 2);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 0, labelWidth);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 1, radWidth);
                    neuroRowCount = neuroRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeneurodtrsstatus")) {
                        radDTRs.setWidgetValue(templateValuesMap.get("pnotespeneurodtrsstatus"), true);
                        tbDTRs.setText(templateValuesMap.get("pnotespeneurodtrscmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneurodtrsstatus")) {
                        radDTRs.setWidgetValue(templateValuesMap.get("pnotestpeneurodtrsstatus"), true);
                        tbDTRs.setText(templateValuesMap.get("pnotestpeneurodtrscmnt"));
                    }
                }

                if ((neuroList != null && neuroList.get(j).equals("Motor"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbMotor = new CheckBox("Motor");
                    cbMotor.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radMotor = new CustomRadioButtonGroup("motors");
                    tbMotor = new TextArea();
                    tbMotor.setVisible(false);
                    tbMotor.setWidth(textWidth);
                    radMotor.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbMotor.setVisible(false);
                            cbMotor.setValue(true, true);
                        }
                    });
                    radMotor.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {
                            tbMotor.setVisible(true);
                            cbMotor.setValue(true, true);
                        }
                    });
                    radMotor.setEnable(false);
                    tbMotor.setEnabled(false);
                    cbMotor.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbMotor.getValue()) {
                                radMotor.setEnable(true);
                                tbMotor.setEnabled(true);
                            } else {
                                radMotor.setEnable(false);
                                tbMotor.setEnabled(false);
                            }
                        }
                    });
                    neuroTable.setWidget(neuroRowCount, 0, cbMotor);
                    neuroTable.setWidget(neuroRowCount, 1, radMotor);
                    neuroTable.setWidget(neuroRowCount + 1, 0, tbMotor);
                    neuroTable.getFlexCellFormatter().setColSpan(neuroRowCount + 1, 0, 2);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 0, labelWidth);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 1, radWidth);
                    neuroRowCount = neuroRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeneuromotorstatus")) {
                        radMotor.setWidgetValue(templateValuesMap.get("pnotespeneuromotorstatus"), true);
                        tbMotor.setText(templateValuesMap.get("pnotespeneuromotorcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneuromotorstatus")) {
                        radMotor.setWidgetValue(templateValuesMap.get("pnotestpeneuromotorstatus"), true);
                        tbMotor.setText(templateValuesMap.get("pnotestpeneuromotorcmnt"));
                    }
                }

                if ((neuroList != null && neuroList.get(j).equals("Sensation"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbSensation = new CheckBox("Sensation");
                    cbSensation.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radSensation = new CustomRadioButtonGroup("sensation");
                    tbSensation = new TextArea();
                    tbSensation.setVisible(false);
                    tbSensation.setWidth(textWidth);
                    radSensation.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbSensation.setVisible(false);
                            cbSensation.setValue(true, true);
                        }
                    });
                    radSensation.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbSensation.setVisible(true);
                            cbSensation.setValue(true, true);
                        }
                    });
                    radSensation.setEnable(false);
                    tbSensation.setEnabled(false);
                    cbSensation.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbSensation.getValue()) {
                                radSensation.setEnable(true);
                                tbSensation.setEnabled(true);
                            } else {
                                radSensation.setEnable(false);
                                tbSensation.setEnabled(false);
                            }
                        }
                    });
                    neuroTable.setWidget(neuroRowCount, 0, cbSensation);
                    neuroTable.setWidget(neuroRowCount, 1, radSensation);
                    neuroTable.setWidget(neuroRowCount + 1, 0, tbSensation);
                    neuroTable.getFlexCellFormatter().setColSpan(neuroRowCount + 1, 0, 2);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setVerticalAlignment(neuroRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 0, labelWidth);
                    neuroTable.getFlexCellFormatter().setWidth(neuroRowCount, 1, radWidth);
                    neuroRowCount = neuroRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespeneurosnststatus")) {
                        radSensation.setWidgetValue(templateValuesMap.get("pnotespeneurosnststatus"), true);
                        tbSensation.setText(templateValuesMap.get("pnotespeneurosnstcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneurosnststatus")) {
                        radSensation.setWidgetValue(templateValuesMap.get("pnotestpeneurosnststatus"), true);
                        tbSensation.setText(templateValuesMap.get("pnotestpeneurosnstcmnt"));
                    }
                }
                if ((neuroList != null && neuroList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (neuroList != null && neuroList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbNeuroFreeForm = new TextArea();
                    tbNeuroFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbNeuroFreeForm);
                    freeHp.setCellWidth(tbNeuroFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespeneurofreecmnt")) {
                        tbNeuroFreeForm.setText(templateValuesMap.get("pnotespeneurofreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpeneurofreecmnt")) {
                        tbNeuroFreeForm.setText(templateValuesMap.get("pnotestpeneurofreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbNeuroExBill = new CheckBox("Procedure");
                cbNeuroExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbNeuroExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespeneuro")) {
                    HashMap<String, String> m = billMap.get("pnotespeneuro");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespeneuro", biw);
                    cbNeuroExBill.setValue(true);

                }
                cbNeuroExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbNeuroExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbNeuroExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespeneuro", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespeneuro");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }

        if ((secList != null && secList.get(i).equals("Psych"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            int psychRowCount = 0;
            Label lbPsych = new Label("Psych");
            lbPsych.setStyleName(AppConstants.STYLE_LABEL_HEADER_MEDIUM);
            examPanel.add(lbPsych);
            final FlexTable psychTable = new FlexTable();
            psychTable.getElement().getStyle().setMarginLeft(30, Unit.PX);
            HorizontalPanel hp = new HorizontalPanel();
            hp.setSpacing(10);
            VerticalPanel rightPanel = new VerticalPanel();
            rightPanel.setWidth("100%");
            rightPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
            rightPanel.setSpacing(5);
            hp.setWidth("100%");
            hp.add(psychTable);
            hp.add(rightPanel);
            hp.setCellWidth(rightPanel, "60%");
            examPanel.add(hp);

            int psychLoopCountMax = 0;
            if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Exam#Psych"))
                psychLoopCountMax = sectionsFieldMap.get("Sections#Exam#Psych").size();
            else if (sectionsFieldMap.containsKey("Sections")
                    && !sectionsFieldMap.containsKey("Sections#Exam#Psych"))
                psychLoopCountMax = 0;
            else
                psychLoopCountMax = 1;
            List<String> psychList = sectionsFieldMap.get("Sections#Exam#Psych");
            for (int j = 0; j < psychLoopCountMax; j++) {
                if ((psychList != null && psychList.get(j).equals("Judgment & insight"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbJudIns = new CheckBox("Judgment & insight");
                    cbJudIns.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radJudIns = new CustomRadioButtonGroup("judins");
                    tbJudIns = new TextArea();
                    tbJudIns.setVisible(false);
                    tbJudIns.setWidth(textWidth);
                    radJudIns.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbJudIns.setVisible(false);
                            cbJudIns.setValue(true, true);
                        }
                    });
                    radJudIns.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbJudIns.setVisible(true);
                            cbJudIns.setValue(true, true);
                        }
                    });
                    radJudIns.setEnable(false);
                    tbJudIns.setEnabled(false);
                    cbJudIns.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbJudIns.getValue()) {
                                radJudIns.setEnable(true);
                                tbJudIns.setEnabled(true);
                            } else {
                                radJudIns.setEnable(false);
                                tbJudIns.setEnabled(false);
                            }
                        }
                    });
                    psychTable.setWidget(psychRowCount, 0, cbJudIns);
                    psychTable.setWidget(psychRowCount, 1, radJudIns);
                    psychTable.setWidget(psychRowCount + 1, 0, tbJudIns);
                    psychTable.getFlexCellFormatter().setColSpan(psychRowCount + 1, 0, 2);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 0, labelWidth);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 1, radWidth);
                    psychRowCount = psychRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespepsychjudinsstatus")) {
                        radJudIns.setWidgetValue(templateValuesMap.get("pnotespepsychjudinsstatus"), true);
                        tbJudIns.setText(templateValuesMap.get("pnotespepsychjudinscmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpepsychjudinsstatus")) {
                        radJudIns.setWidgetValue(templateValuesMap.get("pnotestpepsychjudinsstatus"), true);
                        tbJudIns.setText(templateValuesMap.get("pnotestpepsychjudinscmnt"));
                    }
                }

                if ((psychList != null && psychList.get(j).equals("Mood & affect"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbMoodEffect = new CheckBox("Mood & affect");
                    cbMoodEffect.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radMoodEffect = new CustomRadioButtonGroup("moodeff");
                    tbMoodEffect = new TextArea();
                    tbMoodEffect.setVisible(false);
                    tbMoodEffect.setWidth(textWidth);
                    radMoodEffect.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbMoodEffect.setVisible(false);
                            cbMoodEffect.setValue(true, true);
                        }
                    });
                    radMoodEffect.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbMoodEffect.setVisible(true);
                            cbMoodEffect.setValue(true, true);
                        }
                    });
                    radMoodEffect.setEnable(false);
                    tbMoodEffect.setEnabled(false);
                    cbMoodEffect.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbMoodEffect.getValue()) {
                                radMoodEffect.setEnable(true);
                                tbMoodEffect.setEnabled(true);
                            } else {
                                radMoodEffect.setEnable(false);
                                tbMoodEffect.setEnabled(false);
                            }
                        }
                    });
                    psychTable.setWidget(psychRowCount, 0, cbMoodEffect);
                    psychTable.setWidget(psychRowCount, 1, radMoodEffect);
                    psychTable.setWidget(psychRowCount + 1, 0, tbMoodEffect);
                    psychTable.getFlexCellFormatter().setColSpan(psychRowCount + 1, 0, 2);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 0, labelWidth);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 1, radWidth);
                    psychRowCount = psychRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespepsychmoodeffstatus")) {
                        radMoodEffect.setWidgetValue(templateValuesMap.get("pnotespepsychmoodeffstatus"), true);
                        tbMoodEffect.setText(templateValuesMap.get("pnotespepsychmoodeffcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpepsychmoodeffstatus")) {
                        radMoodEffect.setWidgetValue(templateValuesMap.get("pnotestpepsychmoodeffstatus"),
                                true);
                        tbMoodEffect.setText(templateValuesMap.get("pnotestpepsychmoodeffcmnt"));
                    }
                }

                if ((psychList != null && psychList.get(j).equals("Oriented to time_place_person"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbOrTimePlcPers = new CheckBox("Oriented to time, place, person");
                    cbOrTimePlcPers.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radOrTimePlcPers = new CustomRadioButtonGroup("ortpp");
                    tbOrTimePlcPers = new TextArea();
                    tbOrTimePlcPers.setVisible(false);
                    tbOrTimePlcPers.setWidth(textWidth);
                    radOrTimePlcPers.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbOrTimePlcPers.setVisible(false);
                            cbOrTimePlcPers.setValue(true, true);
                        }
                    });
                    radOrTimePlcPers.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbOrTimePlcPers.setVisible(true);
                            cbOrTimePlcPers.setValue(true, true);

                        }
                    });
                    radOrTimePlcPers.setEnable(false);
                    tbOrTimePlcPers.setEnabled(false);
                    cbOrTimePlcPers.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbOrTimePlcPers.getValue()) {
                                radOrTimePlcPers.setEnable(true);
                                tbOrTimePlcPers.setEnabled(true);
                            } else {
                                radOrTimePlcPers.setEnable(false);
                                tbOrTimePlcPers.setEnabled(false);
                            }
                        }
                    });
                    psychTable.setWidget(psychRowCount, 0, cbOrTimePlcPers);
                    psychTable.setWidget(psychRowCount, 1, radOrTimePlcPers);
                    psychTable.setWidget(psychRowCount + 1, 0, tbOrTimePlcPers);
                    psychTable.getFlexCellFormatter().setColSpan(psychRowCount + 1, 0, 2);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 0, labelWidth);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 1, radWidth);
                    psychRowCount = psychRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespepsychorntppstatus")) {
                        radOrTimePlcPers.setWidgetValue(templateValuesMap.get("pnotespepsychorntppstatus"),
                                true);
                        tbOrTimePlcPers.setText(templateValuesMap.get("pnotespepsychorntppcmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpepsychorntppstatus")) {
                        radOrTimePlcPers.setWidgetValue(templateValuesMap.get("pnotestpepsychorntppstatus"),
                                true);
                        tbOrTimePlcPers.setText(templateValuesMap.get("pnotestpepsychorntppcmnt"));
                    }
                }

                if ((psychList != null && psychList.get(j).equals("Memory"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    cbMemory = new CheckBox("Memory");
                    cbMemory.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                    radMemory = new CustomRadioButtonGroup("memory");
                    tbMemory = new TextArea();
                    tbMemory.setVisible(false);
                    tbMemory.setWidth(textWidth);
                    radMemory.addItem("Normal", "1", new Command() {
                        @Override
                        public void execute() {
                            tbMemory.setVisible(false);
                            cbMemory.setValue(true, true);
                        }
                    });
                    radMemory.addItem("Abnormal", "2", new Command() {
                        @Override
                        public void execute() {

                            tbMemory.setVisible(true);
                            cbMemory.setValue(true, true);
                        }
                    });
                    radMemory.setEnable(false);
                    tbMemory.setEnabled(false);
                    cbMemory.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                        @Override
                        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                            if (cbMemory.getValue()) {
                                radMemory.setEnable(true);
                                tbMemory.setEnabled(true);
                            } else {
                                radMemory.setEnable(false);
                                tbMemory.setEnabled(false);
                            }
                        }
                    });
                    psychTable.setWidget(psychRowCount, 0, cbMemory);
                    psychTable.setWidget(psychRowCount, 1, radMemory);
                    psychTable.setWidget(psychRowCount + 1, 0, tbMemory);
                    psychTable.getFlexCellFormatter().setColSpan(psychRowCount + 1, 0, 2);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 0,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setVerticalAlignment(psychRowCount, 1,
                            HasVerticalAlignment.ALIGN_TOP);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 0, labelWidth);
                    psychTable.getFlexCellFormatter().setWidth(psychRowCount, 1, radWidth);
                    psychRowCount = psychRowCount + 2;
                    if (templateValuesMap.containsKey("pnotespepsychmemorystatus")) {
                        radMemory.setWidgetValue(templateValuesMap.get("pnotespepsychmemorystatus"), true);
                        tbMemory.setText(templateValuesMap.get("pnotespepsychmemorycmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpepsychmemorystatus")) {
                        radMemory.setWidgetValue(templateValuesMap.get("pnotestpepsychmemorystatus"), true);
                        tbMemory.setText(templateValuesMap.get("pnotestpepsychmemorycmnt"));
                    }
                }
                if ((psychList != null && psychList.get(j).equals("Free Form Entry"))
                        || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
                    if (psychList != null && psychList.size() == 1)
                        hp.setCellWidth(rightPanel, "100%");
                    Label lbfreeform = new Label("Free Form Entry");
                    lbfreeform.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

                    tbPsychFreeForm = new TextArea();
                    tbPsychFreeForm.setWidth(textWidth);
                    HorizontalPanel freeHp = new HorizontalPanel();
                    freeHp.setWidth("80%");
                    freeHp.setSpacing(5);
                    freeHp.add(lbfreeform);
                    freeHp.add(tbPsychFreeForm);
                    freeHp.setCellWidth(tbPsychFreeForm, "80%");
                    rightPanel.add(freeHp);

                    if (templateValuesMap.containsKey("pnotespepsychfreecmnt")) {
                        tbPsychFreeForm.setText(templateValuesMap.get("pnotespepsychfreecmnt"));
                    } else if (templateValuesMap.containsKey("pnotestpepsychfreecmnt")) {
                        tbPsychFreeForm.setText(templateValuesMap.get("pnotestpepsychfreecmnt"));
                    }
                }
            }
            if (formtype == EncounterFormType.TEMPLATE_VALUES
                    || formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                VerticalPanel billPanel = new VerticalPanel();
                billPanel.setSpacing(2);
                cbPsychExBill = new CheckBox("Procedure");
                cbPsychExBill.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                final BillInfoWidget biw = new BillInfoWidget();
                billPanel.add(cbPsychExBill);
                billPanel.add(biw);
                rightPanel.add(billPanel);
                biw.setVisible(false);
                if (isBillables && billMap.containsKey("pnotespepsych")) {
                    HashMap<String, String> m = billMap.get("pnotespepsych");
                    biw.setVisible(true);
                    biw.setProceduralCode(new Integer(m.get("proccode")));
                    biw.setDiagnosisCode(new Integer(m.get("diagcode")));
                    billingFieldsWidgetsMap.put("pnotespepsych", biw);
                    cbPsychExBill.setValue(true);

                }
                cbPsychExBill.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent arg0) {
                        if (cbPsychExBill.getValue()) {
                            if (maxbillables == billingFieldsWidgetsMap.size()) {
                                Window.alert("Only " + maxbillables + " procedures can be created...");
                                cbPsychExBill.setValue(false);
                            } else {
                                billingFieldsWidgetsMap.put("pnotespepsych", biw);
                                biw.setVisible(true);
                            }
                        } else {
                            billingFieldsWidgetsMap.remove("pnotespepsych");
                            biw.setVisible(false);
                        }
                    }
                });
            }
        }
    }
    examTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    examPanel.add(examTable);
}

From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java

License:Open Source License

/**
 * Add additional address object to a particular position on the flexTable.
 * // www  . ja  va2 s .co  m
 * @param pos
 *            Integer row number
 * @param a
 *            Address object containing population data.
 */
public void addAddress(final Integer pos, final Address a) {
    // Keep a record of this
    addresses.put(pos, a);

    // It obviously hasn't been updated yet
    a.setUpdated(Boolean.FALSE);

    final CustomListBox type = new CustomListBox();
    type.setVisibleItemCount(1);
    type.addItem("H - " + _("Home"), "H");
    type.addItem("W - " + _("Work"), "W");
    if (a.getType() != null)
        type.setWidgetValue(a.getType());
    flexTable.getFlexTable().setWidget(pos, 0, type);

    final CustomListBox relation = new CustomListBox();
    relation.setVisibleItemCount(1);
    relation.addItem("S - " + _("Self"), "S");
    relation.addItem("P - " + _("Parents"), "P");
    relation.addItem("C - " + _("Cousin"), "C");
    relation.addItem("SH - " + _("Shelter"), "SH");
    relation.addItem("U - " + _("Unrelated"), "U");
    if (a.getRelation() != null)
        relation.setWidgetValue(a.getRelation());
    flexTable.getFlexTable().setWidget(pos, 1, relation);

    final TextBox line1 = new TextBox();
    line1.setText(a.getLine1());
    flexTable.getFlexTable().setWidget(pos, 2, line1);

    final TextBox line2 = new TextBox();
    line2.setText(a.getLine2());
    flexTable.getFlexTable().setWidget(pos, 3, line2);

    // final TextBox csz = new TextBox();
    // csz.setText(a.getCsz());
    // flexTable.getFlexTable().setWidget(pos, 4, csz);

    final TextBox city = new TextBox();
    city.setText(a.getCity());
    flexTable.getFlexTable().setWidget(pos, 4, city);

    final TextBox stpr = new TextBox();
    stpr.setWidth("5em");
    stpr.setText(a.getStpr());
    flexTable.getFlexTable().setWidget(pos, 5, stpr);

    final TextBox postal = new TextBox();
    postal.setWidth("5em");
    postal.setText(a.getPostal());
    flexTable.getFlexTable().setWidget(pos, 6, postal);

    final TextBox country = new TextBox();
    country.setText(a.getCountry());
    flexTable.getFlexTable().setWidget(pos, 7, country);

    final CheckBox active = new CheckBox();
    active.setValue(a.getActive().booleanValue());
    flexTable.getFlexTable().setWidget(pos, 8, active);

    final CustomButton deleteLink = new CustomButton(_("Delete"), AppConstants.ICON_DELETE);
    flexTable.getFlexTable().setWidget(pos, 9, deleteLink);

    deleteLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            for (int i = 0; i <= 9; i++)
                flexTable.getFlexTable().clearCell(pos, i);
            deleteAddress(a);
        }

    });

    ChangeHandler cl = new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            Address x = addresses.get(pos);
            x.setType(type.getWidgetValue());
            x.setRelation(relation.getWidgetValue());
            x.setLine1(line1.getText());
            x.setLine2(line2.getText());
            // x.setCsz(csz.getText());
            x.setCity(city.getText());
            x.setStpr(stpr.getText());
            x.setPostal(postal.getText());
            x.setCountry(country.getText());
            x.setUpdated(Boolean.TRUE);
            x.setActive(new Boolean(active.getValue()));
            addresses.put(pos, x);

            // Sanity check: uncheck all other active ones
            if (active.getValue()) {
                setActiveAddress(pos);
            }
        }
    };

    // Implement changelisteners
    type.addChangeHandler(cl);
    relation.addChangeHandler(cl);
    line1.addChangeHandler(cl);
    line2.addChangeHandler(cl);
    // csz.addChangeHandler(cl);
    city.addChangeHandler(cl);
    stpr.addChangeHandler(cl);
    postal.addChangeHandler(cl);
    country.addChangeHandler(cl);
    active.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent evt) {
            Address x = addresses.get(pos);
            x.setActive(((CheckBox) evt.getSource()).getValue());
            addresses.put(pos, x);

            // Sanity check: uncheck all other active ones
            if (((CheckBox) evt.getSource()).getValue()) {
                setActiveAddress(pos);
            }
        }
    });
}

From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java

License:Open Source License

/**
 * Set the address at flexTable row p to be the only one set active.
 * // w ww  .j a  v a  2s.c  om
 * @param p
 *            Active table row position.
 */
protected void setActiveAddress(Integer p) {
    Iterator<Integer> kI = addresses.keySet().iterator();
    while (kI.hasNext()) {
        Integer thisKey = kI.next();
        if (thisKey.compareTo(p) != 0) {
            CheckBox cb = (CheckBox) flexTable.getFlexTable().getWidget(thisKey, 5);
            cb.setValue(false);
        }
    }
}