Example usage for com.google.gwt.user.client.ui HorizontalPanel setSpacing

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setSpacing

Introduction

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

Prototype

public void setSpacing(int spacing) 

Source Link

Document

Sets the amount of spacing between this panel's cells.

Usage

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

License:Open Source License

private String getHeaderString(String text, AbstractImagePrototype image) {
    // Add the image and text to a horizontal panel
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setSpacing(0);
    hPanel.setWidth("100%");
    hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    hPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    if (image != null)
        hPanel.add(image.createImage());
    HTML headerText = new HTML(text);
    headerText.setStyleName("stackPanelHeader");
    hPanel.add(headerText);//ww  w. java 2s .  co m

    // Return the HTML string for the panel
    return hPanel.getElement().getString();
}

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 ww .  j  a  v a2 s.c o m
    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.PerformBilling.java

License:Open Source License

public PerformBilling() {
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    initWidget(horizontalPanel);/* ww  w .j  ava 2s . c o  m*/
    horizontalPanel.setSize("100%", "100%");

    VerticalPanel performBillPanel = new VerticalPanel();
    horizontalPanel.add(performBillPanel);
    performBillPanel.setSize("100%", "100%");

    final Label performBillingLabel = new Label(_("Performing Bills"));
    performBillingLabel.setStyleName(AppConstants.STYLE_LABEL_HEADER_LARGE);
    performBillPanel.add(performBillingLabel);
    performBillingLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    HorizontalPanel horizontalPanel1 = new HorizontalPanel();
    horizontalPanel1.setSpacing(5);
    horizontalPanel1.add(new CustomButton(_("Process"), AppConstants.ICON_RUN));
    horizontalPanel1.add(new CustomButton(_("Select All"), AppConstants.ICON_SELECT_ALL));
    horizontalPanel1.add(new CustomButton(_("Select None"), AppConstants.ICON_SELECT_NONE));
    horizontalPanel1.add(new CustomButton(_("Return to Main Menu"), AppConstants.ICON_PREV));
    performBillPanel.add(horizontalPanel1);

}

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

License:Open Source License

public ActionItemsBox(boolean showPatientName) {
    this.showPatientName = showPatientName;

    VerticalPanel superVPanel = new VerticalPanel();
    initWidget(superVPanel);//  www.  j a v  a  2  s.  co  m
    superVPanel.setStyleName(AppConstants.STYLE_BUTTON_WIDGETS_CONTAINER);
    superVPanel.setWidth("100%");

    HorizontalPanel headerHPanel = new HorizontalPanel();
    headerHPanel.setSpacing(5);
    superVPanel.add(headerHPanel);

    colExpBtn = new Image(Util.getResourcesURL() + "collapse.15x15.png");
    colExpBtn.getElement().getStyle().setCursor(Cursor.POINTER);
    headerHPanel.add(colExpBtn);
    colExpBtn.addClickHandler(new ClickHandler() {
        boolean expanded = false;

        @Override
        public void onClick(ClickEvent arg0) {
            if (expanded) {
                colExpBtn.setUrl(Util.getResourcesURL() + "collapse.15x15.png");
                contentVPanel.setVisible(true);
            } else {
                colExpBtn.setUrl(Util.getResourcesURL() + "expand.15x15.png");
                contentVPanel.setVisible(false);
            }
            expanded = !expanded;
        }
    });

    Label headerLabel = new Label(_("ACTION ITEMS"));
    headerHPanel.add(headerLabel);
    headerLabel.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

    contentVPanel = new VerticalPanel();
    contentVPanel.setWidth("100%");
    superVPanel.add(contentVPanel);

    contentVPanel.add(actionItemsTable);
    actionItemsTable.setSize("100%", "100%");
    actionItemsTable.addColumn(_("Date"), "stamp"); // col 0
    // marya
    if (this.showPatientName)
        actionItemsTable.addColumn(_("Patient"), "patient_name"); // col 1
    actionItemsTable.addColumn(_("Module Name"), "status_name"); // col 2
    actionItemsTable.addColumn(_("Status"), "summary"); // col 4
    actionItemsTable.addColumn(_("Action"), "action"); // col 4
    actionItemsTable.setIndexName("id");
    actionItemsTable.setMaximumRows(7);
    if (true) {
        actionItemsTable.setTableRowClickHandler(new TableRowClickHandler() {
            @Override
            public void handleRowClick(HashMap<String, String> data, int col) {
                // Get information on row...
                try {
                    final Integer messageId = Integer.parseInt(data.get("id"));
                    JsonUtil.debug("Found messageId " + messageId);
                    if ((col == 0) || (col == 2)) {
                    }
                } catch (Exception e) {
                    GWT.log("Caught exception: ", e);
                }
            }
        });
    }
    actionItemsTable.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {
        @Override
        public Widget setColumn(String columnName, HashMap<String, String> data) {
            // Render only action column, otherwise skip renderer
            if (columnName.compareToIgnoreCase("action") != 0) {
                return null;
            }
            final CustomActionBar actionBar = new CustomActionBar(data);
            actionBar.applyPermissions(false, false, false, true, false);

            actionBar.setHandleCustomAction(new HandleCustomAction() {
                @Override
                public void handleAction(int id, HashMap<String, String> data, int action) {
                    if (action == HandleCustomAction.MODIFY)
                        openEditScreen(id, data);
                }
            });
            // Push value back to table
            return actionBar;
        }
    });
}

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

License:Open Source License

public void createClaimDetailsPanel() {
    newClaimEventPanel.clear();// www. j  a va2s. c  o m
    claimDetailsPanel.clear();
    newClaimEventPanel.setVisible(false);
    claimDetailsPanel.setVisible(true);
    FlexTable claimsInfoParentTable = new FlexTable();
    claimsInfoParentTable.setBorderWidth(1);
    claimsInfoParentTable.getElement().getStyle().setProperty("borderCollapse", "collapse");
    claimDetailsPanel.setWidth("100%");
    claimDetailsPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    claimDetailsPanel.setSpacing(5);
    claimsInfoParentTable.setWidth("100%");
    claimDetailsPanel.add(claimsInfoParentTable);

    Label lbCovInfo = new Label(_("Coverage Information"));
    lbCovInfo.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    lbCovInfo.getElement().getStyle().setProperty("fontSize", "15px");
    lbCovInfo.getElement().getStyle().setProperty("textDecoration", "underline");
    lbCovInfo.getElement().getStyle().setProperty("fontWeight", "bold");

    FlexTable covInfoTable = new FlexTable();
    covInfoTable.setWidth("100%");
    final FlexTable covTypesTable = new FlexTable();
    covTypesTable.setWidth("100%");
    VerticalPanel covInfoVPanel = new VerticalPanel();
    covInfoVPanel.setSpacing(10);
    covInfoVPanel.setWidth("95%");

    covInfoVPanel.add(lbCovInfo);
    covInfoVPanel.add(covInfoTable);
    covInfoVPanel.add(covTypesTable);
    claimsInfoParentTable.setWidget(0, 0, covInfoVPanel);
    claimsInfoParentTable.getFlexCellFormatter().getElement(0, 0).setAttribute("width", "50%");
    claimsInfoParentTable.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);

    Label lbPatient = new Label(_("Patient") + ":");
    lbPatient.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    lbPatientVal = new Label();
    Label lbdob = new Label(_("Date of Birth") + ":");
    lbdob.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbdobVal = new Label();
    Label lbSSN = new Label(_("SSN") + ":");
    lbSSN.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbSSNVal = new Label();

    covInfoTable.setWidget(0, 0, lbPatient);
    covInfoTable.setWidget(0, 1, lbPatientVal);
    covInfoTable.setWidget(0, 2, lbdob);
    covInfoTable.setWidget(0, 3, lbdobVal);
    covInfoTable.setWidget(0, 4, lbSSN);
    covInfoTable.setWidget(0, 5, lbSSNVal);

    final Label lbRespParty = new Label(_("Resp. Party") + ":");
    lbRespParty.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbRespPartyVal = new Label();
    final Label lbRpDob = new Label(_("Date of Birth") + ":");
    lbRpDob.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbRpDobVal = new Label();
    final Label lbRpSSN = new Label(_("SSN") + ":");
    lbRpSSN.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbRpSSNVal = new Label();

    covInfoTable.setWidget(1, 0, lbRespParty);
    covInfoTable.setWidget(1, 1, lbRespPartyVal);
    covInfoTable.setWidget(1, 2, lbRpDob);
    covInfoTable.setWidget(1, 3, lbRpDobVal);
    covInfoTable.setWidget(1, 4, lbRpSSN);
    covInfoTable.setWidget(1, 5, lbRpSSNVal);

    final Label lbPrimary = new Label(_("Primary Coverage") + "/" + _("Location") + "/" + _("Ins. No.") + "/"
            + _("Copay") + "/" + _("Deductible"));
    lbPrimary.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbPrimaryVal = new Label();

    covTypesTable.setWidget(0, 0, lbPrimary);
    covTypesTable.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    covTypesTable.setWidget(0, 1, lbPrimaryVal);
    covTypesTable.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);

    final Label lbSecondary = new Label(_("Secondary Coverage") + "/" + _("Location") + "/" + _("Ins. No.")
            + "/" + _("Copay") + "/" + _("Deductible"));
    lbSecondary.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbSecondaryVal = new Label();

    covTypesTable.setWidget(1, 0, lbSecondary);
    covTypesTable.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
    covTypesTable.setWidget(1, 1, lbSecondaryVal);
    covTypesTable.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);

    final Label lbTertiary = new Label(_("Tertiary Coverage") + "/" + _("Location") + "/" + _("Ins. No.") + "/"
            + _("Copay") + "/" + _("Deductible"));
    lbTertiary.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbTertiaryVal = new Label();

    covTypesTable.setWidget(2, 0, lbTertiary);
    covTypesTable.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
    covTypesTable.setWidget(2, 1, lbTertiaryVal);
    covTypesTable.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);

    Label lbClaimInfo = new Label(_("Claim Information"));
    lbClaimInfo.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    lbClaimInfo.getElement().getStyle().setProperty("fontSize", "15px");
    lbClaimInfo.getElement().getStyle().setProperty("textDecoration", "underline");
    lbClaimInfo.getElement().getStyle().setProperty("fontWeight", "bold");

    final FlexTable clInfoTable = new FlexTable();
    clInfoTable.setWidth("100%");

    VerticalPanel clInfoVPanel = new VerticalPanel();
    clInfoVPanel.setSpacing(10);
    clInfoVPanel.setWidth("95%");

    clInfoVPanel.add(lbClaimInfo);
    clInfoVPanel.add(clInfoTable);
    claimsInfoParentTable.setWidget(0, 1, clInfoVPanel);
    claimsInfoParentTable.getFlexCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);

    Label lbDos = new Label(_("Date of Service") + ":");
    lbDos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbDosVal = new Label();

    clInfoTable.setWidget(0, 0, lbDos);
    clInfoTable.setWidget(0, 1, lbDosVal);

    Label lbProvider = new Label(_("Provider") + ":");
    lbProvider.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbProviderVal = new Label();
    Label lbRefProv = new Label(_("Referring Provider") + ":");
    lbRefProv.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbRefProvVal = new Label();

    clInfoTable.setWidget(1, 0, lbProvider);
    clInfoTable.setWidget(1, 1, lbProviderVal);
    clInfoTable.setWidget(1, 2, lbRefProv);
    clInfoTable.setWidget(1, 3, lbRefProvVal);

    Label lbPOS = new Label(_("POS") + ":");
    lbPOS.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbPOSVal = new Label();
    Label lbCharges = new Label(_("Charges") + ":");
    lbCharges.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbChargesVal = new Label();

    clInfoTable.setWidget(2, 0, lbPOS);
    clInfoTable.setWidget(2, 1, lbPOSVal);
    clInfoTable.setWidget(2, 2, lbCharges);
    clInfoTable.setWidget(2, 3, lbChargesVal);

    Label lbCPT = new Label(_("CPT") + ":");
    lbCPT.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbCPTVal = new Label();
    Label lbPaid = new Label(_("Paid") + ":");
    lbPaid.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbPaidVal = new Label();

    clInfoTable.setWidget(3, 0, lbCPT);
    clInfoTable.setWidget(3, 1, lbCPTVal);
    clInfoTable.setWidget(3, 2, lbPaid);
    clInfoTable.setWidget(3, 3, lbPaidVal);

    Label lbICD = new Label(_("ICD") + ":");
    lbICD.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbICDVal = new Label();
    Label lbBalance = new Label(_("Balance") + ":");
    lbBalance.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    final Label lbBalanceVal = new Label();

    clInfoTable.setWidget(4, 0, lbICD);
    clInfoTable.setWidget(4, 1, lbICDVal);
    clInfoTable.setWidget(4, 2, lbBalance);
    clInfoTable.setWidget(4, 3, lbBalanceVal);

    ArrayList<String> params = new ArrayList<String>();
    params.add("" + claimid);
    Util.callApiMethod("ClaimLog", "claim_information", params, new CustomRequestCallback() {
        @Override
        public void onError() {
        }

        @SuppressWarnings("unchecked")
        @Override
        public void jsonifiedData(Object data) {
            if (data != null) {
                HashMap<String, String> result = (HashMap<String, String>) data;
                if (result.get("patient") != null)
                    lbPatientVal.setText(result.get("patient"));
                if (result.get("rp_name") != null) {
                    lbRespPartyVal.setText(result.get("rp_name"));
                    if (result.get("rp_name").toString().equalsIgnoreCase("self")) {
                        lbRpDob.setVisible(false);
                        lbRpDobVal.setVisible(false);
                        lbRpSSN.setVisible(false);
                        lbRpSSNVal.setVisible(false);
                    }
                } else {
                    lbRespParty.setVisible(false);
                    lbRespPartyVal.setVisible(false);
                    lbRpDob.setVisible(false);
                    lbRpDobVal.setVisible(false);
                    lbRpSSN.setVisible(false);
                    lbRpSSNVal.setVisible(false);
                }
                if (result.get("patient_dob") != null)
                    lbdobVal.setText(result.get("patient_dob"));
                if (result.get("provider_name") != null)
                    lbProviderVal.setText(result.get("provider_name"));
                if (result.get("ssn") != null)
                    lbSSNVal.setText(result.get("ssn"));
                if (result.get("rp_ssn") != null)
                    lbRpSSNVal.setText(result.get("rp_ssn"));
                if (result.get("rp_dob") != null)
                    lbRpDobVal.setText(result.get("rp_dob"));
                if (result.get("ref_provider_name") != null)
                    lbRefProvVal.setText(result.get("ref_provider_name"));
                if (result.get("prim_cov") != null && !result.get("prim_cov").equals("")) {
                    lbPrimaryVal.setText(result.get("prim_cov"));
                    if (result.get("prim_copay") != null)
                        lbPrimaryVal.setText(lbPrimaryVal.getText() + "/" + result.get("prim_copay"));
                    if (result.get("prim_deduct") != null)
                        lbPrimaryVal.setText(lbPrimaryVal.getText() + "/" + result.get("prim_deduct"));
                } else {
                    lbPrimary.setVisible(false);
                    lbPrimaryVal.setVisible(false);
                }

                if (result.get("sec_cov") != null && !result.get("sec_cov").equals("")) {
                    lbSecondaryVal.setText(result.get("sec_cov"));
                    if (result.get("sec_copay") != null)
                        lbSecondaryVal.setText(lbSecondaryVal.getText() + "/" + result.get("sec_copay"));
                    if (result.get("sec_deduct") != null)
                        lbSecondaryVal.setText(lbSecondaryVal.getText() + "/" + result.get("sec_deduct"));
                } else {
                    lbSecondary.setVisible(false);
                    lbSecondaryVal.setVisible(false);
                }

                if (result.get("ter_cov") != null && !result.get("ter_cov").equals("")) {
                    lbTertiaryVal.setText(result.get("ter_cov"));
                    if (result.get("ter_copay") != null)
                        lbTertiaryVal.setText(lbTertiaryVal.getText() + "/" + result.get("ter_copay"));
                    if (result.get("ter_deduct") != null)
                        lbTertiaryVal.setText(lbTertiaryVal.getText() + "/" + result.get("ter_deduct"));
                } else {
                    lbTertiary.setVisible(false);
                    lbTertiaryVal.setVisible(false);
                }

                if (result.get("facility") != null)
                    lbPOSVal.setText(result.get("facility"));
                if (result.get("service_date") != null)
                    lbDosVal.setText(result.get("service_date"));
                if (result.get("diagnosis") != null)
                    lbICDVal.setText(result.get("diagnosis"));
                if (result.get("cpt_code") != null)
                    lbCPTVal.setText(result.get("cpt_code"));
                if (result.get("fee") != null)
                    lbChargesVal.setText(result.get("fee"));
                if (result.get("paid") != null)
                    lbPaidVal.setText(result.get("paid"));
                if (result.get("balance") != null)
                    lbBalanceVal.setText(result.get("balance"));
            }
        }
    }, "HashMap<String,String>");
    HorizontalPanel actionPanel = new HorizontalPanel();
    actionPanel.setSpacing(5);
    final Button addEventBtn = new Button(_("Add Event"));
    addEventBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createClaimLogEventEntryPanel();
        }

    });
    final Button editClaimBtn = new Button(_("Modify Claim"));
    editClaimBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            PatientScreen p = new PatientScreen();
            p.setPatient(patientId);
            Util.spawnTab(patientName, p);
            ProcedureScreen ps = new ProcedureScreen();
            ps.setModificationRecordId(claimid);
            ps.setPatientId(patientId);
            ps.loadData();
            Util.spawnTabPatient(_("Manage Procedures"), ps, p);
            ps.loadData();
        }

    });
    final Button cancelBtn = new Button(_("Return to Search"));
    final ClaimDetailsWidget cdw = this;
    cancelBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cdw.removeFromParent();
            callback.jsonifiedData("cancel");
        }

    });

    final Button newSearchBtn = new Button(_("New Search"));
    newSearchBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cdw.removeFromParent();
            callback.jsonifiedData("new");
        }

    });
    actionPanel.add(addEventBtn);
    actionPanel.add(cancelBtn);
    actionPanel.add(newSearchBtn);
    actionPanel.add(editClaimBtn);
    claimDetailsPanel.add(actionPanel);

    final CustomTable claimsLogTable = new CustomTable();
    claimsLogTable.setAllowSelection(false);
    claimsLogTable.setSize("100%", "100%");
    claimsLogTable.addColumn(_("Date"), "date");
    claimsLogTable.addColumn(_("User"), "user");
    claimsLogTable.addColumn(_("Action"), "action");
    claimsLogTable.addColumn(_("Comment"), "comment");
    Util.callApiMethod("ClaimLog", "events_for_procedure", params, new CustomRequestCallback() {
        @Override
        public void onError() {
        }

        @SuppressWarnings("unchecked")
        @Override
        public void jsonifiedData(Object data) {
            if (data != null) {
                HashMap<String, String>[] result = (HashMap<String, String>[]) data;
                claimsLogTable.loadData(result);
            }
        }
    }, "HashMap<String,String>[]");
    claimDetailsPanel.add(claimsLogTable);
}

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

License:Open Source License

public void createClaimLogEventEntryPanel() {
    newClaimEventPanel.setVisible(true);
    newClaimEventPanel.setSpacing(5);// w  w  w  .  ja  v  a  2  s.c o m
    claimDetailsPanel.setVisible(false);
    Label lbAction = new Label(_("Action"));
    final CustomListBox listAction = new CustomListBox();
    listAction.addItem(_("NONE SELECTED"), "");
    listAction.addItem(_("Call"), "Call");
    listAction.addItem(_("Email"), "Email");

    Label lbComment = new Label(_("Comment"));
    final TextArea commenttb = new TextArea();
    FlexTable eventEntryTable = new FlexTable();
    eventEntryTable.setWidget(0, 0, lbAction);
    eventEntryTable.setWidget(0, 1, listAction);
    eventEntryTable.setWidget(1, 0, lbComment);
    eventEntryTable.setWidget(1, 1, commenttb);

    HorizontalPanel actionPanel = new HorizontalPanel();
    actionPanel.setSpacing(5);
    final Button addEventBtn = new Button(_("Add Event"));
    addEventBtn.addClickHandler(new ClickHandler() {
        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
        public void onClick(ClickEvent event) {
            String msg = "";
            if (listAction.getSelectedIndex() == 0) {
                msg += _("Please select an action.") + "\n";
            }
            if (commenttb.getText() == null || commenttb.getText().equals("")) {
                msg += _("Please enter a comment.") + "\n";
            }
            if (msg.equals("")) {
                final HashMap<String, String> rec = new HashMap<String, String>();
                // putting all columns of table .....
                rec.put((String) "action", (String) listAction.getStoredValue());
                rec.put((String) "comment", (String) commenttb.getText());
                ArrayList params = new ArrayList();
                params.add(claimid);
                params.add(rec);
                Util.callApiMethod("ClaimLog", "log_event", params, new CustomRequestCallback() {
                    @Override
                    public void onError() {
                    }

                    @Override
                    public void jsonifiedData(Object data) {
                        if (data != null) {
                            createClaimDetailsPanel();
                        }
                    }
                }, "Integer");
            } else {
                Window.alert(msg);
            }
        }

    });
    final Button claimDetailsBtn = new Button(_("Claim Details"));
    claimDetailsBtn.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            createClaimDetailsPanel();
        }

    });
    actionPanel.add(addEventBtn);
    actionPanel.add(claimDetailsBtn);
    newClaimEventPanel.add(eventEntryTable);
    newClaimEventPanel.add(actionPanel);
}

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

License:Open Source License

public DocumentBox() {
    super(moduleName);
    VerticalPanel superVPanel = new VerticalPanel();
    initWidget(superVPanel);/*from   w w  w.  j  a  v  a2s  .c o m*/
    superVPanel.setStyleName(AppConstants.STYLE_BUTTON_WIDGETS_CONTAINER);
    superVPanel.setWidth("100%");

    HorizontalPanel headerHPanel = new HorizontalPanel();
    headerHPanel.setSpacing(5);
    superVPanel.add(headerHPanel);

    final Image colExpBtn = new Image(Util.getResourcesURL() + "collapse.15x15.png");
    colExpBtn.getElement().getStyle().setCursor(Cursor.POINTER);
    headerHPanel.add(colExpBtn);
    colExpBtn.addClickHandler(new ClickHandler() {
        boolean expaned = false;

        @Override
        public void onClick(ClickEvent arg0) {
            if (expaned) {
                colExpBtn.setUrl(Util.getResourcesURL() + "collapse.15x15.png");
                contentVPanel.setVisible(true);
            } else {
                colExpBtn.setUrl(Util.getResourcesURL() + "expand.15x15.png");
                contentVPanel.setVisible(false);
            }
            expaned = !expaned;
        }
    });

    Label headerLabel = new Label(_("UNFILED DOCUMENTS"));
    headerHPanel.add(headerLabel);
    headerLabel.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);

    contentVPanel = new VerticalPanel();
    contentVPanel.setWidth("100%");
    superVPanel.add(contentVPanel);

    contentVPanel.add(wDocuments);

    wDocuments.setSize("100%", "100%");
    wDocuments.addColumn(_("Date"), "uffdate"); // col 0
    wDocuments.addColumn(_("Filename"), "ufffilename"); // col 1
    wDocuments.setIndexName("id");
    wDocuments.setMaximumRows(7);
    if (true) {
        wDocuments.setTableRowClickHandler(new TableRowClickHandler() {
            @Override
            public void handleRowClick(HashMap<String, String> data, int col) {
                // final Integer uffId = Integer.parseInt(data.get("id"));
                unfiledDocs = UnfiledDocuments.getInstance();
                unfiledDocs.setSelectedDocument(data);
                Util.spawnTab(AppConstants.UNFILED + " Documents", UnfiledDocuments.getInstance());
                // Util.spawnTab("File Document", documentScreen);
            }
        });
    }
    // Collapsed view
    // wDocuments.setVisible(false);
    // horizontalPanel.add(documentsCountLabel);
}

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

License:Open Source License

public DocumentThumbnailsWidget(DjvuViewer dv, CustomRequestCallback c) {
    callBack = c;/* w w w.  j  a v  a  2 s . c  o m*/
    djviewer = dv;
    VerticalPanel vPanel = new VerticalPanel();
    initWidget(vPanel);
    vPanel.setWidth("100%");
    vPanel.setVisible(true);
    vPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    vPanel.setSpacing(10);
    Label lblHeadingStep2 = new Label(_("Batch Split"));
    lblHeadingStep2.setStyleName(AppConstants.STYLE_LABEL_LARGE_BOLD);
    vPanel.add(lblHeadingStep2);
    Label lbMessage = new Label(_("Select the pages from where you want to split."));
    lbMessage.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
    vPanel.add(lbMessage);
    thumbnailParentContainer = new HorizontalPanel[ROWS_PER_SCREEN];
    for (int i = 0; i < thumbnailParentContainer.length; i++) {
        thumbnailParentContainer[i] = new HorizontalPanel();
        thumbnailParentContainer[i].setSpacing(10);
        vPanel.add(thumbnailParentContainer[i]);
    }
    startcount = 0;
    endcount = 0;
    cbPages = new CheckBox[djviewer.getPageCount()];
    for (int i = 0; i < cbPages.length; i++) {
        cbPages[i] = new CheckBox(_("Page") + " " + (i + 1));
    }
    if (djviewer.getPageCount() > PAGES_PER_SCREEN) {
        endcount = PAGES_PER_SCREEN;
    } else {
        endcount = djviewer.getPageCount();
    }
    thumbnails = new VerticalPanel[endcount];
    updateThumbNails();
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);
    if (djviewer.getPageCount() > PAGES_PER_SCREEN) {
        final CustomButton viewPrevios = new CustomButton(_("Previous"), AppConstants.ICON_PREV);
        viewPrevios.setEnabled(false);
        final CustomButton viewNext = new CustomButton(_("Next"), AppConstants.ICON_NEXT);

        viewPrevios.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent arg0) {
                endcount = startcount;
                startcount -= PAGES_PER_SCREEN;
                if (startcount == 0) {
                    viewPrevios.setEnabled(false);
                }
                viewNext.setEnabled(true);
                updateThumbNails();

            }
        });

        viewNext.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent arg0) {
                startcount += PAGES_PER_SCREEN;
                if ((djviewer.getPageCount() - endcount) > PAGES_PER_SCREEN) {
                    endcount += PAGES_PER_SCREEN;
                } else {
                    endcount += (djviewer.getPageCount() - endcount);
                }
                if (endcount == (djviewer.getPageCount())) {
                    viewNext.setEnabled(false);
                }
                viewPrevios.setEnabled(true);
                updateThumbNails();
            }
        });

        hp.add(viewPrevios);
        hp.add(viewNext);

    }
    final CustomButton SplitBtn = new CustomButton(_("Split"));
    SplitBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            Integer[] pNos = new Integer[djviewer.getPageCount()];
            for (int i = 0; i < djviewer.getPageCount(); i++) {
                if (cbPages[i].getValue()) {
                    pNos[i] = 1;
                } else {
                    pNos[i] = 0;
                }

            }
            callBack.jsonifiedData(pNos);
        }
    });

    final CustomButton cancelBtn = new CustomButton(_("Cancel"), AppConstants.ICON_CANCEL);
    cancelBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            callBack.jsonifiedData(0);
        }
    });
    hp.add(SplitBtn);
    hp.add(cancelBtn);
    vPanel.add(hp);

}

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

License:Open Source License

private void createVitalsTab() {
    FlexTable vitalsTable = new FlexTable();
    int row = 0;//from w w w .ja  va  2s  .c  om
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Vitals/Generals"))
        loopCountMax = sectionsFieldMap.get("Sections#Vitals/Generals").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Vitals/Generals"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Vitals/Generals");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("Blood Pressure"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            HorizontalPanel temperaturePanel = new HorizontalPanel();
            temperaturePanel.setSpacing(5);
            Label lbBp = new Label(_("Blood Pressure"));
            tbBp1 = new TextBox();
            if (templateValuesMap.containsKey("pnotessbp")) {
                tbBp1.setText(templateValuesMap.get("pnotessbp"));
            } else if (templateValuesMap.containsKey("pnotestsbp")) {
                tbBp1.setText(templateValuesMap.get("pnotestsbp"));
            }
            Label sepLabel = new Label("/");
            tbBp2 = new TextBox();
            if (templateValuesMap.containsKey("pnotesdbp")) {
                tbBp2.setText(templateValuesMap.get("pnotesdbp"));
            } else if (templateValuesMap.containsKey("pnotestdbp")) {
                tbBp2.setText(templateValuesMap.get("pnotestdbp"));
            }
            temperaturePanel.add(tbBp1);
            temperaturePanel.add(sepLabel);
            temperaturePanel.add(tbBp2);
            vitalsTable.setWidget(row, 0, lbBp);
            vitalsTable.setWidget(row++, 1, temperaturePanel);
        }
        if ((secList != null && secList.get(i).equals("Temperature"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbTemp = new Label(_("Temperature"));
            int temp1 = 90;

            listTemp = new CustomListBox();
            while (temp1 <= 107) {
                int temp2 = 0;
                while (temp2 <= 9) {
                    String value = temp1 + "." + temp2;
                    listTemp.addItem(value);
                    if (templateValuesMap.containsKey("pnotestemp")) {
                        if (value.equals(templateValuesMap.get("pnotestemp")))
                            listTemp.setSelectedIndex(listTemp.getItemCount() - 1);
                    } else if (templateValuesMap.containsKey("pnotesttemp")) {
                        if (value.equals(templateValuesMap.get("pnotesttemp")))
                            listTemp.setSelectedIndex(listTemp.getItemCount() - 1);
                    }
                    temp2++;
                }
                temp1++;
            }
            listTemp.addItem("108.0");
            vitalsTable.setWidget(row, 0, lbTemp);
            vitalsTable.setWidget(row++, 1, listTemp);
        }
        if ((secList != null && secList.get(i).equals("Heart Rate"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbHeartRate = new Label(_("Heart Rate"));
            tbHeartRate = new TextBox();
            if (templateValuesMap.containsKey("pnotesheartrate")) {
                tbHeartRate.setText(templateValuesMap.get("pnotesheartrate"));
            } else if (templateValuesMap.containsKey("pnotestheartrate")) {
                tbHeartRate.setText(templateValuesMap.get("pnotestheartrate"));
            }
            vitalsTable.setWidget(row, 0, lbHeartRate);
            vitalsTable.setWidget(row++, 1, tbHeartRate);
        }
        if ((secList != null && secList.get(i).equals("Respiratory Rate"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbRespRate = new Label(_("Respiratory Rate"));
            tbRespRate = new TextBox();
            if (templateValuesMap.containsKey("pnotesresprate")) {
                tbRespRate.setText(templateValuesMap.get("pnotesresprate"));
            } else if (templateValuesMap.containsKey("pnotestresprate")) {
                tbRespRate.setText(templateValuesMap.get("pnotestresprate"));
            }
            vitalsTable.setWidget(row, 0, lbRespRate);
            vitalsTable.setWidget(row++, 1, tbRespRate);
        }
        if ((secList != null && secList.get(i).equals("Weight"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbWeight = new Label(_("Weight"));
            tbWeight = new TextBox();
            if (templateValuesMap.containsKey("pnotesweight")) {
                tbWeight.setText(templateValuesMap.get("pnotesweight"));
            } else if (templateValuesMap.containsKey("pnotestweight")) {
                tbWeight.setText(templateValuesMap.get("pnotestweight"));
            }
            vitalsTable.setWidget(row, 0, lbWeight);
            vitalsTable.setWidget(row++, 1, tbWeight);
        }
        if ((secList != null && secList.get(i).equals("Height"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbHeight = new Label(_("Height"));
            tbHeight = new TextBox();
            if (templateValuesMap.containsKey("pnotesheight")) {
                tbHeight.setText(templateValuesMap.get("pnotesheight"));
            } else if (templateValuesMap.containsKey("pnotestheight")) {
                tbHeight.setText(templateValuesMap.get("pnotestheight"));
            }
            vitalsTable.setWidget(row, 0, lbHeight);
            vitalsTable.setWidget(row++, 1, tbHeight);
        }
        if ((secList != null && secList.get(i).equals("BMI"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbBMI = new Label(_("BMI"));
            tbBMIVal = new Label();
            if (templateValuesMap.containsKey("pnotesbmi")) {
                tbBMIVal.setText(templateValuesMap.get("pnotesbmi"));
            } else if (templateValuesMap.containsKey("pnotestbmi")) {
                tbBMIVal.setText(templateValuesMap.get("pnotestbmi"));
            }
            CustomButton calBmiBtn = new CustomButton(_("Calculate"));
            calBmiBtn.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (!tbHeight.getText().equals("") && !tbWeight.getText().equals("")) {
                        if (Util.isNumber(tbHeight.getText()) && Util.isNumber(tbHeight.getText())) {
                            float height = Float.parseFloat(tbHeight.getText());
                            float weight = Float.parseFloat(tbWeight.getText());
                            float bmi = (weight / height) * 703f;
                            tbBMIVal.setText("" + bmi);
                        }
                    }
                }
            });
            vitalsTable.setWidget(row, 0, lbBMI);
            vitalsTable.setWidget(row, 1, tbBMIVal);
            vitalsTable.setWidget(row++, 2, calBmiBtn);
        }

        if ((secList != null && secList.get(i).equals("General (PE)"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbGeneral = new Label(_("General (PE)"));
            tbGeneral = new TextArea();
            tbGeneral.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnotesgeneral")) {
                tbGeneral.setText(templateValuesMap.get("pnotesgeneral"));
            } else if (templateValuesMap.containsKey("pnotestgeneral")) {
                tbGeneral.setText(templateValuesMap.get("pnotestgeneral"));
            }
            vitalsTable.setWidget(row, 0, lbGeneral);
            vitalsTable.setWidget(row++, 1, tbGeneral);
        }
    }
    vitalsTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    vitalGenPanel.add(vitalsTable);
}

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

License:Open Source License

@SuppressWarnings("unchecked")
private void createExamTab() {
    examPanel.setSpacing(10);//from ww  w. ja va 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);
}