package Ġorg . simple . clin ic . contact patient Ċ Ċ import Ġcom . spotify . mob ius . rx 2 . Rx Mob ius Ċ import Ġdagger . ass isted . Ass isted Ċ import Ġdagger . ass isted . Ass isted Factory Ċ import Ġdagger . ass isted . Ass isted Inject Ċ import Ġio . reactivex . Observable Transformer Ċ import Ġio . reactivex . Scheduler Ċ import Ġorg . simple . clin ic . over due . Appointment Cancel Reason Ċ import Ġorg . simple . clin ic . over due . Appointment Repository Ċ import Ġorg . simple . clin ic . patient . Patient Repository Ċ import Ġorg . simple . clin ic . phone . Dial er Ċ import Ġorg . simple . clin ic . util . User Clock Ċ import Ġorg . simple . clin ic . util . filter And Un wrap Just Ċ import Ġorg . simple . clin ic . util . scheduler . Schedulers Provider Ċ import Ġjava . time . LocalDate Ċ Ċ class ĠContact Patient Effect Handler Ġ@ Ass isted Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġpatient Repository : ĠPatient Repository , ĊĠĠĠ Ġprivate Ġval Ġappointment Repository : ĠAppointment Repository , ĊĠĠĠ Ġprivate Ġval Ġclock : ĠUser Clock , ĊĠĠĠ Ġprivate Ġval Ġs chedulers : ĠS chedulers Provider , ĊĠĠĠ Ġ@ Ass isted Ġprivate Ġval Ġui Actions : ĠContact Patient Ui Actions Ċ ) Ġ{ ĊĊĠ Ġ@ Ass isted Factory ĊĠ Ġinterface ĠFactory Ġ{ ĊĠĠĠ Ġfun Ġcreate ( ui Actions : ĠContact Patient Ui Actions ): ĠContact Patient Effect Handler ĊĠ Ġ} ĊĊĠ Ġfun Ġbuild (): ĠObservable Transformer < Contact Patient Effect , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠRx Mob ius ĊĠĠĠĠĠĠĠ Ġ. subtype Effect Handler < Contact Patient Effect , ĠContact Patient Event >() ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Load Patient Profile :: class . java , Ġload Patient Profile ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Load Latest Over due Appointment :: class . java , Ġload Latest Over due Appointment ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Consumer ( Direct Call With Automatic Dial er :: class . java , Ġ{ Ġui Actions . direct ly Call Patient ( it . patient PhoneNumber , ĠD ial er . Automatic ) Ġ}, Ġs chedulers . ui ()) ĊĠĠĠĠĠĠĠ Ġ. add Consumer ( Direct Call With Manual Dial er :: class . java , Ġ{ Ġui Actions . direct ly Call Patient ( it . patient PhoneNumber , ĠD ial er . Manual ) Ġ}, Ġs chedulers . ui ()) ĊĠĠĠĠĠĠĠ Ġ. add Consumer ( Mask ed Call With Automatic Dial er :: class . java , Ġ{ Ġui Actions . masked Call Patient ( it . patient PhoneNumber , Ġit . proxy PhoneNumber , ĠD ial er . Automatic ) Ġ}, Ġs chedulers . ui ()) ĊĠĠĠĠĠĠĠ Ġ. add Consumer ( Mask ed Call With Manual Dial er :: class . java , Ġ{ Ġui Actions . masked Call Patient ( it . patient PhoneNumber , Ġit . proxy PhoneNumber , ĠD ial er . Manual ) Ġ}, Ġs chedulers . ui ()) ĊĠĠĠĠĠĠĠ Ġ. addAction ( Close Screen :: class . java , Ġui Actions :: close Sheet , Ġs chedulers . ui ()) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Mark Patient As Ag reed To Visit :: class . java , Ġmark Patient As Ag reed To Visit ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Consumer ( Show Manual DatePicker :: class . java , Ġ{ Ġui Actions . show Manual DatePicker ( it . pre selected Date , Ġit . date Picker Bounds ) Ġ}, Ġs chedulers . ui ()) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Set Reminder For Appointment :: class . java , Ġset Reminder For Appointment ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Mark Patient As Vis ited :: class . java , Ġmark Patient As Vis ited ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Mark Patient As Dead :: class . java , Ġmark Patient As Dead ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Cancel Appointment :: class . java , Ġcancel Appointment ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Mark Patient As Moved To Private :: class . java , Ġmark Patient As Moved To Private ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. add Transformer ( Mark Patient As Transfer red To Another Facility :: class . java , Ġmark Patient As Moved To Public ( schedul ers . io ())) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmark Patient As Moved To Public ( scheduler : ĠScheduler ): ĠObservable Transformer < Mark Patient As Transfer red To Another Facility , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġpatient Repository . update Patient Status To Migr ated ( patient Uuid Ġ= Ġit . patient Uuid ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠAppointment Cancel Reason . Transfer red To Another Public Ho spital Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map (:: Patient Mark As Migr ated ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmark Patient As Moved To Private ( scheduler : ĠScheduler ): ĠObservable Transformer < Mark Patient As Moved To Private , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġpatient Repository . update Patient Status To Migr ated ( patient Uuid Ġ= Ġit . patient Uuid ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠAppointment Cancel Reason . Moved To Private Pract itioner Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map (:: Patient Mark As Migr ated ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġload Patient Profile ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Load Patient Profile , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġpatient Repository . patient Profile Immediate ( it . patient Uuid ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. filter And Un wrap Just () ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit . without Deleted Phone Numbers (). without Deleted Business Ids () Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map (:: Patient Profile Loaded ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġload Latest Over due Appointment ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Load Latest Over due Appointment , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġappointment Repository . latest Over due Appointment For Patient ( it . patient Uuid , ĠLocalDate . now ( clock )) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map (:: Over due Appointment Loaded ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmark Patient As Ag reed To Visit ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Mark Patient As Ag reed To Visit , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġappointment Repository . mark As Ag reed To Visit ( it . appointment Uuid , Ġclock ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠPatient Marked As Ag reed To Visit Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġset Reminder For Appointment ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Set Reminder For Appointment , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġ( appointment Uuid , Ġreminder Date ) Ġ-> Ġappointment Repository . create Reminder ( appointment Uuid , Ġreminder Date ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠRem inder Set For Appointment Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmark Patient As Vis ited ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Mark Patient As Vis ited , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġappointment Repository . mark As Already Vis ited ( it . appointment Uuid ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠPatient Marked As Vis ited Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmark Patient As Dead ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Mark Patient As Dead , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġpatient Repository . update Patient Status To Dead ( it . patient Uuid ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġappointment Repository . cancel With Reason ( it . appointment Uuid , ĠAppointment Cancel Reason . Dead ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠPatient Marked As Dead Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcancel Appointment ( ĊĠĠĠĠĠ Ġscheduler : ĠScheduler ĊĠ Ġ): ĠObservable Transformer < Cancel Appointment , ĠContact Patient Event > Ġ{ ĊĠĠĠ Ġreturn ĠObservable Transformer Ġ{ Ġeffects Ġ-> ĊĠĠĠĠĠ Ġeffects ĊĠĠĠĠĠĠĠĠĠ Ġ. observe On ( scheduler ) ĊĠĠĠĠĠĠĠĠĠ Ġ. do On Next Ġ{ Ġappointment Repository . cancel With Reason ( it . appointment Uuid , Ġit . reason ) Ġ} ĊĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĠAppointment Marked As Cancelled Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ