-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5268-renew-cancelled-group-coverage'
- Loading branch information
Showing
21 changed files
with
1,054 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
backend/src/main/java/ca/bc/gov/hlth/hnweb/converter/rapid/RPBSPAI0Converter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package ca.bc.gov.hlth.hnweb.converter.rapid; | ||
|
||
import java.time.LocalDate; | ||
|
||
import ca.bc.gov.hlth.hnweb.model.rapid.AI0; | ||
import ca.bc.gov.hlth.hnweb.model.rapid.R45NewPayer; | ||
import ca.bc.gov.hlth.hnweb.model.rapid.RPBSAddress; | ||
import ca.bc.gov.hlth.hnweb.model.rapid.RPBSHeader; | ||
import ca.bc.gov.hlth.hnweb.model.rapid.RPBSPAI0; | ||
import ca.bc.gov.hlth.hnweb.model.rest.groupmember.AddGroupMemberRequest; | ||
import ca.bc.gov.hlth.hnweb.model.rest.groupmember.MemberAddress; | ||
import ca.bc.gov.hlth.hnweb.model.rest.maintenance.RenewCancelledGroupCoverageRequest; | ||
import ca.bc.gov.hlth.hnweb.model.rest.maintenance.RenewCancelledGroupCoverageResponse; | ||
|
||
public class RPBSPAI0Converter extends BaseRapidConverter { | ||
private static final String TRAN_CODE = "RPBSPAI0"; | ||
|
||
public RPBSPAI0Converter() { | ||
super(); | ||
} | ||
|
||
public RPBSPAI0 convertRequest(RenewCancelledGroupCoverageRequest request) { | ||
RPBSHeader rpbsHeader = new RPBSHeader(); | ||
rpbsHeader.setOrganization(userInfo.getOrganization()); | ||
rpbsHeader.setTranCode(getTranCode()); | ||
|
||
AI0 ai0 = new AI0(); | ||
ai0.setGroupNumber(request.getGroupNumber()); | ||
ai0.setPhn(request.getPhn()); | ||
ai0.setNewCoverageEffectiveDate(formatDate(request.getNewCoverageEffectiveDate())); | ||
|
||
RPBSPAI0 rpbspai0 = new RPBSPAI0(); | ||
rpbspai0.setRpbsHeader(rpbsHeader); | ||
rpbspai0.setAi0(ai0); | ||
|
||
return rpbspai0; | ||
} | ||
|
||
public RenewCancelledGroupCoverageResponse convertResponse(RPBSPAI0 rpbspai0) { | ||
RenewCancelledGroupCoverageResponse response = new RenewCancelledGroupCoverageResponse(); | ||
RPBSHeader header = rpbspai0.getRpbsHeader(); | ||
|
||
handleStatus(header, response); | ||
response.setPhn(rpbspai0.getAi0().getPhn()); | ||
|
||
return response; | ||
} | ||
|
||
public AddGroupMemberRequest buildAddGroupMemberRequest(RPBSPAI0 rpbspai0) { | ||
R45NewPayer newPayerData = rpbspai0.getAi0().getNewPayerData(); | ||
AddGroupMemberRequest request = new AddGroupMemberRequest(); | ||
request.setEffectiveDate(LocalDate.parse(rpbspai0.getAi0().getNewCoverageEffectiveDate())); | ||
request.setPhn(newPayerData.getPhn()); | ||
request.setSpousePhn(newPayerData.getSpousePhn()); | ||
request.setDependentPhn1(newPayerData.getDependentPhn1()); | ||
request.setDependentPhn2(newPayerData.getDependentPhn2()); | ||
request.setDependentPhn3(newPayerData.getDependentPhn3()); | ||
request.setDependentPhn4(newPayerData.getDependentPhn4()); | ||
request.setDependentPhn5(newPayerData.getDependentPhn5()); | ||
request.setDependentPhn6(newPayerData.getDependentPhn6()); | ||
request.setDependentPhn7(newPayerData.getDependentPhn7()); | ||
request.setGroupNumber(newPayerData.getGroupNumber()); | ||
request.setGroupMemberNumber(newPayerData.getEmployeeNumber()); | ||
request.setDepartmentNumber(newPayerData.getDepartmentNumber()); | ||
request.setHomeAddress(convertToMemberAddress(newPayerData.getHomeAddress())); | ||
request.setMailingAddress(convertToMemberAddress(newPayerData.getMailAddress())); | ||
request.setPhone(newPayerData.getPhone1().getPhoneNumber()); | ||
return request; | ||
} | ||
|
||
private MemberAddress convertToMemberAddress(RPBSAddress rpbsAddress) { | ||
MemberAddress memberAddress = new MemberAddress(); | ||
|
||
if (rpbsAddress == null) { | ||
return memberAddress; | ||
} | ||
memberAddress.setAddressLine1(rpbsAddress.getAddressLine1()); | ||
memberAddress.setAddressLine2(rpbsAddress.getAddressLine2()); | ||
memberAddress.setAddressLine3(rpbsAddress.getAddressLine3()); | ||
memberAddress.setAddressLine4(rpbsAddress.getAddressLine4()); | ||
memberAddress.setPostalCode(rpbsAddress.getPostalCode()); | ||
|
||
return memberAddress; | ||
} | ||
|
||
@Override | ||
public String getTranCode() { | ||
return TRAN_CODE; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
backend/src/main/java/ca/bc/gov/hlth/hnweb/model/rapid/AI0.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package ca.bc.gov.hlth.hnweb.model.rapid; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class AI0 { | ||
|
||
/** 1 GroupNumber String No 0...7 .. */ | ||
private String groupNumber; | ||
/** 2 PHN String No 0...10 .. */ | ||
private String phn; | ||
/** 3 NewCoverageEffectiveDate RPBSDate No 0...10 .. */ | ||
private String newCoverageEffectiveDate; | ||
/** 4 NewPayerData String No 0...394 .. */ | ||
private R45NewPayer newPayerData; | ||
|
||
public AI0() { | ||
super(); | ||
} | ||
|
||
public AI0(String message) { | ||
super(); | ||
phn = StringUtils.substring(message, 0, 10); | ||
groupNumber = StringUtils.substring(message, 10, 17); | ||
newCoverageEffectiveDate = StringUtils.substring(message, 17, 27); | ||
newPayerData = new R45NewPayer(StringUtils.substring(message, 27,421)); | ||
|
||
} | ||
|
||
public String serialize() { | ||
// Serialize is only used in when creating the request | ||
// where only the first three fields are used | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(StringUtils.rightPad(phn, 10)); | ||
sb.append(StringUtils.rightPad(groupNumber, 7)); | ||
sb.append(StringUtils.rightPad(newCoverageEffectiveDate, 10)); | ||
|
||
return sb.toString(); | ||
} | ||
|
||
public String getGroupNumber() { | ||
return groupNumber; | ||
} | ||
|
||
public void setGroupNumber(String groupNumber) { | ||
this.groupNumber = groupNumber; | ||
} | ||
|
||
public String getPhn() { | ||
return phn; | ||
} | ||
|
||
public void setPhn(String phn) { | ||
this.phn = phn; | ||
} | ||
|
||
public String getNewCoverageEffectiveDate() { | ||
return newCoverageEffectiveDate; | ||
} | ||
|
||
public void setNewCoverageEffectiveDate(String newCoverageEffectiveDate) { | ||
this.newCoverageEffectiveDate = newCoverageEffectiveDate; | ||
} | ||
|
||
public R45NewPayer getNewPayerData() { | ||
return newPayerData; | ||
} | ||
|
||
public void setNewPayerData(R45NewPayer ai0payeeData) { | ||
this.newPayerData = ai0payeeData; | ||
} | ||
|
||
} |
Oops, something went wrong.