@@ -82,21 +82,45 @@ const ParticipantInfo = observer(() => {
8282 const rootStore = useContext ( rootStoreContext )
8383 // particiant store derived from root store
8484 const participantStore = rootStore . ParticipantStore
85+ // TODO: refactor after v1.0.0 release
86+ const queueStore = rootStore . QueueStore
8587 // set up history for routing pushes
8688 const history = useHistory ( )
8789 // get existing participant if applicable else its undefined
8890 const existingParticipant = toJS ( participantStore . participant )
8991 // get existing visit if applicable else its undefined
9092 const existingVisit = toJS ( participantStore . visit )
9193 const insurers = toJS ( participantStore . insurers )
92- const programList = toJS ( participantStore . programs )
94+ let programList = toJS ( participantStore . programs )
9395 const serviceList = toJS ( participantStore . services )
9496
97+ // TODO: refactor after v1.0.0 release
98+ if ( existingParticipant . id && ! existingVisit . id ) {
99+ let filterThesePrograms = [ ]
100+ queueStore . participantWithPrograms . forEach ( currentparticipantprograms => {
101+ if ( existingParticipant . id === currentparticipantprograms . id ) {
102+ filterThesePrograms . push ( toJS ( currentparticipantprograms . programs . name ) )
103+ }
104+ } )
105+ if ( programList . length > 0 ) {
106+ programList = programList . filter (
107+ program =>
108+ program . name !==
109+ filterThesePrograms [ filterThesePrograms . indexOf ( program . name ) ]
110+ )
111+ }
112+ }
113+ // -----------------------------------
114+
95115 useEffect ( ( ) => {
96116 // kick off api calls for insurance list from Mobx
97117 participantStore . getInsurers ( )
98118 // kick off api calls for program list from Mobx
99119 participantStore . getPrograms ( )
120+ // TODO: refactor after v1.0.0 release
121+ const queueSize = Object . keys ( queueStore . queues ) . length
122+ for ( let i = 1 ; i <= queueSize ; i ++ ) queueStore . getQueue ( i )
123+ // -----------------------------------
100124 // eslint-disable-next-line react-hooks/exhaustive-deps
101125 } , [ ] )
102126
@@ -110,6 +134,7 @@ const ParticipantInfo = observer(() => {
110134 // if existing participant and no vist we are coming from search, so update particiapnt only
111135 } else if ( existingParticipant . id && ! existingVisit . id ) {
112136 participantStore . updateParticipant ( )
137+ participantStore . createVisit ( )
113138 // otherwise we are adding a new participant because both participant and visit will be undefined
114139 } else {
115140 participantStore . createParticipant ( )
@@ -356,136 +381,133 @@ const ParticipantInfo = observer(() => {
356381 </ div >
357382 </ Grid >
358383
359- { ( ! existingParticipant . id && ! existingVisit . id ) ||
360- ( existingParticipant . id && existingVisit . id ) ? (
361- < div >
362- < Typography
363- style = { { textAlign : "left" } }
364- component = "h5"
365- variant = "h5"
366- gutterBottom
367- >
368- < br />
369- < br />
370- 2. Check In Participant
371- </ Typography >
372- < Grid container >
373- < FormGroup className = "participant-info" >
374- < Grid container >
375- < Grid item xs >
376- < FormControl className = { classes . formControl } >
377- < InputLabel htmlFor = "demo-controlled-open-select" >
378- Choose Program
379- </ InputLabel >
384+ < div >
385+ < Typography
386+ style = { { textAlign : "left" } }
387+ component = "h5"
388+ variant = "h5"
389+ gutterBottom
390+ >
391+ < br />
392+ < br />
393+ 2. Check In Participant
394+ </ Typography >
395+ < Grid container >
396+ < FormGroup className = "participant-info" >
397+ < Grid container >
398+ < Grid item xs >
399+ < FormControl className = { classes . formControl } >
400+ < InputLabel htmlFor = "demo-controlled-open-select" >
401+ Choose Program
402+ </ InputLabel >
403+ < Select
404+ required
405+ value = { existingVisit . program }
406+ onChange = { e => {
407+ participantStore . setVisitProgram ( e . target . value )
408+ findAndSaveServiceListings ( e )
409+ } }
410+ inputProps = { {
411+ name : "program" ,
412+ id : "demo-controlled-open-select" ,
413+ } }
414+ >
415+ { programList . map ( program => (
416+ < MenuItem
417+ key = { program . id }
418+ value = {
419+ programList && programList . length > 0
420+ ? program . id
421+ : ""
422+ }
423+ >
424+ { programList && programList . length > 0
425+ ? program . name
426+ : "" }
427+ </ MenuItem >
428+ ) ) }
429+ </ Select >
430+ </ FormControl >
431+ </ Grid >
432+
433+ < Grid item xs >
434+ < FormControl className = { classes . formControl } >
435+ < InputLabel htmlFor = "demo-controlled-open-select" >
436+ Select Service
437+ </ InputLabel >
438+ { existingVisit . program && serviceList . length > 0 ? (
380439 < Select
381440 required
382- value = { existingVisit . program }
383- onChange = { e => {
384- participantStore . setVisitProgram ( e . target . value )
385- findAndSaveServiceListings ( e )
386- } }
441+ value = { existingVisit . service }
442+ onChange = { e =>
443+ participantStore . setVisitService ( e . target . value )
444+ }
387445 inputProps = { {
388- name : "program " ,
446+ name : "service " ,
389447 id : "demo-controlled-open-select" ,
390448 } }
391449 >
392- { programList . map ( program => (
450+ { serviceList . map ( service => (
393451 < MenuItem
394- key = { program . id }
452+ key = { service . id }
395453 value = {
396- programList && programList . length > 0
397- ? program . id
454+ serviceList && serviceList . length > 0
455+ ? service . id
398456 : ""
399457 }
400458 >
401- { programList && programList . length > 0
402- ? program . name
459+ { serviceList && serviceList . length > 0
460+ ? service . name
403461 : "" }
404462 </ MenuItem >
405463 ) ) }
406464 </ Select >
407- </ FormControl >
408- </ Grid >
409-
410- < Grid item xs >
411- < FormControl className = { classes . formControl } >
412- < InputLabel htmlFor = "demo-controlled-open-select" >
413- Select Service
414- </ InputLabel >
415- { existingVisit . program && serviceList . length > 0 ? (
416- < Select
417- required
418- value = { existingVisit . service }
419- onChange = { e =>
420- participantStore . setVisitService ( e . target . value )
421- }
422- inputProps = { {
423- name : "service" ,
424- id : "demo-controlled-open-select" ,
425- } }
426- >
427- { serviceList . map ( service => (
428- < MenuItem
429- key = { service . id }
430- value = {
431- serviceList && serviceList . length > 0
432- ? service . id
433- : ""
434- }
435- >
436- { serviceList && serviceList . length > 0
437- ? service . name
438- : "" }
439- </ MenuItem >
440- ) ) }
441- </ Select >
442- ) : null }
443- </ FormControl >
444- </ Grid >
445- < br />
446- < Grid item xs >
447- < FormControl className = { classes . formControl } >
448- < InputLabel htmlFor = "demo-controlled-open-select" >
449- Select Priority Level
450- </ InputLabel >
451- < Select
452- value = { existingVisit . urgency }
453- onChange = { e =>
454- participantStore . setVisitUrgency ( e . target . value )
455- }
456- inputProps = { {
457- name : "priorityLevel" ,
458- id : "demo-controlled-open-select" ,
459- } }
460- >
461- < MenuItem value = { "_1" } > 1 (Lowest)</ MenuItem >
462- < MenuItem value = { "_2" } > 2</ MenuItem >
463- < MenuItem value = { "_3" } > 3</ MenuItem >
464- < MenuItem value = { "_4" } > 4</ MenuItem >
465- < MenuItem value = { "_5" } > 5 (Highest)</ MenuItem >
466- </ Select >
467- </ FormControl >
468- </ Grid >
469- < br />
470- < TextField
471- id = "standard-full-width"
472- style = { { margin : 8 , marginTop : 40 } }
473- placeholder = "Add a note"
474- onChange = { e =>
475- participantStore . setVisitNotes ( e . target . value )
476- }
477- value = { existingVisit . notes }
478- fullWidth
479- margin = "normal"
480- InputLabelProps = { {
481- shrink : true ,
482- } }
483- />
465+ ) : null }
466+ </ FormControl >
484467 </ Grid >
485- </ FormGroup >
486- </ Grid >
487- </ div >
488- ) : null }
468+ < br />
469+ < Grid item xs >
470+ < FormControl className = { classes . formControl } >
471+ < InputLabel htmlFor = "demo-controlled-open-select" >
472+ Select Priority Level
473+ </ InputLabel >
474+ < Select
475+ value = { existingVisit . urgency }
476+ onChange = { e =>
477+ participantStore . setVisitUrgency ( e . target . value )
478+ }
479+ inputProps = { {
480+ name : "priorityLevel" ,
481+ id : "demo-controlled-open-select" ,
482+ } }
483+ >
484+ < MenuItem value = { "_1" } > 1 (Lowest)</ MenuItem >
485+ < MenuItem value = { "_2" } > 2</ MenuItem >
486+ < MenuItem value = { "_3" } > 3</ MenuItem >
487+ < MenuItem value = { "_4" } > 4</ MenuItem >
488+ < MenuItem value = { "_5" } > 5 (Highest)</ MenuItem >
489+ </ Select >
490+ </ FormControl >
491+ </ Grid >
492+ < br />
493+ < TextField
494+ id = "standard-full-width"
495+ style = { { margin : 8 , marginTop : 40 } }
496+ placeholder = "Add a note"
497+ onChange = { e =>
498+ participantStore . setVisitNotes ( e . target . value )
499+ }
500+ value = { existingVisit . notes }
501+ fullWidth
502+ margin = "normal"
503+ InputLabelProps = { {
504+ shrink : true ,
505+ } }
506+ />
507+ </ Grid >
508+ </ FormGroup >
509+ </ Grid >
510+ </ div >
489511
490512 < Button
491513 style = { {
0 commit comments