Skip to content

Commit

Permalink
Update NIH award Format
Browse files Browse the repository at this point in the history
  • Loading branch information
tsande16 committed Oct 25, 2023
1 parent 051e882 commit 71cb224
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public static String normalizeAwardNumber(String awardNumber) {
}

//if matching the NIH format, then normalize it to the expected format by removing leading zeros
if (awardNumber.toUpperCase().matches("[0-9]*-*\\s*[A-Z]{1,2}[0-9]{1,2}\s*[A-Z]{2}[A-Z0-9]{6}-*[A-Z0-9]*")) {
if (awardNumber
.toUpperCase().matches("[0-9]*-*\\s*[A-Z]{1,2}[0-9]{1,2}[A-Z]?\s*[A-Z]{2}[A-Z0-9]{6}-*[A-Z0-9]*")) {
//remove leading zeros, whitespace and make uppercase
awardNumber = awardNumber
.replaceFirst("^0+-*(?!$)", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ public void testNullAndEmptyAwardNumber() throws IOException {
public void testNihAwardNumberCorrectFormatWithSpace() throws IOException {
String awardNumber1 = "K99 NS062901";
String awardNumber2 = "P50 AI074285";
String awardNumber3 = "P2C HD042854";
String awardNumber1Expected = "K99NS062901";
String awardNumber2Expected = "P50AI074285";
String awardNumber3Expected = "P2CHD042854";
assertEquals(awardNumber1Expected, ModelUtil.normalizeAwardNumber(awardNumber1));
assertEquals(awardNumber2Expected, ModelUtil.normalizeAwardNumber(awardNumber2));
assertEquals(awardNumber3Expected, ModelUtil.normalizeAwardNumber(awardNumber3));
}

@Test
Expand Down

0 comments on commit 71cb224

Please sign in to comment.