# CareplanControllerMock.kt

    /*
     * The MIT License
     *
     * Original work sponsored and donated by The Danish Health Data Authority (http://www.sundhedsdatastyrelsen.dk)
     *
     * Copyright (C) 2021 The Danish Health Data Authority (http://www.sundhedsdatastyrelsen.dk)
     *
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy of
     * this software and associated documentation files (the "Software"), to deal in
     * the Software without restriction, including without limitation the rights to
     * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
     * of the Software, and to permit persons to whom the Software is furnished to do
     * so, subject to the following conditions:
     *
     *
     * The above copyright notice and this permission notice shall be included in all
     * copies or substantial portions of the Software.
     *
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     * SOFTWARE.
     */

    package dk.nsp.api.careplan

    import dk.nsp.api.util.extensions.asyncIO
    import dk.nsp.models.*
    import dk.nsp.shared.ResultWrapper
    import dk.nsp.shared.Success
    import kotlinx.coroutines.CoroutineScope
    import kotlinx.coroutines.Deferred
    import java.math.BigDecimal
    import java.time.LocalDateTime

    class CareplanControllerMock : ICareplanController {
        // In this mock we assume that we are 4 weeks pregnant
        private val firstDateOfCareplan = LocalDateTime.now().minusWeeks(4)

        private val defaultActivityPractitioner = ActivityPractitioner(
            "Louise",
            "Hansen",
            "Regionshospitalet Horsens",
            null,
            "12345678",
            "LouiseHansen@rh-horsens.dk",
            "2381 9231"

        )

        private val defaultActivityLocation = ActivityLocation(
            "null",
            ActivityLocationAddress("Sundvej 30", "8700", "Horsens"),
            "Regionshospitalet Horsens",
            "7842 5000",
            null,
            null
        )

        private val observations = listOf(
            Observation(
                LocalDateTime.now().minusWeeks(1),
                listOf(
                    ObservationValues("65", "kg", "Vægt")
                ),
                measuredBy = HealthCarePerformer(
                    person = Person(PersonName(prefixName = "Dr.", firstNames = listOf("Test"), middleNames = listOf("Middle", "Names"), lastName = "Testsen")),
                    role = "SuperRole",
                    healthCareOrganization = null,
                    healthCareOrganizationAdress = null,
                    healthCareOrganizationPhoneNumber = null
                ),
                "1",
                "activityId",
                ObservationType.Weight,
                "measurementId",
                0
            )
        )

        private val activities = listOf(
            Activity(
                Activity.Status.Expected,
                "Scanning",
                defaultActivityPractitioner,
                defaultActivityLocation,
                "12+0",
                ActivityPlannedTime(
                    firstDateOfCareplan.plusWeeks(6).withHour(10).withMinute(0).withSecond(0),
                    firstDateOfCareplan.plusWeeks(6).withHour(11).withMinute(0).withSecond(0)
                ),
                Activity.Ownership.CurrentUser,
                null,
                null,
                null,
                "kind",
                "id?",
                Note(
                    "Her kommer til at stå noget tekst... bla bla bla..",
                    null,
                    LocalDateTime.now().minusMonths(4),
                    HealthCarePerformer(
                        person = Person(PersonName(prefixName = "Dr.", firstNames = listOf("Test"), middleNames = listOf("Middle", "Names"), lastName = "Testsen")),
                        role = "SuperRole",
                        healthCareOrganization = null,
                        healthCareOrganizationAdress = null,
                        healthCareOrganizationPhoneNumber = null
                    ),
                    "documentId",
                    BigDecimal(1),
                    false
                ),
                listOf(),
    //            observations,
                firstDateOfCareplan.plusWeeks(6)
            ),
            Activity(
                Activity.Status.Finished,
                "Sidste ting før termin",
                defaultActivityPractitioner,
                defaultActivityLocation,
                "6+0",
                ActivityPlannedTime(
                    firstDateOfCareplan.minusWeeks(6).withHour(10).withMinute(0).withSecond(0),
                    firstDateOfCareplan.minusWeeks(6).withHour(11).withMinute(0).withSecond(0)
                ),
                Activity.Ownership.CurrentUser,
                null,
                null,
                null,
                "kind",
                "id2",
                Note(
                    "Her kommer til at stå noget tekst... bla bla bla..",
                    null,
                    LocalDateTime.now().minusMonths(4),
                    HealthCarePerformer(
                        person = Person(PersonName(prefixName = "Dr.", firstNames = listOf("Lars"), middleNames = listOf("Middle", "Names"), lastName = "Hepsen")),
                        role = "Sygeplejerske",
                        healthCareOrganization = null,
                        healthCareOrganizationAdress = null,
                        healthCareOrganizationPhoneNumber = null
                    ),
                    "documentId",
                    BigDecimal(1),
                    false
                ),
                listOf(),
    //            observations,
                LocalDateTime.of(2020, 8, 16, 12, 0)
            ),
            Activity(
                Activity.Status.Finished,
                "Noget andet.. et par dage efter termin..",
                defaultActivityPractitioner,
                defaultActivityLocation,
                "43+0",
                ActivityPlannedTime(
                    firstDateOfCareplan.minusWeeks(6).withHour(10).withMinute(0).withSecond(0),
                    firstDateOfCareplan.minusWeeks(6).withHour(11).withMinute(0).withSecond(0)
                ),
                Activity.Ownership.CurrentUser,
                null,
                null,
                null,
                "kind",
                "id3",
                null,
                null,
    //            observations,
                LocalDateTime.of(2020, 8, 12, 12, 0)
            )
    //        CareplanActivityDTO(
    //            null,
    //            null,
    //            "12+0",
    //            null,
    //            CareplanStatusDTO.Expected,
    //            "12 ugers scanning",
    //            null,
    //            null,
    //            null,
    //            null,
    //            null,
    //            "12weekId",
    //            null,
    //            null,
    //            firstDateOfCareplan.plusWeeks(12)
    //        )
        )

        override fun getCareplan(
            scope: CoroutineScope,
            episodeOfCareId: String
        ): Deferred<ResultWrapper<CarePlan>> =
            scope.asyncIO {
                Success(

                    CarePlan(
                        "Patient",
                        "Første barn",
                        CarePlanResponsibleOrganization("Fisk", "Mock"),
                        activities.sortedBy { it.sortDate },
                        null,

                        "Her er der en beskrivelse på første barn",
                        "SOmeId",
                        BigDecimal.ONE
                    )
                )
            }
    }