generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDPS-1086: Moving medical diet, allergy code over from hmpps-prison-p…
…erson-api
- Loading branch information
1 parent
8debbac
commit a801e8d
Showing
86 changed files
with
2,513 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...ndmedicationapi/HealthAndMedicationApi.kt → ...thandmedication/HealthAndMedicationApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/uk/gov/justice/digital/hmpps/healthandmedication/annotation/NullishRange.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.annotation | ||
|
||
import jakarta.validation.Constraint | ||
import jakarta.validation.Payload | ||
import uk.gov.justice.digital.hmpps.healthandmedication.validator.NullishRangeValidator | ||
import kotlin.reflect.KClass | ||
|
||
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Constraint(validatedBy = [NullishRangeValidator::class]) | ||
annotation class NullishRange( | ||
val min: Int, | ||
val max: Int, | ||
val message: String = "The value must be within the specified range, null or Undefined.", | ||
val groups: Array<KClass<*>> = [], | ||
val payload: Array<KClass<out Payload>> = [], | ||
) |
17 changes: 17 additions & 0 deletions
17
...n/uk/gov/justice/digital/hmpps/healthandmedication/annotation/NullishReferenceDataCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.annotation | ||
|
||
import jakarta.validation.Constraint | ||
import jakarta.validation.Payload | ||
import uk.gov.justice.digital.hmpps.healthandmedication.validator.NullishReferenceDataCodeValidator | ||
import kotlin.reflect.KClass | ||
|
||
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Constraint(validatedBy = [NullishReferenceDataCodeValidator::class]) | ||
annotation class NullishReferenceDataCode( | ||
val domains: Array<String> = [], | ||
val allowNull: Boolean = true, | ||
val message: String = "The value must be a reference domain code id of the correct domain, null, or Undefined.", | ||
val groups: Array<KClass<*>> = [], | ||
val payload: Array<KClass<out Payload>> = [], | ||
) |
16 changes: 16 additions & 0 deletions
16
.../gov/justice/digital/hmpps/healthandmedication/annotation/NullishReferenceDataCodeList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.annotation | ||
|
||
import jakarta.validation.Constraint | ||
import jakarta.validation.Payload | ||
import uk.gov.justice.digital.hmpps.healthandmedication.validator.NullishReferenceDataCodeListValidator | ||
import kotlin.reflect.KClass | ||
|
||
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Constraint(validatedBy = [NullishReferenceDataCodeListValidator::class]) | ||
annotation class NullishReferenceDataCodeList( | ||
val domains: Array<String> = [], | ||
val message: String = "The value must be a a list of domain codes of the correct domain, an empty list, or Undefined.", | ||
val groups: Array<KClass<*>> = [], | ||
val payload: Array<KClass<out Payload>> = [], | ||
) |
17 changes: 17 additions & 0 deletions
17
...ain/kotlin/uk/gov/justice/digital/hmpps/healthandmedication/annotation/NullishShoeSize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.annotation | ||
|
||
import jakarta.validation.Constraint | ||
import jakarta.validation.Payload | ||
import uk.gov.justice.digital.hmpps.healthandmedication.validator.NullishShoeSizeValidator | ||
import kotlin.reflect.KClass | ||
|
||
@Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
@Constraint(validatedBy = [NullishShoeSizeValidator::class]) | ||
annotation class NullishShoeSize( | ||
val min: String, | ||
val max: String, | ||
val message: String = "The value must be a whole or half shoe size within the specified range, null or Undefined.", | ||
val groups: Array<KClass<*>> = [], | ||
val payload: Array<KClass<out Payload>> = [], | ||
) |
24 changes: 24 additions & 0 deletions
24
...v/justice/digital/hmpps/healthandmedication/client/prisonersearch/PrisonerSearchClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.client.prisonersearch | ||
|
||
import org.springframework.beans.factory.annotation.Qualifier | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.reactive.function.client.WebClient | ||
import org.springframework.web.reactive.function.client.WebClientResponseException.NotFound | ||
import uk.gov.justice.digital.hmpps.healthandmedication.client.prisonersearch.dto.PrisonerDto | ||
import uk.gov.justice.digital.hmpps.healthandmedication.config.DownstreamServiceException | ||
|
||
@Component | ||
class PrisonerSearchClient(@Qualifier("prisonerSearchWebClient") private val webClient: WebClient) { | ||
fun getPrisoner(prisonerNumber: String): PrisonerDto? = try { | ||
webClient | ||
.get() | ||
.uri("/prisoner/{prisonerNumber}", prisonerNumber) | ||
.retrieve() | ||
.bodyToMono(PrisonerDto::class.java) | ||
.block() | ||
} catch (e: NotFound) { | ||
null | ||
} catch (e: Exception) { | ||
throw DownstreamServiceException("Get prisoner request failed", e) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...uk/gov/justice/digital/hmpps/healthandmedication/client/prisonersearch/dto/PrisonerDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.client.prisonersearch.dto | ||
|
||
data class PrisonerDto( | ||
val prisonerNumber: String, | ||
val prisonId: String? = null, | ||
) |
15 changes: 15 additions & 0 deletions
15
...main/kotlin/uk/gov/justice/digital/hmpps/healthandmedication/config/ClockConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.config | ||
|
||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import java.time.Clock | ||
import java.time.ZoneId | ||
|
||
@Configuration | ||
class ClockConfiguration( | ||
@Value("\${spring.jackson.time-zone}") private val timeZone: String, | ||
) { | ||
@Bean | ||
fun clock(): Clock? = Clock.system(ZoneId.of(timeZone)) | ||
} |
31 changes: 31 additions & 0 deletions
31
.../uk/gov/justice/digital/hmpps/healthandmedication/config/CustomisedJacksonObjectMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package uk.gov.justice.digital.hmpps.healthandmedication.config | ||
|
||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer | ||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer | ||
import com.fasterxml.jackson.datatype.jsr310.ser.ZonedDateTimeSerializer | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import java.time.ZoneId | ||
import java.time.format.DateTimeFormatter | ||
|
||
@Configuration | ||
class CustomisedJacksonObjectMapper( | ||
@Value("\${spring.jackson.time-zone}") private val timeZone: String, | ||
@Value("\${spring.jackson.date-format}") private val zonedDateTimeFormat: String, | ||
) { | ||
@Bean | ||
fun serialiser() = Jackson2ObjectMapperBuilderCustomizer { | ||
val zoneId = ZoneId.of(timeZone) | ||
val naiveDateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(zoneId) | ||
val naiveDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss").withZone(zoneId) | ||
val zonedDateTimeFormatter = DateTimeFormatter.ofPattern(zonedDateTimeFormat).withZone(zoneId) | ||
|
||
it.serializers( | ||
LocalDateSerializer(naiveDateFormatter), | ||
LocalDateTimeSerializer(naiveDateTimeFormatter), | ||
ZonedDateTimeSerializer(zonedDateTimeFormatter), | ||
) | ||
} | ||
} |
Oops, something went wrong.