Example usage for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

List of usage examples for com.google.gwt.user.client.ui FlexTable getFlexCellFormatter

Introduction

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

Prototype

public FlexCellFormatter getFlexCellFormatter() 

Source Link

Document

Explicitly gets the FlexCellFormatter .

Usage

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

License:Open Source License

private void createVitalsTab() {
    FlexTable vitalsTable = new FlexTable();
    int row = 0;/* w ww.j a  v  a 2 s .  c o  m*/
    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

private void createCCPHTab() {
    FlexTable ccphTable = new FlexTable();
    int row = 0;//from w  w  w  . ja va  2  s  .c  om
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#CC & HPI"))
        loopCountMax = sectionsFieldMap.get("Sections#CC & HPI").size();
    else if (sectionsFieldMap.containsKey("Sections") && !sectionsFieldMap.containsKey("Sections#CC & HPI"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#CC & HPI");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("CC"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbCC = new Label(_("CC"));
            tbCC = new TextArea();
            tbCC.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnotescc")) {
                tbCC.setText(templateValuesMap.get("pnotescc"));
            } else if (templateValuesMap.containsKey("pnotestcc")) {
                tbCC.setText(templateValuesMap.get("pnotestcc"));
            }
            ccphTable.setWidget(row, 0, lbCC);
            ccphTable.setWidget(row++, 1, tbCC);
        }
        if ((secList != null && secList.get(i).equals("HPI"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbHPI = new Label(_("HPI"));
            tbHPI = new TextArea();
            tbHPI.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnoteshpi")) {
                tbHPI.setText(templateValuesMap.get("pnoteshpi"));
            } else if (templateValuesMap.containsKey("pnotesthpi")) {
                tbHPI.setText(templateValuesMap.get("pnotesthpi"));
            }
            ccphTable.setWidget(row, 0, lbHPI);
            ccphTable.setWidget(row++, 1, tbHPI);
        }
    }
    ccphTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    ccHpiPanel.add(ccphTable);
}

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

License:Open Source License

private void createRevSysTab() {
    revOfSysPanel.setSpacing(10);//from   w w w  . ja  va  2s  . c o  m
    FlexTable revSysTable = new FlexTable();
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Review Of Systems"))
        loopCountMax = sectionsFieldMap.get("Sections#Review Of Systems").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Review Of Systems"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Review Of Systems");
    Label lbInfo = new Label(_("REVIEW OF SYSTEMS") + ": " + _("(check if done)"));
    lbInfo.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
    revOfSysPanel.add(lbInfo);
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("General"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel generalPanel = new VerticalPanel();
            cbGeneral = new CheckBox(_("General"));
            cbGeneral.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            generalPanel.add(cbGeneral);
            revOfSysPanel.add(generalPanel);
            tbGeneralRos = new TextArea();
            tbGeneralRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbGeneralRos.setSize("700px", "200px");
            cbGeneral.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                @Override
                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                    if (cbGeneral.getValue()) {
                        generalPanel.add(tbGeneralRos);
                    } else {
                        generalPanel.remove(tbGeneralRos);
                    }
                }

            });
            if (templateValuesMap.containsKey("pnotesrosgenralstatus")) {
                if (templateValuesMap.get("pnotesrosgenralstatus").equals("1")) {
                    cbGeneral.setValue(true);
                    if (templateValuesMap.containsKey("pnotesrosgenral")) {
                        generalPanel.add(tbGeneralRos);
                        tbGeneralRos.setText(templateValuesMap.get("pnotesrosgenral"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosgenralstatus")) {
                if (templateValuesMap.get("pnotestrosgenralstatus").equals("1")) {
                    cbGeneral.setValue(true);
                    if (templateValuesMap.containsKey("pnotestrosgenral")) {
                        generalPanel.add(tbGeneralRos);
                        tbGeneralRos.setText(templateValuesMap.get("pnotestrosgenral"));
                    }
                }
            }

        }
        if ((secList != null && secList.get(i).equals("Head"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel headPanel = new VerticalPanel();
            cbHead = new CheckBox(_("Head"));
            cbHead.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            headPanel.add(cbHead);
            revOfSysPanel.add(headPanel);
            tbHeadRos = new TextArea();
            tbHeadRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbHeadRos.setSize("700px", "200px");
            cbHead.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

                @Override
                public void onValueChange(ValueChangeEvent<Boolean> arg0) {
                    if (cbHead.getValue()) {
                        headPanel.add(tbHeadRos);
                    } else {
                        headPanel.remove(tbHeadRos);
                    }
                }

            });
            if (templateValuesMap.containsKey("pnotesrosheadstatus")) {
                if (templateValuesMap.get("pnotesrosheadstatus").equals("1")) {
                    cbHead.setValue(true);
                    if (templateValuesMap.containsKey("pnotesroshead")) {
                        headPanel.add(tbHeadRos);
                        tbHeadRos.setText(templateValuesMap.get("pnotesroshead"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosheadstatus")) {
                if (templateValuesMap.get("pnotestrosheadstatus").equals("1")) {
                    cbHead.setValue(true);
                    if (templateValuesMap.containsKey("pnotestroshead")) {
                        headPanel.add(tbHeadRos);
                        tbHeadRos.setText(templateValuesMap.get("pnotestroshead"));
                    }
                }
            }

        }
        if ((secList != null && secList.get(i).equals("Eyes"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel eyesPanel = new VerticalPanel();
            eyesPanel.setSpacing(5);

            cbEyesRos = new CheckBox(_("Eyes"));
            cbEyesRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            eyesPanel.add(cbEyesRos);
            revOfSysPanel.add(eyesPanel);
            final Label lbInfo2 = new Label("Select if abnormal");
            lbInfo2.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo2.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel eyeHp = new HorizontalPanel();
            eyeHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbPoorVision = new CheckBox(_("poor vision"));
            cbEyesPain = new CheckBox(_("pain"));
            eyeHp.add(cbPoorVision);
            eyeHp.add(cbEyesPain);
            tbEyesRos = new TextArea();
            tbEyesRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbEyesRos.setSize("700px", "200px");
            cbEyesRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbEyesRos.getValue()) {
                        eyesPanel.add(lbInfo2);
                        eyesPanel.add(eyeHp);
                        eyesPanel.add(tbEyesRos);
                    } else {
                        eyesPanel.remove(lbInfo2);
                        eyesPanel.remove(eyeHp);
                        eyesPanel.remove(tbEyesRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesroseyesstatus")) {
                if (templateValuesMap.get("pnotesroseyesstatus").equals("1")) {
                    cbEyesRos.setValue(true);
                    eyesPanel.add(tbEyesRos);
                    selVal = templateValuesMap.get("pnotesroseyes");
                    if (templateValuesMap.get("pnotesroseyescmnts") != null) {
                        tbEyesRos.setText(templateValuesMap.get("pnotesroseyescmnts"));
                    }

                }
            } else if (templateValuesMap.containsKey("pnotestroseyesstatus")) {
                if (templateValuesMap.get("pnotestroseyesstatus").equals("1")) {
                    cbEyesRos.setValue(true);
                    eyesPanel.add(tbEyesRos);
                    selVal = templateValuesMap.get("pnotestroseyes");
                    if (templateValuesMap.get("pnotestroseyescmnts") != null) {
                        tbEyesRos.setText(templateValuesMap.get("pnotestroseyescmnts"));
                    }

                }
            }
            if (selVal != null && !selVal.equals("")) {
                eyesPanel.add(lbInfo2);
                eyesPanel.add(eyeHp);
                if (selVal.indexOf("poor vision") != -1) {
                    cbPoorVision.setValue(true);
                }
                if (selVal.indexOf("pain") != -1) {
                    cbEyesPain.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("ENT"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel entPanel = new VerticalPanel();
            entPanel.setSpacing(5);

            cbEntRos = new CheckBox(_("ENT"));
            cbEntRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            entPanel.add(cbEntRos);
            revOfSysPanel.add(entPanel);
            final Label lbInfo3 = new Label(_("Select if abnormal"));
            lbInfo3.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo3.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel entHp = new HorizontalPanel();
            entHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbSoreThroat = new CheckBox(_("sore throat"));
            cbENTPain = new CheckBox(_("pain"));
            cbCoryza = new CheckBox(_("coryza"));
            cbAcuity = new CheckBox(_("acuity"));
            cbDysphagia = new CheckBox(_("dysphagia"));
            entHp.add(cbSoreThroat);
            entHp.add(cbENTPain);
            entHp.add(cbCoryza);
            entHp.add(cbAcuity);
            entHp.add(cbDysphagia);
            tbENTRos = new TextArea();
            tbENTRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbENTRos.setSize("700px", "200px");
            cbEntRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbEntRos.getValue()) {
                        entPanel.add(lbInfo3);
                        entPanel.add(entHp);
                        entPanel.add(tbENTRos);
                    } else {
                        entPanel.remove(lbInfo3);
                        entPanel.remove(entHp);
                        entPanel.remove(tbENTRos);
                    }
                }
            });

            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosentstatus")) {
                if (templateValuesMap.get("pnotesrosentstatus").equals("1")) {
                    entPanel.add(tbENTRos);
                    cbEntRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosent");
                    if (templateValuesMap.get("pnotesrosentcmnts") != null) {
                        tbENTRos.setText(templateValuesMap.get("pnotesrosentcmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosentstatus")) {
                if (templateValuesMap.get("pnotestrosentstatus").equals("1")) {
                    entPanel.add(tbENTRos);
                    cbEntRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosent");
                    if (templateValuesMap.get("pnotestrosentcmnts") != null) {
                        tbENTRos.setText(templateValuesMap.get("pnotestrosentcmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                entPanel.add(lbInfo3);
                entPanel.add(entHp);
                if (selVal.indexOf("sore throat") != -1) {
                    cbSoreThroat.setValue(true);
                }
                if (selVal.indexOf("pain") != -1) {
                    cbENTPain.setValue(true);
                }
                if (selVal.indexOf("coryza") != -1) {
                    cbCoryza.setValue(true);
                }
                if (selVal.indexOf("acuity") != -1) {
                    cbAcuity.setValue(true);
                }
                if (selVal.indexOf("dysphagia") != -1) {
                    cbDysphagia.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("CV"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel cvPanel = new VerticalPanel();
            cvPanel.setSpacing(5);

            cbCVRos = new CheckBox("CV");
            cbCVRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            cvPanel.add(cbCVRos);
            revOfSysPanel.add(cvPanel);
            final Label lbInfo4 = new Label("Select if abnormal");
            lbInfo4.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo4.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel cvHp = new HorizontalPanel();
            cvHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbCVPain = new CheckBox("pain");
            cbPalpitations = new CheckBox("palpitations");
            cbHypoHyperTension = new CheckBox("hypo/hypertension");
            cvHp.add(cbCVPain);
            cvHp.add(cbPalpitations);
            cvHp.add(cbHypoHyperTension);
            tbCVRos = new TextArea();
            tbCVRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbCVRos.setSize("700px", "200px");
            cbCVRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbCVRos.getValue()) {
                        cvPanel.add(lbInfo4);
                        cvPanel.add(cvHp);
                        cvPanel.add(tbCVRos);
                    } else {
                        cvPanel.remove(lbInfo4);
                        cvPanel.remove(cvHp);
                        cvPanel.remove(tbCVRos);
                    }
                }
            });

            String selVal = "";
            if (templateValuesMap.containsKey("pnotesroscvstatus")) {
                if (templateValuesMap.get("pnotesroscvstatus").equals("1")) {
                    cvPanel.add(tbCVRos);
                    cbCVRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesroscv");
                    if (templateValuesMap.get("pnotesroscvsmnts") != null) {
                        tbCVRos.setText(templateValuesMap.get("pnotesroscvsmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestroscvstatus")) {
                if (templateValuesMap.get("pnotestroscvstatus").equals("1")) {
                    cvPanel.add(tbCVRos);
                    cbCVRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestroscv");
                    if (templateValuesMap.get("pnotestroscvsmnts") != null) {
                        tbCVRos.setText(templateValuesMap.get("pnotestroscvsmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                cvPanel.add(lbInfo4);
                cvPanel.add(cvHp);
                if (selVal.indexOf("pain") != -1) {
                    cbCVPain.setValue(true);
                }
                if (selVal.indexOf("palpitations") != -1) {
                    cbPalpitations.setValue(true);
                }
                if (selVal.indexOf("hypo/hypertension") != -1) {
                    cbHypoHyperTension.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Resp"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel respPanel = new VerticalPanel();
            respPanel.setSpacing(5);

            cbRespRos = new CheckBox("Resp");
            cbRespRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            respPanel.add(cbRespRos);
            revOfSysPanel.add(respPanel);
            final Label lbInfo5 = new Label("Select if abnormal");
            lbInfo5.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo5.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel respHp = new HorizontalPanel();
            respHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbDyspnea = new CheckBox("dyspnea");
            cbCough = new CheckBox("cough");
            cbTachypnea = new CheckBox("tachypnea");
            respHp.add(cbDyspnea);
            respHp.add(cbCough);
            respHp.add(cbTachypnea);
            tbRespRos = new TextArea();
            tbRespRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbRespRos.setSize("700px", "200px");
            cbRespRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbRespRos.getValue()) {
                        respPanel.add(lbInfo5);
                        respPanel.add(respHp);
                        respPanel.add(tbRespRos);
                    } else {
                        respPanel.remove(lbInfo5);
                        respPanel.remove(respHp);
                        respPanel.remove(tbRespRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosrespstatus")) {
                if (templateValuesMap.get("pnotesrosrespstatus").equals("1")) {
                    respPanel.add(tbRespRos);
                    cbRespRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosresp");
                    if (templateValuesMap.get("pnotesrosrespcmnts") != null) {
                        tbRespRos.setText(templateValuesMap.get("pnotesrosrespcmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosrespstatus")) {
                if (templateValuesMap.get("pnotestrosrespstatus").equals("1")) {
                    respPanel.add(tbRespRos);
                    cbRespRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosresp");
                    if (templateValuesMap.get("pnotestrosrespcmnts") != null) {
                        tbRespRos.setText(templateValuesMap.get("pnotestrosrespcmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                respPanel.add(lbInfo5);
                respPanel.add(respHp);
                if (selVal.indexOf("dyspnea") != -1) {
                    cbDyspnea.setValue(true);
                }
                if (selVal.indexOf("cough") != -1) {
                    cbCough.setValue(true);
                }
                if (selVal.indexOf("tachypnea") != -1) {
                    cbTachypnea.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("GI"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel giPanel = new VerticalPanel();
            giPanel.setSpacing(5);

            cbGIRos = new CheckBox("GI");
            cbGIRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            giPanel.add(cbGIRos);
            revOfSysPanel.add(giPanel);
            final Label lbInfo6 = new Label("Select if abnormal");
            lbInfo6.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo6.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel giHp = new HorizontalPanel();
            giHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbPainGI = new CheckBox("pain");
            cbNausea = new CheckBox("nausea");
            cbVomiting = new CheckBox("vomiting");
            cbDiarrhea = new CheckBox("diarrhea");
            cbConstipation = new CheckBox("constipation");
            giHp.add(cbPainGI);
            giHp.add(cbNausea);
            giHp.add(cbVomiting);
            giHp.add(cbDiarrhea);
            giHp.add(cbConstipation);
            tbGIRos = new TextArea();
            tbGIRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbGIRos.setSize("700px", "200px");
            cbGIRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbGIRos.getValue()) {
                        giPanel.add(lbInfo6);
                        giPanel.add(giHp);
                        giPanel.add(tbGIRos);
                    } else {
                        giPanel.remove(lbInfo6);
                        giPanel.remove(giHp);
                        giPanel.remove(tbGIRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosgistatus")) {
                if (templateValuesMap.get("pnotesrosgistatus").equals("1")) {
                    giPanel.add(tbGIRos);
                    cbGIRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesroshgi");
                    if (templateValuesMap.get("pnotesrosgicmnts") != null) {
                        tbGIRos.setText(templateValuesMap.get("pnotesrosgicmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosgistatus")) {
                if (templateValuesMap.get("pnotestrosgistatus").equals("1")) {
                    giPanel.add(tbGIRos);
                    cbGIRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestroshgi");
                    if (templateValuesMap.get("pnotestrosgicmnts") != null) {
                        tbGIRos.setText(templateValuesMap.get("pnotestrosgicmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                giPanel.add(lbInfo6);
                giPanel.add(giHp);
                if (selVal.indexOf("pain") != -1) {
                    cbPainGI.setValue(true);
                }
                if (selVal.indexOf("nausea") != -1) {
                    cbNausea.setValue(true);
                }
                if (selVal.indexOf("vomiting") != -1) {
                    cbVomiting.setValue(true);
                }
                if (selVal.indexOf("diarrhea") != -1) {
                    cbDiarrhea.setValue(true);
                }
                if (selVal.indexOf("constipation") != -1) {
                    cbConstipation.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("GU"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel guPanel = new VerticalPanel();
            guPanel.setSpacing(5);

            cbGUROS = new CheckBox("GU");
            cbGUROS.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            guPanel.add(cbGUROS);
            revOfSysPanel.add(guPanel);
            final Label lbInfo7 = new Label("Select if abnormal");
            lbInfo7.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo7.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel guHp = new HorizontalPanel();
            guHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbPainGU = new CheckBox("pain");
            cbBleeding = new CheckBox("bleeding");
            cbIncontinent = new CheckBox("incontinent");
            cbNocturia = new CheckBox("nocturia");
            cbFoulSmell = new CheckBox("foul smell");
            guHp.add(cbPainGU);
            guHp.add(cbBleeding);
            guHp.add(cbIncontinent);
            guHp.add(cbNocturia);
            guHp.add(cbFoulSmell);
            tbGURos = new TextArea();
            tbGURos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbGURos.setSize("700px", "200px");
            cbGUROS.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbGUROS.getValue()) {
                        guPanel.add(lbInfo7);
                        guPanel.add(guHp);
                        guPanel.add(tbGURos);
                    } else {
                        guPanel.remove(lbInfo7);
                        guPanel.remove(guHp);
                        guPanel.remove(tbGURos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosgustatus")) {
                if (templateValuesMap.get("pnotesrosgustatus").equals("1")) {
                    guPanel.add(tbGURos);
                    cbGUROS.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosgu");
                    if (templateValuesMap.get("pnotesrosgucmnts") != null) {
                        tbGURos.setText(templateValuesMap.get("pnotesrosgucmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosgustatus")) {
                if (templateValuesMap.get("pnotestrosgustatus").equals("1")) {
                    guPanel.add(tbGURos);
                    cbGUROS.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosgu");
                    if (templateValuesMap.get("pnotestrosgucmnts") != null) {
                        tbGURos.setText(templateValuesMap.get("pnotestrosgucmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                guPanel.add(lbInfo7);
                guPanel.add(guHp);
                if (selVal.indexOf("pain") != -1) {
                    cbPainGU.setValue(true);
                }
                if (selVal.indexOf("bleeding") != -1) {
                    cbBleeding.setValue(true);
                }
                if (selVal.indexOf("incontinent") != -1) {
                    cbIncontinent.setValue(true);
                }
                if (selVal.indexOf("nocturia") != -1) {
                    cbNocturia.setValue(true);
                }
                if (selVal.indexOf("foul smell") != -1) {
                    cbFoulSmell.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Muscle"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel musclePanel = new VerticalPanel();
            musclePanel.setSpacing(5);

            cbMuscle = new CheckBox("Muscle");
            cbMuscle.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            musclePanel.add(cbMuscle);
            revOfSysPanel.add(musclePanel);
            final Label lbInfo8 = new Label("Select if abnormal");
            lbInfo8.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo8.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel muscleHp = new HorizontalPanel();
            muscleHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbPainMuscle = new CheckBox("pain");
            cbWeakness = new CheckBox("weakness");
            muscleHp.add(cbPainMuscle);
            muscleHp.add(cbWeakness);
            tbMuscleRos = new TextArea();
            tbMuscleRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbMuscleRos.setSize("700px", "200px");
            cbMuscle.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbMuscle.getValue()) {
                        musclePanel.add(lbInfo8);
                        musclePanel.add(muscleHp);
                        musclePanel.add(tbMuscleRos);
                    } else {
                        musclePanel.remove(lbInfo8);
                        musclePanel.remove(muscleHp);
                        musclePanel.remove(tbMuscleRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosmusclestatus")) {
                if (templateValuesMap.get("pnotesrosmusclestatus").equals("1")) {
                    musclePanel.add(tbMuscleRos);
                    cbMuscle.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosmuscles");
                    if (templateValuesMap.get("pnotesrosmusclescmnts") != null) {
                        tbMuscleRos.setText(templateValuesMap.get("pnotesrosmusclescmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosmusclestatus")) {
                if (templateValuesMap.get("pnotestrosmusclestatus").equals("1")) {
                    musclePanel.add(tbMuscleRos);
                    cbMuscle.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosmuscles");
                    if (templateValuesMap.get("pnotestrosmusclescmnts") != null) {
                        tbMuscleRos.setText(templateValuesMap.get("pnotestrosmusclescmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                musclePanel.add(lbInfo8);
                musclePanel.add(muscleHp);
                if (selVal.indexOf("pain") != -1) {
                    cbPainMuscle.setValue(true);
                }
                if (selVal.indexOf("weakness") != -1) {
                    cbWeakness.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Skin"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel skinPanel = new VerticalPanel();
            skinPanel.setSpacing(5);

            cbSkinRos = new CheckBox("Skin");
            cbSkinRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            skinPanel.add(cbSkinRos);
            revOfSysPanel.add(skinPanel);
            final Label lbInfo9 = new Label("Select if abnormal");
            lbInfo9.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo9.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel skinHp = new HorizontalPanel();
            skinHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbRash = new CheckBox("rash");
            cbPainSkin = new CheckBox("pain");
            cbAbscess = new CheckBox("abscess");
            cbMass = new CheckBox("mass");
            skinHp.add(cbRash);
            skinHp.add(cbPainSkin);
            skinHp.add(cbAbscess);
            skinHp.add(cbMass);
            tbSkinRos = new TextArea();
            tbSkinRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbSkinRos.setSize("700px", "200px");
            cbSkinRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbSkinRos.getValue()) {
                        skinPanel.add(lbInfo9);
                        skinPanel.add(skinHp);
                        skinPanel.add(tbSkinRos);
                    } else {
                        skinPanel.remove(lbInfo9);
                        skinPanel.remove(skinHp);
                        skinPanel.remove(tbSkinRos);
                    }
                }
            });

            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosskinstatus")) {
                if (templateValuesMap.get("pnotesrosskinstatus").equals("1")) {
                    skinPanel.add(tbSkinRos);
                    cbSkinRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosskin");
                    if (templateValuesMap.get("pnotesrosskincmnts") != null) {
                        tbSkinRos.setText(templateValuesMap.get("pnotesrosskincmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosskinstatus")) {
                if (templateValuesMap.get("pnotestrosskinstatus").equals("1")) {
                    skinPanel.add(tbSkinRos);
                    cbSkinRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosskin");
                    if (templateValuesMap.get("pnotestrosskincmnts") != null) {
                        tbSkinRos.setText(templateValuesMap.get("pnotestrosskincmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                skinPanel.add(lbInfo9);
                skinPanel.add(skinHp);
                if (selVal.indexOf("rash") != -1) {
                    cbRash.setValue(true);
                }
                if (selVal.indexOf("pain") != -1) {
                    cbPainSkin.setValue(true);
                }
                if (selVal.indexOf("abscess") != -1) {
                    cbAbscess.setValue(true);
                }
                if (selVal.indexOf("mass") != -1) {
                    cbMass.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Psych"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel psychPanel = new VerticalPanel();
            psychPanel.setSpacing(5);

            cbPsychRos = new CheckBox("Psych");
            cbPsychRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            psychPanel.add(cbPsychRos);
            revOfSysPanel.add(psychPanel);
            final Label lbInfo10 = new Label("Select if abnormal");
            lbInfo10.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo10.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel psychHp = new HorizontalPanel();
            psychHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbFatigue = new CheckBox("fatigue");
            cbInsomnia = new CheckBox("insomnia");
            cbMoodProblem = new CheckBox("mood problem");
            cbCrying = new CheckBox("crying");
            cbDepression = new CheckBox("depression");
            psychHp.add(cbFatigue);
            psychHp.add(cbInsomnia);
            psychHp.add(cbMoodProblem);
            psychHp.add(cbCrying);
            psychHp.add(cbDepression);
            tbPsychRos = new TextArea();
            tbPsychRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbPsychRos.setSize("700px", "200px");
            cbPsychRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbPsychRos.getValue()) {
                        psychPanel.add(lbInfo10);
                        psychPanel.add(psychHp);
                        psychPanel.add(tbPsychRos);
                    } else {
                        psychPanel.remove(lbInfo10);
                        psychPanel.remove(psychHp);
                        psychPanel.remove(tbPsychRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrospsychstatus")) {
                if (templateValuesMap.get("pnotesrospsychstatus").equals("1")) {
                    psychPanel.add(tbPsychRos);
                    cbPsychRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesrospsych");
                    if (templateValuesMap.get("pnotesrospsychcmnts") != null) {
                        tbPsychRos.setText(templateValuesMap.get("pnotesrospsychcmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrospsychstatus")) {
                if (templateValuesMap.get("pnotestrospsychstatus").equals("1")) {
                    psychPanel.add(tbPsychRos);
                    cbPsychRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestrospsych");
                    if (templateValuesMap.get("pnotestrospsychcmnts") != null) {
                        tbPsychRos.setText(templateValuesMap.get("pnotestrospsychcmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                psychPanel.add(lbInfo10);
                psychPanel.add(psychHp);
                if (selVal.indexOf("fatigue") != -1) {
                    cbFatigue.setValue(true);
                }
                if (selVal.indexOf("insomnia") != -1) {
                    cbInsomnia.setValue(true);
                }
                if (selVal.indexOf("mood problem") != -1) {
                    cbMoodProblem.setValue(true);
                }
                if (selVal.indexOf("crying") != -1) {
                    cbCrying.setValue(true);
                }
                if (selVal.indexOf("depression") != -1) {
                    cbDepression.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Endocrine"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel endoPanel = new VerticalPanel();
            endoPanel.setSpacing(5);

            cbEndoRos = new CheckBox("Endocrine");
            cbEndoRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            endoPanel.add(cbEndoRos);
            revOfSysPanel.add(endoPanel);
            final Label lbInfo11 = new Label("Select if abnormal");
            lbInfo11.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo11.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel endoHp = new HorizontalPanel();
            endoHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbHotFlashes = new CheckBox("hot flashes");
            endoHp.add(cbHotFlashes);
            tbEndoRos = new TextArea();
            tbEndoRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbEndoRos.setSize("700px", "200px");
            cbEndoRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbEndoRos.getValue()) {
                        endoPanel.add(lbInfo11);
                        endoPanel.add(endoHp);
                        endoPanel.add(tbEndoRos);
                    } else {
                        endoPanel.remove(lbInfo11);
                        endoPanel.remove(endoHp);
                        endoPanel.remove(tbEndoRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosendostatus")) {
                if (templateValuesMap.get("pnotesrosendostatus").equals("1")) {
                    endoPanel.add(tbEndoRos);
                    cbEndoRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosendo");
                    if (templateValuesMap.get("pnotesrosendocmnts") != null) {
                        tbEndoRos.setText(templateValuesMap.get("pnotesrosendocmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosendostatus")) {
                if (templateValuesMap.get("pnotestrosendostatus").equals("1")) {
                    endoPanel.add(tbEndoRos);
                    cbEndoRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosendo");
                    if (templateValuesMap.get("pnotestrosendocmnts") != null) {
                        tbEndoRos.setText(templateValuesMap.get("pnotestrosendocmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                endoPanel.add(lbInfo11);
                endoPanel.add(endoHp);
                if (selVal.indexOf("hot flashes") != -1) {
                    cbHotFlashes.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Hem/Lymph"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel hemLymPanel = new VerticalPanel();
            hemLymPanel.setSpacing(5);

            cbHemLymRos = new CheckBox("Hem/Lymph");
            cbHemLymRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            hemLymPanel.add(cbHemLymRos);
            revOfSysPanel.add(hemLymPanel);
            final Label lbInfo12 = new Label("Select if abnormal");
            lbInfo12.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo12.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel hemLymHp = new HorizontalPanel();
            hemLymHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbFevers = new CheckBox("fevers");
            cbChills = new CheckBox("chills");
            cbSwelling = new CheckBox("swelling");
            cbNightSweats = new CheckBox("night sweats");
            hemLymHp.add(cbFevers);
            hemLymHp.add(cbChills);
            hemLymHp.add(cbSwelling);
            hemLymHp.add(cbNightSweats);
            tbHemLymRos = new TextArea();
            tbHemLymRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbHemLymRos.setSize("700px", "200px");
            cbHemLymRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbHemLymRos.getValue()) {
                        hemLymPanel.add(lbInfo12);
                        hemLymPanel.add(hemLymHp);
                        hemLymPanel.add(tbHemLymRos);
                    } else {
                        hemLymPanel.remove(lbInfo12);
                        hemLymPanel.remove(hemLymHp);
                        hemLymPanel.remove(tbHemLymRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesroshemlympstatus")) {
                if (templateValuesMap.get("pnotesroshemlympstatus").equals("1")) {
                    hemLymPanel.add(tbHemLymRos);
                    cbHemLymRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesroshemlymp");
                    if (templateValuesMap.get("pnotesroshemlympcmnts") != null) {
                        tbHemLymRos.setText(templateValuesMap.get("pnotesroshemlympcmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestroshemlympstatus")) {
                if (templateValuesMap.get("pnotestroshemlympstatus").equals("1")) {
                    hemLymPanel.add(tbHemLymRos);
                    cbHemLymRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestroshemlymp");
                    if (templateValuesMap.get("pnotestroshemlympcmnts") != null) {
                        tbHemLymRos.setText(templateValuesMap.get("pnotestroshemlympcmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                hemLymPanel.add(lbInfo12);
                hemLymPanel.add(hemLymHp);
                if (selVal.indexOf("fevers") != -1) {
                    cbFevers.setValue(true);
                }
                if (selVal.indexOf("chills") != -1) {
                    cbChills.setValue(true);
                }
                if (selVal.indexOf("swelling") != -1) {
                    cbSwelling.setValue(true);
                }
                if (selVal.indexOf("night sweats") != -1) {
                    cbNightSweats.setValue(true);
                }
            }
        }
        if ((secList != null && secList.get(i).equals("Neuro"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel neuroPanel = new VerticalPanel();
            neuroPanel.setSpacing(5);

            cbNeuroRos = new CheckBox("Neuro");
            cbNeuroRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            neuroPanel.add(cbNeuroRos);
            revOfSysPanel.add(neuroPanel);
            final Label lbInfo13 = new Label("Select if abnormal");
            lbInfo13.getElement().getStyle().setMarginLeft(30, Unit.PX);
            lbInfo13.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
            final HorizontalPanel neuroHp = new HorizontalPanel();
            neuroHp.getElement().getStyle().setMarginLeft(30, Unit.PX);
            cbNumbness = new CheckBox("numbness");
            cbTingling = new CheckBox("tingling");
            cbWeaknessNeuro = new CheckBox("weakness");
            cbHeadache = new CheckBox("headache");
            cbLossOfCons = new CheckBox("loss of consciousness");
            neuroHp.add(cbNumbness);
            neuroHp.add(cbTingling);
            neuroHp.add(cbWeaknessNeuro);
            neuroHp.add(cbHeadache);
            neuroHp.add(cbLossOfCons);
            tbNeuroRos = new TextArea();
            tbNeuroRos.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbNeuroRos.setSize("700px", "200px");
            cbNeuroRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbNeuroRos.getValue()) {
                        neuroPanel.add(lbInfo13);
                        neuroPanel.add(neuroHp);
                        neuroPanel.add(tbNeuroRos);
                    } else {
                        neuroPanel.remove(lbInfo13);
                        neuroPanel.remove(neuroHp);
                        neuroPanel.remove(tbNeuroRos);
                    }
                }
            });
            String selVal = "";
            if (templateValuesMap.containsKey("pnotesrosneurostatus")) {
                if (templateValuesMap.get("pnotesrosneurostatus").equals("1")) {
                    neuroPanel.add(tbNeuroRos);
                    cbNeuroRos.setValue(true);
                    selVal = templateValuesMap.get("pnotesrosneuro");
                    if (templateValuesMap.get("pnotesrosneurocmnts") != null) {
                        tbNeuroRos.setText(templateValuesMap.get("pnotesrosneurocmnts"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosneurostatus")) {
                if (templateValuesMap.get("pnotestrosneurostatus").equals("1")) {
                    neuroPanel.add(tbNeuroRos);
                    cbNeuroRos.setValue(true);
                    selVal = templateValuesMap.get("pnotestrosneuro");
                    if (templateValuesMap.get("pnotestrosneurocmnts") != null) {
                        tbNeuroRos.setText(templateValuesMap.get("pnotestrosneurocmnts"));
                    }
                }
            }
            if (selVal != null && !selVal.equals("")) {
                neuroPanel.add(lbInfo13);
                neuroPanel.add(neuroHp);
                if (selVal.indexOf("numbness") != -1) {
                    cbNumbness.setValue(true);
                }
                if (selVal.indexOf("tingling") != -1) {
                    cbTingling.setValue(true);
                }
                if (selVal.indexOf("weakness") != -1) {
                    cbWeaknessNeuro.setValue(true);
                }
                if (selVal.indexOf("headache") != -1) {
                    cbHeadache.setValue(true);
                }
                if (selVal.indexOf("loss of consciousness") != -1) {
                    cbLossOfCons.setValue(true);
                }
            }
        }

        if ((secList != null && secList.get(i).equals("Immunologic/Allergies"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final VerticalPanel immAllrgPanel = new VerticalPanel();
            cbImmAllrgRos = new CheckBox("Immunologic/Allergies");
            cbImmAllrgRos.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            immAllrgPanel.add(cbImmAllrgRos);
            revOfSysPanel.add(immAllrgPanel);
            tbImmAllrg = new TextArea();
            tbImmAllrg.getElement().getStyle().setMarginLeft(30, Unit.PX);
            tbImmAllrg.setSize("700px", "200px");
            cbImmAllrgRos.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbImmAllrgRos.getValue()) {
                        immAllrgPanel.add(tbImmAllrg);

                    } else {
                        immAllrgPanel.remove(tbImmAllrg);
                    }
                }
            });

            if (templateValuesMap.containsKey("pnotesrosimmallrgstatus")) {
                if (templateValuesMap.get("pnotesrosimmallrgstatus").equals("1")) {
                    cbImmAllrgRos.setValue(true);
                    if (templateValuesMap.containsKey("pnotesrosimmallrg")) {
                        immAllrgPanel.add(tbImmAllrg);
                        tbImmAllrg.setText(templateValuesMap.get("pnotesrosimmallrg"));
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestrosimmallrgstatus")) {
                if (templateValuesMap.get("pnotestrosimmallrgstatus").equals("1")) {
                    cbImmAllrgRos.setValue(true);
                    if (templateValuesMap.containsKey("pnotestrosimmallrg")) {
                        immAllrgPanel.add(tbImmAllrg);
                        tbImmAllrg.setText(templateValuesMap.get("pnotestrosimmallrg"));
                    }
                }
            }

        }
    }
    revSysTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    revOfSysPanel.add(revSysTable);
}

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

License:Open Source License

private void createPastHistoryTab() {
    FlexTable pastHistTable = new FlexTable();
    int row = 0;//from   w  ww.  ja v a 2 s  .co m
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections")
            && sectionsFieldMap.containsKey("Sections#Past Medical History"))
        loopCountMax = sectionsFieldMap.get("Sections#Past Medical History").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Past Medical History"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Past Medical History");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("PH"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbPH = new Label("PH");
            tbPH = new TextArea();
            tbPH.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnotesph")) {
                tbPH.setText(templateValuesMap.get("pnotesph"));
            } else if (templateValuesMap.containsKey("pnotestph")) {
                tbPH.setText(templateValuesMap.get("pnotestph"));
            }
            pastHistTable.setWidget(row, 0, lbPH);
            pastHistTable.setWidget(row++, 1, tbPH);
            if (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES) {
                final CustomListBox listInsInfo = new CustomListBox();
                listInsInfo.addItem("Select information to insert");
                listInsInfo.addItem("Hospitalization", "Hospitalization");
                listInsInfo.addItem("Procedures", "Procedures");
                listInsInfo.addItem("Allergies", "Allergies");
                listInsInfo.addItem("Medications", "Medications");
                listInsInfo.addItem("Current Problems", "Current Problems");
                listInsInfo.addItem("Chronic Problems", "Chronic Problems");
                listInsInfo.addChangeHandler(new ChangeHandler() {
                    @Override
                    public void onChange(ChangeEvent arg0) {
                        if (listInsInfo.getSelectedIndex() != 0) {
                            String value = listInsInfo.getWidgetText();
                            tbPH.setText(tbPH.getText() + "\n\n" + value);
                            insertModuleText(listInsInfo.getWidgetText(), tbPH);
                        }
                    }
                });
                pastHistTable.setWidget(row++, 1, listInsInfo);
            }
        }
    }
    pastHistTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    pastHisPanel.add(pastHistTable);
}

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

License:Open Source License

private void createFamiliyHistoryTab() {
    FlexTable famHistTable = new FlexTable();
    int row = 0;//from   ww w  . ja  v a  2 s .c om
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Family History"))
        loopCountMax = sectionsFieldMap.get("Sections#Family History").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Family History"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Family History");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("FH"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbFH = new Label("FH");
            tbFH = new TextArea();
            tbFH.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnotesfh")) {
                tbFH.setText(templateValuesMap.get("pnotesfh"));
            } else if (templateValuesMap.containsKey("pnotestfh")) {
                tbFH.setText(templateValuesMap.get("pnotestfh"));
            }
            famHistTable.setWidget(row, 0, lbFH);
            famHistTable.setWidget(row++, 1, tbFH);
        }
    }
    famHistTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    famHisPanel.add(famHistTable);
}

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

License:Open Source License

private void createSocialHistoryTab() {
    Label lbInfo = new Label("SOCIAL HISTORY(Select if Applies)");
    lbInfo.setStyleName(AppConstants.STYLE_LABEL_NORMAL_ITALIC);
    socHisPanel.add(lbInfo);/* w w w. j a  v  a 2s  .  co m*/
    socHisPanel.setSpacing(10);
    final FlexTable socialHistTable = new FlexTable();
    int shRowCount = 0;
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Social History"))
        loopCountMax = sectionsFieldMap.get("Sections#Social History").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Social History"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> shSecList = sectionsFieldMap.get("Sections#Social History");
    for (int i = 0; i < loopCountMax; i++) {
        if ((shSecList != null && shSecList.get(i).equals("Alcohol"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbAlcohol = new CheckBox("Alcohol");
            cbAlcohol.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbAlcohol = new TextBox();
            tbAlcohol.setWidth("400px");
            tbAlcohol.setEnabled(false);
            cbAlcohol.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbAlcohol.getValue())
                        tbAlcohol.setEnabled(true);
                    else
                        tbAlcohol.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbAlcohol);
            socialHistTable.setWidget(shRowCount, 1, tbAlcohol);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshalcoholstatus")) {
                if (templateValuesMap.get("pnotesshalcoholstatus").equals("1")) {
                    cbAlcohol.setValue(true);
                    tbAlcohol.setEnabled(true);
                    tbAlcohol.setText(templateValuesMap.get("pnotesshalcoholcmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshalcoholstatus")) {
                if (templateValuesMap.get("pnotestshalcoholstatus").equals("1")) {
                    cbAlcohol.setValue(true);
                    tbAlcohol.setEnabled(true);
                    tbAlcohol.setText(templateValuesMap.get("pnotestshalcoholcmnt"));
                }
            }
        }

        if ((shSecList != null && shSecList.get(i).equals("Tobacco"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbTobacco = new CheckBox("Tobacco");
            cbTobacco.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbTobacco = new TextBox();
            tbTobacco.setWidth("400px");
            tbTobacco.setEnabled(false);
            cbCounseledCessation = new CheckBox("Counseled about cessation");
            cbCounseledCessation.setEnabled(false);
            cbTobacco.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbTobacco.getValue()) {
                        tbTobacco.setEnabled(true);
                        cbCounseledCessation.setEnabled(true);
                    } else {
                        tbTobacco.setEnabled(false);
                        cbCounseledCessation.setEnabled(false);
                    }

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbTobacco);
            socialHistTable.setWidget(shRowCount++, 1, tbTobacco);
            socialHistTable.setWidget(shRowCount, 1, cbCounseledCessation);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshtobaccostatus")) {
                if (templateValuesMap.get("pnotesshtobaccostatus").equals("1")) {
                    cbTobacco.setValue(true);
                    tbTobacco.setEnabled(true);
                    cbCounseledCessation.setEnabled(true);
                    tbTobacco.setText(templateValuesMap.get("pnotesshtobaccocmnt"));
                    if (templateValuesMap.containsKey("pnotesshtcounseled")) {
                        if (templateValuesMap.get("pnotesshtcounseled").equals("1")) {
                            cbCounseledCessation.setValue(true);
                        }
                    }
                }
            } else if (templateValuesMap.containsKey("pnotestshtobaccostatus")) {
                if (templateValuesMap.get("pnotestshtobaccostatus").equals("1")) {
                    cbTobacco.setValue(true);
                    tbTobacco.setEnabled(true);
                    tbTobacco.setText(templateValuesMap.get("pnotestshtobaccocmnt"));
                    cbCounseledCessation.setEnabled(true);
                    if (templateValuesMap.containsKey("pnotestshtcounseled")) {
                        if (templateValuesMap.get("pnotestshtcounseled").equals("1")) {
                            cbCounseledCessation.setValue(true);
                        }
                    }
                }
            }

        }

        if ((shSecList != null && shSecList.get(i).equals("Illicit drugs"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbIllDrugs = new CheckBox("Illicit drugs");
            cbIllDrugs.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbIllDrugs = new TextBox();
            tbIllDrugs.setWidth("400px");
            tbIllDrugs.setEnabled(false);
            cbIllDrugs.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbIllDrugs.getValue())
                        tbIllDrugs.setEnabled(true);
                    else
                        tbIllDrugs.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbIllDrugs);
            socialHistTable.setWidget(shRowCount, 1, tbIllDrugs);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshilctdrugstatus")) {
                if (templateValuesMap.get("pnotesshilctdrugstatus").equals("1")) {
                    cbIllDrugs.setValue(true);
                    tbIllDrugs.setEnabled(true);
                    tbIllDrugs.setText(templateValuesMap.get("pnotesshilctdrugscmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshilctdrugstatus")) {
                if (templateValuesMap.get("pnotestshilctdrugstatus").equals("1")) {
                    cbIllDrugs.setValue(true);
                    tbIllDrugs.setEnabled(true);
                    tbIllDrugs.setText(templateValuesMap.get("pnotestshilctdrugscmnt"));
                }
            }
        }

        if ((shSecList != null && shSecList.get(i).equals("Lives with"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbLivesWith = new CheckBox("Lives with");
            cbLivesWith.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbLivesWith = new TextBox();
            tbLivesWith.setWidth("400px");
            tbLivesWith.setEnabled(false);
            cbLivesWith.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbLivesWith.getValue())
                        tbLivesWith.setEnabled(true);
                    else
                        tbLivesWith.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbLivesWith);
            socialHistTable.setWidget(shRowCount, 1, tbLivesWith);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshliveswithstatus")) {
                if (templateValuesMap.get("pnotesshliveswithstatus").equals("1")) {
                    cbLivesWith.setValue(true);
                    tbLivesWith.setEnabled(true);
                    tbLivesWith.setText(templateValuesMap.get("pnotesshliveswithcmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshliveswithstatus")) {
                if (templateValuesMap.get("pnotestshliveswithstatus").equals("1")) {
                    cbLivesWith.setValue(true);
                    tbLivesWith.setEnabled(true);
                    tbLivesWith.setText(templateValuesMap.get("pnotestshliveswithcmnt"));
                }
            }
        }

        if ((shSecList != null && shSecList.get(i).equals("Occupation"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final Label cbOccupation = new Label("Occupation");
            cbOccupation.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbOccupation = new TextBox();
            tbOccupation.setWidth("400px");
            socialHistTable.setWidget(shRowCount, 0, cbOccupation);
            socialHistTable.setWidget(shRowCount, 1, tbOccupation);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshoccupation")) {
                tbOccupation.setText(templateValuesMap.get("pnotesshoccupation"));
            } else if (templateValuesMap.containsKey("pnotestshoccupation")) {
                tbOccupation.setText(templateValuesMap.get("pnotestshoccupation"));
            }
        }

        if ((shSecList != null && shSecList.get(i).equals("HIV risk factors"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbHivRiskFactor = new CheckBox("HIV risk factors");
            cbHivRiskFactor.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbHivRiskFactor = new TextBox();
            tbHivRiskFactor.setWidth("400px");
            tbHivRiskFactor.setEnabled(false);
            cbHivRiskFactor.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbHivRiskFactor.getValue())
                        tbHivRiskFactor.setEnabled(true);
                    else
                        tbHivRiskFactor.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbHivRiskFactor);
            socialHistTable.setWidget(shRowCount, 1, tbHivRiskFactor);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshivrskfacstatus")) {
                if (templateValuesMap.get("pnotesshivrskfacstatus").equals("1")) {
                    cbHivRiskFactor.setValue(true);
                    tbHivRiskFactor.setEnabled(true);
                    tbHivRiskFactor.setText(templateValuesMap.get("pnotesshivrskfaccmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshivrskfacstatus")) {
                if (templateValuesMap.get("pnotestshivrskfacstatus").equals("1")) {
                    cbHivRiskFactor.setValue(true);
                    tbHivRiskFactor.setEnabled(true);
                    tbHivRiskFactor.setText(templateValuesMap.get("pnotestshivrskfaccmnt"));
                }
            }
        }
        if ((shSecList != null && shSecList.get(i).equals("Travel"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbTravel = new CheckBox("Travel");
            cbTravel.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbTravel = new TextBox();
            tbTravel.setWidth("400px");
            tbTravel.setEnabled(false);
            cbTravel.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbTravel.getValue())
                        tbTravel.setEnabled(true);
                    else
                        tbTravel.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbTravel);
            socialHistTable.setWidget(shRowCount, 1, tbTravel);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshtravelstatus")) {
                if (templateValuesMap.get("pnotesshtravelstatus").equals("1")) {
                    cbTravel.setValue(true);
                    tbTravel.setEnabled(true);
                    tbTravel.setText(templateValuesMap.get("pnotesshtravelcmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshtravelstatus")) {
                if (templateValuesMap.get("pnotestshtravelstatus").equals("1")) {
                    cbTravel.setValue(true);
                    tbTravel.setEnabled(true);
                    tbTravel.setText(templateValuesMap.get("pnotestshtravelcmnt"));
                }
            }
        }
        if ((shSecList != null && shSecList.get(i).equals("Pets"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbPets = new CheckBox("Pets");
            cbPets.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbPets = new TextBox();
            tbPets.setWidth("400px");
            tbPets.setEnabled(false);
            cbPets.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbPets.getValue())
                        tbPets.setEnabled(true);
                    else
                        tbPets.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbPets);
            socialHistTable.setWidget(shRowCount, 1, tbPets);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshpetsstatus")) {
                if (templateValuesMap.get("pnotesshpetsstatus").equals("1")) {
                    cbPets.setValue(true);
                    tbPets.setEnabled(true);
                    tbPets.setText(templateValuesMap.get("pnotesshpetscmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshpetsstatus")) {
                if (templateValuesMap.get("pnotestshpetsstatus").equals("1")) {
                    cbPets.setValue(true);
                    tbPets.setEnabled(true);
                    tbPets.setText(templateValuesMap.get("pnotestshpetscmnt"));
                }
            }
        }
        if ((shSecList != null && shSecList.get(i).equals("Hobbies"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            cbHobbies = new CheckBox("Hobbies");
            cbHobbies.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            tbHobbies = new TextBox();
            tbHobbies.setWidth("400px");
            tbHobbies.setEnabled(false);
            cbHobbies.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent arg0) {
                    if (cbHobbies.getValue())
                        tbHobbies.setEnabled(true);
                    else
                        tbHobbies.setEnabled(false);

                }

            });
            socialHistTable.setWidget(shRowCount, 0, cbHobbies);
            socialHistTable.setWidget(shRowCount, 1, tbHobbies);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshhobbiesstatus")) {
                if (templateValuesMap.get("pnotesshhobbiesstatus").equals("1")) {
                    cbHobbies.setValue(true);
                    tbHobbies.setEnabled(true);
                    tbHobbies.setText(templateValuesMap.get("pnotesshhobbiescmnt"));
                }
            } else if (templateValuesMap.containsKey("pnotestshhobbiesstatus")) {
                if (templateValuesMap.get("pnotestshhobbiesstatus").equals("1")) {
                    cbHobbies.setValue(true);
                    tbHobbies.setEnabled(true);
                    tbHobbies.setText(templateValuesMap.get("pnotestshhobbiescmnt"));
                }
            }
        }
        if ((shSecList != null && shSecList.get(i).equals("Housing"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            final Label lbHousing = new Label("Housing");
            lbHousing.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
            radHousing = new CustomRadioButtonGroup("housing");
            radHousing.addItem("Urban house", "1");
            radHousing.addItem("Trailer", "2");
            radHousing.addItem("Farm", "3");
            radHousing.addItem("Homeless", "4");
            socialHistTable.setWidget(shRowCount, 0, lbHousing);
            socialHistTable.setWidget(shRowCount, 1, radHousing);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 0,
                    HasVerticalAlignment.ALIGN_TOP);
            socialHistTable.getFlexCellFormatter().setVerticalAlignment(shRowCount, 1,
                    HasVerticalAlignment.ALIGN_TOP);
            shRowCount++;
            if (templateValuesMap.containsKey("pnotesshhousing")) {
                radHousing.setWidgetValue(templateValuesMap.get("pnotesshhousing"));
            } else if (templateValuesMap.containsKey("pnotestshhousing")) {
                radHousing.setWidgetValue(templateValuesMap.get("pnotestshhousing"));
            }
        }
    }
    socialHistTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    socHisPanel.add(socialHistTable);
}

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

License:Open Source License

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                cbEyesExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbEntExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

                }
                cbNeckExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

                }
                cbBreastExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

                }
                cbRespExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbCVExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbGIExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbGUExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

                }
                cbLympExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

                }
                cbSkinExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbMSExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbNeuroExBill.addClickHandler(new ClickHandler() {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                }
                cbPsychExBill.addClickHandler(new ClickHandler() {

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

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

License:Open Source License

private void createAssessmentPlanTab() {
    FlexTable assessPlanTable = new FlexTable();
    int row = 0;//from w ww . jav  a  2 s . c o m
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Assessment/Plan"))
        loopCountMax = sectionsFieldMap.get("Sections#Assessment/Plan").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Assessment/Plan"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Assessment/Plan");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("Assessment"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbAssessment = new Label("Assessment");
            tbAssessment = new TextArea();
            tbAssessment.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnotes_A")) {
                tbAssessment.setText(templateValuesMap.get("pnotes_A"));
            } else if (templateValuesMap.containsKey("pnotest_A")) {
                tbAssessment.setText(templateValuesMap.get("pnotest_A"));
            }
            assessPlanTable.setWidget(row, 0, lbAssessment);
            assessPlanTable.setWidget(row++, 1, tbAssessment);
        }
        if ((secList != null && secList.get(i).equals("Plan"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbPlan = new Label("Plan");
            tbPlanAssess = new TextArea();
            tbPlanAssess.setSize("700px", "100px");
            if (templateValuesMap.containsKey("pnotes_P")) {
                tbPlanAssess.setText(templateValuesMap.get("pnotes_P"));
            } else if (templateValuesMap.containsKey("pnotest_P")) {
                tbPlanAssess.setText(templateValuesMap.get("pnotest_P"));
            }
            assessPlanTable.setWidget(row, 0, lbPlan);
            assessPlanTable.setWidget(row++, 1, tbPlanAssess);
        }
    }
    assessPlanTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    assessPlanPanel.add(assessPlanTable);
}

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

License:Open Source License

private void createFreeFormEntryTab() {
    FlexTable freeFormTable = new FlexTable();
    int row = 0;//from   w w  w .j  a  v a  2 s. c o  m
    int loopCountMax = 0;
    if (sectionsFieldMap.containsKey("Sections") && sectionsFieldMap.containsKey("Sections#Free Form Entry"))
        loopCountMax = sectionsFieldMap.get("Sections#Free Form Entry").size();
    else if (sectionsFieldMap.containsKey("Sections")
            && !sectionsFieldMap.containsKey("Sections#Free Form Entry"))
        loopCountMax = 0;
    else
        loopCountMax = 1;
    List<String> secList = sectionsFieldMap.get("Sections#Free Form Entry");
    for (int i = 0; i < loopCountMax; i++) {
        if ((secList != null && secList.get(i).equals("Free Form Entry"))
                || (formtype == EncounterFormType.ENCOUNTER_NOTE_VALUES && currTemplate.equals(""))) {
            Label lbFreeFormEntry = new Label("Free Form Entry");
            editorContainer = new HorizontalPanel();
            rte = new Editor();
            editorContainer.add(rte);
            if (templateValuesMap.containsKey("pnoteshandp")) {
                rte.setHTML(templateValuesMap.get("pnoteshandp"));
            } else if (templateValuesMap.containsKey("pnotesthandp")) {
                rte.setHTML(templateValuesMap.get("pnotesthandp"));
            }
            freeFormTable.setWidget(row, 0, lbFreeFormEntry);
            freeFormTable.setWidget(row++, 1, editorContainer);
        }
    }
    freeFormTable.getFlexCellFormatter().setWidth(0, 0, "155px");
    freeFormPanel.add(freeFormTable);
}

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

License:Open Source License

public FlexTable loadPersonalInfo(HashMap<String, String> retrieveData) {

    FlexTable personalInfoTable = new FlexTable();
    personalInfoTable.setBorderWidth(1);
    Label personaInfolbl = new Label("Personal Info");
    personaInfolbl.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
    personalInfoTable.setWidget(0, 0, personaInfolbl);
    personalInfoTable.getFlexCellFormatter().setColSpan(0, 0, 2);
    personalInfoTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HorizontalPanel.ALIGN_CENTER);
    personalInfoTable.getRowFormatter().setStyleName(1, AppConstants.STYLE_HEADER_PANEL);
    int row = 2;/*  w w w .  ja v  a2 s . c  o m*/
    personalInfoTable.setWidget(row, 0, new Label(_("Marital Status")));
    personalInfoTable.setWidget(row, 1, new Label(retrieveData.get("ptmarital")));
    row++;
    personalInfoTable.setWidget(row, 0, new Label(_("Religion")));
    personalInfoTable.setWidget(row, 1,
            new Label(PatientForm.returnReligion(Integer.parseInt(retrieveData.get("ptreligion")))));
    row++;
    personalInfoTable.setWidget(row, 0, new Label(_("Race")));
    personalInfoTable.setWidget(row, 1,
            new Label(PatientForm.returnRace(Integer.parseInt(retrieveData.get("ptrace")))));
    row++;
    personalInfoTable.setWidget(row, 0, new Label(_("Type OF Billing")));
    personalInfoTable.setWidget(row, 1,
            new Label(PatientForm.returnTypeOfBilling(retrieveData.get("ptbilltype"))));
    row++;
    personalInfoTable.setWidget(row, 0, new Label(_("Employee Status")));
    personalInfoTable.setWidget(row, 1,
            new Label(PatientForm.returnEmploymentStatus(retrieveData.get("ptempl"))));
    row++;
    personalInfoTable.setWidget(row, 0, new Label(_("Admission Date")));
    personalInfoTable.setWidget(row, 1, new Label(retrieveData.get("admissiondate")));
    row++;
    personalInfoTable.setWidget(row, 0, new Label("Program Type"));
    VerticalPanel verticalPanel = new VerticalPanel();
    if (retrieveData.get("progmh") != null && retrieveData.get("progmh").length() > 0) {
        HorizontalPanel horizontalPanel = new HorizontalPanel();
        horizontalPanel.add(new Label(_("Mental Health") + ":" + retrieveData.get("progmh")));
        verticalPanel.add(horizontalPanel);
    }
    if (retrieveData.get("progsa") != null && retrieveData.get("progsa").length() > 0) {
        HorizontalPanel horizontalPanel = new HorizontalPanel();
        horizontalPanel.add(new Label(_("Substance Abuse") + ":" + retrieveData.get("progsa")));
        verticalPanel.add(horizontalPanel);
    }
    if (retrieveData.get("progsstar") != null && retrieveData.get("progsstar").length() > 0) {
        HorizontalPanel horizontalPanel = new HorizontalPanel();
        horizontalPanel.add(new Label("SSTAR Only:" + retrieveData.get("progsstar")));
        verticalPanel.add(horizontalPanel);
    }
    personalInfoTable.setWidget(row, 1, verticalPanel);

    return personalInfoTable;

}