generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
53d6352
commit 0addf14
Showing
8 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
...ammes-and-oasys/src/dev/resources/simulations/__files/pni-calculation-no-calculation.json
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,13 @@ | ||
{ | ||
"source": "OASys", | ||
"inputs": { | ||
"crnSource": "pris", | ||
"crn": "P467262", | ||
"additionalParameter": "Y", | ||
"laoPrivilege": "ALLOW" | ||
}, | ||
"probNumber": "P467262", | ||
"prisNumber": "A8747PN", | ||
"limitedAccessOffender": false, | ||
"pniCalc": null | ||
} |
32 changes: 32 additions & 0 deletions
32
...d-programmes-and-oasys/src/dev/resources/simulations/__files/pni-calculation-success.json
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,32 @@ | ||
{ | ||
"source": "OASys", | ||
"inputs": { | ||
"crnSource": "pris", | ||
"crn": "P467261", | ||
"additionalParameter": "N", | ||
"laoPrivilege": "ALLOW" | ||
}, | ||
"probNumber": "P467261", | ||
"prisNumber": "A8746PN", | ||
"limitedAccessOffender": false, | ||
"pniCalc": [ | ||
{ | ||
"offenderPk": 869584726, | ||
"riskLevel": "L", | ||
"missingFields": null, | ||
"sexDomainLevel": "L", | ||
"sexDomainScore": 0, | ||
"thinkingDomainLevel": "M", | ||
"thinkingDomainScore": 1, | ||
"relationshipDomainLevel": "M", | ||
"relationshipDomainScore": 1, | ||
"selfManagementDomainLevel": "H", | ||
"selfManagementDomainScore": 2, | ||
"totalDomainScore": 4, | ||
"overallNeedLevel": "M", | ||
"pniCalculation": "A", | ||
"saraRiskLevelToPartner": 1, | ||
"saraRiskLevelToOther": 2 | ||
} | ||
] | ||
} |
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
20 changes: 20 additions & 0 deletions
20
...ammes-and-oasys/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/PniCalculation.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,20 @@ | ||
package uk.gov.justice.digital.hmpps.controller | ||
|
||
import uk.gov.justice.digital.hmpps.integrations.oasys.Level | ||
import uk.gov.justice.digital.hmpps.integrations.oasys.PniCalculation.Type | ||
|
||
data class PniCalculation( | ||
val sexDomain: LevelScore, | ||
val thinkingDomain: LevelScore, | ||
val relationshipDomain: LevelScore, | ||
val selfManagementDomain: LevelScore, | ||
val riskLevel: Level, | ||
val needLevel: Level, | ||
val totalDomainScore: Int, | ||
val pni: Type, | ||
val saraRiskLevel: SaraRiskLevel, | ||
val missingFields: List<String> = listOf(), | ||
) | ||
|
||
data class LevelScore(val level: Level, val score: Int) | ||
data class SaraRiskLevel(val toPartner: Int, val toOther: Int) |
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
48 changes: 48 additions & 0 deletions
48
...es-and-oasys/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/oasys/PniResult.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,48 @@ | ||
package uk.gov.justice.digital.hmpps.integrations.oasys | ||
|
||
import uk.gov.justice.digital.hmpps.controller.LevelScore | ||
import uk.gov.justice.digital.hmpps.controller.SaraRiskLevel | ||
import uk.gov.justice.digital.hmpps.controller.PniCalculation as IntegrationModel | ||
|
||
data class PniResult(val pniCalc: List<PniCalculation>?) | ||
data class PniCalculation( | ||
val missingFields: List<String>?, | ||
val riskLevel: Level, | ||
val sexDomainLevel: Level, | ||
val sexDomainScore: Int, | ||
val thinkingDomainLevel: Level, | ||
val thinkingDomainScore: Int, | ||
val relationshipDomainLevel: Level, | ||
val relationshipDomainScore: Int, | ||
val selfManagementDomainLevel: Level, | ||
val selfManagementDomainScore: Int, | ||
val overallNeedLevel: Level, | ||
val totalDomainScore: Int, | ||
val pniCalculation: Type, | ||
val saraRiskLevelToPartner: Int, | ||
val saraRiskLevelToOther: Int, | ||
) { | ||
enum class Type { | ||
H, M, A, O | ||
} | ||
} | ||
|
||
enum class Level { | ||
H, M, L | ||
} | ||
|
||
fun PniResult.asIntegrationModel(): IntegrationModel? = with(pniCalc?.firstOrNull()) { | ||
if (this == null) null | ||
else IntegrationModel( | ||
sexDomain = LevelScore(sexDomainLevel, sexDomainScore), | ||
thinkingDomain = LevelScore(thinkingDomainLevel, thinkingDomainScore), | ||
relationshipDomain = LevelScore(relationshipDomainLevel, relationshipDomainScore), | ||
selfManagementDomain = LevelScore(selfManagementDomainLevel, selfManagementDomainScore), | ||
riskLevel = riskLevel, | ||
needLevel = overallNeedLevel, | ||
totalDomainScore = totalDomainScore, | ||
pni = pniCalculation, | ||
saraRiskLevel = SaraRiskLevel(saraRiskLevelToPartner, saraRiskLevelToOther), | ||
missingFields = missingFields ?: listOf(), | ||
) | ||
} |