Skip to content

Commit f883e9a

Browse files
authored
CDPS-1148: Implement create and update military record endpoints (#21)
1 parent 4dbf3bf commit f883e9a

File tree

10 files changed

+598
-15
lines changed

10 files changed

+598
-15
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/PrisonApiClient.kt

+15
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import org.springframework.web.bind.annotation.PathVariable
55
import org.springframework.web.bind.annotation.RequestBody
66
import org.springframework.web.service.annotation.GetExchange
77
import org.springframework.web.service.annotation.HttpExchange
8+
import org.springframework.web.service.annotation.PostExchange
89
import org.springframework.web.service.annotation.PutExchange
910
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.dto.UpdateBirthCountry
11+
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request.CreateMilitaryRecord
1012
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request.UpdateBirthPlace
13+
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request.UpdateMilitaryRecord
1114
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request.UpdateNationality
1215
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request.UpdateReligion
1316
import uk.gov.justice.digital.hmpps.personintegrationapi.common.client.response.MilitaryRecordPrisonDto
@@ -37,6 +40,18 @@ interface PrisonApiClient {
3740
@PathVariable offenderNo: String,
3841
): ResponseEntity<MilitaryRecordPrisonDto>
3942

43+
@PutExchange("/{offenderNo}/military-records")
44+
fun updateMilitaryRecord(
45+
@PathVariable offenderNo: String,
46+
@RequestBody updateMilitaryRecord: UpdateMilitaryRecord,
47+
): ResponseEntity<Void>
48+
49+
@PostExchange("/{offenderNo}/military-records")
50+
fun createMilitaryRecord(
51+
@PathVariable offenderNo: String,
52+
@RequestBody createMilitaryRecord: CreateMilitaryRecord,
53+
): ResponseEntity<Void>
54+
4055
@PutExchange("/{offenderNo}/religion")
4156
fun updateReligionForWorkingName(
4257
@PathVariable offenderNo: String,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request
2+
3+
import io.swagger.v3.oas.annotations.media.Schema
4+
import java.time.LocalDate
5+
6+
@Schema(description = "Create a military record.")
7+
class CreateMilitaryRecord(
8+
@Schema(
9+
description = "Code identifying the war zone where the service took place.",
10+
example = "AFG",
11+
)
12+
val warZoneCode: String? = null,
13+
14+
@Schema(
15+
description = "Start date of the military service.",
16+
example = "2017-06-01",
17+
)
18+
val startDate: LocalDate,
19+
20+
@Schema(
21+
description = "End date of the military service, if applicable.",
22+
example = "2019-12-01",
23+
)
24+
val endDate: LocalDate? = null,
25+
26+
@Schema(
27+
description = "Code indicating the discharge status from the UK military forces.",
28+
example = "HON",
29+
)
30+
val militaryDischargeCode: String? = null,
31+
32+
@Schema(
33+
description = "Code identifying the branch of the UK military in which the individual served.",
34+
example = "ARM",
35+
)
36+
val militaryBranchCode: String,
37+
38+
@Schema(
39+
description = "Additional notes or details about the military service.",
40+
example = "Deployed to Afghanistan in support of Operation Herrick.",
41+
)
42+
val description: String? = null,
43+
44+
@Schema(
45+
description = "Unit number in which the individual served.",
46+
example = "2nd Battalion, The Royal Anglian Regiment",
47+
)
48+
val unitNumber: String? = null,
49+
50+
@Schema(
51+
description = "Location where the individual enlisted in the UK military.",
52+
example = "Windsor, Berkshire",
53+
)
54+
val enlistmentLocation: String? = null,
55+
56+
@Schema(
57+
description = "Location where the individual was discharged from the UK military.",
58+
example = "Colchester, Essex",
59+
)
60+
val dischargeLocation: String? = null,
61+
62+
@Schema(
63+
description = "Flag indicating if the individual was registered for UK selective military service (National Service).",
64+
example = "false",
65+
)
66+
val selectiveServicesFlag: Boolean,
67+
68+
@Schema(
69+
description = "Code identifying the individual's military rank in the UK forces.",
70+
example = "CPL_ARM",
71+
)
72+
val militaryRankCode: String? = null,
73+
74+
@Schema(
75+
description = "Service number of the individual within the UK military.",
76+
example = "2345678",
77+
)
78+
val serviceNumber: String? = null,
79+
80+
@Schema(
81+
description = "Code identifying any disciplinary actions taken against the individual during service.",
82+
example = "CM",
83+
)
84+
val disciplinaryActionCode: String? = null,
85+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package uk.gov.justice.digital.hmpps.personintegrationapi.common.client.request
2+
3+
import io.swagger.v3.oas.annotations.media.Schema
4+
import java.time.LocalDate
5+
6+
@Schema(description = "Create a military record.")
7+
class UpdateMilitaryRecord(
8+
@Schema(
9+
description = "Booking ID of the prisoner.",
10+
example = "1234567",
11+
)
12+
val bookingId: Long,
13+
14+
@Schema(
15+
description = "Sequence number of the military record within the booking.",
16+
example = "1",
17+
)
18+
val militarySeq: Int,
19+
20+
@Schema(
21+
description = "Code identifying the war zone where the service took place.",
22+
example = "AFG",
23+
)
24+
val warZoneCode: String? = null,
25+
26+
@Schema(
27+
description = "Start date of the military service.",
28+
example = "2017-06-01",
29+
)
30+
val startDate: LocalDate,
31+
32+
@Schema(
33+
description = "End date of the military service, if applicable.",
34+
example = "2019-12-01",
35+
)
36+
val endDate: LocalDate? = null,
37+
38+
@Schema(
39+
description = "Code indicating the discharge status from the UK military forces.",
40+
example = "HON",
41+
)
42+
val militaryDischargeCode: String? = null,
43+
44+
@Schema(
45+
description = "Code identifying the branch of the UK military in which the individual served.",
46+
example = "ARM",
47+
)
48+
val militaryBranchCode: String,
49+
50+
@Schema(
51+
description = "Additional notes or details about the military service.",
52+
example = "Deployed to Afghanistan in support of Operation Herrick.",
53+
)
54+
val description: String? = null,
55+
56+
@Schema(
57+
description = "Unit number in which the individual served.",
58+
example = "2nd Battalion, The Royal Anglian Regiment",
59+
)
60+
val unitNumber: String? = null,
61+
62+
@Schema(
63+
description = "Location where the individual enlisted in the UK military.",
64+
example = "Windsor, Berkshire",
65+
)
66+
val enlistmentLocation: String? = null,
67+
68+
@Schema(
69+
description = "Location where the individual was discharged from the UK military.",
70+
example = "Colchester, Essex",
71+
)
72+
val dischargeLocation: String? = null,
73+
74+
@Schema(
75+
description = "Flag indicating if the individual was registered for UK selective military service (National Service).",
76+
example = "false",
77+
)
78+
val selectiveServicesFlag: Boolean,
79+
80+
@Schema(
81+
description = "Code identifying the individual's military rank in the UK forces.",
82+
example = "CPL_ARM",
83+
)
84+
val militaryRankCode: String? = null,
85+
86+
@Schema(
87+
description = "Service number of the individual within the UK military.",
88+
example = "2345678",
89+
)
90+
val serviceNumber: String? = null,
91+
92+
@Schema(
93+
description = "Code identifying any disciplinary actions taken against the individual during service.",
94+
example = "CM",
95+
)
96+
val disciplinaryActionCode: String? = null,
97+
)

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/common/client/response/MilitaryRecord.kt

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ data class MilitaryRecordPrisonDto(
77
)
88

99
data class MilitaryRecord(
10+
val bookingId: Long,
11+
val militarySeq: Int,
1012
val warZoneCode: String?,
1113
val warZoneDescription: String?,
1214
val startDate: LocalDate,

src/main/kotlin/uk/gov/justice/digital/hmpps/personintegrationapi/corepersonrecord/dto/response/MilitaryRecordDto.kt

+27-15
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@ import java.time.LocalDate
88
@JsonInclude(Include.NON_NULL)
99
@Schema(description = "DTO representing a military record with details about service in the UK Armed Forces.")
1010
data class MilitaryRecordDto(
11+
@Schema(
12+
description = "Booking ID of the prisoner.",
13+
example = "1234567",
14+
)
15+
val bookingId: Long,
16+
17+
@Schema(
18+
description = "Sequence number of the military record within the booking.",
19+
example = "1",
20+
)
21+
val militarySeq: Int,
22+
1123
@Schema(
1224
description = "Code identifying the war zone where the service took place.",
1325
example = "AFG",
1426
)
15-
val warZoneCode: String?,
27+
val warZoneCode: String? = null,
1628

1729
@Schema(
1830
description = "Description of the war zone where the service took place.",
1931
example = "Afghanistan",
2032
)
21-
val warZoneDescription: String?,
33+
val warZoneDescription: String? = null,
2234

2335
@Schema(
2436
description = "Start date of the military service.",
@@ -30,19 +42,19 @@ data class MilitaryRecordDto(
3042
description = "End date of the military service, if applicable.",
3143
example = "2019-12-01",
3244
)
33-
val endDate: LocalDate?,
45+
val endDate: LocalDate? = null,
3446

3547
@Schema(
3648
description = "Code indicating the discharge status from the UK military forces.",
3749
example = "HON",
3850
)
39-
val militaryDischargeCode: String?,
51+
val militaryDischargeCode: String? = null,
4052

4153
@Schema(
4254
description = "Description of the discharge status from the UK military forces.",
4355
example = "Honourable",
4456
)
45-
val militaryDischargeDescription: String?,
57+
val militaryDischargeDescription: String? = null,
4658

4759
@Schema(
4860
description = "Code identifying the branch of the UK military in which the individual served.",
@@ -54,31 +66,31 @@ data class MilitaryRecordDto(
5466
description = "Description of the military branch of the UK Armed Forces.",
5567
example = "Army",
5668
)
57-
val militaryBranchDescription: String,
69+
val militaryBranchDescription: String? = null,
5870

5971
@Schema(
6072
description = "Additional notes or details about the military service.",
6173
example = "Deployed to Afghanistan in support of Operation Herrick.",
6274
)
63-
val description: String?,
75+
val description: String? = null,
6476

6577
@Schema(
6678
description = "Unit number in which the individual served.",
6779
example = "2nd Battalion, The Royal Anglian Regiment",
6880
)
69-
val unitNumber: String?,
81+
val unitNumber: String? = null,
7082

7183
@Schema(
7284
description = "Location where the individual enlisted in the UK military.",
7385
example = "Windsor, Berkshire",
7486
)
75-
val enlistmentLocation: String?,
87+
val enlistmentLocation: String? = null,
7688

7789
@Schema(
7890
description = "Location where the individual was discharged from the UK military.",
7991
example = "Colchester, Essex",
8092
)
81-
val dischargeLocation: String?,
93+
val dischargeLocation: String? = null,
8294

8395
@Schema(
8496
description = "Flag indicating if the individual was registered for UK selective military service (National Service).",
@@ -90,29 +102,29 @@ data class MilitaryRecordDto(
90102
description = "Code identifying the individual's military rank in the UK forces.",
91103
example = "CPL_ARM",
92104
)
93-
val militaryRankCode: String?,
105+
val militaryRankCode: String? = null,
94106

95107
@Schema(
96108
description = "Description of the individual's military rank in the UK forces.",
97109
example = "Corporal",
98110
)
99-
val militaryRankDescription: String?,
111+
val militaryRankDescription: String? = null,
100112

101113
@Schema(
102114
description = "Service number of the individual within the UK military.",
103115
example = "2345678",
104116
)
105-
val serviceNumber: String?,
117+
val serviceNumber: String? = null,
106118

107119
@Schema(
108120
description = "Code identifying any disciplinary actions taken against the individual during service.",
109121
example = "CM",
110122
)
111-
val disciplinaryActionCode: String?,
123+
val disciplinaryActionCode: String? = null,
112124

113125
@Schema(
114126
description = "Description of any disciplinary actions taken against the individual during service.",
115127
example = "Court Martial",
116128
)
117-
val disciplinaryActionDescription: String?,
129+
val disciplinaryActionDescription: String? = null,
118130
)

0 commit comments

Comments
 (0)