- BSDAPI2 ; IHS/ANMC/LJF - PUBLIC API'S THAT LIST APPT DATA; [ 04/14/2003 4:17 PM ]
- ;;5.3;PIMS;;APR 26, 2002
- ;
- ;
- LIST(BSDDT,BSDTYP,BSDCLN,BSDARR) ;PEP; returns list of patient appts for date and clinic
- ;IHS/ITSC/WAR 4/14/03 - P60/WAR19 changed the passing of the 4th
- ; parameter. The parameter should be passed by 'value' (no period
- ; in front of variable) not by 'reference'. Problem occured at
- ; APPTLN()+13^BSDAPI2 (when indirection processed @(X)=LINE).
- ; Bad Call: D LIST^BSDAPI2(DATE,TYPE,.CLINIC,.ARRAY) where
- ; Good Call: D LIST^BSDAPI2(DATE,TYPE,.CLINIC,ARRAY) where
- ;
- ; DATE = Appointment date in FM format
- ;
- ; TYPE contains "W" to include walk-ins; contains "C" to include cancelled appts or set to null for neither
- ;
- ; CLINIC = "ALL" for all clinics with appts on date OR array of clinic internal entry numbers
- ; >> If you set CLINIC=ALL and you have clinics from multiple facilities, you must set CLINIC("DEV")
- ; equal to the internal entry number of Medical Center Division you want used.)
- ; >> Principal clinics can be passed and they will expand to all clinics under them
- ;
- ; ARRAY = array name where you want list returns; can be local or global array
- ; send array ending in ( or , such as S ARRAY="XYZ(" or S ARRAY="^ABC(""XYZ"","
- ; will be subscripted by simple number count (XYZ(1), XYZ(2) or ^ABC("XYZ",1), ^ABC("XYZ",2))
- ; structure: patient DFN ^ Clinic IEN ^ Appt Date/Time ^ Type ^ Length of Appt ^ Other Info
- ;
- ;
- NEW BSDC,VAUTD,BSDCR
- I $G(BSDCLN)="ALL" S VAUTD=$G(CLINIC("DEV")) ;set up division for multi-facilities
- S BSDCR=0 ;don't include chart requests
- ; loop through array of clinics and create list one clinic at a time
- S BSDC=0 F S BSDC=$S($G(BSDCLN)="ALL":$O(^SC(BSDC)),1:$O(BSDCLN(BSDC))) Q:'BSDC D CLINIC
- Q
- ;
- CLINIC ; called for each clinic
- NEW BSD,IEN
- ; check if clinic is active and not cancelled for date
- I $$CHECK(BSDC,BSDDT),$$ACTIVITY^BSDAL2(BSDC,BSDDT) D
- . ;get each appt time for date and clinic
- . S BSD=BSDDT
- . F S BSD=$O(^SC(BSDC,"S",BSD)) Q:'BSD!(BSD\1>BSDDT) D
- .. ; find each appt at date/time then call APPTLN to print info
- .. S IEN=0
- .. F S IEN=$O(^SC(BSDC,"S",BSD,1,IEN)) Q:'IEN D APPTLN(BSDC,BSD,IEN) ;build appt data line
- Q
- ;
- APPTLN(CLN,DATE,IEN) ; -- for each individual appt, build patient data line
- NEW TYPE,DFN,LINE
- S TYPE="S" ;scheduled
- I $P($G(^SC(BSDC,"S",BSD,1,IEN,0)),U,9)="C" S TYPE="C" ;canceled
- S DFN=+$G(^SC(CLN,"S",DATE,1,IEN,0)) Q:'DFN
- I $P($G(^DPT(DFN,"S",DATE,0)),U,2)["C" S TYPE="C" ;canceled
- I BSDTYP'["C",TYPE="C" Q ;quit if canceled not included
- I TYPE="S",$$WALKIN^BSDU2(DFN,DATE) S TYPE="W" ;or a walk-in?
- I TYPE="W",BSDTYP'["W" Q ;quit if walk-ins not included
- ;
- ; -- build data line: patient^clinic^date/time^type^length^other info
- S LINE=DFN_U_CLN_U_DATE_U_TYPE_U_$P($G(^SC(CLN,"S",DATE,1,IEN,0)),U,2)_U_$P($G(^(0)),U,4)
- ; -- set data line into array
- S BSDCNT=$G(BSDCNT)+1,X=BSDARR_BSDCNT_")",@(X)=LINE
- Q
- ;
- CHECK(CLN,APDT) ;check if clinic for this division and not cancelled or inactive
- I $$GET1^DIQ(44,CLN,2,"I")'="C" Q 0 ;not a clinic
- I $G(VAUTD),$$GET1^DIQ(44,CLN,3.5,"I")'=VAUTD Q 0 ;wrong division
- I '$$ACTV^BSDU(CLN,APDT) Q 0 ;not active
- I $G(^SC(CLN,"ST",APDT,1))["**CANCELLED" Q 0 ;cancelled
- Q 1
- BSDAPI2 ; IHS/ANMC/LJF - PUBLIC API'S THAT LIST APPT DATA; [ 04/14/2003 4:17 PM ]
- +1 ;;5.3;PIMS;;APR 26, 2002
- +2 ;
- +3 ;
- LIST(BSDDT,BSDTYP,BSDCLN,BSDARR) ;PEP; returns list of patient appts for date and clinic
- +1 ;IHS/ITSC/WAR 4/14/03 - P60/WAR19 changed the passing of the 4th
- +2 ; parameter. The parameter should be passed by 'value' (no period
- +3 ; in front of variable) not by 'reference'. Problem occured at
- +4 ; APPTLN()+13^BSDAPI2 (when indirection processed @(X)=LINE).
- +5 ; Bad Call: D LIST^BSDAPI2(DATE,TYPE,.CLINIC,.ARRAY) where
- +6 ; Good Call: D LIST^BSDAPI2(DATE,TYPE,.CLINIC,ARRAY) where
- +7 ;
- +8 ; DATE = Appointment date in FM format
- +9 ;
- +10 ; TYPE contains "W" to include walk-ins; contains "C" to include cancelled appts or set to null for neither
- +11 ;
- +12 ; CLINIC = "ALL" for all clinics with appts on date OR array of clinic internal entry numbers
- +13 ; >> If you set CLINIC=ALL and you have clinics from multiple facilities, you must set CLINIC("DEV")
- +14 ; equal to the internal entry number of Medical Center Division you want used.)
- +15 ; >> Principal clinics can be passed and they will expand to all clinics under them
- +16 ;
- +17 ; ARRAY = array name where you want list returns; can be local or global array
- +18 ; send array ending in ( or , such as S ARRAY="XYZ(" or S ARRAY="^ABC(""XYZ"","
- +19 ; will be subscripted by simple number count (XYZ(1), XYZ(2) or ^ABC("XYZ",1), ^ABC("XYZ",2))
- +20 ; structure: patient DFN ^ Clinic IEN ^ Appt Date/Time ^ Type ^ Length of Appt ^ Other Info
- +21 ;
- +22 ;
- +23 NEW BSDC,VAUTD,BSDCR
- +24 ;set up division for multi-facilities
- IF $GET(BSDCLN)="ALL"
- SET VAUTD=$GET(CLINIC("DEV"))
- +25 ;don't include chart requests
- SET BSDCR=0
- +26 ; loop through array of clinics and create list one clinic at a time
- +27 SET BSDC=0
- FOR
- SET BSDC=$SELECT($GET(BSDCLN)="ALL":$ORDER(^SC(BSDC)),1:$ORDER(BSDCLN(BSDC)))
- IF 'BSDC
- QUIT
- DO CLINIC
- +28 QUIT
- +29 ;
- CLINIC ; called for each clinic
- +1 NEW BSD,IEN
- +2 ; check if clinic is active and not cancelled for date
- +3 IF $$CHECK(BSDC,BSDDT)
- IF $$ACTIVITY^BSDAL2(BSDC,BSDDT)
- Begin DoDot:1
- +4 ;get each appt time for date and clinic
- +5 SET BSD=BSDDT
- +6 FOR
- SET BSD=$ORDER(^SC(BSDC,"S",BSD))
- IF 'BSD!(BSD\1>BSDDT)
- QUIT
- Begin DoDot:2
- +7 ; find each appt at date/time then call APPTLN to print info
- +8 SET IEN=0
- +9 ;build appt data line
- FOR
- SET IEN=$ORDER(^SC(BSDC,"S",BSD,1,IEN))
- IF 'IEN
- QUIT
- DO APPTLN(BSDC,BSD,IEN)
- End DoDot:2
- End DoDot:1
- +10 QUIT
- +11 ;
- APPTLN(CLN,DATE,IEN) ; -- for each individual appt, build patient data line
- +1 NEW TYPE,DFN,LINE
- +2 ;scheduled
- SET TYPE="S"
- +3 ;canceled
- IF $PIECE($GET(^SC(BSDC,"S",BSD,1,IEN,0)),U,9)="C"
- SET TYPE="C"
- +4 SET DFN=+$GET(^SC(CLN,"S",DATE,1,IEN,0))
- IF 'DFN
- QUIT
- +5 ;canceled
- IF $PIECE($GET(^DPT(DFN,"S",DATE,0)),U,2)["C"
- SET TYPE="C"
- +6 ;quit if canceled not included
- IF BSDTYP'["C"
- IF TYPE="C"
- QUIT
- +7 ;or a walk-in?
- IF TYPE="S"
- IF $$WALKIN^BSDU2(DFN,DATE)
- SET TYPE="W"
- +8 ;quit if walk-ins not included
- IF TYPE="W"
- IF BSDTYP'["W"
- QUIT
- +9 ;
- +10 ; -- build data line: patient^clinic^date/time^type^length^other info
- +11 SET LINE=DFN_U_CLN_U_DATE_U_TYPE_U_$PIECE($GET(^SC(CLN,"S",DATE,1,IEN,0)),U,2)_U_$PIECE($GET(^(0)),U,4)
- +12 ; -- set data line into array
- +13 SET BSDCNT=$GET(BSDCNT)+1
- SET X=BSDARR_BSDCNT_")"
- SET @(X)=LINE
- +14 QUIT
- +15 ;
- CHECK(CLN,APDT) ;check if clinic for this division and not cancelled or inactive
- +1 ;not a clinic
- IF $$GET1^DIQ(44,CLN,2,"I")'="C"
- QUIT 0
- +2 ;wrong division
- IF $GET(VAUTD)
- IF $$GET1^DIQ(44,CLN,3.5,"I")'=VAUTD
- QUIT 0
- +3 ;not active
- IF '$$ACTV^BSDU(CLN,APDT)
- QUIT 0
- +4 ;cancelled
- IF $GET(^SC(CLN,"ST",APDT,1))["**CANCELLED"
- QUIT 0
- +5 QUIT 1