@@ -303,6 +303,31 @@ module.exports = router => {
303303
304304 } )
305305
306+ router . post ( '/vaccinate/answer-eligibility' , ( req , res ) => {
307+ const data = req . session . data
308+
309+ let nextPage ;
310+
311+ if ( data . patientName && data . patientName != "" && data . repeatPatient === "yes" ) {
312+
313+ if ( data . vaccine === "Pertussis" || ( ( data . vaccine == "RSV" ) && ( data . eligibility === "Pregnant" ) ) ) {
314+ nextPage = "/vaccinate/patient-estimated-due-date"
315+ } else {
316+ nextPage = "/vaccinate/consent"
317+ }
318+
319+ } else {
320+
321+ if ( ( data . vaccine === "COVID-19" ) || ( data . vaccine == "Flu" ) ) {
322+ nextPage = "/vaccinate/location"
323+ } else {
324+ nextPage = "/vaccinate/patient"
325+ }
326+ }
327+
328+ res . redirect ( nextPage )
329+ } )
330+
306331 // Routing page after DONE
307332 router . post ( '/vaccinate/what-next' , ( req , res ) => {
308333
@@ -334,6 +359,7 @@ module.exports = router => {
334359 req . session . data . vaccine = ""
335360 req . session . data . vaccineProduct = ""
336361 req . session . data . vaccineBatch = ""
362+ req . session . data . eligibility = ""
337363
338364 res . redirect ( '/vaccinate/vaccine?repeatPatient=yes&repeatVaccination=no' )
339365
@@ -354,11 +380,12 @@ module.exports = router => {
354380
355381 if ( vaccineBatch === "add-new" ) {
356382 redirectPath = "/vaccinate/add-batch"
357- } else if ( vaccine === "Pertussis" ) {
358- redirectPath = "/vaccinate/patient"
359- } else {
360- // RSV, Covid or Flu
383+ } else if ( [ "COVID-19" , "Flu" , "RSV" ] . includes ( data . vaccine ) ) {
361384 redirectPath = "/vaccinate/eligibility"
385+ } else if ( data . repeatPatient === "yes" ) {
386+ redirectPath = "/vaccinate/patient-estimated-due-date"
387+ } else {
388+ redirectPath = "/vaccinate/patient"
362389 }
363390 res . redirect ( redirectPath )
364391 } )
0 commit comments