---
# System prepended metadata

title: project Falcon

---

# project Falcon


## Flow - Happy path
> We'll also need a query for fetching max number of patients for selected testStation
```plantuml

actor "User/Frontend" as u

boundary Backend as b

@startuml


== Authing user and adding patient data ==

u -> b: 1. <b>We need your phone number</b>\nuser submits phone number for OTP session
note over u #99FF99
mutation {
          newOtpSession(phoneNumber: "${phone_number}", userAgnostic: <u><b>false</b></u>) {
            otpCode
          }
        }
end note

note over b
  backend creates or updates user...
end note

b->u: sends SMS

u->b: 2. <b>Confirm SMS code</b>\nuser submits OTP code
note over u #99FF99
  mutation {
    signInUserOtp(phoneNumber: "+4791222121", code: "5987") {
      id
      firstName
      lastName
      patient { // you can fetch patient data associated to user
          id
          name
          email
          phoneNumber
      }
    }
  }
end note
b->u: backend returns <b>User</b> object (with optional Patient obj)




u->b: 4. system checks if he has some appointments already
note over u #FFAAAA
<b>@TODO!</b>
(multiple times, as many 
times as there are patients,
albeit it can be squashed into 1 request)

mutation {
          upcomingAppointments(patientId) {
             // (list of appointment data)
          }
        }
end note

== ...if there are no upcoming appointments... ==

u->b: 5. system fetches available slots
note over u #99FF99


query {
  testAvailabilityCalendar(
      serviceCenterIds: [1],
      dateFrom: "2022-01-29",
      dateTo: "2022-01-31",
      requiredCapacity: 5,
      hourFrom: "09:00",
      hourTo: "12:00") {
      serviceCenter {
        id
        name
        title
        street
        zip
        city
        googlePlaceId
        lat
        lng
      }
      availability
  }
}
end note

b->u: backend returns availability data
note over u
<b>Select a time for testing at XYZ center</b>
 user chooses some available slot
end note


u->b: 3. <b>Tell us who you are</b>\nuser checks and updates his info
note over u #FFAAAA

<b>by now we DO have access to already existing user</b>
mutation {
          updateUser(userAttributes...) {
              id
          }
        }
<b>it should, in fact update User as well as User's patient object</b>
end note


u->b: 4. <b>Other patients</b>\nuser adds his co-patients
note over u #FFAAAA
<b>@TODO!</b>
(multiple times)
these will be patients dependant on user's patients
mutation {
          createPatients(patientAttributes[]...) {
              id
          }
        }

we must allow duplicated record
end note



u->b: 6.user creates a TestAppointment
note over u
<b>@TODO: needs modifications to accept patientIds<b/>
mutation {
  createAppointment(
      productSlug: "loc-tst-c19-pu",
      serviceCenterId: 1,
      date: "2022-01-26",
      hour: "12:00",
      patientIds: [3331,3332,3333,3334],
      ) {
        id
        date
        hour
  }
}
end note
b->u: response with TestAppointments objects

u->u: final success screen


@enduml
```