Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Add age input in newCall GUI #65

Open
pinpox opened this issue Feb 14, 2021 · 9 comments
Open

Add age input in newCall GUI #65

pinpox opened this issue Feb 14, 2021 · 9 comments
Assignees

Comments

@pinpox
Copy link
Member

pinpox commented Feb 14, 2021

The database now includes a boolean field for the vaccine type called young_only. The frontend need two radio boxes to input true or false when creating a new call. The title shown to the user should be something like "Nur für >65j: ja/nein" or "Impstoff: astraceneca / andere"

@pinpox pinpox added this to the Real World test milestone Feb 14, 2021
@manuliner
Copy link
Contributor

why no dropdown with the options of the Vaccines Availaible

btw. > 65 is the wrong criteria

currently planned possibilities

SMS Registrars -> Biontech/Moderna

Imported -> Astra Zeneca

@manuliner
Copy link
Contributor

i strongly disagree with this logic, We should specifiy the vaccine available in an field in the users tables

Also should it be possible to add persons to vaccines

if the timer walks over the persons to look for fitting persons, it should check if the vaccine of the call is fitting to the person

Criteria:

  1. is the Person top priority
  2. is the Person correct VaccineGroup
  3. is the Person already informed/attached to another call?
  4. is the Person state "ungeimpft" / "open for message"

@pinpox
Copy link
Member Author

pinpox commented Feb 15, 2021

i strongly disagree with this logic, We should specifiy the vaccine available in an field in the users tables

Also should it be possible to add persons to vaccines

if the timer walks over the persons to look for fitting persons, it should check if the vaccine of the call is fitting to the person

Criteria:

1. is the Person top priority

2. is the Person correct VaccineGroup

3. is the Person already informed/attached to another call?

4. is the Person state "ungeimpft" / "open for message"

I don't understand. Why should we put the available vaccine in the users table? The users table is just the users allowed to login and their default values for calls. What we want is to be able to specify for each call, if it is the "special kind" of vaccine, which is only usable on lower ages. So the logic is: On import or registration not only save the number, but also a field specifying if the person is compatible with all vaccines ("young") or only with a subset of them ("old"). Upon issuing a call, we will include that field in the logic, alongside all other criteria.

Im writing a test in a separate branch for the algorithm selecting the next person, you can view it here:

backend-go/bridge_test.go

Lines 455 to 524 in cd12450

// Lower group numbers should always go first. If the number of
// persons with group nubmer below the highest returned group is
// greater or equal of to the number we are looking for, the result
// is wrong. A call should first be issued to alle the persons of
// lower groups before trying the next one up
if lowerPersonNum >= tt.num {
t.Error("Bridge.GetNextPersonsForCall selected persons with higher group than necessary")
return
}
// if diff := cmp.Diff(tt.want, got); diff != "" {
// t.Errorf("Bridge.GetNextPersonsForCall() mismatch (-want +got):\n%s", diff)
// }
// Check there are no duplicates in the persons returned. We place
// the returned slice in a map, with the phone as key and a
// arbitrary value (1). For each person, we try to get it by
// accessing the map, if it fails, we add it (this is good and
// means the person was not yet in the map). If it succeds we exit
// with an error, this means we tried to access a key (phonenumber)
// that already exists in the map, meaning that it is duplicate
duplicate_frequency := make(map[string]int)
for _, pers := range got {
if _, ok := duplicate_frequency[pers.Phone]; ok {
t.Error("Bridge.GetNextPersonsForCall returned duplicates")
} else {
duplicate_frequency[pers.Phone] = 1
}
}
// Check if less than the requested number of persons where
// returned, even though we had enough to choose from
if len(got) < tt.num && len(allPersons) > tt.num {
t.Error("Bridge.GetNextPersonsForCall returned not enough persons, even though available")
return
}
// Check the number of persons returned does not exist the number requested
if len(got) > tt.num {
t.Error("Bridge.GetNextPersonsForCall returned too many persons")
return
}
for _, v := range got {
// check none is already vaccinated
if v.Status {
t.Errorf("Bridge.GetNextPersonsForCall returned already vaccinated person Phone: %v\n", v.Phone)
return
}
// check if all persons meet only_young criteria (no old persons in call for young only)
if !v.Young && call.Call.YoungOnly {
t.Errorf("Bridge.GetNextPersonsForCall returned person not compatible with call: %v\n", v.Phone)
return
}
}
// check not already notified persons are retrieved
for _, i := range invitations {
for _, p := range got {
if i.Phone == p.Phone && i.CallID == tt.callID {
t.Errorf("Bridge.GetNextPersonsForCall returned phone %s already notified for call: %v\n", p.Phone, tt.callID)
return
}
}
}
// TODO check: order within one group should be randomized
})
}

If I misunderstood any of the criteria let me know, the goal is to have that test check if the selection is correct based on these persons: https://github.com/impfbruecke/backend-go/blob/add-tests-3/testdata/fixtures/persons_selectnext.yml

@pinpox
Copy link
Member Author

pinpox commented Feb 15, 2021

Further clarification:

To find new persons to notify for a call we have this function GetNextPersonsForCall(numPersons, callID).
It takes two parameters: The number of persons we want to get and the callID for which we want the persons.
It will return the next persons that should be notified for that call based on:

  • lower group number first
  • random within group numbers
  • no duplicates
  • if the call is young_only == true, only persons that are "young"
  • only persons that have not yet been notified

All this criteria are tested in the unit test for that function:

func TestBridge_GetNextPersonsForCall(t *testing.T) {

The test is still failing since I'm working on it and will be merged when it passes. When the test passes, we know it does what we want.

We currently have 4 testcases for the function:

backend-go/bridge_test.go

Lines 418 to 421 in cd12450

{"Call without age restriction, 5/11 persons", 5, 0, false},
{"Call without age restriction, 20/11 persons", 20, 0, false},
{"Call with age restriction, 5/11 persons", 5, 1, false},
{"Call with age restriction, 20/11 persons", 20, 1, false},

They will all return an array of persons, chosen from this database: https://github.com/impfbruecke/backend-go/blob/add-tests-3/testdata/fixtures/persons_selectnext.yml . I think that should cover all of the logic

@manuliner
Copy link
Contributor

manuliner commented Feb 15, 2021

the reason ist, that the this is only one criteria for one case. What if there is a study which result in legal vaccination of asta for 65 + persons. Then our vaccine algorihtum doesen work, because it is hardcoded. If if we attach the allowed vaccines to the persons, we can change it via sql

@manuliner
Copy link
Contributor

the reason for putting it in the users table is, if there are different user, i could be possible that they don't have all vacccines available.

i am thinking of some kind of parameters sets attached to each vaccine which will describe the criteteria if a person is allowed to get this vaccine

e..g current criteria
Biontech/Moderna -> import via SMS
Astra -> import via backend

@pinpox
Copy link
Member Author

pinpox commented Feb 15, 2021

We can't cover all possible legislative changes anyway. Let's worry about changes when they occur, for now this is the algorithm and I'd try to get it working as it is and worry about future problems when they come. In case the legislation changes, we will have to change the logic anyway. If you want a more general approach, we could save the person's age as a number instead of only the "young/old" marker. Atm we would have no benefits though and only added complexity for possible further legislative changes that might or might not arrive.

If you expect that many changes in the process, I'll just add a field age in the persons (not users) table and you can add an age restriction for the newCall ui

The data-model currently ties a vaccine to a call. So each call will be marked with the vaccine or vaccine type it is for, selection will be done by the function mentioned above on the criteria specified.

@manuliner
Copy link
Contributor

age will be mandatory info at import

i will add the corresponding form fields

for newCall i will add the form field maxAge, minAge for each vaccine and fill them with data

MAX maxAge will be 200

@pinpox
Copy link
Member Author

pinpox commented Feb 15, 2021

Todos & plan of action from our last call:

  • We add age to the persons table, replacing young/old
  • We add ageMin and ageMax to the call DB, specifying the allowed rang
  • We add the necessary inputs in the GUI

@pinpox pinpox mentioned this issue Feb 15, 2021
3 tasks
@pinpox pinpox changed the title Add radio box to frontend for young_only (vaccine type) Add age input in newCall GUI Feb 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants