-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIMTP-2909 Parse PER Administrative Communications Contact #156
Open
x0l08og
wants to merge
5
commits into
walmartlabs:master
Choose a base branch
from
x0l08og:2909
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
54 changes: 54 additions & 0 deletions
54
src/main/java/com/walmartlabs/x12/common/segment/PERAdministrativeCommunication.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,54 @@ | ||
package com.walmartlabs.x12.common.segment; | ||
|
||
/** | ||
* Purpose: To identify a person or office to whom administrative communications should be directed | ||
*/ | ||
public class PERAdministrativeCommunication { | ||
|
||
public static final String IDENTIFIER = "PER"; | ||
|
||
// PER01, Code identifying the major duty or responsibility of the person or group named | ||
private String contactFunctionCode; | ||
|
||
// PER02, Free-form name | ||
private String freeFormName; | ||
|
||
// PER03/05/07, Code identifying the type of communication number | ||
private String communicationNumberQualifier; | ||
|
||
// PER04/06/08, Complete communications number including country or area code when applicable | ||
private String communicationNumber; | ||
|
||
|
||
public String getContactFunctionCode() { | ||
return contactFunctionCode; | ||
} | ||
|
||
public void setContactFunctionCode(String contactFunctionCode) { | ||
this.contactFunctionCode = contactFunctionCode; | ||
} | ||
|
||
public String getFreeFormName() { | ||
return freeFormName; | ||
} | ||
|
||
public void setFreeFormName(String freeFormName) { | ||
this.freeFormName = freeFormName; | ||
} | ||
|
||
public String getCommunicationNumberQualifier() { | ||
return communicationNumberQualifier; | ||
} | ||
|
||
public void setCommunicationNumberQualifier(String communicationNumberQualifier) { | ||
this.communicationNumberQualifier = communicationNumberQualifier; | ||
} | ||
|
||
public String getCommunicationNumber() { | ||
return communicationNumber; | ||
} | ||
|
||
public void setCommunicationNumber(String communicationNumber) { | ||
this.communicationNumber = communicationNumber; | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
...java/com/walmartlabs/x12/common/segment/parser/PERAdministrativeCommunicationsParser.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,45 @@ | ||
package com.walmartlabs.x12.common.segment.parser; | ||
|
||
import com.walmartlabs.x12.X12Segment; | ||
import com.walmartlabs.x12.common.segment.PERAdministrativeCommunication; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public final class PERAdministrativeCommunicationsParser { | ||
|
||
/** | ||
* parse the segment | ||
* | ||
* @param segment | ||
* @return | ||
*/ | ||
public static List<PERAdministrativeCommunication> parse(X12Segment segment) { | ||
List<PERAdministrativeCommunication> perList = new ArrayList<>(); | ||
|
||
if (segment != null) { | ||
String segmentIdentifier = segment.getIdentifier(); | ||
if (PERAdministrativeCommunication.IDENTIFIER.equals(segmentIdentifier)) { | ||
int size = segment.segmentSize(); | ||
if (size > 2) { | ||
String functionCode = segment.getElement(1); | ||
String freeFormName = segment.getElement(2); | ||
for (int i = 4; i < size; i += 2) { | ||
PERAdministrativeCommunication per = new PERAdministrativeCommunication(); | ||
per.setContactFunctionCode(functionCode); | ||
per.setFreeFormName(freeFormName); | ||
per.setCommunicationNumberQualifier(segment.getElement(i - 1)); | ||
per.setCommunicationNumber(segment.getElement(i)); | ||
|
||
perList.add(per); | ||
} | ||
} | ||
} | ||
} | ||
return perList; | ||
} | ||
|
||
private PERAdministrativeCommunicationsParser() { | ||
// you can't make me | ||
} | ||
} |
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
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
79 changes: 79 additions & 0 deletions
79
.../com/walmartlabs/x12/common/segment/parser/PERAdministrativeCommunicationsParserTest.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,79 @@ | ||
package com.walmartlabs.x12.common.segment.parser; | ||
|
||
import com.walmartlabs.x12.X12Segment; | ||
import com.walmartlabs.x12.common.segment.PERAdministrativeCommunication; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
|
||
public class PERAdministrativeCommunicationsParserTest { | ||
|
||
@Test | ||
public void test_parse_null_segment() { | ||
X12Segment segment = null; | ||
List<PERAdministrativeCommunication> perList = PERAdministrativeCommunicationsParser.parse(segment); | ||
assertNotNull(perList); | ||
assertEquals(0, perList.size()); | ||
} | ||
|
||
@Test | ||
public void test_parse_empty_segment() { | ||
X12Segment segment = new X12Segment(""); | ||
List<PERAdministrativeCommunication> perList = PERAdministrativeCommunicationsParser.parse(segment); | ||
assertNotNull(perList); | ||
assertEquals(0, perList.size()); | ||
} | ||
|
||
@Test | ||
public void test_parse_segment() { | ||
X12Segment segment = new X12Segment("PER*PY*FSMA CONTACT*TE*+18884636332*EA*FoodSafetyPlanBuilder@fda.hhs.gov"); | ||
List<PERAdministrativeCommunication> perList = PERAdministrativeCommunicationsParser.parse(segment); | ||
assertNotNull(perList); | ||
assertEquals(2, perList.size()); | ||
|
||
PERAdministrativeCommunication perAdministrativeCommunication = perList.get(0); | ||
assertEquals("PY", perAdministrativeCommunication.getContactFunctionCode()); | ||
assertEquals("FSMA CONTACT", perAdministrativeCommunication.getFreeFormName()); | ||
assertEquals("TE", perAdministrativeCommunication.getCommunicationNumberQualifier()); | ||
assertEquals("+18884636332", perAdministrativeCommunication.getCommunicationNumber()); | ||
|
||
perAdministrativeCommunication = perList.get(1); | ||
assertEquals("PY", perAdministrativeCommunication.getContactFunctionCode()); | ||
assertEquals("FSMA CONTACT", perAdministrativeCommunication.getFreeFormName()); | ||
assertEquals("EA", perAdministrativeCommunication.getCommunicationNumberQualifier()); | ||
assertEquals("FoodSafetyPlanBuilder@fda.hhs.gov", perAdministrativeCommunication.getCommunicationNumber()); | ||
} | ||
|
||
@Test | ||
public void test_parse_segment_ur() { | ||
X12Segment segment = new X12Segment("PER*PY*FSMA CONTACT*UR*localhost:8080"); | ||
List<PERAdministrativeCommunication> perList = PERAdministrativeCommunicationsParser.parse(segment); | ||
assertNotNull(perList); | ||
assertEquals(1, perList.size()); | ||
|
||
PERAdministrativeCommunication perAdministrativeCommunication = perList.get(0); | ||
assertEquals("PY", perAdministrativeCommunication.getContactFunctionCode()); | ||
assertEquals("FSMA CONTACT", perAdministrativeCommunication.getFreeFormName()); | ||
assertEquals("UR", perAdministrativeCommunication.getCommunicationNumberQualifier()); | ||
assertEquals("localhost:8080", perAdministrativeCommunication.getCommunicationNumber()); | ||
} | ||
|
||
@Test | ||
public void test_parse_segment_not_balanced() { | ||
X12Segment segment = new X12Segment("PER*PY*FSMA CONTACT*TE*+18884636332*EA"); | ||
List<PERAdministrativeCommunication> perList = PERAdministrativeCommunicationsParser.parse(segment); | ||
assertNotNull(perList); | ||
assertEquals(1, perList.size()); | ||
|
||
PERAdministrativeCommunication perAdministrativeCommunication = perList.get(0); | ||
assertEquals("PY", perAdministrativeCommunication.getContactFunctionCode()); | ||
assertEquals("FSMA CONTACT", perAdministrativeCommunication.getFreeFormName()); | ||
assertEquals("TE", perAdministrativeCommunication.getCommunicationNumberQualifier()); | ||
assertEquals("+18884636332", perAdministrativeCommunication.getCommunicationNumber()); | ||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be telephone number or email, can we change these to communicationDetailQualifier and communicationDetail or communicationInfoQualifier and communicationInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this name communicationNumberQualifier/communicationNumber from 856 Ship Notice/Manifest pdf..