-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add juridisk henvisning for pasienter under 13 år
- Loading branch information
1 parent
75ec2ea
commit f415edd
Showing
11 changed files
with
252 additions
and
97 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
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/no/nav/syfo/rules/patientunder13/PatientAgeUnder13RuleHit.kt
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,18 @@ | ||
package no.nav.syfo.rules.patientunder13 | ||
|
||
import no.nav.syfo.model.Status | ||
import no.nav.syfo.rules.common.RuleHit | ||
|
||
enum class PatientAgeUnder13RuleHit( | ||
val ruleHit: RuleHit, | ||
) { | ||
PASIENT_YNGRE_ENN_13( | ||
ruleHit = | ||
RuleHit( | ||
rule = "PASIENT_YNGRE_ENN_13", | ||
status = Status.INVALID, | ||
messageForSender = "Pasienten er under 13 år. Sykmelding kan ikke benyttes.", | ||
messageForUser = "Pasienten er under 13 år. Sykmelding kan ikke benyttes.", | ||
), | ||
), | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/kotlin/no/nav/syfo/rules/patientunder13/PatientAgeUnder13RuleTree.kt
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,38 @@ | ||
package no.nav.syfo.rules.patientunder13 | ||
|
||
import no.nav.syfo.model.Status | ||
import no.nav.syfo.model.Status.INVALID | ||
import no.nav.syfo.model.Status.OK | ||
import no.nav.syfo.rules.common.RuleResult | ||
import no.nav.syfo.rules.dsl.RuleNode | ||
import no.nav.syfo.rules.dsl.tree | ||
|
||
enum class PatientAgeUnder13Rules { | ||
PASIENT_YNGRE_ENN_13, | ||
} | ||
|
||
val patientAgeUnder13RuleTree = | ||
tree<PatientAgeUnder13Rules, RuleResult>(PatientAgeUnder13Rules.PASIENT_YNGRE_ENN_13) { | ||
yes(INVALID, PatientAgeUnder13RuleHit.PASIENT_YNGRE_ENN_13) | ||
no(OK) | ||
} | ||
|
||
internal fun RuleNode<PatientAgeUnder13Rules, RuleResult>.yes( | ||
status: Status, | ||
ruleHit: PatientAgeUnder13RuleHit? = null | ||
) { | ||
yes(RuleResult(status, ruleHit?.ruleHit)) | ||
} | ||
|
||
internal fun RuleNode<PatientAgeUnder13Rules, RuleResult>.no( | ||
status: Status, | ||
ruleHit: PatientAgeUnder13RuleHit? = null | ||
) { | ||
no(RuleResult(status, ruleHit?.ruleHit)) | ||
} | ||
|
||
fun getRule(rules: PatientAgeUnder13Rules): Rule<PatientAgeUnder13Rules> { | ||
return when (rules) { | ||
PatientAgeUnder13Rules.PASIENT_YNGRE_ENN_13 -> pasientUnder13Aar | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/no/nav/syfo/rules/patientunder13/PatientAgeUnder13RulesExecution.kt
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,50 @@ | ||
package no.nav.syfo.rules.patientunder13 | ||
|
||
import no.nav.syfo.logger | ||
import no.nav.syfo.model.Sykmelding | ||
import no.nav.syfo.model.juridisk.JuridiskHenvisning | ||
import no.nav.syfo.model.juridisk.Lovverk | ||
import no.nav.syfo.rules.common.MedJuridisk | ||
import no.nav.syfo.rules.common.RuleExecution | ||
import no.nav.syfo.rules.common.RuleResult | ||
import no.nav.syfo.rules.dsl.ResultNode | ||
import no.nav.syfo.rules.dsl.RuleNode | ||
import no.nav.syfo.rules.dsl.TreeNode | ||
import no.nav.syfo.rules.dsl.TreeOutput | ||
import no.nav.syfo.rules.dsl.join | ||
import no.nav.syfo.rules.dsl.printRulePath | ||
import no.nav.syfo.services.RuleMetadataSykmelding | ||
|
||
typealias PatientAgeUnder13TreeOutput = TreeOutput<PatientAgeUnder13Rules, RuleResult> | ||
|
||
class PatientAgeUnder13RulesExecution( | ||
val rootNode: TreeNode<PatientAgeUnder13Rules, RuleResult> = patientAgeUnder13RuleTree | ||
) : RuleExecution<PatientAgeUnder13Rules> { | ||
override fun runRules(sykmelding: Sykmelding, ruleMetadata: RuleMetadataSykmelding) = | ||
rootNode.evaluate(sykmelding, ruleMetadata).also { patientAgeUnder13 -> | ||
logger.info("Rules ${sykmelding.id}, ${patientAgeUnder13.printRulePath()}") | ||
} to | ||
MedJuridisk( | ||
JuridiskHenvisning( | ||
lovverk = Lovverk.FOLKETRYGDLOVEN, | ||
paragraf = "8-3", | ||
ledd = 1, | ||
punktum = null, | ||
bokstav = null, | ||
), | ||
) | ||
} | ||
|
||
private fun TreeNode<PatientAgeUnder13Rules, RuleResult>.evaluate( | ||
sykmelding: Sykmelding, | ||
ruleMetadata: RuleMetadataSykmelding, | ||
): PatientAgeUnder13TreeOutput = | ||
when (this) { | ||
is ResultNode -> PatientAgeUnder13TreeOutput(treeResult = result) | ||
is RuleNode -> { | ||
val rule = getRule(rule) | ||
val result = rule(sykmelding, ruleMetadata) | ||
val childNode = if (result.ruleResult) yes else no | ||
result join childNode.evaluate(sykmelding, ruleMetadata) | ||
} | ||
} |
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,24 @@ | ||
package no.nav.syfo.rules.patientunder13 | ||
|
||
import no.nav.syfo.model.Sykmelding | ||
import no.nav.syfo.rules.dsl.RuleResult | ||
import no.nav.syfo.services.RuleMetadataSykmelding | ||
import no.nav.syfo.services.sortedTOMDate | ||
|
||
typealias Rule<T> = | ||
(sykmelding: Sykmelding, ruleMetadataSykmelding: RuleMetadataSykmelding) -> RuleResult<T> | ||
|
||
typealias PatientAgeOver70Rule = Rule<PatientAgeUnder13Rules> | ||
|
||
val pasientUnder13Aar: PatientAgeOver70Rule = { sykmelding, ruleMetadata -> | ||
val sisteTomDato = sykmelding.perioder.sortedTOMDate().last() | ||
val pasientFodselsdato = ruleMetadata.ruleMetadata.pasientFodselsdato | ||
|
||
val pasientUnder13Aar = sisteTomDato < pasientFodselsdato.plusYears(13) | ||
|
||
RuleResult( | ||
ruleInputs = mapOf("pasientUnder13Aar" to pasientUnder13Aar), | ||
rule = PatientAgeUnder13Rules.PASIENT_YNGRE_ENN_13, | ||
ruleResult = pasientUnder13Aar, | ||
) | ||
} |
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
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
Oops, something went wrong.