Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
22ef39c7
Commit
22ef39c7
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-171: Having cutoff date for when to attempt suggestion
parent
3c0d3227
No related branches found
No related tags found
1 merge request
!274
GREG-171: Populating gender and birthdate with suggestions based on national ID
Pipeline
#114712
failed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/utils/index.ts
+18
-2
18 additions, 2 deletions
frontend/src/utils/index.ts
with
18 additions
and
2 deletions
frontend/src/utils/index.ts
+
18
−
2
View file @
22ef39c7
...
@@ -240,11 +240,26 @@ export function isFemaleBasedOnNationalId(nationalId: string): boolean {
...
@@ -240,11 +240,26 @@ export function isFemaleBasedOnNationalId(nationalId: string): boolean {
return
parseInt
(
nationalId
.
charAt
(
8
),
10
)
%
2
===
0
return
parseInt
(
nationalId
.
charAt
(
8
),
10
)
%
2
===
0
}
}
/**
* The ID-number format is scheduled to change in the future:
* https://www.skatteetaten.no/deling/opplysninger/folkeregisteropplysninger/pid/
*
* Do not attempt a suggestion if we are at the time when the format will change.
*/
function
shouldAttemptSuggestion
():
boolean
{
const
currentYear
=
getYear
(
new
Date
())
// Keeping it simple, if this code is still running and should be revised.
// The new numbers are scheduled to appear in 2032
return
currentYear
<=
2031
}
export
function
extractGenderOrBlank
(
nationalId
?:
string
):
string
{
export
function
extractGenderOrBlank
(
nationalId
?:
string
):
string
{
if
(
if
(
nationalId
==
null
||
nationalId
==
null
||
nationalId
===
''
||
nationalId
===
''
||
isValidFnr
(
nationalId
)
!==
true
isValidFnr
(
nationalId
)
!==
true
||
!
shouldAttemptSuggestion
()
)
{
)
{
return
''
return
''
}
}
...
@@ -300,7 +315,8 @@ export function extractBirthdateFromNationalId(
...
@@ -300,7 +315,8 @@ export function extractBirthdateFromNationalId(
if
(
if
(
nationalId
==
null
||
nationalId
==
null
||
nationalId
===
''
||
nationalId
===
''
||
isValidFnr
(
nationalId
)
!==
true
isValidFnr
(
nationalId
)
!==
true
||
!
shouldAttemptSuggestion
()
)
{
)
{
return
null
return
null
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment