Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @Override
  protected void initializeComponent(FacesContext context) {
    ELUtil.getInstance().autowire(this);
    iwc = IWContext.getIWContext(context);
    if (!iwc.isLoggedOn()) {
      return;
    }
    if (userId == null) {
      userId = iwc.getCurrentUserId();
    }

    //        HtmlTag div = new
    // HtmlTag();//(HtmlTag)context.getApplication().createComponent(HtmlTag.COMPONENT_TYPE);
    //        getChildren().add(div);
    //        div.setValue(divTag);
    Layer main = new Layer();
    this.add(main);

    IWBundle bundle = getBundle(context, IWBundleStarter.IW_BUNDLE_IDENTIFIER);
    iwrb = bundle.getResourceBundle(iwc);

    if (groupId == null) {
      Label label = new Label();
      main.add(label);
      label.addText(iwrb.getLocalizedString("no_group_set", "No group set"));
      return;
    }

    Group group = null;
    Collection<Group> groups = null;
    try {
      group = this.getUserBusiness().getGroupBusiness().getGroupByGroupID(Integer.valueOf(groupId));
      groups = this.getUserBusiness().getUserGroups(userId);
    } catch (Exception e) {
      Logger.getLogger(this.getClass().getName())
          .log(Level.WARNING, "failed getting groups by ids", e);
    }

    GenericButton joinButton = new GenericButton();
    main.add(joinButton);
    GenericButton leaveButton = new GenericButton();
    main.add(leaveButton);

    StringBuilder parameters =
        new StringBuilder()
            .append(this.userId)
            .append(CoreConstants.JS_STR_PARAM_SEPARATOR)
            .append(this.groupId)
            .append("','#")
            .append(joinButton.getId())
            .append("','#")
            .append(leaveButton.getId())
            .append(CoreConstants.JS_STR_PARAM_END);

    joinButton.setValue(iwrb.getLocalizedString("join", "Join"));
    String action =
        new StringBuilder("GroupJoinerHelper.joinGroup('").append(parameters).toString();
    joinButton.setOnClick(action);
    leaveButton.setValue(iwrb.getLocalizedString("leave", "Leave"));
    action = new StringBuilder("GroupJoinerHelper.leaveGroup('").append(parameters).toString();
    leaveButton.setOnClick(action);

    if (groups.contains(group)) {
      joinButton.setStyleAttribute("display : none;");
    } else {
      leaveButton.setStyleAttribute("display : none;");
    }

    addActions(main);
  }