#   C 1 3   l i v e   w a l k   a g a i n s t   t h e   r u n n i n g   d e v   s e r v e r   ( 1 2 7 . 0 . 0 . 1 : 8 0 1 0 ) . 
 
 # 
 
 #   R e p l a y s   t h e   r e a l   s i g n - i n   ( P O S T   / l o g i n   +   M F A   v e r i f y )   f o r   a   d o c t o r ,   f r o n t d e s k , 
 
 #   a n d   a d m i n ,   t h e n   d r i v e s   t h e   f e e d b a c k / c o m p l a i n t s   s u r f a c e   o v e r   H T T P : 
 
 # 
 
 #   -   a   c l i n i c i a n   s u b m i t s   a   f e e d b a c k   i t e m   ( t y p e :   f e e d b a c k / c o n c e r n / c o m p l a i n t ) 
 
 #   -   t h e   i t e m   a p p e a r s   i n   t h e   i n b o x / l i s t 
 
 #   -   t h e   a s s i g n e d   o w n e r   c a n   m a r k   i t   i n   p r o g r e s s ,   r e s o l v e d ,   c l o s e d 
 
 #   -   a   n o n - o w n e r   c a n n o t   c h a n g e   t h e   s t a t u s 
 
 #   -   t h e   c l i n i c a l - a f f i n i t y   f l a g   i s   v i s i b l e 
 
 #   -   f e e d b a c k / c o m p l a i n t s   n e v e r   s i l e n t l y   a l t e r   s i g n e d   c l i n i c a l   r e c o r d s 
 
 # 
 
 #   R u n   a g a i n s t   t h e   s e e d e d   d e v   d a t a b a s e .   N o   r e a l   n o t i f i c a t i o n s   a r e   s e n t . 
 
 # 
 
 #   U s a g e :   p h p   s c r i p t s / w a l k - c 1 3 . p h p 
 
 # 
 
 
 
 r e q u i r e   _ _ D I R _ _ . ' / . . / v e n d o r / a u t o l o a d . p h p ' ; 
 
 $ a p p   =   r e q u i r e   _ _ D I R _ _ . ' / . . / b o o t s t r a p / a p p . p h p ' ; 
 
 $ a p p - > m a k e ( \ I l l u m i n a t e \ C o n t r a c t s \ C o n s o l e \ K e r n e l : : c l a s s ) - > b o o t s t r a p ( ) ; 
 
 
 
 u s e   A p p \ M o d e l s \ F e e d b a c k C o m p l a i n t ; 
 
 u s e   A p p \ M o d e l s \ U s e r ; 
 
 u s e   G u z z l e H t t p \ C l i e n t ; 
 
 u s e   G u z z l e H t t p \ C o o k i e \ C o o k i e J a r ; 
 
 u s e   P s r \ H t t p \ M e s s a g e \ R e s p o n s e I n t e r f a c e ; 
 
 
 
 c o n s t   B A S E   =   ' h t t p : / / 1 2 7 . 0 . 0 . 1 : 8 0 1 0 ' ; 
 
 c o n s t   P A S S W O R D   =   ' B i t m e d D e m o 2 0 2 6 ! ' ; 
 
 c o n s t   M F A _ C O D E _ D O C T O R   =   ' 1 2 3 4 5 6 ' ;       / /   d e t e r m i n i s t i c   d e m o   M F A 
 
 c o n s t   M F A _ C O D E _ N U R S E   =   ' 6 5 4 3 2 1 ' ; 
 
 
 
 $ f a i l u r e s   =   0 ; 
 
 
 
 f u n c t i o n   c h e c k ( s t r i n g   $ l a b e l ,   b o o l   $ o k ) :   v o i d 
 
 { 
 
         g l o b a l   $ f a i l u r e s ; 
 
         i f   ( !   $ o k )   { 
 
                 $ f a i l u r e s + + ; 
 
         } 
 
         e c h o   '         ' . s t r _ p a d ( $ l a b e l ,   7 8 ) . ( $ o k   ?   ' O K '   :   ' F A I L ' ) . P H P _ E O L ; 
 
 } 
 
 
 
 f u n c t i o n   c l i e n t ( ) :   C l i e n t 
 
 { 
 
         r e t u r n   n e w   C l i e n t ( [ 
 
                 ' b a s e _ u r i '   = >   B A S E , 
 
                 ' c o o k i e s '   = >   n e w   C o o k i e J a r , 
 
                 ' h t t p _ e r r o r s '   = >   f a l s e , 
 
                 ' a l l o w _ r e d i r e c t s '   = >   f a l s e , 
 
                 ' t i m e o u t '   = >   2 0 , 
 
         ] ) ; 
 
 } 
 
 
 
 f u n c t i o n   f o l l o w ( C l i e n t   $ c ,   R e s p o n s e I n t e r f a c e   $ r ,   s t r i n g   $ l a b e l ,   s t r i n g   $ f r o m U r i ) :   a r r a y 
 
 { 
 
         $ u r i   =   $ f r o m U r i ; 
 
         $ h o p s   =   0 ; 
 
         w h i l e   ( $ r - > g e t S t a t u s C o d e ( )   > =   3 0 0   & &   $ r - > g e t S t a t u s C o d e ( )   <   4 0 0   & &   $ h o p s   <   1 0 )   { 
 
                 $ l o c a t i o n   =   $ r - > g e t H e a d e r L i n e ( ' L o c a t i o n ' ) ; 
 
                 i f   ( $ l o c a t i o n   = = =   ' ' )   {   b r e a k ;   } 
 
                 $ u r i   =   s t r _ s t a r t s _ w i t h ( $ l o c a t i o n ,   ' h t t p ' )   ?   $ l o c a t i o n   :   B A S E . $ l o c a t i o n ; 
 
                 $ r   =   $ c - > g e t ( $ l o c a t i o n ) ; 
 
                 $ h o p s + + ; 
 
         } 
 
         e c h o   "         { $ l a b e l } :   f i n a l   { $ r - > g e t S t a t u s C o d e ( ) }   " . s u b s t r ( $ u r i ,   0 ,   1 0 0 ) . P H P _ E O L ; 
 
         r e t u r n   [ $ r ,   $ u r i ] ; 
 
 } 
 
 
 
 f u n c t i o n   t o k e n ( C l i e n t   $ c ,   s t r i n g   $ p a t h ) :   s t r i n g 
 
 { 
 
         $ r   =   $ c - > g e t ( $ p a t h ) ; 
 
         i f   ( !   p r e g _ m a t c h ( ' / n a m e = \ " _ t o k e n \ "   v a l u e = \ " ( [ ^ \ " ] + ) \ " / ' ,   ( s t r i n g )   $ r - > g e t B o d y ( ) ,   $ m ) )   { 
 
                 t h r o w   n e w   R u n t i m e E x c e p t i o n ( " n o   c s r f   t o k e n   a t   { $ p a t h }   ( s t a t u s   { $ r - > g e t S t a t u s C o d e ( ) } ) " ) ; 
 
         } 
 
         r e t u r n   $ m [ 1 ] ; 
 
 } 
 
 
 
 f u n c t i o n   l o g i n ( s t r i n g   $ e m a i l ,   s t r i n g   $ m f a C o d e ) :   C l i e n t 
 
 { 
 
         $ c   =   c l i e n t ( ) ; 
 
         $ r   =   $ c - > p o s t ( ' / l o g i n ' ,   [ ' f o r m _ p a r a m s '   = >   [ 
 
                 ' _ t o k e n '   = >   t o k e n ( $ c ,   ' / l o g i n ' ) , 
 
                 ' e m a i l '   = >   $ e m a i l , 
 
                 ' p a s s w o r d '   = >   P A S S W O R D , 
 
         ] ] ) ; 
 
         [ $ r ,   $ u r i ]   =   f o l l o w ( $ c ,   $ r ,   " l o g i n   { $ e m a i l } " ,   B A S E . ' / l o g i n ' ) ; 
 
         i f   ( s t r _ c o n t a i n s ( $ u r i ,   ' m f a ' ) )   { 
 
                 $ r   =   $ c - > p o s t ( ' / m f a / v e r i f y ' ,   [ ' f o r m _ p a r a m s '   = >   [ ' _ t o k e n '   = >   t o k e n ( $ c ,   $ u r i ) ,   ' c o d e '   = >   $ m f a C o d e ] ] ) ; 
 
                 [ $ r ,   $ u r i ]   =   f o l l o w ( $ c ,   $ r ,   " m f a   { $ e m a i l } " ,   $ u r i ) ; 
 
         } 
 
         i f   ( s t r _ c o n t a i n s ( $ u r i ,   ' l o g i n ' ) )   { 
 
                 t h r o w   n e w   R u n t i m e E x c e p t i o n ( " l o g i n   d i d   n o t   c o m p l e t e   f o r   { $ e m a i l } " ) ; 
 
         } 
 
         r e t u r n   $ c ; 
 
 } 
 
 
 
 f u n c t i o n   f e t c h ( C l i e n t   $ c ,   s t r i n g   $ p a t h ,   i n t   $ e x p e c t e d ) :   s t r i n g 
 
 { 
 
         $ r   =   $ c - > g e t ( $ p a t h ) ; 
 
         $ b o d y   =   ( s t r i n g )   $ r - > g e t B o d y ( ) ; 
 
         c h e c k ( ' G E T   ' . $ p a t h . '   - >   ' . $ r - > g e t S t a t u s C o d e ( ) . '   ( ' . $ e x p e c t e d . '   e x p e c t e d ) ' ,   $ r - > g e t S t a t u s C o d e ( )   = = =   $ e x p e c t e d ) ; 
 
         r e t u r n   $ b o d y ; 
 
 } 
 
 
 
 / /   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 / /   P r e c o n d i t i o n s :   t h e   a c c o u n t s   t h i s   w a l k   n a m e s   m u s t   e x i s t . 
 
 / /   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
 $ d o c t o r   =   U s e r : : w i t h o u t T e n a n t S c o p e ( ) - > w h e r e ( ' e m a i l ' ,   ' d o c t o r @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ) - > f i r s t ( ) ; 
 
 $ f r o n t d e s k   =   U s e r : : w i t h o u t T e n a n t S c o p e ( ) - > w h e r e ( ' e m a i l ' ,   ' f r o n t d e s k @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ) - > f i r s t ( ) ; 
 
 $ a d m i n   =   U s e r : : w i t h o u t T e n a n t S c o p e ( ) - > w h e r e ( ' e m a i l ' ,   ' t e n a n t _ a d m i n @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ) - > f i r s t ( ) ; 
 
 
 
 i f   ( !   $ d o c t o r   | |   !   $ f r o n t d e s k   | |   !   $ a d m i n )   { 
 
         t h r o w   n e w   R u n t i m e E x c e p t i o n ( ' T h i s   w a l k   e x p e c t s   t h e   s e e d e d   d e m o   a c c o u n t s   ( d o c t o r @ ,   f r o n t d e s k @ ,   t e n a n t _ a d m i n @ ) . ' ) ; 
 
 } 
 
 
 
 $ f a i l u r e s   =   0 ; 
 
 
 
 e c h o   ' - - -   s t e p   1 :   d o c t o r   s u b m i t s   a   f e e d b a c k   i t e m ' . P H P _ E O L ; 
 
 $ d o c t o r C l i e n t   =   l o g i n ( ' d o c t o r @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ,   M F A _ C O D E _ D O C T O R ) ; 
 
 $ b o d y   =   f e t c h ( $ d o c t o r C l i e n t ,   ' / f e e d b a c k ' ,   2 0 0 ) ; 
 
 c h e c k ( ' f e e d b a c k   l i s t   s h o w s   f o r m ' ,   s t r _ c o n t a i n s ( $ b o d y ,   ' S e n d   f e e d b a c k ' ) ) ; 
 
 
 
 $ r   =   $ d o c t o r C l i e n t - > p o s t ( ' / f e e d b a c k ' ,   [ ' f o r m _ p a r a m s '   = >   [ 
 
         ' _ t o k e n '   = >   t o k e n ( $ d o c t o r C l i e n t ,   ' / f e e d b a c k ' ) , 
 
         ' t y p e '   = >   ' f e e d b a c k ' , 
 
         ' s u b j e c t '   = >   ' C l i n i c   h o u r s   f e e d b a c k ' , 
 
         ' b o d y '   = >   ' T h e   w a i t i n g   r o o m   i s   t o o   w a r m . ' , 
 
         ' u s e r _ i d '   = >   $ d o c t o r - > i d , 
 
         ' d e a d l i n e '   = >   d a t e ( ' Y - m - d ' ,   s t r t o t i m e ( ' + 7   d a y s ' ) ) , 
 
 ] ] ) ; 
 
 [ $ r ,   $ u r i ]   =   f o l l o w ( $ d o c t o r C l i e n t ,   $ r ,   ' P O S T   / f e e d b a c k ' ,   B A S E . ' / f e e d b a c k ' ) ; 
 
 c h e c k ( ' f e e d b a c k   s u b m i t   r e d i r e c t s   b a c k ' ,   s t r _ c o n t a i n s ( $ u r i ,   ' / f e e d b a c k ' ) ) ; 
 
 
 
 $ f e e d b a c k   =   F e e d b a c k C o m p l a i n t : : l a t e s t ( ' i d ' ) - > f i r s t ( ) ; 
 
 c h e c k ( ' f e e d b a c k   r o w   w a s   c r e a t e d ' ,   $ f e e d b a c k   ! = =   n u l l ) ; 
 
 $ f e e d b a c k I d   =   ( i n t )   $ f e e d b a c k - > i d ; 
 
 
 
 e c h o   ' - - -   s t e p   2 :   f e e d b a c k   i t e m   a p p e a r s   i n   t h e   l i s t ' . P H P _ E O L ; 
 
 $ b o d y   =   f e t c h ( $ d o c t o r C l i e n t ,   ' / f e e d b a c k ' ,   2 0 0 ) ; 
 
 c h e c k ( ' f e e d b a c k   l i s t   s h o w s   t h e   i t e m ' ,   s t r _ c o n t a i n s ( $ b o d y ,   ' C l i n i c   h o u r s   f e e d b a c k ' ) ) ; 
 
 
 
 e c h o   ' - - -   s t e p   3 :   f r o n t d e s k   c a n   m a r k   i t e m   i n   p r o g r e s s ' . P H P _ E O L ; 
 
 $ f r o n t d e s k C l i e n t   =   l o g i n ( ' f r o n t d e s k @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ,   M F A _ C O D E _ N U R S E ) ; 
 
 $ r   =   $ f r o n t d e s k C l i e n t - > p u t ( " / f e e d b a c k / { $ f e e d b a c k I d } " ,   [ ' f o r m _ p a r a m s '   = >   [ 
 
         ' _ t o k e n '   = >   t o k e n ( $ f r o n t d e s k C l i e n t ,   " / f e e d b a c k / { $ f e e d b a c k I d } " ) , 
 
         ' s t a t u s '   = >   ' i n _ p r o g r e s s ' , 
 
 ] ] ) ; 
 
 [ $ r ,   $ u r i ]   =   f o l l o w ( $ f r o n t d e s k C l i e n t ,   $ r ,   ' P U T   / f e e d b a c k ' ,   B A S E . ' / f e e d b a c k ' ) ; 
 
 c h e c k ( ' i n - p r o g r e s s   r e d i r e c t ' ,   s t r _ c o n t a i n s ( $ u r i ,   " / f e e d b a c k / { $ f e e d b a c k I d } " ) ) ; 
 
 
 
 $ f e e d b a c k R e l o a d   =   F e e d b a c k C o m p l a i n t : : f i n d ( $ f e e d b a c k I d ) ; 
 
 c h e c k ( ' s t a t u s   u p d a t e d   t o   i n _ p r o g r e s s ' ,   $ f e e d b a c k R e l o a d - > s t a t u s   = = =   ' i n _ p r o g r e s s ' ) ; 
 
 
 
 e c h o   ' - - -   s t e p   4 :   a d m i n   c a n   m a r k   i t e m   r e s o l v e d   w i t h   r e s p o n s e ' . P H P _ E O L ; 
 
 $ a d m i n C l i e n t   =   l o g i n ( ' t e n a n t _ a d m i n @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ,   M F A _ C O D E _ N U R S E ) ; 
 
 $ r   =   $ a d m i n C l i e n t - > p u t ( " / f e e d b a c k / { $ f e e d b a c k I d } " ,   [ ' f o r m _ p a r a m s '   = >   [ 
 
         ' _ t o k e n '   = >   t o k e n ( $ a d m i n C l i e n t ,   " / f e e d b a c k / { $ f e e d b a c k I d } " ) , 
 
         ' s t a t u s '   = >   ' r e s o l v e d ' , 
 
         ' r e s p o n s e '   = >   ' W e   h a v e   a d d r e s s e d   y o u r   c o n c e r n   a b o u t   t h e   w a i t i n g   r o o m   t e m p e r a t u r e . ' , 
 
 ] ] ) ; 
 
 [ $ r ,   $ u r i ]   =   f o l l o w ( $ a d m i n C l i e n t ,   $ r ,   ' P U T   / f e e d b a c k ' ,   B A S E . ' / f e e d b a c k ' ) ; 
 
 c h e c k ( ' r e s o l v e d   r e d i r e c t ' ,   s t r _ c o n t a i n s ( $ u r i ,   " / f e e d b a c k / { $ f e e d b a c k I d } " ) ) ; 
 
 
 
 $ f e e d b a c k R e s o l v e d   =   F e e d b a c k C o m p l a i n t : : f i n d ( $ f e e d b a c k I d ) ; 
 
 c h e c k ( ' s t a t u s   u p d a t e d   t o   r e s o l v e d ' ,   $ f e e d b a c k R e s o l v e d - > s t a t u s   = = =   ' r e s o l v e d ' ) ; 
 
 c h e c k ( ' r e s p o n s e   t e x t   s t o r e d ' ,   s t r _ c o n t a i n s ( $ f e e d b a c k R e s o l v e d - > r e s p o n s e ,   ' w a i t i n g   r o o m ' ) ) ; 
 
 
 
 e c h o   ' - - -   s t e p   5 :   d o c t o r   ( n o n - o w n e r )   c a n n o t   m a r k   i t e m   i n   p r o g r e s s ' . P H P _ E O L ; 
 
 $ d o c t o r 2 C l i e n t   =   l o g i n ( ' d o c t o r @ l a g o s f a m i l y c l i n i c . b i t m e d . t e s t ' ,   M F A _ C O D E _ D O C T O R ) ; 
 
 $ r   =   $ d o c t o r 2 C l i e n t - > p u t ( " / f e e d b a c k / { $ f e e d b a c k I d } " ,   [ ' f o r m _ p a r a m s '   = >   [ 
 
         ' _ t o k e n '   = >   t o k e n ( $ d o c t o r 2 C l i e n t ,   " / f e e d b a c k / { $ f e e d b a c k I d } " ) , 
 
         ' s t a t u s '   = >   ' i n _ p r o g r e s s ' , 
 
 ] ] ) ; 
 
 c h e c k ( ' d o c t o r   c a n n o t   c h a n g e   s t a t u s ' ,   $ r - > g e t S t a t u s C o d e ( )   = = =   4 0 3 ) ; 
 
 
 
 e c h o   ' - - -   s t e p   6 :   c l i n i c a l - a f f i n i t y   f l a g   i s   v i s i b l e ' . P H P _ E O L ; 
 
 $ b o d y   =   f e t c h ( $ d o c t o r C l i e n t ,   " / f e e d b a c k / { $ f e e d b a c k I d } / a f f i n i t y " ,   2 0 0 ) ; 
 
 c h e c k ( ' a f f i n i t y   e n d p o i n t   r e t u r n s   J S O N ' ,   s t r _ c o n t a i n s ( $ b o d y ,   ' a f f e c t s _ c l i n i c a l _ r e c o r d ' ) ) ; 
 
 
 
 e c h o   ' - - -   s t e p   7 :   f e e d b a c k   n e v e r   s i l e n t l y   a l t e r s   s i g n e d   c l i n i c a l   r e c o r d s ' . P H P _ E O L ; 
 
 c h e c k ( ' a f f e c t s _ c l i n i c a l _ r e c o r d   d e f a u l t s   t o   f a l s e ' ,   F e e d b a c k C o m p l a i n t : : f i r s t ( ) - > a f f e c t s _ c l i n i c a l _ r e c o r d   = = =   f a l s e ) ; 
 
 
 
 e c h o   P H P _ E O L ; 
 
 i f   ( $ f a i l u r e s   = = =   0 )   { 
 
         e c h o   ' W A L K   P A S S E D :   e v e r y   e x p e c t e d   s t a t u s   a n d   p h r a s e   w a s   f o u n d . ' . P H P _ E O L ; 
 
         e x i t ( 0 ) ; 
 
 } 
 
 e c h o   ' W A L K   F A I L E D :   ' . $ f a i l u r e s . '   c h e c k ( s )   d i d   n o t   h o l d . ' . P H P _ E O L ; 
 
 e x i t ( 1 ) ; 
 
 