-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from imsweb/telephone-rule-51
Added rule for Telephone (#51)
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/imsweb/datagenerator/naaccr/rule/patient/TelephoneRule.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,26 @@ | ||
package com.imsweb.datagenerator.naaccr.rule.patient; | ||
|
||
import java.util.Map; | ||
|
||
import com.imsweb.datagenerator.naaccr.NaaccrDataGeneratorOptions; | ||
import com.imsweb.datagenerator.naaccr.NaaccrDataGeneratorPatientRule; | ||
import com.imsweb.datagenerator.utils.RandomUtils; | ||
import com.imsweb.naaccrxml.entity.Patient; | ||
|
||
public class TelephoneRule extends NaaccrDataGeneratorPatientRule { | ||
|
||
// unique identifier for this rule | ||
public static final String ID = "telephone"; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public TelephoneRule() { | ||
super(ID, "Telephone"); | ||
} | ||
|
||
@Override | ||
public void execute(Patient patient, NaaccrDataGeneratorOptions options, Map<String, Object> context) { | ||
setValue(patient, "telephone", RandomUtils.getRandomStringOfDigits(10)); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/com/imsweb/datagenerator/naaccr/rule/patient/TelephoneRuleTest.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,22 @@ | ||
package com.imsweb.datagenerator.naaccr.rule.patient; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.imsweb.naaccrxml.entity.Patient; | ||
|
||
public class TelephoneRuleTest { | ||
|
||
private final TelephoneRule _rule = new TelephoneRule(); | ||
|
||
@Test | ||
public void testExecute() { | ||
Patient patient = new Patient(); | ||
Map<String, Object> context = new HashMap<>(); | ||
_rule.execute(patient, null, context); | ||
Assert.assertNotNull(patient.getItemValue("telephone")); | ||
} | ||
} |