ORQPTQ2 ; slc/CLA - Functions which return patient lists and list sources pt 2 ;3/14/05 10:50
;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,10,85,187,190,195,215**;Dec 17, 1997
;
; Ref. to ^UTILITY via IA 10061
; DBIA 3869 GETPLIST^SDAMA202 ^TMP($J,"SDAMA202")
;
CLIN(Y) ; RETURN LIST OF CLINICS
N ORLST,IEN,I
D GETLST^XPAR(.ORLST,"ALL","ORWD COMMON CLINIC")
S I=0 F S I=$O(ORLST(I)) Q:'I D
. S IEN=$P(ORLST(I),U,2) I $$ACTLOC^ORWU(IEN)=1 D
.. S Y(I)=IEN_U_$P(^SC(IEN,0),U,1)
Q
;
CLINPTS(Y,CLIN,ORBDATE,OREDATE) ; RETURN LIST OF PTS W/CLINIC APPT W/IN BEGINNING AND END DATES
; PKS-8/2003: Modified for new scheduling pkg APIs.
I +$G(CLIN)<1 S Y(1)="^No clinic identified" Q
I $$ACTLOC^ORWU(CLIN)'=1 S Y(1)="^Clinic is inactive or Occasion Of Service" Q
N DFN,NAME,I,J,X,ORJ,ORSRV,ORNOWDT,CHKX,CHKIN,MAXAPPTS,ORC,CLNAM,ORFLDS,ORCLIN,ORRESULT,ORSTART,OREND,ORSTAT,ORASTAT,ORERR,ORI,ORPT,ORPTSTAT,ORMAX,ORHOLD
S MAXAPPTS=200
S ORNOWDT=$$NOW^XLFDT
S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
S DFN=0,I=1
I ORBDATE="" S ORBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC START DATE",1,"E"))
I OREDATE="" S OREDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC STOP DATE",1,"E"))
;
; Convert ORBDATE, OREDATE to FM Date/Time:
D DT^DILF("T",ORBDATE,.ORBDATE,"","")
D DT^DILF("T",OREDATE,.OREDATE,"","")
I (ORBDATE=-1)!(OREDATE=-1) S Y(1)="^Error in date range." Q
S OREDATE=$P(OREDATE,".")_.5 ; Add 1/2 day to end date.
; IA# 3869:
K ^TMP($J,"SDAMA202","GETPLIST") ; Clean house before starting.
S ORRESULT=""
S ORCLIN=+CLIN,ORFLDS="1;3;4;12",ORASTAT="R;NT",ORSTART=ORBDATE,OREND=OREDATE,ORSTAT="" ; Assign parameters.
; ORFLDS: 1;3;4;12 = ApptDateTime;ApptStatus;IEN^PtName;PtStatus.
D GETPLIST^SDAMA202(ORCLIN,ORFLDS,ORASTAT,ORSTART,OREND,.ORRESULT,ORSTAT) ; DBIA 3869.
;
; Deal with server errors:
S ORERR=$$CLINERR^ORQRY01
I $L(ORERR) S Y(1)=U_ORERR Q
;
; Reassign ^TMP array to local array:
S (ORPT,ORI)=0,ORMAX=MAXAPPTS
I ORRESULT'>0 S Y(1)="^No appointments." Q
F S ORPT=$O(^TMP($J,"SDAMA202","GETPLIST",ORPT)) Q:ORPT=""!(ORI>ORMAX) D ;DBIA 3869
.S ORI=ORI+1
.S Y(ORI)=$G(^TMP($J,"SDAMA202","GETPLIST",ORPT,4)) ; IEN^Name.
.S Y(ORI)=Y(ORI)_U_ORCLIN ; ^Clinic IEN.
.S Y(ORI)=Y(ORI)_U_$G(^TMP($J,"SDAMA202","GETPLIST",ORPT,1)) ; App't.
.S ORPTSTAT=$G(^TMP($J,"SDAMA202","GETPLIST",ORPT,12)) ; Pt Status.
.S ORPTSTAT=$S(ORPTSTAT="I":"IPT",ORPTSTAT="O":"OPT",1:"")
.S ORHOLD=$G(^TMP($J,"SDAMA202","GETPLIST",ORPT,3)) ; Appt Status.
.I ORPTSTAT=""&(ORHOLD="NT") S ORPTSTAT="NT" ; "No Action Taken."
.S Y(ORI)=Y(ORI)_U_U_U_U_U_ORPTSTAT ; Pt I or O status (or "NT").
;
K ^TMP($J,"SDAMA202","GETPLIST") ; Clean house after finishing.
;
Q
;
CDATRANG(ORY) ; return default start and stop dates for clinics in form start^stop
N ORBDATE,OREDATE,ORSRV
S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
S ORBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC START DATE",1,"E"))
S OREDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC STOP DATE",1,"E"))
S ORBDATE=$S($L($G(ORBDATE)):ORBDATE,1:""),OREDATE=$S($L($G(OREDATE)):OREDATE,1:"")
S ORY=$$UP^XLFSTR(ORBDATE)_"^"_$$UP^XLFSTR(OREDATE)
Q
PTAPPTS(Y,DFN,ORBDATE,OREDATE,CLIN) ; return appts for a patient between beginning and end dates for a clinic, if no clinic return all appointments
;I +$G(CLIN)<1 S Y(1)="^No clinic identified" Q
I +$G(CLIN)>0,$$ACTLOC^ORWU(CLIN)'=1 S Y(1)="^Clinic is inactive or Occasion Of Service" Q
N ERR,ERRMSG,VASD,NUM,CNT,INVDT,INT,EXT,ORSRV,VAERR K ^UTILITY("VASD",$J) S NUM=0,CNT=1 ;IA 10061
I (ORBDATE="")!(OREDATE="") D ;get user's service and set up entities:
.S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
I ORBDATE="" D
.I '$L(CLIN) S ORBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORQQEAPT ENC APPT START",1,"E"))
.S:ORBDATE="" ORBDATE="T" ;default start date across all clinics is today
I OREDATE="" D
.I '$L(CLIN) S OREDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$G(ORSRV)_"^DIV^SYS^PKG","ORQQEAPT ENC APPT STOP",1,"E"))
.S:OREDATE="" OREDATE="T" ;default end date across all clinics is today
;CONVERT ORBDATE AND OREDATE INTO FILEMAN DATE/TIME
D DT^DILF("T",ORBDATE,.ORBDATE,"","")
D DT^DILF("T",OREDATE,.OREDATE,"","")
I (ORBDATE=-1)!(OREDATE=-1) S Y(1)="^Error in date range." Q
S VASD("F")=ORBDATE
S VASD("T")=$P(OREDATE,".")_.5 ;ADD 1/2 DAY TO END DATE
I $L($G(CLIN)) S VASD("C",CLIN)=""
D SDA^ORQRY01(.ERR,.ERRMSG)
I ERR K ^UTILITY("VASD",$J) S Y(1)=ERRMSG Q
F S NUM=$O(^UTILITY("VASD",$J,NUM)) Q:'NUM D
.S INT=^UTILITY("VASD",$J,NUM,"I"),INVDT=9999999-$P(INT,U)
.S EXT=^UTILITY("VASD",$J,NUM,"E")
.S Y(CNT)=$P(INT,U)_U_$P(EXT,U,2)_U_$P(EXT,U,3)_U_$P(EXT,U,4)_U_INVDT
.S CNT=CNT+1
S:+$G(Y(1))<1 Y(1)="^No appointments."
K ^UTILITY("VASD",$J)
Q
PROV(Y) ; RETURN LIST OF PROVIDERS
N I,IEN,NAME,TDATE
S I=1,NAME=""
F S NAME=$O(^VA(200,"B",NAME)) Q:NAME="" S IEN=0,IEN=$O(^(NAME,IEN)) D
.Q:$E(NAME)="*"
.I $D(^XUSEC("PROVIDER",IEN)),$$ACTIVE^XUSER(IEN) S Y(I)=IEN_"^"_NAME,I=I+1
Q
PROVPTS(Y,PROV) ; RETURN LIST OF PATIENTS LINKED TO A PRIMARY PROVIDER
I +$G(PROV)<1 S Y(1)="^No provider identified" Q
N ORI,DFN
S ORI=1,DFN=0
F S DFN=$O(^DPT("APR",PROV,DFN)) Q:DFN'>0 S Y(ORI)=+DFN_"^"_$P(^DPT(+DFN,0),"^"),ORI=ORI+1
S:+$G(Y(1))<1 Y(1)="^No patients found."
Q
SPEC(Y) ; RETURN LIST OF TREATING SPECIALTIES
N I,NAME,IEN
S I=1,NAME=""
;access to DIC(45.7 global granted under DBIA #519:
F S NAME=$O(^DIC(45.7,"B",NAME)) Q:NAME="" S IEN=0,IEN=$O(^(NAME,IEN)) I $$ACTIVE^DGACT(45.7,IEN) S Y(I)=IEN_"^"_NAME,I=I+1
Q
SPECPTS(Y,SPEC) ; RETURN LIST OF PATIENTS LINKED TO A TREATING SPECIALTY
I +$G(SPEC)<1 S Y(1)="^No specialty identified" Q
N ORI,DFN
S ORI=1,DFN=0
F S DFN=$O(^DPT("ATR",SPEC,DFN)) Q:DFN'>0 S Y(ORI)=+DFN_"^"_$P(^DPT(+DFN,0),"^"),ORI=ORI+1
S:+$G(Y(1))<1 Y(1)="^No patients found."
Q
WARD(Y) ; RETURN LIST OF ACTIVE WARDS
N I,IEN,NAME,D0
S I=1,NAME=""
;access to DIC(42 global granted under DBIA #36:
F S NAME=$O(^DIC(42,"B",NAME)) Q:NAME="" S IEN=$O(^(NAME,0)) D
. S D0=IEN D WIN^DGPMDDCF
. I X=0 S Y(I)=IEN_"^"_NAME,I=I+1
Q
WARDPTS(Y,WARD) ; RETURN LIST OF PATIENTS IN A WARD
; SLC/PKS - Modifications for Room/Bed data on 1/19/2001.
I +$G(WARD)<1 S Y(1)="^No ward identified" Q
N ORI,DFN,RBDAT
S ORI=1,DFN=0
; Access to DIC(42 global granted under DBIA #36:
S WARD=$P(^DIC(42,WARD,0),"^") ;GET WARD NAME FOR "CN" LOOKUP
; Next section modified 1/19/2001 by PKS:
F D Q:DFN'>0
.S DFN=$O(^DPT("CN",WARD,DFN)) Q:DFN'>0
.S Y(ORI)=+DFN_"^"_$P(^DPT(+DFN,0),"^")
.S RBDAT=""
.; Add patient room/bed information where data exists:
.S RBDAT=$P($G(^DPT(+DFN,.101)),U)
.I RBDAT'="" D ; Any R/B data?
..I $L(RBDAT)<4 S RBDAT=RBDAT_" " ; Add if < 4 chars.
..S RBDAT=$E(RBDAT,1,4) ; Get first 4 only.
.S Y(ORI)=Y(ORI)_U_RBDAT ; Add R/B to string
.S ORI=ORI+1 ; Increment counter.
;
S:+$G(Y(1))<1 Y(1)="^No patients found."
Q
NLIST(ORQY) ; return a null list
S ORQY(1)=""
Q
ORQPTQ2 ; slc/CLA - Functions which return patient lists and list sources pt 2 ;3/14/05 10:50
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,10,85,187,190,195,215**;Dec 17, 1997
+2 ;
+3 ; Ref. to ^UTILITY via IA 10061
+4 ; DBIA 3869 GETPLIST^SDAMA202 ^TMP($J,"SDAMA202")
+5 ;
CLIN(Y) ; RETURN LIST OF CLINICS
+1 NEW ORLST,IEN,I
+2 DO GETLST^XPAR(.ORLST,"ALL","ORWD COMMON CLINIC")
+3 SET I=0
FOR
SET I=$ORDER(ORLST(I))
IF 'I
QUIT
Begin DoDot:1
+4 SET IEN=$PIECE(ORLST(I),U,2)
IF $$ACTLOC^ORWU(IEN)=1
Begin DoDot:2
+5 SET Y(I)=IEN_U_$PIECE(^SC(IEN,0),U,1)
End DoDot:2
End DoDot:1
+6 QUIT
+7 ;
CLINPTS(Y,CLIN,ORBDATE,OREDATE) ; RETURN LIST OF PTS W/CLINIC APPT W/IN BEGINNING AND END DATES
+1 ; PKS-8/2003: Modified for new scheduling pkg APIs.
+2 IF +$GET(CLIN)<1
SET Y(1)="^No clinic identified"
QUIT
+3 IF $$ACTLOC^ORWU(CLIN)'=1
SET Y(1)="^Clinic is inactive or Occasion Of Service"
QUIT
+4 NEW DFN,NAME,I,J,X,ORJ,ORSRV,ORNOWDT,CHKX,CHKIN,MAXAPPTS,ORC,CLNAM,ORFLDS,ORCLIN,ORRESULT,ORSTART,OREND,ORSTAT,ORASTAT,ORERR,ORI,ORPT,ORPTSTAT,ORMAX,ORHOLD
+5 SET MAXAPPTS=200
+6 SET ORNOWDT=$$NOW^XLFDT
+7 SET ORSRV=$GET(^VA(200,DUZ,5))
IF +ORSRV>0
SET ORSRV=$PIECE(ORSRV,U)
+8 SET DFN=0
SET I=1
+9 IF ORBDATE=""
SET ORBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$GET(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC START DATE",1,"E"))
+10 IF OREDATE=""
SET OREDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$GET(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC STOP DATE",1,"E"))
+11 ;
+12 ; Convert ORBDATE, OREDATE to FM Date/Time:
+13 DO DT^DILF("T",ORBDATE,.ORBDATE,"","")
+14 DO DT^DILF("T",OREDATE,.OREDATE,"","")
+15 IF (ORBDATE=-1)!(OREDATE=-1)
SET Y(1)="^Error in date range."
QUIT
+16 ; Add 1/2 day to end date.
SET OREDATE=$PIECE(OREDATE,".")_.5
+17 ; IA# 3869:
+18 ; Clean house before starting.
KILL ^TMP($JOB,"SDAMA202","GETPLIST")
+19 SET ORRESULT=""
+20 ; Assign parameters.
SET ORCLIN=+CLIN
SET ORFLDS="1;3;4;12"
SET ORASTAT="R;NT"
SET ORSTART=ORBDATE
SET OREND=OREDATE
SET ORSTAT=""
+21 ; ORFLDS: 1;3;4;12 = ApptDateTime;ApptStatus;IEN^PtName;PtStatus.
+22 ; DBIA 3869.
DO GETPLIST^SDAMA202(ORCLIN,ORFLDS,ORASTAT,ORSTART,OREND,.ORRESULT,ORSTAT)
+23 ;
+24 ; Deal with server errors:
+25 SET ORERR=$$CLINERR^ORQRY01
+26 IF $LENGTH(ORERR)
SET Y(1)=U_ORERR
QUIT
+27 ;
+28 ; Reassign ^TMP array to local array:
+29 SET (ORPT,ORI)=0
SET ORMAX=MAXAPPTS
+30 IF ORRESULT'>0
SET Y(1)="^No appointments."
QUIT
+31 ;DBIA 3869
FOR
SET ORPT=$ORDER(^TMP($JOB,"SDAMA202","GETPLIST",ORPT))
IF ORPT=""!(ORI>ORMAX)
QUIT
Begin DoDot:1
+32 SET ORI=ORI+1
+33 ; IEN^Name.
SET Y(ORI)=$GET(^TMP($JOB,"SDAMA202","GETPLIST",ORPT,4))
+34 ; ^Clinic IEN.
SET Y(ORI)=Y(ORI)_U_ORCLIN
+35 ; App't.
SET Y(ORI)=Y(ORI)_U_$GET(^TMP($JOB,"SDAMA202","GETPLIST",ORPT,1))
+36 ; Pt Status.
SET ORPTSTAT=$GET(^TMP($JOB,"SDAMA202","GETPLIST",ORPT,12))
+37 SET ORPTSTAT=$SELECT(ORPTSTAT="I":"IPT",ORPTSTAT="O":"OPT",1:"")
+38 ; Appt Status.
SET ORHOLD=$GET(^TMP($JOB,"SDAMA202","GETPLIST",ORPT,3))
+39 ; "No Action Taken."
IF ORPTSTAT=""&(ORHOLD="NT")
SET ORPTSTAT="NT"
+40 ; Pt I or O status (or "NT").
SET Y(ORI)=Y(ORI)_U_U_U_U_U_ORPTSTAT
End DoDot:1
+41 ;
+42 ; Clean house after finishing.
KILL ^TMP($JOB,"SDAMA202","GETPLIST")
+43 ;
+44 QUIT
+45 ;
CDATRANG(ORY) ; return default start and stop dates for clinics in form start^stop
+1 NEW ORBDATE,OREDATE,ORSRV
+2 SET ORSRV=$GET(^VA(200,DUZ,5))
IF +ORSRV>0
SET ORSRV=$PIECE(ORSRV,U)
+3 SET ORBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$GET(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC START DATE",1,"E"))
+4 SET OREDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$GET(ORSRV)_"^DIV^SYS^PKG","ORLP DEFAULT CLINIC STOP DATE",1,"E"))
+5 SET ORBDATE=$SELECT($LENGTH($GET(ORBDATE)):ORBDATE,1:"")
SET OREDATE=$SELECT($LENGTH($GET(OREDATE)):OREDATE,1:"")
+6 SET ORY=$$UP^XLFSTR(ORBDATE)_"^"_$$UP^XLFSTR(OREDATE)
+7 QUIT
PTAPPTS(Y,DFN,ORBDATE,OREDATE,CLIN) ; return appts for a patient between beginning and end dates for a clinic, if no clinic return all appointments
+1 ;I +$G(CLIN)<1 S Y(1)="^No clinic identified" Q
+2 IF +$GET(CLIN)>0
IF $$ACTLOC^ORWU(CLIN)'=1
SET Y(1)="^Clinic is inactive or Occasion Of Service"
QUIT
+3 ;IA 10061
NEW ERR,ERRMSG,VASD,NUM,CNT,INVDT,INT,EXT,ORSRV,VAERR
KILL ^UTILITY("VASD",$JOB)
SET NUM=0
SET CNT=1
+4 ;get user's service and set up entities:
IF (ORBDATE="")!(OREDATE="")
Begin DoDot:1
+5 SET ORSRV=$GET(^VA(200,DUZ,5))
IF +ORSRV>0
SET ORSRV=$PIECE(ORSRV,U)
End DoDot:1
+6 IF ORBDATE=""
Begin DoDot:1
+7 IF '$LENGTH(CLIN)
SET ORBDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$GET(ORSRV)_"^DIV^SYS^PKG","ORQQEAPT ENC APPT START",1,"E"))
+8 ;default start date across all clinics is today
IF ORBDATE=""
SET ORBDATE="T"
End DoDot:1
+9 IF OREDATE=""
Begin DoDot:1
+10 IF '$LENGTH(CLIN)
SET OREDATE=$$UP^XLFSTR($$GET^XPAR("USR^SRV.`"_+$GET(ORSRV)_"^DIV^SYS^PKG","ORQQEAPT ENC APPT STOP",1,"E"))
+11 ;default end date across all clinics is today
IF OREDATE=""
SET OREDATE="T"
End DoDot:1
+12 ;CONVERT ORBDATE AND OREDATE INTO FILEMAN DATE/TIME
+13 DO DT^DILF("T",ORBDATE,.ORBDATE,"","")
+14 DO DT^DILF("T",OREDATE,.OREDATE,"","")
+15 IF (ORBDATE=-1)!(OREDATE=-1)
SET Y(1)="^Error in date range."
QUIT
+16 SET VASD("F")=ORBDATE
+17 ;ADD 1/2 DAY TO END DATE
SET VASD("T")=$PIECE(OREDATE,".")_.5
+18 IF $LENGTH($GET(CLIN))
SET VASD("C",CLIN)=""
+19 DO SDA^ORQRY01(.ERR,.ERRMSG)
+20 IF ERR
KILL ^UTILITY("VASD",$JOB)
SET Y(1)=ERRMSG
QUIT
+21 FOR
SET NUM=$ORDER(^UTILITY("VASD",$JOB,NUM))
IF 'NUM
QUIT
Begin DoDot:1
+22 SET INT=^UTILITY("VASD",$JOB,NUM,"I")
SET INVDT=9999999-$PIECE(INT,U)
+23 SET EXT=^UTILITY("VASD",$JOB,NUM,"E")
+24 SET Y(CNT)=$PIECE(INT,U)_U_$PIECE(EXT,U,2)_U_$PIECE(EXT,U,3)_U_$PIECE(EXT,U,4)_U_INVDT
+25 SET CNT=CNT+1
End DoDot:1
+26 IF +$GET(Y(1))<1
SET Y(1)="^No appointments."
+27 KILL ^UTILITY("VASD",$JOB)
+28 QUIT
PROV(Y) ; RETURN LIST OF PROVIDERS
+1 NEW I,IEN,NAME,TDATE
+2 SET I=1
SET NAME=""
+3 FOR
SET NAME=$ORDER(^VA(200,"B",NAME))
IF NAME=""
QUIT
SET IEN=0
SET IEN=$ORDER(^(NAME,IEN))
Begin DoDot:1
+4 IF $EXTRACT(NAME)="*"
QUIT
+5 IF $DATA(^XUSEC("PROVIDER",IEN))
IF $$ACTIVE^XUSER(IEN)
SET Y(I)=IEN_"^"_NAME
SET I=I+1
End DoDot:1
+6 QUIT
PROVPTS(Y,PROV) ; RETURN LIST OF PATIENTS LINKED TO A PRIMARY PROVIDER
+1 IF +$GET(PROV)<1
SET Y(1)="^No provider identified"
QUIT
+2 NEW ORI,DFN
+3 SET ORI=1
SET DFN=0
+4 FOR
SET DFN=$ORDER(^DPT("APR",PROV,DFN))
IF DFN'>0
QUIT
SET Y(ORI)=+DFN_"^"_$PIECE(^DPT(+DFN,0),"^")
SET ORI=ORI+1
+5 IF +$GET(Y(1))<1
SET Y(1)="^No patients found."
+6 QUIT
SPEC(Y) ; RETURN LIST OF TREATING SPECIALTIES
+1 NEW I,NAME,IEN
+2 SET I=1
SET NAME=""
+3 ;access to DIC(45.7 global granted under DBIA #519:
+4 FOR
SET NAME=$ORDER(^DIC(45.7,"B",NAME))
IF NAME=""
QUIT
SET IEN=0
SET IEN=$ORDER(^(NAME,IEN))
IF $$ACTIVE^DGACT(45.7,IEN)
SET Y(I)=IEN_"^"_NAME
SET I=I+1
+5 QUIT
SPECPTS(Y,SPEC) ; RETURN LIST OF PATIENTS LINKED TO A TREATING SPECIALTY
+1 IF +$GET(SPEC)<1
SET Y(1)="^No specialty identified"
QUIT
+2 NEW ORI,DFN
+3 SET ORI=1
SET DFN=0
+4 FOR
SET DFN=$ORDER(^DPT("ATR",SPEC,DFN))
IF DFN'>0
QUIT
SET Y(ORI)=+DFN_"^"_$PIECE(^DPT(+DFN,0),"^")
SET ORI=ORI+1
+5 IF +$GET(Y(1))<1
SET Y(1)="^No patients found."
+6 QUIT
WARD(Y) ; RETURN LIST OF ACTIVE WARDS
+1 NEW I,IEN,NAME,D0
+2 SET I=1
SET NAME=""
+3 ;access to DIC(42 global granted under DBIA #36:
+4 FOR
SET NAME=$ORDER(^DIC(42,"B",NAME))
IF NAME=""
QUIT
SET IEN=$ORDER(^(NAME,0))
Begin DoDot:1
+5 SET D0=IEN
DO WIN^DGPMDDCF
+6 IF X=0
SET Y(I)=IEN_"^"_NAME
SET I=I+1
End DoDot:1
+7 QUIT
WARDPTS(Y,WARD) ; RETURN LIST OF PATIENTS IN A WARD
+1 ; SLC/PKS - Modifications for Room/Bed data on 1/19/2001.
+2 IF +$GET(WARD)<1
SET Y(1)="^No ward identified"
QUIT
+3 NEW ORI,DFN,RBDAT
+4 SET ORI=1
SET DFN=0
+5 ; Access to DIC(42 global granted under DBIA #36:
+6 ;GET WARD NAME FOR "CN" LOOKUP
SET WARD=$PIECE(^DIC(42,WARD,0),"^")
+7 ; Next section modified 1/19/2001 by PKS:
+8 FOR
Begin DoDot:1
+9 SET DFN=$ORDER(^DPT("CN",WARD,DFN))
IF DFN'>0
QUIT
+10 SET Y(ORI)=+DFN_"^"_$PIECE(^DPT(+DFN,0),"^")
+11 SET RBDAT=""
+12 ; Add patient room/bed information where data exists:
+13 SET RBDAT=$PIECE($GET(^DPT(+DFN,.101)),U)
+14 ; Any R/B data?
IF RBDAT'=""
Begin DoDot:2
+15 ; Add if < 4 chars.
IF $LENGTH(RBDAT)<4
SET RBDAT=RBDAT_" "
+16 ; Get first 4 only.
SET RBDAT=$EXTRACT(RBDAT,1,4)
End DoDot:2
+17 ; Add R/B to string
SET Y(ORI)=Y(ORI)_U_RBDAT
+18 ; Increment counter.
SET ORI=ORI+1
End DoDot:1
IF DFN'>0
QUIT
+19 ;
+20 IF +$GET(Y(1))<1
SET Y(1)="^No patients found."
+21 QUIT
NLIST(ORQY) ; return a null list
+1 SET ORQY(1)=""
+2 QUIT