@ministryofjustice/hmpps-arns-frontend-components-lib 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arns/components/badge/macro.njk +1 -0
- package/dist/arns/components/badge/template.njk +75 -44
- package/dist/index.cjs.js +162 -161
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +162 -161
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
|
@@ -17,6 +17,7 @@ Usage:
|
|
|
17
17
|
|
|
18
18
|
@param {object} params
|
|
19
19
|
@param {RiskData} params.data - Risk data from ArnsComponents.getRiskData()
|
|
20
|
+
@param {string} params.predictor - The predictor data of interest
|
|
20
21
|
@param {boolean} [params.showScore=false] - Whether to display the percentage score
|
|
21
22
|
@param {string} [params.classes] - Additional CSS classes
|
|
22
23
|
#}
|
|
@@ -1,59 +1,90 @@
|
|
|
1
1
|
{#
|
|
2
|
-
|
|
2
|
+
ARNS Predictor Badge Component
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Displays risk predictor score badges.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
Usage:
|
|
7
|
+
In route handler:
|
|
8
|
+
const riskData = await arnsComponents.getRiskData(token, 'crn', 'X123456')
|
|
9
|
+
res.render('page', { riskData })
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
In template:
|
|
12
|
+
{% from "components/badge/macro.njk" import predictorBadge %}
|
|
13
|
+
{{ predictorBadge({ data: riskData }) }}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
With options:
|
|
16
|
+
{{ predictorBadge({ data: riskData, showScore: true }) }}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
@param {object} params
|
|
19
|
+
@param {RiskData} params.data - Risk data from ArnsComponents.getRiskData()
|
|
20
|
+
@param {string} params.predictor - The predictor data of interest
|
|
21
|
+
@param {boolean} [params.showScore=false] - Whether to display the percentage score
|
|
22
|
+
@param {string} [params.classes] - Additional CSS classes
|
|
22
23
|
#}
|
|
23
|
-
|
|
24
24
|
{% set badges = params.data.badges if params.data else [] %}
|
|
25
25
|
{% set showScore = params.showScore if params.showScore else false %}
|
|
26
26
|
|
|
27
27
|
{% if badges and badges.length %}
|
|
28
|
-
<div class="predictor-badges{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{%
|
|
36
|
-
|
|
37
|
-
{%
|
|
38
|
-
|
|
39
|
-
{%
|
|
40
|
-
|
|
41
|
-
{%
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
<div class="predictor-badges{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
29
|
+
{% for entry in badges %}
|
|
30
|
+
{% for key, predictor in entry %}
|
|
31
|
+
{% if predictor %}
|
|
32
|
+
{% if predictor.type == params.predictor %}
|
|
33
|
+
{% set badgeLabel = '' %}
|
|
34
|
+
{% switch key %}
|
|
35
|
+
{% case 'allReoffendingPredictor' %}
|
|
36
|
+
{% set badgeLabel = 'ALL REOFFENDING PREDICTOR' %}
|
|
37
|
+
{% case 'violentReoffendingPredictor' %}
|
|
38
|
+
{% set badgeLabel = 'VIOLENT REOFFENDING PREDICTOR' %}
|
|
39
|
+
{% case 'seriousViolentReoffendingPredictor' %}
|
|
40
|
+
{% set badgeLabel = 'SERIOUS VIOLENT REOFFENDING PREDICTOR' %}
|
|
41
|
+
{% case 'directContactSexualReoffendingPredictor' %}
|
|
42
|
+
{% set badgeLabel = 'DIRECT CONTACT - SEXUAL REOFFENDING PREDICTOR' %}
|
|
43
|
+
{% case 'indirectImageContactSexualReoffendingPredictor' %}
|
|
44
|
+
{% set badgeLabel = 'IMAGES AND INDIRECT CONTACT - SEXUAL REOFFENDING PREDICTOR' %}
|
|
45
|
+
{% case 'combinedSeriousReoffendingPredictor' %}
|
|
46
|
+
{% set badgeLabel = 'COMBINED SERIOUS REOFFENDING PREDICTOR' %}
|
|
47
|
+
{% case 'ogrs3PredictorScore' %}
|
|
48
|
+
{% set badgeLabel = 'OGRS3' %}
|
|
49
|
+
{% case 'ovpPredictorScore' %}
|
|
50
|
+
{% set badgeLabel = 'OVP' %}
|
|
51
|
+
{% case 'ogpPredictorScore' %}
|
|
52
|
+
{% set badgeLabel = 'OGP' %}
|
|
53
|
+
{% case 'rsrPredictorScore' %}
|
|
54
|
+
{% set badgeLabel = 'RSR' %}
|
|
55
|
+
{% case 'ospdcPredictorScore' %}
|
|
56
|
+
{% set badgeLabel = 'OSP-DC' %}
|
|
57
|
+
{% case 'ospiicPredictorScore' %}
|
|
58
|
+
{% set badgeLabel = 'OSP-IIC' %}
|
|
59
|
+
{% default %}
|
|
60
|
+
{% set badgeLabel = 'LABEL NOT FOUND' %}
|
|
61
|
+
{% endswitch %}
|
|
62
|
+
|
|
63
|
+
{% set badgeClass = '' %}
|
|
64
|
+
{% switch predictor.level %}
|
|
65
|
+
{% case 'VERY_HIGH' %}
|
|
66
|
+
{% set badgeClass = 'predictor-badge--very-high' %}
|
|
67
|
+
{% case 'HIGH' %}
|
|
68
|
+
{% set badgeClass = 'predictor-badge--high' %}
|
|
69
|
+
{% case 'MEDIUM' %}
|
|
70
|
+
{% set badgeClass = 'predictor-badge--medium' %}
|
|
71
|
+
{% case 'LOW' %}
|
|
72
|
+
{% set badgeClass = 'predictor-badge--low' %}
|
|
73
|
+
{% endswitch %}
|
|
74
|
+
<div class="{{ badgeClass }}">
|
|
75
|
+
<span class="predictor-badge__type_and_level">{{ badgeLabel | upper }} <strong>{{ predictor.level | replace('_', ' ') }}</strong></span>
|
|
76
|
+
|
|
77
|
+
{% if showScore and predictor.score %}
|
|
78
|
+
<span class="predictor-badge__score">{{ predictor.score }}%</span>
|
|
79
|
+
{% endif %}
|
|
50
80
|
|
|
51
|
-
|
|
52
|
-
|
|
81
|
+
{% if predictor.staticOrDynamic %}
|
|
82
|
+
<span class="predictor-badge__static_or_dynamic">{{ predictor.staticOrDynamic | capitalize }}</span>
|
|
83
|
+
{% endif %}
|
|
84
|
+
</div>
|
|
53
85
|
{% endif %}
|
|
54
|
-
|
|
55
|
-
{%
|
|
86
|
+
{% endif %}
|
|
87
|
+
{% endfor %}
|
|
56
88
|
{% endfor %}
|
|
57
|
-
|
|
58
|
-
</div>
|
|
89
|
+
</div>
|
|
59
90
|
{% endif %}
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,169 +4,170 @@ var hmppsRestClient = require('@ministryofjustice/hmpps-rest-client');
|
|
|
4
4
|
|
|
5
5
|
function transformBadgeData(dto) {
|
|
6
6
|
const badgeEntries = [];
|
|
7
|
-
dto.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (ovp) {
|
|
27
|
-
const entry = {
|
|
28
|
-
ovpPredictorScore: {
|
|
29
|
-
level: ovp.ovpRisk,
|
|
30
|
-
score: ovp.twoYears,
|
|
31
|
-
type: 'OVP',
|
|
32
|
-
staticOrDynamic: null,
|
|
33
|
-
completedDate: listEntry.completedDate.toString(),
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
badgeEntries.push(entry);
|
|
37
|
-
}
|
|
38
|
-
if (ogp) {
|
|
39
|
-
const entry = {
|
|
40
|
-
ogpPredictorScore: {
|
|
41
|
-
level: ogp.ogpRisk,
|
|
42
|
-
score: ogp.ogp2Year,
|
|
43
|
-
type: 'OGP',
|
|
44
|
-
staticOrDynamic: null,
|
|
45
|
-
completedDate: listEntry.completedDate.toString(),
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
badgeEntries.push(entry);
|
|
49
|
-
}
|
|
50
|
-
if (rsr) {
|
|
51
|
-
const entry = {
|
|
52
|
-
rsrPredictorScore: {
|
|
53
|
-
level: rsr.scoreLevel,
|
|
54
|
-
score: rsr.percentageScore,
|
|
55
|
-
type: 'RSR',
|
|
56
|
-
staticOrDynamic: rsr.staticOrDynamic,
|
|
57
|
-
completedDate: listEntry.completedDate.toString(),
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
badgeEntries.push(entry);
|
|
61
|
-
}
|
|
62
|
-
if (osp) {
|
|
63
|
-
const entry = {
|
|
64
|
-
ospdcPredictorScore: {
|
|
65
|
-
level: osp.ospIndecentScoreLevel,
|
|
66
|
-
score: osp.ospIndecentPercentageScore,
|
|
67
|
-
type: 'OSP/DC',
|
|
68
|
-
staticOrDynamic: null,
|
|
69
|
-
completedDate: listEntry.completedDate.toString(),
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
badgeEntries.push(entry);
|
|
73
|
-
}
|
|
74
|
-
if (osp) {
|
|
75
|
-
const entry = {
|
|
76
|
-
ospiicPredictorScore: {
|
|
77
|
-
level: osp.ospIndecentScoreLevel,
|
|
78
|
-
score: osp.ospIndecentPercentageScore,
|
|
79
|
-
type: 'OSP/IIC',
|
|
80
|
-
staticOrDynamic: null,
|
|
81
|
-
completedDate: listEntry.completedDate.toString(),
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
badgeEntries.push(entry);
|
|
85
|
-
}
|
|
7
|
+
const latestEntry = dto.reduce((latest, current) => (current.completedDate > latest.completedDate ? current : latest));
|
|
8
|
+
if (latestEntry.outputVersion === '1') {
|
|
9
|
+
// OGRS3-gen
|
|
10
|
+
const ogrs3 = latestEntry.output.groupReconvictionScore;
|
|
11
|
+
const ovp = latestEntry.output.violencePredictorScore;
|
|
12
|
+
const ogp = latestEntry.output.generalPredictorScore;
|
|
13
|
+
const rsr = latestEntry.output.riskOfSeriousRecidivismScore;
|
|
14
|
+
const osp = latestEntry.output.sexualPredictorScore;
|
|
15
|
+
if (ogrs3) {
|
|
16
|
+
const entry = {
|
|
17
|
+
ogrs3PredictorScore: {
|
|
18
|
+
level: ogrs3.scoreLevel,
|
|
19
|
+
score: ogrs3.twoYears,
|
|
20
|
+
type: 'OGRS3',
|
|
21
|
+
staticOrDynamic: null,
|
|
22
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
badgeEntries.push(entry);
|
|
86
26
|
}
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
score: ogrs4.score,
|
|
99
|
-
type: 'All reoffending predictor',
|
|
100
|
-
staticOrDynamic: ogrs4.staticOrDynamic,
|
|
101
|
-
completedDate: listEntry.completedDate.toString(),
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
badgeEntries.push(entry);
|
|
105
|
-
}
|
|
106
|
-
if (ovp2) {
|
|
107
|
-
const entry = {
|
|
108
|
-
violentReoffendingPredictor: {
|
|
109
|
-
level: ovp2.band,
|
|
110
|
-
score: ovp2.score,
|
|
111
|
-
type: 'Violent reoffending predictor',
|
|
112
|
-
staticOrDynamic: ovp2.staticOrDynamic,
|
|
113
|
-
completedDate: listEntry.completedDate.toString(),
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
badgeEntries.push(entry);
|
|
117
|
-
}
|
|
118
|
-
if (snsv) {
|
|
119
|
-
const entry = {
|
|
120
|
-
seriousViolentReoffendingPredictor: {
|
|
121
|
-
level: snsv.band,
|
|
122
|
-
score: snsv.score,
|
|
123
|
-
type: 'Serious violent reoffending predictor',
|
|
124
|
-
staticOrDynamic: snsv.staticOrDynamic,
|
|
125
|
-
completedDate: listEntry.completedDate.toString(),
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
badgeEntries.push(entry);
|
|
129
|
-
}
|
|
130
|
-
if (ospdc) {
|
|
131
|
-
const entry = {
|
|
132
|
-
directContactSexualReoffendingPredictor: {
|
|
133
|
-
level: ospdc.band,
|
|
134
|
-
score: ospdc.score,
|
|
135
|
-
type: 'Direct contact sexual reoffending predictor',
|
|
136
|
-
staticOrDynamic: null,
|
|
137
|
-
completedDate: listEntry.completedDate.toString(),
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
badgeEntries.push(entry);
|
|
141
|
-
}
|
|
142
|
-
if (ospiic) {
|
|
143
|
-
const entry = {
|
|
144
|
-
indirectImageContactSexualReoffendingPredictor: {
|
|
145
|
-
level: ospiic.band,
|
|
146
|
-
score: ospiic.score,
|
|
147
|
-
type: 'Indirect image contact sexual reoffending predictor',
|
|
148
|
-
staticOrDynamic: null,
|
|
149
|
-
completedDate: listEntry.completedDate.toString(),
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
badgeEntries.push(entry);
|
|
153
|
-
}
|
|
154
|
-
if (rsr) {
|
|
155
|
-
const entry = {
|
|
156
|
-
combinedSeriousReoffendingPredictor: {
|
|
157
|
-
level: rsr.band,
|
|
158
|
-
score: rsr.score,
|
|
159
|
-
type: 'Combined serious reoffending predictor',
|
|
160
|
-
staticOrDynamic: rsr.staticOrDynamic,
|
|
161
|
-
completedDate: listEntry.completedDate.toString(),
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
badgeEntries.push(entry);
|
|
165
|
-
}
|
|
27
|
+
if (ovp) {
|
|
28
|
+
const entry = {
|
|
29
|
+
ovpPredictorScore: {
|
|
30
|
+
level: ovp.ovpRisk,
|
|
31
|
+
score: ovp.twoYears,
|
|
32
|
+
type: 'OVP',
|
|
33
|
+
staticOrDynamic: null,
|
|
34
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
badgeEntries.push(entry);
|
|
166
38
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
39
|
+
if (ogp) {
|
|
40
|
+
const entry = {
|
|
41
|
+
ogpPredictorScore: {
|
|
42
|
+
level: ogp.ogpRisk,
|
|
43
|
+
score: ogp.ogp2Year,
|
|
44
|
+
type: 'OGP',
|
|
45
|
+
staticOrDynamic: null,
|
|
46
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
badgeEntries.push(entry);
|
|
50
|
+
}
|
|
51
|
+
if (rsr) {
|
|
52
|
+
const entry = {
|
|
53
|
+
rsrPredictorScore: {
|
|
54
|
+
level: rsr.scoreLevel,
|
|
55
|
+
score: rsr.percentageScore,
|
|
56
|
+
type: 'RSR',
|
|
57
|
+
staticOrDynamic: rsr.staticOrDynamic,
|
|
58
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
badgeEntries.push(entry);
|
|
62
|
+
}
|
|
63
|
+
if (osp) {
|
|
64
|
+
const entry = {
|
|
65
|
+
ospdcPredictorScore: {
|
|
66
|
+
level: osp.ospContactScoreLevel,
|
|
67
|
+
score: osp.ospContactPercentageScore,
|
|
68
|
+
type: 'OSP/DC',
|
|
69
|
+
staticOrDynamic: null,
|
|
70
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
badgeEntries.push(entry);
|
|
74
|
+
}
|
|
75
|
+
if (osp) {
|
|
76
|
+
const entry = {
|
|
77
|
+
ospiicPredictorScore: {
|
|
78
|
+
level: osp.ospIndecentScoreLevel,
|
|
79
|
+
score: osp.ospIndecentPercentageScore,
|
|
80
|
+
type: 'OSP/IIC',
|
|
81
|
+
staticOrDynamic: null,
|
|
82
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
badgeEntries.push(entry);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (latestEntry.outputVersion === '2') {
|
|
89
|
+
// OGRS4-gen
|
|
90
|
+
const arp = latestEntry.output.allReoffendingPredictor;
|
|
91
|
+
const vrp = latestEntry.output.violentReoffendingPredictor;
|
|
92
|
+
const svrp = latestEntry.output.seriousViolentReoffendingPredictor;
|
|
93
|
+
const dcsrp = latestEntry.output.directContactSexualReoffendingPredictor;
|
|
94
|
+
const iicsrp = latestEntry.output.indirectImageContactSexualReoffendingPredictor;
|
|
95
|
+
const csrp = latestEntry.output.combinedSeriousReoffendingPredictor;
|
|
96
|
+
if (arp) {
|
|
97
|
+
const entry = {
|
|
98
|
+
allReoffendingPredictor: {
|
|
99
|
+
level: arp.band,
|
|
100
|
+
score: arp.score,
|
|
101
|
+
type: 'ARP',
|
|
102
|
+
staticOrDynamic: arp.staticOrDynamic,
|
|
103
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
badgeEntries.push(entry);
|
|
107
|
+
}
|
|
108
|
+
if (vrp) {
|
|
109
|
+
const entry = {
|
|
110
|
+
violentReoffendingPredictor: {
|
|
111
|
+
level: vrp.band,
|
|
112
|
+
score: vrp.score,
|
|
113
|
+
type: 'VRP',
|
|
114
|
+
staticOrDynamic: vrp.staticOrDynamic,
|
|
115
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
badgeEntries.push(entry);
|
|
119
|
+
}
|
|
120
|
+
if (svrp) {
|
|
121
|
+
const entry = {
|
|
122
|
+
seriousViolentReoffendingPredictor: {
|
|
123
|
+
level: svrp.band,
|
|
124
|
+
score: svrp.score,
|
|
125
|
+
type: 'SVRP',
|
|
126
|
+
staticOrDynamic: svrp.staticOrDynamic,
|
|
127
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
badgeEntries.push(entry);
|
|
131
|
+
}
|
|
132
|
+
if (dcsrp) {
|
|
133
|
+
const entry = {
|
|
134
|
+
directContactSexualReoffendingPredictor: {
|
|
135
|
+
level: dcsrp.band,
|
|
136
|
+
score: dcsrp.score,
|
|
137
|
+
type: 'DC/SRP',
|
|
138
|
+
staticOrDynamic: null,
|
|
139
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
badgeEntries.push(entry);
|
|
143
|
+
}
|
|
144
|
+
if (iicsrp) {
|
|
145
|
+
const entry = {
|
|
146
|
+
indirectImageContactSexualReoffendingPredictor: {
|
|
147
|
+
level: iicsrp.band,
|
|
148
|
+
score: iicsrp.score,
|
|
149
|
+
type: 'IIC/SRP',
|
|
150
|
+
staticOrDynamic: null,
|
|
151
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
badgeEntries.push(entry);
|
|
155
|
+
}
|
|
156
|
+
if (csrp) {
|
|
157
|
+
const entry = {
|
|
158
|
+
combinedSeriousReoffendingPredictor: {
|
|
159
|
+
level: csrp.band,
|
|
160
|
+
score: csrp.score,
|
|
161
|
+
type: 'CSRP',
|
|
162
|
+
staticOrDynamic: csrp.staticOrDynamic,
|
|
163
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
badgeEntries.push(entry);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else
|
|
170
|
+
throw new Error('unexpected version');
|
|
170
171
|
return badgeEntries;
|
|
171
172
|
}
|
|
172
173
|
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/components/badge/transformation.ts","../src/ArnsComponents.ts"],"sourcesContent":[null,null],"names":["RestClient"],"mappings":";;;;AAGM,SAAU,kBAAkB,CAAC,GAA+B,EAAA;IAChE,MAAM,YAAY,GAAiB,EAAE;AAErC,IAAA,GAAG,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/components/badge/transformation.ts","../src/ArnsComponents.ts"],"sourcesContent":[null,null],"names":["RestClient"],"mappings":";;;;AAGM,SAAU,kBAAkB,CAAC,GAA+B,EAAA;IAChE,MAAM,YAAY,GAAiB,EAAE;AAErC,IAAA,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,MAAM,OAAO,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AAEtH,IAAA,IAAI,WAAW,CAAC,aAAa,KAAK,GAAG,EAAE;;AAErC,QAAA,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,sBAAsB;AACvD,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,sBAAsB;AACrD,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,qBAAqB;AACpD,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,4BAA4B;AAC3D,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,oBAAoB;QAEnD,IAAI,KAAK,EAAE;AACT,YAAA,MAAM,KAAK,GAAe;AACxB,gBAAA,mBAAmB,EAAE;oBACnB,KAAK,EAAE,KAAK,CAAC,UAAU;oBACvB,KAAK,EAAE,KAAK,CAAC,QAAQ;AACrB,oBAAA,IAAI,EAAE,OAAO;AACb,oBAAA,eAAe,EAAE,IAAI;AACrB,oBAAA,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,QAAQ,EAAE;AACpD,iBAAA;aACF;AACD,YAAA,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1B;QAEA,IAAI,GAAG,EAAE;AACP,YAAA,MAAM,KAAK,GAAe;AACxB,gBAAA,iBAAiB,EAAE;oBACjB,KAAK,EAAE,GAAG,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 -2,169 +2,170 @@ import { RestClient } from '@ministryofjustice/hmpps-rest-client';
|
|
|
2
2
|
|
|
3
3
|
function transformBadgeData(dto) {
|
|
4
4
|
const badgeEntries = [];
|
|
5
|
-
dto.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (ovp) {
|
|
25
|
-
const entry = {
|
|
26
|
-
ovpPredictorScore: {
|
|
27
|
-
level: ovp.ovpRisk,
|
|
28
|
-
score: ovp.twoYears,
|
|
29
|
-
type: 'OVP',
|
|
30
|
-
staticOrDynamic: null,
|
|
31
|
-
completedDate: listEntry.completedDate.toString(),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
badgeEntries.push(entry);
|
|
35
|
-
}
|
|
36
|
-
if (ogp) {
|
|
37
|
-
const entry = {
|
|
38
|
-
ogpPredictorScore: {
|
|
39
|
-
level: ogp.ogpRisk,
|
|
40
|
-
score: ogp.ogp2Year,
|
|
41
|
-
type: 'OGP',
|
|
42
|
-
staticOrDynamic: null,
|
|
43
|
-
completedDate: listEntry.completedDate.toString(),
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
badgeEntries.push(entry);
|
|
47
|
-
}
|
|
48
|
-
if (rsr) {
|
|
49
|
-
const entry = {
|
|
50
|
-
rsrPredictorScore: {
|
|
51
|
-
level: rsr.scoreLevel,
|
|
52
|
-
score: rsr.percentageScore,
|
|
53
|
-
type: 'RSR',
|
|
54
|
-
staticOrDynamic: rsr.staticOrDynamic,
|
|
55
|
-
completedDate: listEntry.completedDate.toString(),
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
badgeEntries.push(entry);
|
|
59
|
-
}
|
|
60
|
-
if (osp) {
|
|
61
|
-
const entry = {
|
|
62
|
-
ospdcPredictorScore: {
|
|
63
|
-
level: osp.ospIndecentScoreLevel,
|
|
64
|
-
score: osp.ospIndecentPercentageScore,
|
|
65
|
-
type: 'OSP/DC',
|
|
66
|
-
staticOrDynamic: null,
|
|
67
|
-
completedDate: listEntry.completedDate.toString(),
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
badgeEntries.push(entry);
|
|
71
|
-
}
|
|
72
|
-
if (osp) {
|
|
73
|
-
const entry = {
|
|
74
|
-
ospiicPredictorScore: {
|
|
75
|
-
level: osp.ospIndecentScoreLevel,
|
|
76
|
-
score: osp.ospIndecentPercentageScore,
|
|
77
|
-
type: 'OSP/IIC',
|
|
78
|
-
staticOrDynamic: null,
|
|
79
|
-
completedDate: listEntry.completedDate.toString(),
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
badgeEntries.push(entry);
|
|
83
|
-
}
|
|
5
|
+
const latestEntry = dto.reduce((latest, current) => (current.completedDate > latest.completedDate ? current : latest));
|
|
6
|
+
if (latestEntry.outputVersion === '1') {
|
|
7
|
+
// OGRS3-gen
|
|
8
|
+
const ogrs3 = latestEntry.output.groupReconvictionScore;
|
|
9
|
+
const ovp = latestEntry.output.violencePredictorScore;
|
|
10
|
+
const ogp = latestEntry.output.generalPredictorScore;
|
|
11
|
+
const rsr = latestEntry.output.riskOfSeriousRecidivismScore;
|
|
12
|
+
const osp = latestEntry.output.sexualPredictorScore;
|
|
13
|
+
if (ogrs3) {
|
|
14
|
+
const entry = {
|
|
15
|
+
ogrs3PredictorScore: {
|
|
16
|
+
level: ogrs3.scoreLevel,
|
|
17
|
+
score: ogrs3.twoYears,
|
|
18
|
+
type: 'OGRS3',
|
|
19
|
+
staticOrDynamic: null,
|
|
20
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
badgeEntries.push(entry);
|
|
84
24
|
}
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
score: ogrs4.score,
|
|
97
|
-
type: 'All reoffending predictor',
|
|
98
|
-
staticOrDynamic: ogrs4.staticOrDynamic,
|
|
99
|
-
completedDate: listEntry.completedDate.toString(),
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
badgeEntries.push(entry);
|
|
103
|
-
}
|
|
104
|
-
if (ovp2) {
|
|
105
|
-
const entry = {
|
|
106
|
-
violentReoffendingPredictor: {
|
|
107
|
-
level: ovp2.band,
|
|
108
|
-
score: ovp2.score,
|
|
109
|
-
type: 'Violent reoffending predictor',
|
|
110
|
-
staticOrDynamic: ovp2.staticOrDynamic,
|
|
111
|
-
completedDate: listEntry.completedDate.toString(),
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
badgeEntries.push(entry);
|
|
115
|
-
}
|
|
116
|
-
if (snsv) {
|
|
117
|
-
const entry = {
|
|
118
|
-
seriousViolentReoffendingPredictor: {
|
|
119
|
-
level: snsv.band,
|
|
120
|
-
score: snsv.score,
|
|
121
|
-
type: 'Serious violent reoffending predictor',
|
|
122
|
-
staticOrDynamic: snsv.staticOrDynamic,
|
|
123
|
-
completedDate: listEntry.completedDate.toString(),
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
badgeEntries.push(entry);
|
|
127
|
-
}
|
|
128
|
-
if (ospdc) {
|
|
129
|
-
const entry = {
|
|
130
|
-
directContactSexualReoffendingPredictor: {
|
|
131
|
-
level: ospdc.band,
|
|
132
|
-
score: ospdc.score,
|
|
133
|
-
type: 'Direct contact sexual reoffending predictor',
|
|
134
|
-
staticOrDynamic: null,
|
|
135
|
-
completedDate: listEntry.completedDate.toString(),
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
badgeEntries.push(entry);
|
|
139
|
-
}
|
|
140
|
-
if (ospiic) {
|
|
141
|
-
const entry = {
|
|
142
|
-
indirectImageContactSexualReoffendingPredictor: {
|
|
143
|
-
level: ospiic.band,
|
|
144
|
-
score: ospiic.score,
|
|
145
|
-
type: 'Indirect image contact sexual reoffending predictor',
|
|
146
|
-
staticOrDynamic: null,
|
|
147
|
-
completedDate: listEntry.completedDate.toString(),
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
badgeEntries.push(entry);
|
|
151
|
-
}
|
|
152
|
-
if (rsr) {
|
|
153
|
-
const entry = {
|
|
154
|
-
combinedSeriousReoffendingPredictor: {
|
|
155
|
-
level: rsr.band,
|
|
156
|
-
score: rsr.score,
|
|
157
|
-
type: 'Combined serious reoffending predictor',
|
|
158
|
-
staticOrDynamic: rsr.staticOrDynamic,
|
|
159
|
-
completedDate: listEntry.completedDate.toString(),
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
badgeEntries.push(entry);
|
|
163
|
-
}
|
|
25
|
+
if (ovp) {
|
|
26
|
+
const entry = {
|
|
27
|
+
ovpPredictorScore: {
|
|
28
|
+
level: ovp.ovpRisk,
|
|
29
|
+
score: ovp.twoYears,
|
|
30
|
+
type: 'OVP',
|
|
31
|
+
staticOrDynamic: null,
|
|
32
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
badgeEntries.push(entry);
|
|
164
36
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
37
|
+
if (ogp) {
|
|
38
|
+
const entry = {
|
|
39
|
+
ogpPredictorScore: {
|
|
40
|
+
level: ogp.ogpRisk,
|
|
41
|
+
score: ogp.ogp2Year,
|
|
42
|
+
type: 'OGP',
|
|
43
|
+
staticOrDynamic: null,
|
|
44
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
badgeEntries.push(entry);
|
|
48
|
+
}
|
|
49
|
+
if (rsr) {
|
|
50
|
+
const entry = {
|
|
51
|
+
rsrPredictorScore: {
|
|
52
|
+
level: rsr.scoreLevel,
|
|
53
|
+
score: rsr.percentageScore,
|
|
54
|
+
type: 'RSR',
|
|
55
|
+
staticOrDynamic: rsr.staticOrDynamic,
|
|
56
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
badgeEntries.push(entry);
|
|
60
|
+
}
|
|
61
|
+
if (osp) {
|
|
62
|
+
const entry = {
|
|
63
|
+
ospdcPredictorScore: {
|
|
64
|
+
level: osp.ospContactScoreLevel,
|
|
65
|
+
score: osp.ospContactPercentageScore,
|
|
66
|
+
type: 'OSP/DC',
|
|
67
|
+
staticOrDynamic: null,
|
|
68
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
badgeEntries.push(entry);
|
|
72
|
+
}
|
|
73
|
+
if (osp) {
|
|
74
|
+
const entry = {
|
|
75
|
+
ospiicPredictorScore: {
|
|
76
|
+
level: osp.ospIndecentScoreLevel,
|
|
77
|
+
score: osp.ospIndecentPercentageScore,
|
|
78
|
+
type: 'OSP/IIC',
|
|
79
|
+
staticOrDynamic: null,
|
|
80
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
badgeEntries.push(entry);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (latestEntry.outputVersion === '2') {
|
|
87
|
+
// OGRS4-gen
|
|
88
|
+
const arp = latestEntry.output.allReoffendingPredictor;
|
|
89
|
+
const vrp = latestEntry.output.violentReoffendingPredictor;
|
|
90
|
+
const svrp = latestEntry.output.seriousViolentReoffendingPredictor;
|
|
91
|
+
const dcsrp = latestEntry.output.directContactSexualReoffendingPredictor;
|
|
92
|
+
const iicsrp = latestEntry.output.indirectImageContactSexualReoffendingPredictor;
|
|
93
|
+
const csrp = latestEntry.output.combinedSeriousReoffendingPredictor;
|
|
94
|
+
if (arp) {
|
|
95
|
+
const entry = {
|
|
96
|
+
allReoffendingPredictor: {
|
|
97
|
+
level: arp.band,
|
|
98
|
+
score: arp.score,
|
|
99
|
+
type: 'ARP',
|
|
100
|
+
staticOrDynamic: arp.staticOrDynamic,
|
|
101
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
badgeEntries.push(entry);
|
|
105
|
+
}
|
|
106
|
+
if (vrp) {
|
|
107
|
+
const entry = {
|
|
108
|
+
violentReoffendingPredictor: {
|
|
109
|
+
level: vrp.band,
|
|
110
|
+
score: vrp.score,
|
|
111
|
+
type: 'VRP',
|
|
112
|
+
staticOrDynamic: vrp.staticOrDynamic,
|
|
113
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
badgeEntries.push(entry);
|
|
117
|
+
}
|
|
118
|
+
if (svrp) {
|
|
119
|
+
const entry = {
|
|
120
|
+
seriousViolentReoffendingPredictor: {
|
|
121
|
+
level: svrp.band,
|
|
122
|
+
score: svrp.score,
|
|
123
|
+
type: 'SVRP',
|
|
124
|
+
staticOrDynamic: svrp.staticOrDynamic,
|
|
125
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
badgeEntries.push(entry);
|
|
129
|
+
}
|
|
130
|
+
if (dcsrp) {
|
|
131
|
+
const entry = {
|
|
132
|
+
directContactSexualReoffendingPredictor: {
|
|
133
|
+
level: dcsrp.band,
|
|
134
|
+
score: dcsrp.score,
|
|
135
|
+
type: 'DC/SRP',
|
|
136
|
+
staticOrDynamic: null,
|
|
137
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
badgeEntries.push(entry);
|
|
141
|
+
}
|
|
142
|
+
if (iicsrp) {
|
|
143
|
+
const entry = {
|
|
144
|
+
indirectImageContactSexualReoffendingPredictor: {
|
|
145
|
+
level: iicsrp.band,
|
|
146
|
+
score: iicsrp.score,
|
|
147
|
+
type: 'IIC/SRP',
|
|
148
|
+
staticOrDynamic: null,
|
|
149
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
badgeEntries.push(entry);
|
|
153
|
+
}
|
|
154
|
+
if (csrp) {
|
|
155
|
+
const entry = {
|
|
156
|
+
combinedSeriousReoffendingPredictor: {
|
|
157
|
+
level: csrp.band,
|
|
158
|
+
score: csrp.score,
|
|
159
|
+
type: 'CSRP',
|
|
160
|
+
staticOrDynamic: csrp.staticOrDynamic,
|
|
161
|
+
completedDate: latestEntry.completedDate.toString(),
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
badgeEntries.push(entry);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else
|
|
168
|
+
throw new Error('unexpected version');
|
|
168
169
|
return badgeEntries;
|
|
169
170
|
}
|
|
170
171
|
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/components/badge/transformation.ts","../src/ArnsComponents.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAGM,SAAU,kBAAkB,CAAC,GAA+B,EAAA;IAChE,MAAM,YAAY,GAAiB,EAAE;AAErC,IAAA,GAAG,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/components/badge/transformation.ts","../src/ArnsComponents.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAGM,SAAU,kBAAkB,CAAC,GAA+B,EAAA;IAChE,MAAM,YAAY,GAAiB,EAAE;AAErC,IAAA,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,MAAM,OAAO,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AAEtH,IAAA,IAAI,WAAW,CAAC,aAAa,KAAK,GAAG,EAAE;;AAErC,QAAA,M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,EAAE;AACpD,iBAAA;aACF;AACD,YAAA,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAC1B;IACF;;AAAO,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;AAE5C,IAAA,OAAO,YAAY;AACrB;;AC7Kc,MAAO,cAAc,CAAA;AAGjC,IAAA,WAAA,CACE,oBAA0C,EAC1C,MAA4B,EAC5B,SAA2B,OAAO,EAAA;AAElC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,CAAC;IACpF;AAEA,IAAA,MAAM,WAAW,CACf,WAAiC,EACjC,cAAsB,EACtB,eAAuB,EAAA;QAEvB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CACxC,EAAE,IAAI,EAAE,CAAA,sBAAA,EAAyB,cAAc,CAAA,CAAA,EAAI,eAAe,EAAE,EAAE,EACtE,WAAW,CACZ;QAED,OAAO;AACL,YAAA,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC;AACpC,YAAA,GAAG,EAAE,QAAQ;SACd;IACH;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-arns-frontend-components-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "ARNS front-end library for risk score visualisations",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"@types/jest": "^30.0.0",
|
|
92
92
|
"@types/superagent": "^8.1.9",
|
|
93
93
|
"@types/supertest": "^6.0.3",
|
|
94
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
95
|
-
"cheerio": "^1.
|
|
94
|
+
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
95
|
+
"cheerio": "^1.2.0",
|
|
96
96
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
97
97
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
98
98
|
"express": "^5.2.1",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"jest-junit": "^16.0.0",
|
|
103
103
|
"lint-staged": "^16.1.2",
|
|
104
104
|
"nock": "^14.0.10",
|
|
105
|
-
"rollup": "^4.
|
|
105
|
+
"rollup": "^4.57.0",
|
|
106
106
|
"rollup-plugin-copy": "^3.5.0",
|
|
107
107
|
"rollup-plugin-dts": "^6.3.0",
|
|
108
108
|
"supertest": "^7.1.1",
|