@ministryofjustice/hmpps-arns-frontend-components-lib 0.0.3 → 0.0.4
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 +0 -23
- package/dist/arns/components/badge/template.njk +44 -72
- package/dist/index.cjs.js +54 -165
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +26 -101
- package/dist/index.esm.js +54 -165
- package/dist/index.esm.js.map +1 -1
- package/dist/transformers/AllPredictorVersionedDtoToAssessmentsTransformer.d.ts +3 -0
- package/dist/types/AssessmentV1.d.ts +11 -0
- package/dist/types/AssessmentV2.d.ts +11 -0
- package/dist/types/Assessments.d.ts +3 -0
- package/dist/types/Predictor.d.ts +7 -0
- package/dist/types/RiskData.d.ts +2 -4
- package/dist/types/dtos/{allPredictorDto.d.ts → AllPredictorDto.d.ts} +8 -8
- package/dist/types/dtos/{allPredictorVersionedDto.d.ts → AllPredictorVersionedDto.d.ts} +2 -2
- package/dist/types/dtos/{basePredictorDto.d.ts → BasePredictorDto.d.ts} +1 -1
- package/dist/types/dtos/{ogpScoreDto.d.ts → OgpScoreDto.d.ts} +1 -1
- package/dist/types/dtos/{ogrScoreDto.d.ts → OgrScoreDto.d.ts} +1 -1
- package/dist/types/dtos/{ospScoreDto.d.ts → OspScoreDto.d.ts} +1 -1
- package/dist/types/dtos/{ovpScoreDto.d.ts → OvpScoreDto.d.ts} +1 -1
- package/dist/types/dtos/{rsrScoreDto.d.ts → RsrScoreDto.d.ts} +3 -3
- package/dist/types/dtos/{staticOrDynamicPredictorDto.d.ts → StaticOrDynamicPredictorDto.d.ts} +2 -2
- package/dist/types/dtos/{versionedStaticOrDynamicPredictorDto.d.ts → VersionedStaticOrDynamicPredictorDto.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/components/badge/transformation.d.ts +0 -3
- package/dist/types/badgeData.d.ts +0 -12
- /package/dist/types/dtos/{assessmentStatusDto.d.ts → AssessmentStatusDto.d.ts} +0 -0
- /package/dist/types/{bandLevel.d.ts → dtos/BandLevel.d.ts} +0 -0
- /package/dist/types/dtos/{rsrScoreSourceDto.d.ts → RsrScoreSourceDto.d.ts} +0 -0
- /package/dist/types/{staticOrDynamic.d.ts → dtos/StaticOrDynamic.d.ts} +0 -0
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
{#
|
|
2
|
-
ARNS Predictor Badge Component
|
|
3
|
-
|
|
4
|
-
Displays risk predictor score badges.
|
|
5
|
-
|
|
6
|
-
Usage:
|
|
7
|
-
In route handler:
|
|
8
|
-
const riskData = await arnsComponents.getRiskData(token, 'crn', 'X123456')
|
|
9
|
-
res.render('page', { riskData })
|
|
10
|
-
|
|
11
|
-
In template:
|
|
12
|
-
{% from "components/badge/macro.njk" import predictorBadge %}
|
|
13
|
-
{{ predictorBadge({ data: riskData }) }}
|
|
14
|
-
|
|
15
|
-
With options:
|
|
16
|
-
{{ predictorBadge({ data: riskData, showScore: true }) }}
|
|
17
|
-
|
|
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
|
|
23
|
-
#}
|
|
24
1
|
{% macro predictorBadge(params) %}
|
|
25
2
|
{%- include "./template.njk" -%}
|
|
26
3
|
{% endmacro %}
|
|
@@ -1,90 +1,62 @@
|
|
|
1
1
|
{#
|
|
2
|
-
ARNS Predictor Badge Component
|
|
2
|
+
ARNS Predictor Badge Component
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
@name predictorBadge
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
@description Displays specified risk predictor score badges.
|
|
7
|
+
It uses the latest assessment from the provided data set.
|
|
8
|
+
|
|
9
|
+
@example
|
|
7
10
|
In route handler:
|
|
8
11
|
const riskData = await arnsComponents.getRiskData(token, 'crn', 'X123456')
|
|
9
12
|
res.render('page', { riskData })
|
|
10
13
|
|
|
11
14
|
In template:
|
|
12
15
|
{% from "components/badge/macro.njk" import predictorBadge %}
|
|
13
|
-
{{ predictorBadge({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@param {
|
|
21
|
-
@param {
|
|
22
|
-
@param {string}
|
|
16
|
+
{{ predictorBadge({
|
|
17
|
+
data: riskData,
|
|
18
|
+
predictor: "allReoffendingPredictor",
|
|
19
|
+
showScore: true,
|
|
20
|
+
classes: "class-name-here"
|
|
21
|
+
}) }}
|
|
22
|
+
|
|
23
|
+
@param {object} params
|
|
24
|
+
@param {RiskData} params.data - Risk data object from ArnsComponents.getRiskData() containing an 'assessments' array
|
|
25
|
+
@param {string} params.predictor - The name of the specific predictor to display
|
|
26
|
+
@param {boolean} [params.showScore=false] - If true, displays the percentage score
|
|
27
|
+
@param {string} [params.classes] - Optional CSS utility classes to apply to the container
|
|
23
28
|
#}
|
|
24
|
-
{% set
|
|
29
|
+
{% set latestAssessment = params.data.assessments | first if params.data.assessments else null %}
|
|
25
30
|
{% set showScore = params.showScore if params.showScore else false %}
|
|
26
31
|
|
|
27
|
-
{% if
|
|
32
|
+
{% if latestAssessment is defined %}
|
|
28
33
|
<div class="predictor-badges{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
29
|
-
{% for
|
|
30
|
-
{%
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
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 %}
|
|
34
|
+
{% for key, predictor in latestAssessment %}
|
|
35
|
+
{% if key == params.predictor %}
|
|
36
|
+
|
|
37
|
+
{% set badgeClass = '' %}
|
|
38
|
+
{% switch predictor.band %}
|
|
39
|
+
{% case 'VERY HIGH' %}
|
|
40
|
+
{% set badgeClass = 'predictor-badge--very-high' %}
|
|
41
|
+
{% case 'HIGH' %}
|
|
42
|
+
{% set badgeClass = 'predictor-badge--high' %}
|
|
43
|
+
{% case 'MEDIUM' %}
|
|
44
|
+
{% set badgeClass = 'predictor-badge--medium' %}
|
|
45
|
+
{% case 'LOW' %}
|
|
46
|
+
{% set badgeClass = 'predictor-badge--low' %}
|
|
47
|
+
{% endswitch %}
|
|
48
|
+
<div class="{{ badgeClass }}">
|
|
49
|
+
<span class="predictor-badge__type_and_level">{{ predictor.name | upper }} <strong>{{ predictor.band }}</strong></span>
|
|
50
|
+
|
|
51
|
+
{% if showScore and predictor.score is defined %}
|
|
52
|
+
<span class="predictor-badge__score">{{ predictor.score }}%</span>
|
|
53
|
+
{% endif %}
|
|
80
54
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{% endif %}
|
|
84
|
-
</div>
|
|
55
|
+
{% if predictor.staticOrDynamic %}
|
|
56
|
+
<span class="predictor-badge__static_or_dynamic">{{ predictor.staticOrDynamic }}</span>
|
|
85
57
|
{% endif %}
|
|
86
|
-
|
|
87
|
-
{%
|
|
58
|
+
</div>
|
|
59
|
+
{% endif %}
|
|
88
60
|
{% endfor %}
|
|
89
61
|
</div>
|
|
90
62
|
{% endif %}
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,173 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
var hmppsRestClient = require('@ministryofjustice/hmpps-rest-client');
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
function transformAllPredictorVersionedDtoToAssessments(dtos) {
|
|
6
|
+
// Sort DTOs by datetime (newest first)
|
|
7
|
+
const sortedDtos = [...dtos].sort((a, b) => {
|
|
8
|
+
return new Date(b.completedDate).getTime() - new Date(a.completedDate).getTime();
|
|
9
|
+
});
|
|
10
|
+
return sortedDtos.map(dto => {
|
|
11
|
+
const completedDate = dto.completedDate.toString();
|
|
12
|
+
const date = new Date(completedDate);
|
|
13
|
+
const dateFormatDayMonthYear = new Intl.DateTimeFormat('en-GB', {
|
|
14
|
+
day: '2-digit',
|
|
15
|
+
month: 'long',
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
}).format(date);
|
|
18
|
+
const time = date.toLocaleTimeString('en-GB', {
|
|
19
|
+
hour: '2-digit',
|
|
20
|
+
minute: '2-digit',
|
|
21
|
+
hour12: false,
|
|
22
|
+
});
|
|
23
|
+
const dateFormatDayMonthYearTime = `${dateFormatDayMonthYear} at ${time}`;
|
|
24
|
+
const { output } = dto;
|
|
25
|
+
if (dto.outputVersion === '1') {
|
|
26
|
+
return {
|
|
27
|
+
outputVersion: '1',
|
|
28
|
+
completedDateTime: dateFormatDayMonthYearTime,
|
|
29
|
+
ogrs3: mapPredictor('OGRS', output.groupReconvictionScore.scoreLevel, null, output.groupReconvictionScore.twoYears, dateFormatDayMonthYear),
|
|
30
|
+
ovp: mapPredictor('OVP', output.violencePredictorScore.ovpRisk, null, output.violencePredictorScore.twoYears, dateFormatDayMonthYear),
|
|
31
|
+
ogp: mapPredictor('OGP', output.generalPredictorScore.ogpRisk, null, output.generalPredictorScore.ogp2Year, dateFormatDayMonthYear),
|
|
32
|
+
rsr: mapPredictor('RSR', output.riskOfSeriousRecidivismScore.scoreLevel, output.riskOfSeriousRecidivismScore.staticOrDynamic, output.riskOfSeriousRecidivismScore.percentageScore, dateFormatDayMonthYear),
|
|
33
|
+
ospdc: mapPredictor('OSP-DC', output.sexualPredictorScore.ospContactScoreLevel, null, output.sexualPredictorScore.ospContactPercentageScore, dateFormatDayMonthYear),
|
|
34
|
+
ospiic: mapPredictor('OSP-IIC', output.sexualPredictorScore.ospIndecentScoreLevel, null, output.sexualPredictorScore.ospIndecentPercentageScore, dateFormatDayMonthYear),
|
|
24
35
|
};
|
|
25
|
-
badgeEntries.push(entry);
|
|
26
36
|
}
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
if (dto.outputVersion === '2') {
|
|
38
|
+
return {
|
|
39
|
+
outputVersion: '2',
|
|
40
|
+
completedDateTime: dateFormatDayMonthYearTime,
|
|
41
|
+
allReoffendingPredictor: mapPredictor('All Reoffending Predictor', output.allReoffendingPredictor.band, output.allReoffendingPredictor.staticOrDynamic, output.allReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
42
|
+
violentReoffendingPredictor: mapPredictor('Violent Reoffending Predictor', output.violentReoffendingPredictor.band, output.violentReoffendingPredictor.staticOrDynamic, output.violentReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
43
|
+
seriousViolentReoffendingPredictor: mapPredictor('Serious Violent Reoffending Predictor', output.seriousViolentReoffendingPredictor.band, output.seriousViolentReoffendingPredictor.staticOrDynamic, output.seriousViolentReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
44
|
+
directContactSexualReoffendingPredictor: mapPredictor('Direct Contact - Sexual Reoffending Predictor', output.directContactSexualReoffendingPredictor.band, null, output.directContactSexualReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
45
|
+
indirectImageContactSexualReoffendingPredictor: mapPredictor('Images and Indirect Contact – Sexual Reoffending Predictor', output.indirectImageContactSexualReoffendingPredictor.band, null, output.indirectImageContactSexualReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
46
|
+
combinedSeriousReoffendingPredictor: mapPredictor('Combined Serious Reoffending Predictor', output.combinedSeriousReoffendingPredictor.band, output.combinedSeriousReoffendingPredictor.staticOrDynamic, output.combinedSeriousReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
36
47
|
};
|
|
37
|
-
badgeEntries.push(entry);
|
|
38
48
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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');
|
|
171
|
-
return badgeEntries;
|
|
49
|
+
throw new Error(`Unsupported output version: ${dto.outputVersion}`);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function mapPredictor(name, band, staticOrDynamic, score, date) {
|
|
53
|
+
return {
|
|
54
|
+
name,
|
|
55
|
+
band: band.replace(/_/g, ' ').toUpperCase(),
|
|
56
|
+
staticOrDynamic: staticOrDynamic
|
|
57
|
+
? staticOrDynamic.charAt(0).toUpperCase() + staticOrDynamic.slice(1).toLowerCase()
|
|
58
|
+
: null,
|
|
59
|
+
score,
|
|
60
|
+
completedDate: date,
|
|
61
|
+
};
|
|
172
62
|
}
|
|
173
63
|
|
|
174
64
|
class ArnsComponents {
|
|
@@ -178,8 +68,7 @@ class ArnsComponents {
|
|
|
178
68
|
async getRiskData(authOptions, identifierType, identifierValue) {
|
|
179
69
|
const response = await this.restClient.get({ path: `/risks/predictors/all/${identifierType}/${identifierValue}` }, authOptions);
|
|
180
70
|
return {
|
|
181
|
-
|
|
182
|
-
raw: response,
|
|
71
|
+
assessments: transformAllPredictorVersionedDtoToAssessments(response),
|
|
183
72
|
};
|
|
184
73
|
}
|
|
185
74
|
}
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/transformers/AllPredictorVersionedDtoToAssessmentsTransformer.ts","../src/ArnsComponents.ts"],"sourcesContent":[null,null],"names":["RestClient"],"mappings":";;;;AAIM,SAAU,8CAA8C,CAAC,IAAgC,EAAA;;AAE7F,IAAA,MAAM,UAAU,GAA+B,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAC3D,CAAC,CAA2B,EAAE,CAA2B,KAAI;QAC3D,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;AAClF,IAAA,CAAC,CACF;AAED,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,IAAG;QAC1B,MAAM,aAAa,GAAW,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE;AAC1D,QAAA,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC;QACpC,MAAM,sBAAsB,GAAW,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;AACtE,YAAA,GAAG,EAAE,SAAS;AACd,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,IAAI,EAAE,SAAS;AAChB,SAAA,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;AACf,QAAA,MAAM,IAAI,GAAW,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;AACpD,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,MAAM,EAAE,SAAS;AACjB,YAAA,MAAM,EAAE,KAAK;AACd,SAAA,CAAC;AACF,QAAA,MAAM,0BAA0B,GAAG,CAAA,EAA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,IAAY,EAAE,eAAuB,EAAE,KAAa,EAAE,IAAY,EAAA;IACpG,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;AAC3C,QAAA,eAAe,EAAE;AACf,cAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW;AAChF,cAAE,IAAI;QACR,KAAK;AACL,QAAA,aAAa,EAAE,IAAI;KACpB;AACH;;ACpIc,MAAO,cAAc,CAAA;AAGjC,IAAA,WAAA,CACE,oBAA0C,EAC1C,MAA4B,EAC5B,SAA2B,OAAO,EAAA;AAElC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAIA,0BAAU,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,WAAW,EAAE,8CAA8C,CAAC,QAAQ,CAAC;SACtE;IACH;AACD;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,115 +5,40 @@ import Logger from 'bunyan';
|
|
|
5
5
|
interface ArnsComponentsConfig extends ApiConfig {
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare enum BandLevel {
|
|
14
|
-
LOW = "LOW",
|
|
15
|
-
MEDIUM = "MEDIUM",
|
|
16
|
-
HIGH = "HIGH",
|
|
17
|
-
VERY_HIGH = "VERY_HIGH",
|
|
18
|
-
NOT_APPLICABLE = "NOT_APPLICABLE"
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface BadgeData {
|
|
22
|
-
level: `${BandLevel}`;
|
|
23
|
-
score: number;
|
|
24
|
-
type: string;
|
|
25
|
-
staticOrDynamic: `${StaticOrDynamic}`;
|
|
8
|
+
interface Predictor {
|
|
9
|
+
name: string;
|
|
10
|
+
band: string;
|
|
11
|
+
staticOrDynamic?: string;
|
|
12
|
+
score?: number;
|
|
26
13
|
completedDate: string;
|
|
27
14
|
}
|
|
28
|
-
interface BadgeEntry {
|
|
29
|
-
[key: string]: BadgeData;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare enum AssessmentStatusDto {
|
|
33
|
-
COMPLETE = "COMPLETE",
|
|
34
|
-
LOCKED_INCOMPLETE = "LOCKED_INCOMPLETE"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
interface BasePredictorDto {
|
|
38
|
-
score: number;
|
|
39
|
-
band: `${BandLevel}`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
interface StaticOrDynamicPredictorDto extends BasePredictorDto {
|
|
43
|
-
staticOrDynamic: `${StaticOrDynamic}`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface VersionedStaticOrDynamicPredictorDto extends StaticOrDynamicPredictorDto {
|
|
47
|
-
algorithmVersion: string;
|
|
48
|
-
}
|
|
49
15
|
|
|
50
|
-
interface
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
16
|
+
interface AssessmentV1 {
|
|
17
|
+
outputVersion: '1';
|
|
18
|
+
completedDateTime: string;
|
|
19
|
+
ogrs3?: Predictor;
|
|
20
|
+
ovp?: Predictor;
|
|
21
|
+
ogp?: Predictor;
|
|
22
|
+
rsr: Predictor;
|
|
23
|
+
ospdc: Predictor;
|
|
24
|
+
ospiic: Predictor;
|
|
54
25
|
}
|
|
55
26
|
|
|
56
|
-
interface
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
27
|
+
interface AssessmentV2 {
|
|
28
|
+
outputVersion: '2';
|
|
29
|
+
completedDateTime: string;
|
|
30
|
+
allReoffendingPredictor?: Predictor;
|
|
31
|
+
violentReoffendingPredictor?: Predictor;
|
|
32
|
+
seriousViolentReoffendingPredictor?: Predictor;
|
|
33
|
+
directContactSexualReoffendingPredictor?: Predictor;
|
|
34
|
+
indirectImageContactSexualReoffendingPredictor?: Predictor;
|
|
35
|
+
combinedSeriousReoffendingPredictor?: Predictor;
|
|
63
36
|
}
|
|
64
37
|
|
|
65
|
-
|
|
66
|
-
ogpStaticWeightedScore: number;
|
|
67
|
-
ogpDynamicWeightedScore: number;
|
|
68
|
-
ogpTotalWeightedScore: number;
|
|
69
|
-
ogp1Year: number;
|
|
70
|
-
ogp2Year: number;
|
|
71
|
-
ogpRisk: `${BandLevel}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
declare enum RsrScoreSourceDto {
|
|
75
|
-
OASYS = "OASYS"
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
interface RsrScoreDto {
|
|
79
|
-
percentageScore: number;
|
|
80
|
-
staticOrDynamic: `${StaticOrDynamic}`;
|
|
81
|
-
source: `${RsrScoreSourceDto}`;
|
|
82
|
-
algorithmVersion: string;
|
|
83
|
-
scoreLevel: `${BandLevel}`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
interface OspScoreDto {
|
|
87
|
-
ospIndecentPercentageScore: number;
|
|
88
|
-
ospContactPercentageScore: number;
|
|
89
|
-
ospIndecentScoreLevel: `${BandLevel}`;
|
|
90
|
-
ospContactScoreLevel: `${BandLevel}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface AllPredictorDto {
|
|
94
|
-
allReoffendingPredictor?: StaticOrDynamicPredictorDto;
|
|
95
|
-
violentReoffendingPredictor?: StaticOrDynamicPredictorDto;
|
|
96
|
-
seriousViolentReoffendingPredictor?: StaticOrDynamicPredictorDto;
|
|
97
|
-
directContactSexualReoffendingPredictor?: BasePredictorDto;
|
|
98
|
-
indirectImageContactSexualReoffendingPredictor?: BasePredictorDto;
|
|
99
|
-
combinedSeriousReoffendingPredictor?: VersionedStaticOrDynamicPredictorDto;
|
|
100
|
-
groupReconvictionScore?: OgrScoreDto;
|
|
101
|
-
violencePredictorScore?: OvpScoreDto;
|
|
102
|
-
generalPredictorScore?: OgpScoreDto;
|
|
103
|
-
riskOfSeriousRecidivismScore?: RsrScoreDto;
|
|
104
|
-
sexualPredictorScore?: OspScoreDto;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
interface AllPredictorVersionedDto {
|
|
108
|
-
completedDate: string;
|
|
109
|
-
status: `${AssessmentStatusDto}`;
|
|
110
|
-
outputVersion: string;
|
|
111
|
-
output?: AllPredictorDto;
|
|
112
|
-
}
|
|
38
|
+
type Assessments = AssessmentV1 | AssessmentV2;
|
|
113
39
|
|
|
114
40
|
interface RiskData {
|
|
115
|
-
|
|
116
|
-
raw: AllPredictorVersionedDto[];
|
|
41
|
+
assessments: Assessments[];
|
|
117
42
|
}
|
|
118
43
|
|
|
119
44
|
declare class ArnsComponents {
|
|
@@ -123,4 +48,4 @@ declare class ArnsComponents {
|
|
|
123
48
|
}
|
|
124
49
|
|
|
125
50
|
export { ArnsComponents };
|
|
126
|
-
export type { ArnsComponentsConfig,
|
|
51
|
+
export type { ArnsComponentsConfig, Assessments, RiskData };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,172 +1,62 @@
|
|
|
1
1
|
import { RestClient } from '@ministryofjustice/hmpps-rest-client';
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
function transformAllPredictorVersionedDtoToAssessments(dtos) {
|
|
4
|
+
// Sort DTOs by datetime (newest first)
|
|
5
|
+
const sortedDtos = [...dtos].sort((a, b) => {
|
|
6
|
+
return new Date(b.completedDate).getTime() - new Date(a.completedDate).getTime();
|
|
7
|
+
});
|
|
8
|
+
return sortedDtos.map(dto => {
|
|
9
|
+
const completedDate = dto.completedDate.toString();
|
|
10
|
+
const date = new Date(completedDate);
|
|
11
|
+
const dateFormatDayMonthYear = new Intl.DateTimeFormat('en-GB', {
|
|
12
|
+
day: '2-digit',
|
|
13
|
+
month: 'long',
|
|
14
|
+
year: 'numeric',
|
|
15
|
+
}).format(date);
|
|
16
|
+
const time = date.toLocaleTimeString('en-GB', {
|
|
17
|
+
hour: '2-digit',
|
|
18
|
+
minute: '2-digit',
|
|
19
|
+
hour12: false,
|
|
20
|
+
});
|
|
21
|
+
const dateFormatDayMonthYearTime = `${dateFormatDayMonthYear} at ${time}`;
|
|
22
|
+
const { output } = dto;
|
|
23
|
+
if (dto.outputVersion === '1') {
|
|
24
|
+
return {
|
|
25
|
+
outputVersion: '1',
|
|
26
|
+
completedDateTime: dateFormatDayMonthYearTime,
|
|
27
|
+
ogrs3: mapPredictor('OGRS', output.groupReconvictionScore.scoreLevel, null, output.groupReconvictionScore.twoYears, dateFormatDayMonthYear),
|
|
28
|
+
ovp: mapPredictor('OVP', output.violencePredictorScore.ovpRisk, null, output.violencePredictorScore.twoYears, dateFormatDayMonthYear),
|
|
29
|
+
ogp: mapPredictor('OGP', output.generalPredictorScore.ogpRisk, null, output.generalPredictorScore.ogp2Year, dateFormatDayMonthYear),
|
|
30
|
+
rsr: mapPredictor('RSR', output.riskOfSeriousRecidivismScore.scoreLevel, output.riskOfSeriousRecidivismScore.staticOrDynamic, output.riskOfSeriousRecidivismScore.percentageScore, dateFormatDayMonthYear),
|
|
31
|
+
ospdc: mapPredictor('OSP-DC', output.sexualPredictorScore.ospContactScoreLevel, null, output.sexualPredictorScore.ospContactPercentageScore, dateFormatDayMonthYear),
|
|
32
|
+
ospiic: mapPredictor('OSP-IIC', output.sexualPredictorScore.ospIndecentScoreLevel, null, output.sexualPredictorScore.ospIndecentPercentageScore, dateFormatDayMonthYear),
|
|
22
33
|
};
|
|
23
|
-
badgeEntries.push(entry);
|
|
24
34
|
}
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
if (dto.outputVersion === '2') {
|
|
36
|
+
return {
|
|
37
|
+
outputVersion: '2',
|
|
38
|
+
completedDateTime: dateFormatDayMonthYearTime,
|
|
39
|
+
allReoffendingPredictor: mapPredictor('All Reoffending Predictor', output.allReoffendingPredictor.band, output.allReoffendingPredictor.staticOrDynamic, output.allReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
40
|
+
violentReoffendingPredictor: mapPredictor('Violent Reoffending Predictor', output.violentReoffendingPredictor.band, output.violentReoffendingPredictor.staticOrDynamic, output.violentReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
41
|
+
seriousViolentReoffendingPredictor: mapPredictor('Serious Violent Reoffending Predictor', output.seriousViolentReoffendingPredictor.band, output.seriousViolentReoffendingPredictor.staticOrDynamic, output.seriousViolentReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
42
|
+
directContactSexualReoffendingPredictor: mapPredictor('Direct Contact - Sexual Reoffending Predictor', output.directContactSexualReoffendingPredictor.band, null, output.directContactSexualReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
43
|
+
indirectImageContactSexualReoffendingPredictor: mapPredictor('Images and Indirect Contact – Sexual Reoffending Predictor', output.indirectImageContactSexualReoffendingPredictor.band, null, output.indirectImageContactSexualReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
44
|
+
combinedSeriousReoffendingPredictor: mapPredictor('Combined Serious Reoffending Predictor', output.combinedSeriousReoffendingPredictor.band, output.combinedSeriousReoffendingPredictor.staticOrDynamic, output.combinedSeriousReoffendingPredictor.score, dateFormatDayMonthYear),
|
|
34
45
|
};
|
|
35
|
-
badgeEntries.push(entry);
|
|
36
46
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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');
|
|
169
|
-
return badgeEntries;
|
|
47
|
+
throw new Error(`Unsupported output version: ${dto.outputVersion}`);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function mapPredictor(name, band, staticOrDynamic, score, date) {
|
|
51
|
+
return {
|
|
52
|
+
name,
|
|
53
|
+
band: band.replace(/_/g, ' ').toUpperCase(),
|
|
54
|
+
staticOrDynamic: staticOrDynamic
|
|
55
|
+
? staticOrDynamic.charAt(0).toUpperCase() + staticOrDynamic.slice(1).toLowerCase()
|
|
56
|
+
: null,
|
|
57
|
+
score,
|
|
58
|
+
completedDate: date,
|
|
59
|
+
};
|
|
170
60
|
}
|
|
171
61
|
|
|
172
62
|
class ArnsComponents {
|
|
@@ -176,8 +66,7 @@ class ArnsComponents {
|
|
|
176
66
|
async getRiskData(authOptions, identifierType, identifierValue) {
|
|
177
67
|
const response = await this.restClient.get({ path: `/risks/predictors/all/${identifierType}/${identifierValue}` }, authOptions);
|
|
178
68
|
return {
|
|
179
|
-
|
|
180
|
-
raw: response,
|
|
69
|
+
assessments: transformAllPredictorVersionedDtoToAssessments(response),
|
|
181
70
|
};
|
|
182
71
|
}
|
|
183
72
|
}
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/transformers/AllPredictorVersionedDtoToAssessmentsTransformer.ts","../src/ArnsComponents.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAIM,SAAU,8CAA8C,CAAC,IAAgC,EAAA;;AAE7F,IAAA,MAAM,UAAU,GAA+B,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAC3D,CAAC,CAA2B,EAAE,CAA2B,KAAI;QAC3D,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE;AAClF,IAAA,CAAC,CACF;AAED,IAAA,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,IAAG;QAC1B,MAAM,aAAa,GAAW,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE;AAC1D,QAAA,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,aAAa,CAAC;QACpC,MAAM,sBAAsB,GAAW,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;AACtE,YAAA,GAAG,EAAE,SAAS;AACd,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,IAAI,EAAE,SAAS;AAChB,SAAA,CAAC,CAAC,MAA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outputVersion: '2';
|
|
4
|
+
completedDateTime: string;
|
|
5
|
+
allReoffendingPredictor?: Predictor;
|
|
6
|
+
violentReoffendingPredictor?: Predictor;
|
|
7
|
+
seriousViolentReoffendingPredictor?: Predictor;
|
|
8
|
+
directContactSexualReoffendingPredictor?: Predictor;
|
|
9
|
+
indirectImageContactSexualReoffendingPredictor?: Predictor;
|
|
10
|
+
combinedSeriousReoffendingPredictor?: Predictor;
|
|
11
|
+
}
|
package/dist/types/RiskData.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AllPredictorVersionedDto } from './dtos/allPredictorVersionedDto';
|
|
1
|
+
import { Assessments } from './Assessments';
|
|
3
2
|
export interface RiskData {
|
|
4
|
-
|
|
5
|
-
raw: AllPredictorVersionedDto[];
|
|
3
|
+
assessments: Assessments[];
|
|
6
4
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BasePredictorDto } from './
|
|
2
|
-
import { StaticOrDynamicPredictorDto } from './
|
|
3
|
-
import { VersionedStaticOrDynamicPredictorDto } from './
|
|
4
|
-
import { OgrScoreDto } from './
|
|
5
|
-
import { OvpScoreDto } from './
|
|
6
|
-
import { OgpScoreDto } from './
|
|
7
|
-
import { RsrScoreDto } from './
|
|
8
|
-
import { OspScoreDto } from './
|
|
1
|
+
import { BasePredictorDto } from './BasePredictorDto';
|
|
2
|
+
import { StaticOrDynamicPredictorDto } from './StaticOrDynamicPredictorDto';
|
|
3
|
+
import { VersionedStaticOrDynamicPredictorDto } from './VersionedStaticOrDynamicPredictorDto';
|
|
4
|
+
import { OgrScoreDto } from './OgrScoreDto';
|
|
5
|
+
import { OvpScoreDto } from './OvpScoreDto';
|
|
6
|
+
import { OgpScoreDto } from './OgpScoreDto';
|
|
7
|
+
import { RsrScoreDto } from './RsrScoreDto';
|
|
8
|
+
import { OspScoreDto } from './OspScoreDto';
|
|
9
9
|
export interface AllPredictorDto {
|
|
10
10
|
allReoffendingPredictor?: StaticOrDynamicPredictorDto;
|
|
11
11
|
violentReoffendingPredictor?: StaticOrDynamicPredictorDto;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AssessmentStatusDto } from './
|
|
2
|
-
import { AllPredictorDto } from './
|
|
1
|
+
import { AssessmentStatusDto } from './AssessmentStatusDto';
|
|
2
|
+
import { AllPredictorDto } from './AllPredictorDto';
|
|
3
3
|
export interface AllPredictorVersionedDto {
|
|
4
4
|
completedDate: string;
|
|
5
5
|
status: `${AssessmentStatusDto}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StaticOrDynamic } from '
|
|
2
|
-
import { BandLevel } from '
|
|
3
|
-
import { RsrScoreSourceDto } from './
|
|
1
|
+
import { StaticOrDynamic } from './StaticOrDynamic';
|
|
2
|
+
import { BandLevel } from './BandLevel';
|
|
3
|
+
import { RsrScoreSourceDto } from './RsrScoreSourceDto';
|
|
4
4
|
export interface RsrScoreDto {
|
|
5
5
|
percentageScore: number;
|
|
6
6
|
staticOrDynamic: `${StaticOrDynamic}`;
|
package/dist/types/dtos/{staticOrDynamicPredictorDto.d.ts → StaticOrDynamicPredictorDto.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StaticOrDynamic } from '
|
|
2
|
-
import { BasePredictorDto } from './
|
|
1
|
+
import { StaticOrDynamic } from './StaticOrDynamic';
|
|
2
|
+
import { BasePredictorDto } from './BasePredictorDto';
|
|
3
3
|
export interface StaticOrDynamicPredictorDto extends BasePredictorDto {
|
|
4
4
|
staticOrDynamic: `${StaticOrDynamic}`;
|
|
5
5
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StaticOrDynamicPredictorDto } from './
|
|
1
|
+
import { StaticOrDynamicPredictorDto } from './StaticOrDynamicPredictorDto';
|
|
2
2
|
export interface VersionedStaticOrDynamicPredictorDto extends StaticOrDynamicPredictorDto {
|
|
3
3
|
algorithmVersion: string;
|
|
4
4
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { StaticOrDynamic } from './staticOrDynamic';
|
|
2
|
-
import { BandLevel } from './bandLevel';
|
|
3
|
-
export interface BadgeData {
|
|
4
|
-
level: `${BandLevel}`;
|
|
5
|
-
score: number;
|
|
6
|
-
type: string;
|
|
7
|
-
staticOrDynamic: `${StaticOrDynamic}`;
|
|
8
|
-
completedDate: string;
|
|
9
|
-
}
|
|
10
|
-
export interface BadgeEntry {
|
|
11
|
-
[key: string]: BadgeData;
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|