Skip to content
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

PI-2670 - Common-platform-and-delius - Feature flag to toggle data creation #4490

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

joseph-bcl
Copy link
Contributor

No description provided.

@joseph-bcl joseph-bcl requested a review from a team as a code owner December 12, 2024 16:32
@github-actions github-actions bot added the enhancement New feature or request label Dec 12, 2024
Comment on lines +73 to +77
"firstName" to savedEntities.person.forename,
"surname" to savedEntities.person.surname,
"dob" to savedEntities.person.dateOfBirth.toString(),
"genderCode" to savedEntities.person.gender.description,
"pnc" to savedEntities.person.pncNumber.toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be careful not to log PII to application insights, so probably best to stick with the identifiers in here (e.g. CRN / hearing / defendant id).

I know this makes the "dry run" events a bit useless, but we can at least get an idea of how many we would create. And maybe we could make a call to the prepare a case system to get more details.

Comment on lines +52 to +57
dateOfBirth.let {
val age = Period.between(it, LocalDate.now()).years
require(age > 10) {
"Date of birth would indicate person is under ten years old: $it"
}
}
Copy link
Contributor

@marcus-bcl marcus-bcl Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it simplify things to move this out into the Handler, or into a "validate" method?

That way you could perform this validation regardless of the feature flag, and only call insertPerson if the flag is enabled - e.g. the Handler would become something like:

// this could potentially be moved to a validate method:
val dateOfBirth = requireNotNull(defendant.personDefendant?.personDetails?.dateOfBirth) { "Date of birth not found in message" }
val age = Period.between(dateOfBirth, LocalDate.now()).years
require(age > 10) { "Date of birth would indicate person is under ten years old: $it" }

// only need to check the flag in one place:
if (featureFlags.enabled("common-platform-record-creation-toggle")) {
    val (person, address) = personService.insertPerson(defendant, notification.message.hearing.courtCentre.code)
    notifier.caseCreated(person)
    address?.let { notifier.addressCreated(it) }
    telemetryService.trackEvent("PersonCreated", mapOf("hearingId" to ..., "defendantId" to ..., "crn" to ..., etc))
} else {
    telemetryService.trackEvent("SimulatedPersonCreated", mapOf("hearingId" to ..., "defendantId" to ...))
}

I'm possibly missing some important detail though, so please let me know if I am! 😄

@@ -54,19 +54,44 @@ class Handler(
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we haven't discussed this previously, but probably worth adding an event here too when we find a match - so we can see how many we get that already exist in Delius.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants