예제 #1
0
  // public PresentationObject getVisitForm(IWContext iwc, User userVK) throws
  // java.rmi.RemoteException {
  public UIComponent getDoctorForm() {
    IWResourceBundle iwrb = this.getResourceBundle(_iwc);
    Form myForm = new Form();
    myForm.setName(prmForm);

    Table table = new Table(3, 3);
    table.setCellpadding(0);
    table.setCellspacing(0);
    table.setBorder(0);
    table.setVerticalAlignment(1, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(3, 1, Table.VERTICAL_ALIGN_TOP);
    table.setVerticalAlignment(1, 2, Table.VERTICAL_ALIGN_BOTTOM);
    table.setVerticalAlignment(1, 3, Table.VERTICAL_ALIGN_BOTTOM);

    table.setWidth(400);
    table.setWidth(2, 1, 15);
    table.setWidth(1, 1, 73);

    myForm.add(table);

    Age age = null;
    String doctorInfo = null;

    if (user != null && user.getDateOfBirth() != null) age = new Age(user.getDateOfBirth());
    else if (user != null && user.getPersonalID() != null)
      age = new Age(PIDChecker.getInstance().getDateFromPersonalID(user.getPersonalID()));

    int userIDDr = 45;

    if (age != null && age.getYears() >= 70) {
      userIDDr = 46; // 45   41047
    }

    PresentationObject picture = null;
    User doctor = null;

    int userImageID = -1;
    try {
      doctor =
          ((UserBusiness) IBOLookup.getServiceInstance(_iwc, UserBusiness.class)).getUser(userIDDr);
    } catch (Exception fe) {
      log(fe);
    }

    if (doctor != null) userImageID = doctor.getSystemImageID();

    if (userImageID == -1) {
      Table fakeImageTable = new Table(1, 1);
      fakeImageTable.setAlignment(1, 1, Table.HORIZONTAL_ALIGN_CENTER);
      fakeImageTable.setBorder(4);
      fakeImageTable.setHeight(140);
      fakeImageTable.setWidth(100);
      String fakeImageColor = "#CCCCCC";
      Text photoText = new Text(iwrb.getLocalizedString("managerview.photo_text", "Photo"));
      photoText.setBold();
      photoText.setFontColor(fakeImageColor);
      photoText.setFontSize(Text.FONT_SIZE_12_STYLE_TAG);
      fakeImageTable.add(photoText, 1, 1);
      fakeImageTable.setBorderColor(fakeImageColor);
      picture = fakeImageTable;
    } else {
      Image image = new Image();
      image.setImageID(userImageID);
      image.setWidth(73);

      picture = image;
    }
    table.add(picture, 1, 1);

    if (age != null && age.getYears() >= 70) {
      doctorInfo =
          "<b>Dr. Inga Pren</b><br>Allmänläkare<br>Telefon:<br>018-987624<br>Telefontid: Mån-ons, kl 08:30-10.00<br>Webbsida: <a href='http://www.flogsta.se' target='_new'>www.flogsta.se</a>";
    } else {
      doctorInfo =
          "<b>Dr. Magne Syhl</b><br>Allmänläkare<br>Telefon:<br>018-987654<br>Telefontid: Mån-ons, kl 08-10.00<br>Webbsida: <a href='http://www.gimovc.se' target='_new'>www.gimovc.se</a>";
    }

    table.add(doctorInfo, 3, 1);
    GenericButton message =
        getButton(new GenericButton("send_message", localize(prmSendMessage, "Send message")));
    if (_messagePage != null) message.setPageToOpen(_messagePage);

    table.add(message, 3, 2);
    table.setHeight(3, 2, "25");

    GenericButton visitbooking =
        getButton(new GenericButton("visit", localize(prmVisitBooking, "Book an appointment")));
    if (_appointmentPage != null) visitbooking.setPageToOpen(_appointmentPage);

    SubmitButton smb = new SubmitButton();
    smb.setStyleClass("ehealth_InterfaceButton");
    smb.setValue("Skicka meddelande >");
    smb.setPageToOpen(132);

    table.add(visitbooking, 3, 3);

    return myForm;
  }
    public PresentationObject getObjectToAddToColumn(
        int colIndex, int rowIndex, Object item, IWContext iwc, boolean beforeEntities)
        throws Exception {
      if (item == null) {
        if (beforeEntities && (rowIndex == 1)) {
          Text text = new Text();
          text.setFontFace(Text.FONT_FACE_ARIAL);
          text.setFontColor("#FFFFFF");
          text.setFontSize(Text.FONT_SIZE_7_HTML_1);
          text.setBold();

          switch (colIndex) {
            case 1:
              text.setText("Choose");
              break;
            case 3:
              text.setText("Name");
              break;
            case 5:
              text.setText("Title");
              break;
            case 7:
              text.setText("Phone");
              break;
            case 9:
              text.setText("e-mail");
              break;
            default:
              return null;
          }
          return text;
        }
      } else {
        Text text = new Text("");

        StaffHolder staffHolder = (StaffHolder) item;

        switch (colIndex) {
          case 1:
            return getCheckBox(staffHolder.getGroupID());
            // break;
          case 3:
            /** @todo change accesscontrol */
            //              boolean staffHolderIsSuperAdmin =
            // iwc.getAccessController().getAdministratorUser().getID() == staffHolder.getUserID();
            //              if(iwc.isSuperAdmin() && !staffHolderIsSuperAdmin){  //tmp
            //                text = new Link(staffHolder.getName());
            //  //              ((Link)text).setWindowToOpen(StaffEditor.class);
            //  //
            // ((Link)text).addParameter(StaffBusiness.PARAMETER_USER_ID,staffHolder.getUserID());
            //                ((Link)text).setWindowToOpen(StaffPropertyWindow.class);
            //                ((Link)text).addParameter(StaffPropertyWindow.PARAMETERSTRING_USER_ID,
            // staffHolder.getUserID());
            //              } else {
            text.setText(staffHolder.getName());
            //              }
            break;
          case 5:
            if (staffHolder.getTitle() != null) {
              text.setText(staffHolder.getTitle());
            }
            break;
          case 7:
            if (staffHolder.getWorkPhone() != null) {
              text.setText(staffHolder.getWorkPhone());
            }
            break;
          case 9:
            if (staffHolder.getEmail() != null) {
              text.setText(staffHolder.getEmail());
            }
            break;
          default:
            return null;
        }
        text.setFontSize(Text.FONT_SIZE_7_HTML_1);
        text.setFontFace(Text.FONT_FACE_ARIAL);
        return text;
      }
      return null;
    }