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