Skip to content

Commit

Permalink
Merge pull request #52 from imsweb/telephone-rule-51
Browse files Browse the repository at this point in the history
Added rule for Telephone (#51)
  • Loading branch information
depryf authored Feb 8, 2024
2 parents 2057d49 + a36bd00 commit de9d49f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Changes in version 1.32**

- Added new rule to populate Telephone (issue #51).
- Updated Layout library from version 5.3 to version 5.5.
- Updated NAACCR XML library from version 10.0 to version 10.1.

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The NAACCR generator current provides rules for the following fields:
- NAPIIA
- Diagnostic Procedure Text fields (random data only)
- Tumor Text fields (random data only)
- Telephone

Here is an example using the NAACCR generator:
```java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.imsweb.datagenerator.naaccr.rule.patient.RaceRule;
import com.imsweb.datagenerator.naaccr.rule.patient.SexRule;
import com.imsweb.datagenerator.naaccr.rule.patient.SsnRule;
import com.imsweb.datagenerator.naaccr.rule.patient.TelephoneRule;
import com.imsweb.datagenerator.naaccr.rule.patient.VitalStatusRule;
import com.imsweb.datagenerator.naaccr.rule.tumor.AddressAtDxRule;
import com.imsweb.datagenerator.naaccr.rule.tumor.AgeRule;
Expand Down Expand Up @@ -98,6 +99,7 @@ protected NaaccrDataGenerator(boolean useMaidenNameField) {
_patientRules.add(new BirthRule());
_patientRules.add(new AddressCurrentRule());
_patientRules.add(new ComputedEthnicityRule());
_patientRules.add(new TelephoneRule());

// default tumor rules
_tumorRules = new ArrayList<>();
Expand Down
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));
}
}
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"));
}
}

0 comments on commit de9d49f

Please sign in to comment.