GMVCLIN ;HOIFO/YH,FT-RETURNS A LIST OF PATIENTS WITH CLINIC APPOINTMENTS WITHIN A GIVEN PERIOD ;6/24/03 10:32
;;5.0;GEN. MED. REC. - VITALS;**1**;Oct 31, 2002
;
; This routine uses the following IAs:
; #3869 - ^SDAMA202 calls (controlled)
; #10040 - ^SC( references (supported)
; #10103 - ^XLFDT calls (supported)
;
CLINPTS(RESULT,CLIN,BDATE) ; GMV CLINIC PT [RPC entry point]
; Return list of patients with clinic appointments within given period
; Input:
; RESULT - array name to return data in
; CLIN - clinic name
; BDATE - TODAY, TOMORROW, YESTERDAY, PAST WEEK, OR PAST MONTH
;
; Output:
; RESULT(n)=DFN^patient name^clinic name^appt date/time (external)^
; SSN^DOB (external)^sex, age^^...^^^^^...
;
; RESULT(1)=contains any error message
;
N DFN,EDATE,GMVCLIN,GMVCNT,GMVDT,GMVI,GMVJ,GMVNODE,GMVNOW
N GMVOUT,GMVPAT,GMVRESLT,NAME,X
K RESULT
I '$D(^SC("B",CLIN)) S RESULT(1)="ERROR^No clinic identified" G QCLIN
S GMVCLIN=$O(^SC("B",CLIN,0))
I GMVCLIN'>0 S RESULT(1)="ERROR^No clinic identified" G QCLIN
S GMVNOW=$$NOW^XLFDT,EDATE=$P(GMVNOW,".")_".24"
S BDATE=$$UP^XLFSTR(BDATE)
S BDATE=$S(BDATE="TODAY":"T",BDATE="TOMORROW":"T+1",BDATE="YESTERDAY":"T-1",BDATE="PAST WEEK":"T-7",BDATE="PAST MONTH":"T-30",1:"")
I BDATE="" S RESULT(1)="ERROR^Error in date range." G QCLIN
; convert bdate and edate into fileman date/time
D DT^DILF("T",BDATE,.BDATE,"","")
I BDATE>EDATE S EDATE=BDATE_".24"
; call scheduling api to get appt data
D GETPLIST^SDAMA202(GMVCLIN,"1;4;","R",BDATE,EDATE,.GMVRESLT,"")
; if GMVRESLT < 0, scheduling api returned an error
I GMVRESLT<0 D G QCLIN
.S RESULT(1)="ERROR"_U_$O(^TMP($J,"SDAMA202","GETPLIST","ERROR",0))
.Q
; generate error message if # of appts > 200
I $D(^TMP($J,"SDAMA202","GETPLIST",201,0)) D G QCLIN
.S RESULT(1)="ERROR^Too many appointments found. Please narrow search."
.Q
S (GMVCNT,GMVI)=0
F S GMVI=$O(^TMP($J,"SDAMA202","GETPLIST",GMVI)) Q:'GMVI D
.S GMVNODE=^TMP($J,"SDAMA202","GETPLIST",GMVI,4) ;dfn^patient name
.Q:$P(GMVNODE,U,1)=""!($P(GMVNODE,U,2)="")
.S DFN=$P(GMVNODE,U,1),NAME=$P(GMVNODE,U,2)
.S GMVDT=$P(^TMP($J,"SDAMA202","GETPLIST",GMVI,1),U,1) ;appt date/time
.S GMVOUT(NAME,DFN)=DFN_"^"_NAME_"^"_CLIN_"^"_$$FMTE^XLFDT(GMVDT)
.S GMVCNT=GMVCNT+1
.Q
I $D(GMVOUT) D
.S GMVI=0,NAME=""
.F S NAME=$O(GMVOUT(NAME)) Q:NAME="" D
..S DFN=0
..F S DFN=$O(GMVOUT(NAME,DFN)) Q:'DFN D
...S GMVPAT=""
...D PTINFO^GMVUTL3(.GMVPAT,DFN)
...S GMVI=GMVI+1,RESULT(GMVI)=GMVOUT(NAME,DFN)_"^"_GMVPAT
...Q
..Q
.Q
QCLIN ; called from above
I '$D(RESULT(1)) S RESULT(1)="No patients found"
K ^TMP($J,"SDAMA202")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMVCLIN 2741 printed Dec 13, 2024@01:58:28 Page 2
GMVCLIN ;HOIFO/YH,FT-RETURNS A LIST OF PATIENTS WITH CLINIC APPOINTMENTS WITHIN A GIVEN PERIOD ;6/24/03 10:32
+1 ;;5.0;GEN. MED. REC. - VITALS;**1**;Oct 31, 2002
+2 ;
+3 ; This routine uses the following IAs:
+4 ; #3869 - ^SDAMA202 calls (controlled)
+5 ; #10040 - ^SC( references (supported)
+6 ; #10103 - ^XLFDT calls (supported)
+7 ;
CLINPTS(RESULT,CLIN,BDATE) ; GMV CLINIC PT [RPC entry point]
+1 ; Return list of patients with clinic appointments within given period
+2 ; Input:
+3 ; RESULT - array name to return data in
+4 ; CLIN - clinic name
+5 ; BDATE - TODAY, TOMORROW, YESTERDAY, PAST WEEK, OR PAST MONTH
+6 ;
+7 ; Output:
+8 ; RESULT(n)=DFN^patient name^clinic name^appt date/time (external)^
+9 ; SSN^DOB (external)^sex, age^^...^^^^^...
+10 ;
+11 ; RESULT(1)=contains any error message
+12 ;
+13 NEW DFN,EDATE,GMVCLIN,GMVCNT,GMVDT,GMVI,GMVJ,GMVNODE,GMVNOW
+14 NEW GMVOUT,GMVPAT,GMVRESLT,NAME,X
+15 KILL RESULT
+16 IF '$DATA(^SC("B",CLIN))
SET RESULT(1)="ERROR^No clinic identified"
GOTO QCLIN
+17 SET GMVCLIN=$ORDER(^SC("B",CLIN,0))
+18 IF GMVCLIN'>0
SET RESULT(1)="ERROR^No clinic identified"
GOTO QCLIN
+19 SET GMVNOW=$$NOW^XLFDT
SET EDATE=$PIECE(GMVNOW,".")_".24"
+20 SET BDATE=$$UP^XLFSTR(BDATE)
+21 SET BDATE=$SELECT(BDATE="TODAY":"T",BDATE="TOMORROW":"T+1",BDATE="YESTERDAY":"T-1",BDATE="PAST WEEK":"T-7",BDATE="PAST MONTH":"T-30",1:"")
+22 IF BDATE=""
SET RESULT(1)="ERROR^Error in date range."
GOTO QCLIN
+23 ; convert bdate and edate into fileman date/time
+24 DO DT^DILF("T",BDATE,.BDATE,"","")
+25 IF BDATE>EDATE
SET EDATE=BDATE_".24"
+26 ; call scheduling api to get appt data
+27 DO GETPLIST^SDAMA202(GMVCLIN,"1;4;","R",BDATE,EDATE,.GMVRESLT,"")
+28 ; if GMVRESLT < 0, scheduling api returned an error
+29 IF GMVRESLT<0
Begin DoDot:1
+30 SET RESULT(1)="ERROR"_U_$ORDER(^TMP($JOB,"SDAMA202","GETPLIST","ERROR",0))
+31 QUIT
End DoDot:1
GOTO QCLIN
+32 ; generate error message if # of appts > 200
+33 IF $DATA(^TMP($JOB,"SDAMA202","GETPLIST",201,0))
Begin DoDot:1
+34 SET RESULT(1)="ERROR^Too many appointments found. Please narrow search."
+35 QUIT
End DoDot:1
GOTO QCLIN
+36 SET (GMVCNT,GMVI)=0
+37 FOR
SET GMVI=$ORDER(^TMP($JOB,"SDAMA202","GETPLIST",GMVI))
if 'GMVI
QUIT
Begin DoDot:1
+38 ;dfn^patient name
SET GMVNODE=^TMP($JOB,"SDAMA202","GETPLIST",GMVI,4)
+39 if $PIECE(GMVNODE,U,1)=""!($PIECE(GMVNODE,U,2)="")
QUIT
+40 SET DFN=$PIECE(GMVNODE,U,1)
SET NAME=$PIECE(GMVNODE,U,2)
+41 ;appt date/time
SET GMVDT=$PIECE(^TMP($JOB,"SDAMA202","GETPLIST",GMVI,1),U,1)
+42 SET GMVOUT(NAME,DFN)=DFN_"^"_NAME_"^"_CLIN_"^"_$$FMTE^XLFDT(GMVDT)
+43 SET GMVCNT=GMVCNT+1
+44 QUIT
End DoDot:1
+45 IF $DATA(GMVOUT)
Begin DoDot:1
+46 SET GMVI=0
SET NAME=""
+47 FOR
SET NAME=$ORDER(GMVOUT(NAME))
if NAME=""
QUIT
Begin DoDot:2
+48 SET DFN=0
+49 FOR
SET DFN=$ORDER(GMVOUT(NAME,DFN))
if 'DFN
QUIT
Begin DoDot:3
+50 SET GMVPAT=""
+51 DO PTINFO^GMVUTL3(.GMVPAT,DFN)
+52 SET GMVI=GMVI+1
SET RESULT(GMVI)=GMVOUT(NAME,DFN)_"^"_GMVPAT
+53 QUIT
End DoDot:3
+54 QUIT
End DoDot:2
+55 QUIT
End DoDot:1
QCLIN ; called from above
+1 IF '$DATA(RESULT(1))
SET RESULT(1)="No patients found"
+2 KILL ^TMP($JOB,"SDAMA202")
+3 QUIT
+4 ;