Skip to content

Commit

Permalink
Stocke tous les choix pour la question sur la vaccination
Browse files Browse the repository at this point in the history
Cela permet de pré-remplir correctement la réponse lorsque l’on revient sur
la question, et ouvre la porte à des conseils différenciés à l’avenir.
  • Loading branch information
ronnix committed Apr 21, 2021
1 parent f0f1da4 commit ff93f96
Show file tree
Hide file tree
Showing 20 changed files with 169 additions and 141 deletions.
12 changes: 9 additions & 3 deletions contenus/réponses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ Vous n’avez <b>jamais</b> eu la Covid (<a href="#historique">modifier</a>)



## [reponse_vaccins_deja_vaccine.md](reponse_vaccins_deja_vaccine.md)
## [reponse_vaccins_completement.md](reponse_vaccins_completement.md)

Vous avez <b>déjà</b> été vacciné·e (<a href="#vaccins">modifier</a>)
Vous avez <b>déjà</b> été complètement vacciné·e (<a href="#vaccins">modifier</a>)



## [reponse_vaccins_pas_encore_vaccine.md](reponse_vaccins_pas_encore_vaccine.md)
## [reponse_vaccins_en_cours.md](reponse_vaccins_en_cours.md)

Vous avez <b>déjà</b> été partiellement vacciné·e (<a href="#vaccins">modifier</a>)



## [reponse_vaccins_pas_encore.md](reponse_vaccins_pas_encore.md)

Vous n’avez <b>pas encore</b> été vacciné·e (<a href="#vaccins">modifier</a>)

Expand Down
1 change: 1 addition & 0 deletions contenus/réponses/reponse_vaccins_completement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vous avez <b>déjà</b> été complètement vacciné·e (<a href="#vaccins">modifier</a>)
1 change: 0 additions & 1 deletion contenus/réponses/reponse_vaccins_deja_vaccine.md

This file was deleted.

1 change: 1 addition & 0 deletions contenus/réponses/reponse_vaccins_en_cours.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vous avez <b>déjà</b> été partiellement vacciné·e (<a href="#vaccins">modifier</a>)
66 changes: 42 additions & 24 deletions src/scripts/algorithme/orientation.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,29 +433,19 @@ export default class AlgorithmeOrientation {
}

vaccinBlockNamesToDisplay() {
const blockNames = []
function displayConseilsPersonnels(profil, algoOrientation) {
const algoVaccination = new AlgorithmeVaccination(profil, algoOrientation)
if (algoVaccination.isProfessionnelDeSante()) {
blockNames.push('conseils-vaccins-activite-pro-sante')
} else if (algoVaccination.isSup60()) {
blockNames.push('conseils-vaccins-60-ans')
} else if (algoVaccination.isARisque()) {
if (algoVaccination.isTresHautRisque()) {
blockNames.push('conseils-vaccins-tres-haut-risque')
} else if (algoVaccination.isSup50()) {
blockNames.push('conseils-vaccins-50-ans-a-risque')
} else {
blockNames.push('conseils-vaccins-demande-medecin')
}
}
}
if (this.profil.vaccins) {
blockNames.push('reponse-vaccins-deja-vaccine')
blockNames.push('conseils-vaccins-deja-vaccine')
let blockNames = []

// Rappel de la réponse sur la vaccination.
if (this.profil.vaccins === 'completement') {
blockNames.push('reponse-vaccins-completement')
} else if (this.profil.vaccins === 'en_cours') {
blockNames.push('reponse-vaccins-en-cours')
} else {
blockNames.push('reponse-vaccins-pas-encore-vaccine')
blockNames.push('conseils-vaccins-pas-encore-vaccine')
blockNames.push('reponse-vaccins-pas-encore')
}

// Rappel de la réponse sur la Covid passée.
if (this.profil.vaccins !== 'completement') {
if (this.profil.covid_passee) {
if (this.profil.hasCovidPlus6Mois()) {
blockNames.push('reponse-historique-6-mois-plus')
Expand All @@ -467,22 +457,50 @@ export default class AlgorithmeOrientation {
} else {
blockNames.push('reponse-historique-sans')
}
}

// Conseils personnalisés.
const algoVaccination = new AlgorithmeVaccination(this.profil, this)

if (algoVaccination.isCompletementVaccine()) {
blockNames.push('conseils-vaccins-deja-vaccine')
} else {
blockNames.push('conseils-vaccins-pas-encore-vaccine')
if (this.profil.covid_passee) {
if (this.profil.hasCovidPlus6Mois()) {
blockNames.push('conseils-vaccins-6-mois-plus')
displayConseilsPersonnels(this.profil, this)
blockNames = blockNames.concat(
this._conseilsVaccins(algoVaccination)
)
} else if (this.profil.hasCovidPlus3Mois()) {
blockNames.push('conseils-vaccins-3-6-mois')
} else {
blockNames.push('conseils-vaccins-3-mois-moins')
}
} else {
displayConseilsPersonnels(this.profil, this)
blockNames = blockNames.concat(this._conseilsVaccins(algoVaccination))
}
}
return blockNames
}

_conseilsVaccins(algoVaccination) {
if (algoVaccination.isProfessionnelDeSante()) {
return ['conseils-vaccins-activite-pro-sante']
} else if (algoVaccination.isSup60()) {
return ['conseils-vaccins-60-ans']
} else if (algoVaccination.isARisque()) {
if (algoVaccination.isTresHautRisque()) {
return ['conseils-vaccins-tres-haut-risque']
} else if (algoVaccination.isSup50()) {
return ['conseils-vaccins-50-ans-a-risque']
} else {
return ['conseils-vaccins-demande-medecin']
}
}
return []
}

gestesBarriereBlockNamesToDisplay() {
const blockNames = ['conseils-gestes-barrieres-masque']
if (this.personneFragile) {
Expand Down
4 changes: 4 additions & 0 deletions src/scripts/algorithme/vaccination.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class AlgorithmeVaccination {
)
}

isCompletementVaccine() {
return this.profil.vaccins === 'completement'
}

isVaccinable() {
return (
this.isSup60() ||
Expand Down
12 changes: 8 additions & 4 deletions src/scripts/page/questionnaire/vaccins.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { createEvent, toggleFormButtonOnRadioRequired } from '../../formutils'
import {
createEvent,
getRadioValue,
toggleFormButtonOnRadioRequired,
} from '../../formutils'

export default function vaccins(form, app) {
premierDemarrageFormulaire(app)

// Remplir le formulaire avec les données du profil.
if (app.profil.vaccins) {
form.querySelector('#vaccins_radio_completement').checked = true
if (typeof app.profil.vaccins !== 'undefined') {
form.querySelector('#vaccins_radio_' + app.profil.vaccins).checked = true
// L’indice n’est pas significatif, on veut que l’évènement soit
// envoyé pour n’importe laquelle des options.
form['vaccins_radio'][0].dispatchEvent(createEvent('change'))
Expand All @@ -20,7 +24,7 @@ export default function vaccins(form, app) {
form.addEventListener('submit', (event) => {
event.preventDefault()
const form = event.target
app.profil.vaccins = form.elements['vaccins_radio'].value === 'completement'
app.profil.vaccins = getRadioValue(form, 'vaccins_radio')

app.enregistrerProfilActuel().then(() => {
app.goToNextPage('vaccins')
Expand Down
8 changes: 6 additions & 2 deletions src/scripts/profil.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ export default class Profil {
this.depistage_variante = data['depistage_variante']
this._depistage_start_date = data['_depistage_start_date']

this.vaccins = data['vaccins']
if (typeof data['vaccins'] === 'boolean') {
this.vaccins = data['vaccins'] ? 'completement' : 'pas_encore'
} else {
this.vaccins = data['vaccins']
}

this.covid_passee = data['covid_passee']
this._covid_passee_date = data['_covid_passee_date']
Expand Down Expand Up @@ -343,7 +347,7 @@ export default class Profil {
depistage_type: '',
depistage_resultat: '',
depistage_variante: 'aucune',
vaccins: false,
vaccins: 'pas_encore',
covid_passee: false,
departement: '34',
activite_pro: false,
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function createProfil({
depistage_resultat = '',
depistage_variante = undefined,
_depistage_start_date = undefined,
vaccins = false,
vaccins = 'pas_encore',
covid_passee = false,
_covid_passee_date = undefined,
departement = '34',
Expand Down
24 changes: 5 additions & 19 deletions src/scripts/tests/integration/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,12 @@ async function remplirDepistage(page, depistage, date, type, resultat) {
}

async function remplirVaccins(page, vaccins) {
let text
let radio_label

if (vaccins) {
radio_label = await page.waitForSelector(
'#page.ready label[for="vaccins_radio_completement"]'
)
await radio_label.click()

text = '"Continuer"'
} else {
radio_label = await page.waitForSelector(
'#page.ready label[for="vaccins_radio_pas_encore"]'
)
await radio_label.click()

text = '"Continuer"'
}
let radio_label = await page.waitForSelector(
`#page.ready label[for="vaccins_radio_${vaccins}"]`
)
await radio_label.click()

let bouton = await page.waitForSelector(`#page.ready >> text=${text}`)
let bouton = await page.waitForSelector(`#page.ready >> text="Continuer"`)
await Promise.all([
bouton.click(),
page.waitForNavigation({ url: `**/#historique` }),
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/tests/integration/test.pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Pages', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
depistage: false,
symptomesActuels: [],
symptomesPasses: false,
Expand Down
18 changes: 10 additions & 8 deletions src/scripts/tests/integration/test.parcours.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: ['temperature'],
debutSymptomes: 'aujourdhui',
depistage: false,
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: ['souffle'],
debutSymptomes: 'aujourdhui',
depistage: false,
Expand Down Expand Up @@ -198,7 +198,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: true,
debutSymptomes: 'hier',
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: ['contact_direct'],
Expand Down Expand Up @@ -288,6 +288,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -338,6 +339,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -388,7 +390,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -441,7 +443,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -492,7 +494,7 @@ describe('Parcours', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/tests/integration/test.plausible.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Plausible', function () {
])

await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Plausible', function () {

await remplirQuestionnaire(page, {
nom: 'Mamie',
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Plausible', function () {
page.waitForNavigation({ url: '**/#vaccins' }),
])
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('Plausible', function () {
await Promise.all([bouton.click(), page.waitForNavigation({ url: '**/#nom' })])
await remplirQuestionnaire(page, {
nom: 'Papy',
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/tests/integration/test.profils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Profils', function () {

// Remplir le questionnaire.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: [],
symptomesPasses: false,
contactARisque: [],
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/tests/integration/test.suivi.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Suivi', function () {

// Remplir le questionnaire avec symptômes actuels.
await remplirQuestionnaire(page, {
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: ['temperature'],
debutSymptomes: 'aujourdhui',
depistage: false,
Expand Down Expand Up @@ -243,7 +243,7 @@ describe('Suivi', function () {
// Remplir le questionnaire avec symptômes actuels.
await remplirQuestionnaire(page, {
nom: 'Mamie',
vaccins: false,
vaccins: 'pas_encore',
symptomesActuels: ['temperature'],
debutSymptomes: 'aujourdhui',
depistage: false,
Expand Down
Loading

0 comments on commit ff93f96

Please sign in to comment.