@ministryofjustice/hmpps-arns-frontend-components-lib 0.0.2 → 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 -22
- package/dist/arns/components/badge/template.njk +38 -35
- package/dist/index.cjs.js +55 -165
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +26 -101
- package/dist/index.esm.js +55 -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,25 +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 {boolean} [params.showScore=false] - Whether to display the percentage score
|
|
21
|
-
@param {string} [params.classes] - Additional CSS classes
|
|
22
|
-
#}
|
|
23
1
|
{% macro predictorBadge(params) %}
|
|
24
2
|
{%- include "./template.njk" -%}
|
|
25
3
|
{% endmacro %}
|
|
@@ -1,59 +1,62 @@
|
|
|
1
1
|
{#
|
|
2
2
|
ARNS Predictor Badge Component
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
@name predictorBadge
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const riskData = await arnsComponents.getRiskData(token, 'crn', 'X123456')
|
|
9
|
-
res.render('page', { riskData })
|
|
6
|
+
@description Displays specified risk predictor score badges.
|
|
7
|
+
It uses the latest assessment from the provided data set.
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
@example
|
|
10
|
+
In route handler:
|
|
11
|
+
const riskData = await arnsComponents.getRiskData(token, 'crn', 'X123456')
|
|
12
|
+
res.render('page', { riskData })
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
In template:
|
|
15
|
+
{% from "components/badge/macro.njk" import predictorBadge %}
|
|
16
|
+
{{ predictorBadge({
|
|
17
|
+
data: riskData,
|
|
18
|
+
predictor: "allReoffendingPredictor",
|
|
19
|
+
showScore: true,
|
|
20
|
+
classes: "class-name-here"
|
|
21
|
+
}) }}
|
|
17
22
|
|
|
18
23
|
@param {object} params
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
22
28
|
#}
|
|
23
|
-
|
|
24
|
-
{% set badges = params.data.badges if params.data else [] %}
|
|
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
|
|
28
|
-
<div class="predictor-badges{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
{% if latestAssessment is defined %}
|
|
33
|
+
<div class="predictor-badges{% if params.classes %} {{ params.classes }}{% endif %}">
|
|
34
|
+
{% for key, predictor in latestAssessment %}
|
|
35
|
+
{% if key == params.predictor %}
|
|
36
|
+
|
|
32
37
|
{% set badgeClass = '' %}
|
|
33
|
-
{% switch predictor.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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' %}
|
|
42
47
|
{% endswitch %}
|
|
43
|
-
|
|
44
48
|
<div class="{{ badgeClass }}">
|
|
45
|
-
<span class="predictor-badge__type_and_level">{{ predictor.
|
|
49
|
+
<span class="predictor-badge__type_and_level">{{ predictor.name | upper }} <strong>{{ predictor.band }}</strong></span>
|
|
46
50
|
|
|
47
|
-
{% if showScore and predictor.score %}
|
|
51
|
+
{% if showScore and predictor.score is defined %}
|
|
48
52
|
<span class="predictor-badge__score">{{ predictor.score }}%</span>
|
|
49
53
|
{% endif %}
|
|
50
54
|
|
|
51
55
|
{% if predictor.staticOrDynamic %}
|
|
52
|
-
<span class="predictor-badge__static_or_dynamic">{{ predictor.staticOrDynamic
|
|
56
|
+
<span class="predictor-badge__static_or_dynamic">{{ predictor.staticOrDynamic }}</span>
|
|
53
57
|
{% endif %}
|
|
54
58
|
</div>
|
|
55
59
|
{% endif %}
|
|
56
60
|
{% endfor %}
|
|
57
|
-
|
|
58
|
-
</div>
|
|
61
|
+
</div>
|
|
59
62
|
{% endif %}
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,172 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
var hmppsRestClient = require('@ministryofjustice/hmpps-rest-client');
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
}
|
|
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),
|
|
35
|
+
};
|
|
86
36
|
}
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
}
|
|
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),
|
|
47
|
+
};
|
|
166
48
|
}
|
|
167
|
-
|
|
168
|
-
throw new Error('unexpected version');
|
|
49
|
+
throw new Error(`Unsupported output version: ${dto.outputVersion}`);
|
|
169
50
|
});
|
|
170
|
-
|
|
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
|
+
};
|
|
171
62
|
}
|
|
172
63
|
|
|
173
64
|
class ArnsComponents {
|
|
@@ -177,8 +68,7 @@ class ArnsComponents {
|
|
|
177
68
|
async getRiskData(authOptions, identifierType, identifierValue) {
|
|
178
69
|
const response = await this.restClient.get({ path: `/risks/predictors/all/${identifierType}/${identifierValue}` }, authOptions);
|
|
179
70
|
return {
|
|
180
|
-
|
|
181
|
-
raw: response,
|
|
71
|
+
assessments: transformAllPredictorVersionedDtoToAssessments(response),
|
|
182
72
|
};
|
|
183
73
|
}
|
|
184
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,M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
-
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,171 +1,62 @@
|
|
|
1
1
|
import { RestClient } from '@ministryofjustice/hmpps-rest-client';
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
}
|
|
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),
|
|
33
|
+
};
|
|
84
34
|
}
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
}
|
|
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),
|
|
45
|
+
};
|
|
164
46
|
}
|
|
165
|
-
|
|
166
|
-
throw new Error('unexpected version');
|
|
47
|
+
throw new Error(`Unsupported output version: ${dto.outputVersion}`);
|
|
167
48
|
});
|
|
168
|
-
|
|
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
|
+
};
|
|
169
60
|
}
|
|
170
61
|
|
|
171
62
|
class ArnsComponents {
|
|
@@ -175,8 +66,7 @@ class ArnsComponents {
|
|
|
175
66
|
async getRiskData(authOptions, identifierType, identifierValue) {
|
|
176
67
|
const response = await this.restClient.get({ path: `/risks/predictors/all/${identifierType}/${identifierValue}` }, authOptions);
|
|
177
68
|
return {
|
|
178
|
-
|
|
179
|
-
raw: response,
|
|
69
|
+
assessments: transformAllPredictorVersionedDtoToAssessments(response),
|
|
180
70
|
};
|
|
181
71
|
}
|
|
182
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,MAAM,CAAC,IAAI,CAAC;AACf,QAAA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ime: 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
|