Ejemplo n.º 1
0
  private String buildUserRequest(ECommerceUpdate oneUpdate) {
    StringBuffer requestBuf = new StringBuffer();
    String timeNow = getTimeStampString();
    String username = oneUpdate.getUsername();
    String actionDate = oneUpdate.getActionDate();

    MemberDBBean dbBean = new MemberDBBean(getClass().getName());
    Long user_id = new Long(0);
    Long practice_id = new Long(0);
    Member member = new Member();
    Vector dates = new Vector();
    String practice_username = "";
    try {
      user_id = dbBean.getDrWebId(username);
      practice_id = dbBean.getPracticeId(user_id);
      practice_username = dbBean.getUsername(practice_id);
      member = dbBean.retrieveURSMember(user_id, practice_id);
      dates = dbBean.retrieveRxDates(user_id);
    } catch (Exception e) {
      e.printStackTrace();
    }

    System.out.println("username=========" + username);
    System.out.println("user_id=========" + user_id);
    System.out.println("practice_id=========" + practice_id);
    System.out.println("practice_username=========" + practice_username);

    if (practice_id == 0) throw new IllegalArgumentException("No practice is associated.");

    if (user_id > 0 && practice_id > 0 && member.getMemberID() > 0) {
      requestBuf.append("service=Rcopia&action=updateUser");
      requestBuf.append("&time=");
      requestBuf.append(timeNow);

      requestBuf.append("&practice_username="******"&user_username="******"&drwebid=");
      requestBuf.append(member.getMemberID());
      requestBuf.append("&firstName=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getFirstName())));
      requestBuf.append("&lastName=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getLastName())));
      requestBuf.append("&middleInitial=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getMiddleName())));
      requestBuf.append("&suffix=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getSuffix())));
      requestBuf.append("&memberType=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getMemberType())));
      requestBuf.append("&status=");
      String aflag = StringFunctions.objectToString(member.getActiveFlag());
      String rflag = StringFunctions.objectToString(member.getEPS());
      if (aflag.equals("A")) {
        if (rflag.equals("D") || rflag.equals("X") || rflag.equals("V") || rflag.equals("I"))
          aflag = rflag;
        else if (rflag.equals("R") || rflag.equals("NM")) aflag = "I";
      } else if (!aflag.equals("A")
          && !aflag.equals("I")
          && !aflag.equals("D")
          && !aflag.equals("X")) aflag = "O";

      requestBuf.append(StringFunctions.urlEncoded(aflag));
      Vector disableInfo = new Vector();
      if (aflag.equals("D")) {
        try {
          disableInfo = dbBean.getLastDisabledInformation(new Long(user_id));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      requestBuf.append("&disabled_by=");
      if (disableInfo != null && !disableInfo.isEmpty()) {
        requestBuf.append(StringFunctions.objectToString(disableInfo.elementAt(1)));
      }
      requestBuf.append("&disabled_reason=");
      if (disableInfo != null && !disableInfo.isEmpty()) {
        requestBuf.append(StringFunctions.objectToString(disableInfo.elementAt(2)));
      }
      requestBuf.append("&disable_date=");
      if (disableInfo != null && !disableInfo.isEmpty()) {
        requestBuf.append(StringFunctions.objectToString(disableInfo.elementAt(4)));
      }

      requestBuf.append("&isTest=");
      if (member.getIsTest() != null && !member.getIsTest().equals(""))
        requestBuf.append(
            StringFunctions.urlEncoded(StringFunctions.objectToString(member.getIsTest())));
      else requestBuf.append("n");

      requestBuf.append("&isProvider=");

      String m = member.getMemberType();
      if (m != null && !m.equals("M") && !m.equals("NP") && !m.equals("PA") && !m.equals("D"))
        requestBuf.append("n");
      else requestBuf.append("y");

      requestBuf.append("&dea=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getDEA())));
      requestBuf.append("&spec1_desc=");
      if (member.getPrimarySpecialty() != null)
        requestBuf.append(
            StringFunctions.urlEncoded(
                StringFunctions.objectToString(member.getPrimarySpecialty())));
      requestBuf.append("&practice_drwebid=");
      requestBuf.append(practice_id);

      Vector groups = member.getGroups();
      String groupIds = "";
      String groupNames = "";
      if (groups != null && !groups.isEmpty()) {
        int s = groups.size();
        for (int y = 0; y < s; y++) {
          PracticeGroup pg = (PracticeGroup) groups.elementAt(y);
          groupIds += pg.getGroupID();
          groupNames += pg.getGroupName();
          if (y > 0) {
            groupIds += "|";
            groupNames += "|";
          }
        }
      }

      requestBuf.append("&groupID=");
      requestBuf.append(groupIds);
      requestBuf.append("&groupName=");
      requestBuf.append(StringFunctions.urlEncoded(StringFunctions.objectToString(groupNames)));
      requestBuf.append("&officeName=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getOfficeName())));
      requestBuf.append("&address1=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryAddress1())));
      requestBuf.append("&address2=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryAddress2())));
      requestBuf.append("&city=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryCity())));
      requestBuf.append("&state=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryState())));
      requestBuf.append("&zip=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryZip())));
      requestBuf.append("&phoneNumber=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryPhone())));
      requestBuf.append("&faxNumber=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryFax())));
      requestBuf.append("&email=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getEmail())));

      Vector affils = member.getAffiliations();

      String sponsor = "";
      String sales = "";
      String acct_manager = "";
      String deploy_manager = "";
      String ipa = "";

      if (affils != null && !affils.isEmpty()) {
        int si = affils.size();
        for (int t = 0; t < si; t++) {
          UserAffiliation ua = (UserAffiliation) affils.elementAt(t);
          if (ua.getAffiliationType().equals("SP")) sponsor = ua.getAffiliationName();
          else if (ua.getAffiliationType().equals("SA")) sales = ua.getAffiliationName();
          if (ua.getAffiliationType().equals("AM")) acct_manager = ua.getAffiliationName();
          if (ua.getAffiliationType().equals("DM")) deploy_manager = ua.getAffiliationName();
          if (ua.getAffiliationType().equals("IPA")) ipa = ua.getAffiliationName();
        }
      }

      requestBuf.append("&ipa=");
      requestBuf.append(StringFunctions.urlEncoded(StringFunctions.objectToString(ipa)));
      requestBuf.append("&sponsor=");
      requestBuf.append(StringFunctions.urlEncoded(StringFunctions.objectToString(sponsor)));
      requestBuf.append("&salesrep=");
      requestBuf.append(StringFunctions.urlEncoded(StringFunctions.objectToString(sales)));
      requestBuf.append("&accountManager=");
      requestBuf.append(StringFunctions.urlEncoded(StringFunctions.objectToString(acct_manager)));
      requestBuf.append("&deploymentManager=");
      requestBuf.append(StringFunctions.urlEncoded(StringFunctions.objectToString(deploy_manager)));

      if (dates != null && !dates.isEmpty()) {
        Vector d = (Vector) dates.elementAt(0);
        requestBuf.append("&rx1Date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(0)));
        requestBuf.append("&rx5Date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(1)));
        requestBuf.append("&rx50Date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(2)));
        requestBuf.append("&rx200Date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(3)));
        requestBuf.append("&last_script_date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(4)));
        requestBuf.append("&last_pda_activity_date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(5)));
        requestBuf.append("&total_scripts=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(6)));
        requestBuf.append("&last_login_date=");
        requestBuf.append(StringFunctions.objectToString(d.elementAt(7)));

      } else {
        requestBuf.append("&rx1Date=");
        requestBuf.append("&rx5Date=");
        requestBuf.append("&rx50Date=");
        requestBuf.append("&rx200Date=");
        requestBuf.append("&last_script_date=");
        requestBuf.append("&last_pda_activity_date=");
        requestBuf.append("&total_scripts=");
        requestBuf.append("&last_login_date=");
      }
    }

    return requestBuf.toString();
  }
Ejemplo n.º 2
0
  private String buildUserRegistrationRequest(ECommerceUpdate oneUpdate) {
    StringBuffer requestBuf = new StringBuffer();
    String timeNow = getTimeStampString();
    int pendingItemID = oneUpdate.getPendingItemID().intValue();

    MemberDBBean dbBean = new MemberDBBean(getClass().getName());
    Member member = null;
    PracticeGroup practice = null;

    try {
      member = dbBean.retrieveUserRegistration(pendingItemID);
      practice = member.getPractice();
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (member.getMemberID() > 0) {
      requestBuf.append("service=Order&action=registerUser");
      requestBuf.append("&drwebid=");
      requestBuf.append(member.getMemberID());
      requestBuf.append("&username="******"&password="******"&firstName=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getFirstName())));
      requestBuf.append("&lastName=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getLastName())));
      requestBuf.append("&email=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getEmail())));
      requestBuf.append("&memberTypeSelectBox=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getMemberType())));
      requestBuf.append("&practicename");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(practice.getPracticeName())));
      requestBuf.append("&address1=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryAddress1())));
      requestBuf.append("&address2=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryAddress2())));
      requestBuf.append("&city=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryCity())));
      requestBuf.append("&state=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryState())));
      requestBuf.append("&zip=");
      requestBuf.append(
          StringFunctions.urlEncoded(StringFunctions.objectToString(member.getPrimaryZip())));
      requestBuf.append("&PhoneAreaCode1=");
      requestBuf.append(member.getPrimaryPhone().substring(1, 3));
      requestBuf.append("&PhonePrefix1=");
      requestBuf.append(member.getPrimaryPhone().substring(6, 8));
      requestBuf.append("&PhoneSuffix1=");
      requestBuf.append(member.getPrimaryPhone().substring(10, 13));
      requestBuf.append("&time=");
      requestBuf.append(getTimeStampString());
    }

    return requestBuf.toString();
  }