Skip to content

Commit

Permalink
birth test
Browse files Browse the repository at this point in the history
  • Loading branch information
adamloup-enquizit committed Sep 19, 2024
1 parent 31c86ec commit 16e0e32
Show file tree
Hide file tree
Showing 15 changed files with 683 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package gov.cdc.nbs.patient.profile.birth;

import java.time.LocalDate;

public record BirthDemographic(
LocalDate asOf,
LocalDate bornOn,
String sex,
String multiple,
Integer order,
String city,
String state,
String county,
String country
) {

BirthDemographic(final LocalDate asOf) {
this(asOf, null, null, null, null, null, null, null, null);
}

BirthDemographic withBornOn(final LocalDate value) {
return new BirthDemographic(
asOf(),
value,
sex(),
multiple(),
order(),
city(),
state(),
county(),
country()
);
}

BirthDemographic withSex(final String value) {
return new BirthDemographic(
asOf(),
bornOn(),
value,
multiple(),
order(),
city(),
state(),
county(),
country()
);
}

BirthDemographic withMultiple(final String value) {
return new BirthDemographic(
asOf(),
bornOn(),
sex(),
value,
order(),
city(),
state(),
county(),
country()
);
}

BirthDemographic withOrder(final int value) {
return new BirthDemographic(
asOf(),
bornOn(),
sex(),
multiple(),
value,
city(),
state(),
county(),
country()
);
}

BirthDemographic withCity(final String value) {
return new BirthDemographic(
asOf(),
bornOn(),
sex(),
multiple(),
order(),
value,
state(),
county(),
country()
);
}

BirthDemographic withCounty(final String value) {
return new BirthDemographic(
asOf(),
bornOn(),
sex(),
multiple(),
order(),
city(),
state(),
value,
country()
);
}

BirthDemographic withState(final String value) {
return new BirthDemographic(
asOf(),
bornOn(),
sex(),
multiple(),
order(),
city(),
value,
county(),
country()
);
}

BirthDemographic withCountry(final String value) {
return new BirthDemographic(
asOf(),
bornOn(),
sex(),
multiple(),
order(),
city(),
state(),
county(),
value
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gov.cdc.nbs.accumulation.Including;
import gov.cdc.nbs.patient.profile.administrative.Administrative;
import gov.cdc.nbs.patient.profile.birth.BirthDemographic;
import gov.cdc.nbs.patient.profile.names.NameDemographic;

import java.time.Instant;
Expand All @@ -10,6 +11,7 @@

public record NewPatient(
Administrative administrative,
BirthDemographic birth,
List<NameDemographic> names,
List<Address> addresses,
List<Phone> phoneEmails,
Expand All @@ -32,6 +34,7 @@ public record Address(
String comment) {
}


public record Phone(
Instant asOf,
String type,
Expand All @@ -44,12 +47,14 @@ public record Phone(
String comment) {
}


public record Race(
Instant asOf,
String race,
List<String> detailed) {
}


public record Identification(
Instant asOf,
String type,
Expand All @@ -60,6 +65,7 @@ public record Identification(
public NewPatient(Instant asOf) {
this(
new Administrative(asOf),
null,
Collections.emptyList(),
Collections.emptyList(),
Collections.emptyList(),
Expand All @@ -70,6 +76,7 @@ public NewPatient(Instant asOf) {
public NewPatient withAdministrative(final Administrative administrative) {
return new NewPatient(
administrative,
birth(),
names(),
addresses(),
phoneEmails(),
Expand All @@ -81,11 +88,24 @@ public NewPatient withAdministrative(final Administrative administrative) {
public NewPatient withName(final NameDemographic name) {
return new NewPatient(
administrative(),
birth(),
Including.include(names(), name),
addresses(),
phoneEmails(),
races(),
identifications()
);
}

public NewPatient withBirth(final BirthDemographic value) {
return new NewPatient(
administrative(),
value,
names(),
addresses(),
phoneEmails(),
races(),
identifications()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void clean() {
@Given("I am adding a new patient with addresses")
public void i_am_adding_a_new_patient_with_addresses() {
NewPatient newPatient = new NewPatient(
null,
null,
Collections.emptyList(),
List.of(
Expand All @@ -91,6 +92,7 @@ public void i_am_adding_a_new_patient_with_addresses() {
@Given("I am adding a new patient with emails")
public void i_am_adding_a_new_patient_with_emails() {
NewPatient newPatient = new NewPatient(
null,
null,
Collections.emptyList(),
Collections.emptyList(),
Expand All @@ -116,6 +118,7 @@ public void i_am_adding_a_new_patient_with_emails() {
@Given("I am adding a new patient with phones")
public void i_am_adding_a_new_patient_with_phones() {
NewPatient newPatient = new NewPatient(
null,
null,
Collections.emptyList(),
Collections.emptyList(),
Expand All @@ -141,7 +144,7 @@ public void i_am_adding_a_new_patient_with_phones() {

@Given("I am adding a new patient with races")
public void i_am_adding_a_new_patient_with_races() {
NewPatient newPatient = new NewPatient(null, null, null, null, List.of(new NewPatient.Race(
NewPatient newPatient = new NewPatient(null,null, null, null, null, List.of(new NewPatient.Race(
RandomUtil.getRandomDateInPast(),
"category-value",
Arrays.asList("detail1", "detail2"))), null);
Expand All @@ -150,7 +153,7 @@ public void i_am_adding_a_new_patient_with_races() {

@Given("I am adding a new patient with identifications")
public void i_am_adding_a_new_patient_with_identifications() {
NewPatient newPatient = new NewPatient(null, null, null, null, null, List.of(new NewPatient.Identification(
NewPatient newPatient = new NewPatient(null,null, null, null, null, null, List.of(new NewPatient.Identification(
RandomUtil.getRandomDateInPast(),
"DL",
"TX",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package gov.cdc.nbs.patient.profile.birth;

import gov.cdc.nbs.testing.support.Active;
import io.cucumber.java.en.Given;

import java.time.LocalDate;

public class BirthDemographicEntrySteps {

private final Active<BirthDemographic> input;

BirthDemographicEntrySteps(final Active<BirthDemographic> input) {
this.input = input;
}

@Given("I enter the birth demographics as of date {localDate}")
public void i_enter_patient_birth_as_of(final LocalDate value) {
this.input.active(new BirthDemographic(value));
}

@Given("I enter the birth demographics with the patient born on {localDate}")
public void i_enter_patient_birth_born_on(final LocalDate value) {
this.input.active(current -> current.withBornOn(value));
}

@Given("I enter the birth demographics with the patient born as {sex}")
public void i_enter_patient_birth_born_as(final String value) {
this.input.active(current -> current.withSex(value));
}

@Given("I enter the birth demographics with the patient multiple as {indicator}")
public void i_enter_patient_birth_multiple_as(final String value) {
this.input.active(current -> current.withMultiple(value));
}

@Given("I enter the birth demographics with the patient born {nth}")
public void i_enter_patient_birth_multiple_as(final int value) {
this.input.active(current -> current.withOrder(value));
}

@Given("I enter the birth demographics with the patient born in the city {string}")
public void i_enter_patient_birth_city_as(final String value) {
this.input.active(current -> current.withCity(value));
}

@Given("I enter the birth demographics with the patient born in the county {county}")
public void i_enter_patient_birth_county_as(final String value) {
this.input.active(current -> current.withCounty(value));
}

@Given("I enter the birth demographics with the patient born in the state {state}")
public void i_enter_patient_birth_state_as(final String value) {
this.input.active(current -> current.withState(value));
}

@Given("I enter the birth demographics with the patient born in the country {county}")
public void i_enter_patient_birth_country_as(final String value) {
this.input.active(current -> current.withCountry(value));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package gov.cdc.nbs.patient.profile.birth;

import gov.cdc.nbs.testing.support.Active;
import io.cucumber.spring.ScenarioScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Clock;
import java.time.LocalDate;

@Configuration
class BirthDemographicSupportConfiguration {

@Bean
@ScenarioScope
Active<BirthDemographic> activeBirthDemographic(final Clock clock) {
return new Active<>(() -> new BirthDemographic(LocalDate.now(clock)));
}
}
Loading

0 comments on commit 16e0e32

Please sign in to comment.