1

This is the Member:

public class Member implements Serializable {
    private static final long serialVersionUID = 1L;

    @EmbeddedId
    private MemberPK id;

    @Column(name="BUSINESS_UNIT", nullable=true, length=2)
    private char businessUnit;

    @Column(name="DELETED_IND", nullable=false, length=1)
    private char deletedInd;

    @Column(name = "FIRSTNAME",length=14)
    private String firstname;

    @Column(name = "LASTNAME", length = 14)

}

This is the Eligibility:

public class Eligibility implements Serializable {
    private static final long serialVersionUID = 1L;

    @EmbeddedId
    private MemberSpanPK id;

    @Column(name = "AFF_NBR", nullable=false, length=16)
    private String affNbr;

    @Column(name = "BUSINESS_UNIT", length = 2)
    private Character businessUnit;

    @Column(name = "CARRIER", nullable=true, length = 2)
    private char carrier;

    @Column(name="DELETED_IND", nullable=false, length=1)
}

And this is the third object that I want to put the first 2 objects into.

public class MemberData {

    // Members
    private String membernbr;
    private String medicaidNbr;
    private String namefirst;
    private String namelast;    

    //Eligibility 
    private String memberpcp;
    private String bu;
    private String carrier;
    private String deletedInd;
}
Brian McFarland
  • 9,052
  • 6
  • 38
  • 56
Massman72
  • 11
  • 2

1 Answers1

0

How about simple domain driven method with accessors and mutators (getters and setters)?

MemberData memberData = new MemberData();
memberData.copyMember(/* Member instance */); //Inside get from member and set at memberData.
memberData.copyEligibility(/* Eligibility instance*/); //Inside get from eligibility and set at memberData.

You can run some top level loops to have corresponding eligibility data for a member, and create a MemberData instance.

**** EDIT ****

Please see the sample objects and code sample...

public class Member implements Serializable {
public MemberPK getId() {
    return id;
}

public void setId(MemberPK id) {
    this.id = id;
}

public char getBusinessUnit() {
    return businessUnit;
}

public void setBusinessUnit(char businessUnit) {
    this.businessUnit = businessUnit;
}

public char getDeletedInd() {
    return deletedInd;
}

public void setDeletedInd(char deletedInd) {
    this.deletedInd = deletedInd;
}

public String getFirstname() {
    return firstname;
}

public void setFirstname(String firstname) {
    this.firstname = firstname;
}

private static final long serialVersionUID = 1L;

private MemberPK id;

private char businessUnit;

private char deletedInd;

private String firstname;


}

public class Eligibility implements Serializable {
private static final long serialVersionUID = 1L;

private MemberSpanPK id;

private String affNbr;

private Character businessUnit;

private char carrier;

private String deleteInd;

public MemberSpanPK getId() {
    return id;
}

public void setId(MemberSpanPK id) {
    this.id = id;
}

public String getAffNbr() {
    return affNbr;
}

public void setAffNbr(String affNbr) {
    this.affNbr = affNbr;
}

public Character getBusinessUnit() {
    return businessUnit;
}

public void setBusinessUnit(Character businessUnit) {
    this.businessUnit = businessUnit;
}

public char getCarrier() {
    return carrier;
}

public void setCarrier(char carrier) {
    this.carrier = carrier;
}

public String getDeleteInd() {
    return deleteInd;
}

public void setDeleteInd(String deleteInd) {
    this.deleteInd = deleteInd;
} 
}

public class MemberPK {
private String memberNbr;

public String getMemberNbr() {
    return memberNbr;
}

public void setMemberNbr(String memberNbr) {
    this.memberNbr = memberNbr;
}
}

public class MemberSpanPK {
private String memberNbr;

public String getMemberNbr() {
    return memberNbr;
}

public void setMemberNbr(String memberNbr) {
    this.memberNbr = memberNbr;
}
}

public class EligibilityVO {
//Eligibility 
private String memberpcp;
private String bu;
private String carrier;
private String deletedInd;
public String getMemberpcp() {
    return memberpcp;
}
public void setMemberpcp(String memberpcp) {
    this.memberpcp = memberpcp;
}
public String getBu() {
    return bu;
}
public void setBu(String bu) {
    this.bu = bu;
}
public String getCarrier() {
    return carrier;
}
public void setCarrier(String carrier) {
    this.carrier = carrier;
}
public String getDeletedInd() {
    return deletedInd;
}
public void setDeletedInd(String deletedInd) {
    this.deletedInd = deletedInd;
}
}

public class MemberData {
 // Members
private String membernbr;
private String medicaidNbr;
private String namefirst;
private String namelast;
private List<EligibilityVO> eligibilities;
public List<EligibilityVO> getEligibilities() {
    return eligibilities;
}
public void setEligibilities(List<EligibilityVO> eligibilities) {
    this.eligibilities = eligibilities;
}
public void addEligibilities(EligibilityVO eligibility) {
    if(null == this.eligibilities) {
        this.eligibilities = new ArrayList<EligibilityVO>();
    }
    this.eligibilities.add(eligibility);
}
public String getMembernbr() {
    return membernbr;
}
public void setMembernbr(String membernbr) {
    this.membernbr = membernbr;
}
public String getMedicaidNbr() {
    return medicaidNbr;
}
public void setMedicaidNbr(String medicaidNbr) {
    this.medicaidNbr = medicaidNbr;
}
public String getNamefirst() {
    return namefirst;
}
public void setNamefirst(String namefirst) {
    this.namefirst = namefirst;
}
public String getNamelast() {
    return namelast;
}
public void setNamelast(String namelast) {
    this.namelast = namelast;
}    

}

And the sample class to merge the data...

public class MergeData {

public static void main(String[] args) {

  List<Member> members = new ArrayList<Member>();//Your service level member list here
  List<Eligibility> eligibilities = new ArrayList<Eligibility>();//Your service level eligibility list here
  List<MemberData> memberDatas = new ArrayList<MemberData>();
  for (Member member : members) {
    MemberData memberData = new MemberData(); 
    for (Eligibility eligibility : eligibilities) {
        if(member.getId().getMemberNbr() == eligibility.getId().getMemberNbr()) {
            EligibilityVO eliVo = new EligibilityVO();
            eliVo.setBu(eligibility.getAffNbr());
            //set others
            memberData.addEligibilities(eliVo);
        }
    }
    memberData.setNamefirst(member.getFirstname());
    //Set others
  }
  }
  }

Hope this helps.

  • will this work if I have multiple members and multiple eligibility results for each member? – Massman72 Feb 04 '15 at 16:22
  • I believe you are trying to say 1-M relationship between Member and Eligibility correct? Yes, it will. In that case, though , your MemberData should also have accommodation for multiple eligibilty, as of now which is not. – Aninda Bhattacharyya Feb 04 '15 at 16:40
  • yes. how do I make the MemberData accomodate the multiple eligibility? – Massman72 Feb 04 '15 at 16:48
  • Seggregate your MemberData in 2 pieces... 1. All the member fields as you already have as instance variables. 2. Have a new object EligibilityVO(name, your choice) and have the memberpcp, bu, carrier and deleteInd. 2. Maintain a List in MemberData and populate it from your domain (database backed) Member and Eligibility object. Makes sense? – Aninda Bhattacharyya Feb 04 '15 at 16:50
  • Yes, if you have a list of members. – Aninda Bhattacharyya Feb 04 '15 at 17:26
  • Are you clear now about the structure of the objects and implementation or you need a code example? – Aninda Bhattacharyya Feb 04 '15 at 18:15
  • code example would be great to make sure I am clear. – Massman72 Feb 04 '15 at 18:56
  • I would love to help with that. Please let me know what is your constraint/ property to identify eligibility/ eligibilities for a particular member. I have not seen any meaningfull from your objects. – Aninda Bhattacharyya Feb 04 '15 at 18:59
  • the composite id in member(MemberPK id) and eligibility(MemberSpanPK id) and a membernbr that is passed in the restful call but not needed in the response. – Massman72 Feb 04 '15 at 20:53
  • It is actually needed, to regroup your data and create dependendent object structure. Else you will not be able to identify which eligibilities are for which member and populate the member data. Hope it is clear. – Aninda Bhattacharyya Feb 04 '15 at 22:46
  • The eligibility query uses a membernbr, void_ <> 'V' or is null, deleted_ind <> 'Y', bu = 'businessUnit', and source_instance_desc = 'source_instance_desc' . The source_instance_desc is passed from the restful call, the businessUnit is from the member query as is the source_instance_desc. Is that what you are needing? – Massman72 Feb 05 '15 at 13:46
  • I am still not clear and probably I am also not making myself clear. I need you to tell me that what is/ are the property to decide which eligibility belongs to which member. Its can be a member_id(or other names) in Eligibility or vice versa. – Aninda Bhattacharyya Feb 05 '15 at 17:03
  • From the member object it is the membernbr, businessUnit, and the source_instance_desc . I realize I did not include the businessUnit nor the source_instance_desc in the original Member entity model. These are inserted into the eligibility query to get the eligibility data for each member. – Massman72 Feb 05 '15 at 17:33
  • So please confirm membernbr, businessUnit, and the source_instance_desc is probably the composite key, unique, for each member and same is present in Eligibility object, to relate one or more eligibilities for each member? – Aninda Bhattacharyya Feb 05 '15 at 17:58
  • no. there is a composite key in each entity model MemberPK and EligibilityPK. both are primary keys but there is no primary foreign key relationship. I did not create these, I would not have done it that way. the member query uses membernbr, deleted_Ind <> 'Y' in the where clause. The Eligibility query uses membernbr, void_ <> 'V' or is null, deleted_ind <> 'Y', bu = 'businessUnit', and source_instance_desc = 'source_instance_desc' in the where clause and gets the membernbr, businessUnit, and source_instance_desc from the member query to determine the result set for the eligibility. – Massman72 Feb 05 '15 at 19:07
  • So only membernbr is common between Member and Eligibility and safe to use for gathering eligibilities for a single member? – Aninda Bhattacharyya Feb 05 '15 at 19:11
  • Please see the code example. Please note, this is purely example based and can change in some cases, as per your requirement. Hope this helps. – Aninda Bhattacharyya Feb 05 '15 at 20:47