-
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 flerre regler (#188)
* Add juridisk henvisning for pasienter under 13 år * use github commit sha for versjon * change to sourceVersionURL * Legg inn manglende juridiske henvisninger * add test to show that all rules are run
- Loading branch information
1 parent
9041d57
commit 78a011b
Showing
32 changed files
with
841 additions
and
512 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
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
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
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, | ||
) | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/no/nav/syfo/rules/periode/PeriodeRuleHit.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,43 @@ | ||
package no.nav.syfo.rules.periode | ||
|
||
import no.nav.syfo.model.Status | ||
import no.nav.syfo.rules.common.RuleHit | ||
|
||
enum class PeriodeRuleHit(val ruleHit: RuleHit) { | ||
FREMDATERT_MER_ENN_30_DAGER( | ||
ruleHit = | ||
RuleHit( | ||
rule = "FREMDATERT", | ||
status = Status.INVALID, | ||
messageForSender = | ||
"Sykmeldingen kan ikke rettes, det må skrives en ny. " + | ||
"Pasienten har fått beskjed om å vente på ny sykmelding fra deg. Grunnet følgende:" + | ||
"Hvis sykmeldingen er fremdatert mer enn 30 dager etter behandletDato avvises meldingen.", | ||
messageForUser = "Sykmeldingen er datert mer enn 30 dager fram i tid.", | ||
), | ||
), | ||
TILBAKEDATERT_MER_ENN_3_AR( | ||
ruleHit = | ||
RuleHit( | ||
rule = "TILBAKEDATERT_MER_ENN_3_AR", | ||
status = Status.INVALID, | ||
messageForSender = | ||
"Sykmeldingen kan ikke rettes, det må skrives en ny. " + | ||
"Pasienten har fått beskjed om å vente på ny sykmelding fra deg. Grunnet følgende: " + | ||
"Sykmeldinges fom-dato er mer enn 3 år tilbake i tid.", | ||
messageForUser = "Startdatoen er mer enn tre år tilbake.", | ||
), | ||
), | ||
TOTAL_VARIGHET_OVER_ETT_AAR( | ||
ruleHit = | ||
RuleHit( | ||
rule = "TOTAL_VARIGHET_OVER_ETT_AAR", | ||
status = Status.INVALID, | ||
messageForSender = | ||
"Sykmeldingen kan ikke rettes, det må skrives en ny. " + | ||
"Pasienten har fått beskjed om å vente på ny sykmelding fra deg. Grunnet følgende:" + | ||
"Sykmeldingen første fom og siste tom har ein varighet som er over 1 år", | ||
messageForUser = "Den kan ikke ha en varighet på over ett år.", | ||
), | ||
), | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/no/nav/syfo/rules/periode/PeriodeRuleTree.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.periode | ||
|
||
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 | ||
import no.nav.syfo.rules.periode.PeriodeRuleHit.* | ||
import no.nav.syfo.rules.periodvalidering.PeriodLogicRuleHit | ||
|
||
enum class PeriodeRules { | ||
FREMDATERT_MER_ENN_30_DAGER, | ||
TILBAKEDATERT_MER_ENN_3_AR, | ||
TOTAL_VARIGHET_OVER_ETT_AAR, | ||
} | ||
|
||
val periodeRuleTree = | ||
tree<PeriodeRules, RuleResult>(PeriodeRules.FREMDATERT_MER_ENN_30_DAGER) { | ||
yes(INVALID, FREMDATERT_MER_ENN_30_DAGER) | ||
no(PeriodeRules.TILBAKEDATERT_MER_ENN_3_AR) { | ||
yes(INVALID, TILBAKEDATERT_MER_ENN_3_AR) | ||
no(PeriodeRules.TOTAL_VARIGHET_OVER_ETT_AAR) { | ||
yes(INVALID, TOTAL_VARIGHET_OVER_ETT_AAR) | ||
no(OK) | ||
} | ||
} | ||
} | ||
|
||
internal fun RuleNode<PeriodeRules, RuleResult>.yes( | ||
status: Status, | ||
ruleHit: PeriodeRuleHit? = null | ||
) { | ||
yes(RuleResult(status, ruleHit?.ruleHit)) | ||
} | ||
|
||
internal fun RuleNode<PeriodeRules, RuleResult>.no( | ||
status: Status, | ||
ruleHit: PeriodLogicRuleHit? = null | ||
) { | ||
no(RuleResult(status, ruleHit?.ruleHit)) | ||
} | ||
|
||
fun getRule(rules: PeriodeRules): Rule<PeriodeRules> { | ||
return when (rules) { | ||
PeriodeRules.FREMDATERT_MER_ENN_30_DAGER -> fremdatertOver30Dager | ||
PeriodeRules.TILBAKEDATERT_MER_ENN_3_AR -> tilbakeDatertOver3Ar | ||
PeriodeRules.TOTAL_VARIGHET_OVER_ETT_AAR -> varighetOver1AAr | ||
} | ||
} |
Oops, something went wrong.