Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BSDAPI2

BSDAPI2.m

Go to the documentation of this file.
  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
  1. ;
  1. ;
  1. 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
  1. ; parameter. The parameter should be passed by 'value' (no period
  1. ; in front of variable) not by 'reference'. Problem occured at
  1. ; APPTLN()+13^BSDAPI2 (when indirection processed @(X)=LINE).
  1. ; Bad Call: D LIST^BSDAPI2(DATE,TYPE,.CLINIC,.ARRAY) where
  1. ; Good Call: D LIST^BSDAPI2(DATE,TYPE,.CLINIC,ARRAY) where
  1. ;
  1. ; DATE = Appointment date in FM format
  1. ;
  1. ; TYPE contains "W" to include walk-ins; contains "C" to include cancelled appts or set to null for neither
  1. ;
  1. ; CLINIC = "ALL" for all clinics with appts on date OR array of clinic internal entry numbers
  1. ; >> If you set CLINIC=ALL and you have clinics from multiple facilities, you must set CLINIC("DEV")
  1. ; equal to the internal entry number of Medical Center Division you want used.)
  1. ; >> Principal clinics can be passed and they will expand to all clinics under them
  1. ;
  1. ; ARRAY = array name where you want list returns; can be local or global array
  1. ; send array ending in ( or , such as S ARRAY="XYZ(" or S ARRAY="^ABC(""XYZ"","
  1. ; will be subscripted by simple number count (XYZ(1), XYZ(2) or ^ABC("XYZ",1), ^ABC("XYZ",2))
  1. ; structure: patient DFN ^ Clinic IEN ^ Appt Date/Time ^ Type ^ Length of Appt ^ Other Info
  1. ;
  1. ;
  1. NEW BSDC,VAUTD,BSDCR
  1. I $G(BSDCLN)="ALL" S VAUTD=$G(CLINIC("DEV")) ;set up division for multi-facilities
  1. S BSDCR=0 ;don't include chart requests
  1. ; loop through array of clinics and create list one clinic at a time
  1. S BSDC=0 F S BSDC=$S($G(BSDCLN)="ALL":$O(^SC(BSDC)),1:$O(BSDCLN(BSDC))) Q:'BSDC D CLINIC
  1. Q
  1. ;
  1. CLINIC ; called for each clinic
  1. NEW BSD,IEN
  1. ; check if clinic is active and not cancelled for date
  1. I $$CHECK(BSDC,BSDDT),$$ACTIVITY^BSDAL2(BSDC,BSDDT) D
  1. . ;get each appt time for date and clinic
  1. . S BSD=BSDDT
  1. . F S BSD=$O(^SC(BSDC,"S",BSD)) Q:'BSD!(BSD\1>BSDDT) D
  1. .. ; find each appt at date/time then call APPTLN to print info
  1. .. S IEN=0
  1. .. F S IEN=$O(^SC(BSDC,"S",BSD,1,IEN)) Q:'IEN D APPTLN(BSDC,BSD,IEN) ;build appt data line
  1. Q
  1. ;
  1. APPTLN(CLN,DATE,IEN) ; -- for each individual appt, build patient data line
  1. NEW TYPE,DFN,LINE
  1. S TYPE="S" ;scheduled
  1. I $P($G(^SC(BSDC,"S",BSD,1,IEN,0)),U,9)="C" S TYPE="C" ;canceled
  1. S DFN=+$G(^SC(CLN,"S",DATE,1,IEN,0)) Q:'DFN
  1. I $P($G(^DPT(DFN,"S",DATE,0)),U,2)["C" S TYPE="C" ;canceled
  1. I BSDTYP'["C",TYPE="C" Q ;quit if canceled not included
  1. I TYPE="S",$$WALKIN^BSDU2(DFN,DATE) S TYPE="W" ;or a walk-in?
  1. I TYPE="W",BSDTYP'["W" Q ;quit if walk-ins not included
  1. ;
  1. ; -- build data line: patient^clinic^date/time^type^length^other info
  1. 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)
  1. ; -- set data line into array
  1. S BSDCNT=$G(BSDCNT)+1,X=BSDARR_BSDCNT_")",@(X)=LINE
  1. Q
  1. ;
  1. CHECK(CLN,APDT) ;check if clinic for this division and not cancelled or inactive
  1. I $$GET1^DIQ(44,CLN,2,"I")'="C" Q 0 ;not a clinic
  1. I $G(VAUTD),$$GET1^DIQ(44,CLN,3.5,"I")'=VAUTD Q 0 ;wrong division
  1. I '$$ACTV^BSDU(CLN,APDT) Q 0 ;not active
  1. I $G(^SC(CLN,"ST",APDT,1))["**CANCELLED" Q 0 ;cancelled
  1. Q 1