1 | SDAM1 ;MJK/ALB - Appt Mgt (Patient);Apr 23 1999
|
---|
2 | ;;5.3;Scheduling;**149,155,193,189,445,478,466**;Aug 13, 1993;Build 2
|
---|
3 | ;
|
---|
4 | INIT ; -- get init pat appt data
|
---|
5 | ; input: DFN := ifn of pat
|
---|
6 | ; output: ^TMP("SDAM" := appt array
|
---|
7 | S X=$P($G(^DG(43,1,"SCLR")),U,12),SDPRD=$S(X:X,1:2)
|
---|
8 | S X1=DT,X2=-SDPRD D C^%DTC S SDBEG=X
|
---|
9 | S X1=DT,X2=999 D C^%DTC S SDEND=X
|
---|
10 | D CHGCAP^VALM("NAME","Clinic")
|
---|
11 | S X="ALL" D LIST^SDAM
|
---|
12 | Q
|
---|
13 | ;
|
---|
14 | BLD ; -- scan apts
|
---|
15 | N SDAMDD,SDNAME,SDMAX,SDLARGE,DFN,SDCL,BL,XC,XW,AC,AW,TC,TW,NC,NW,SC,SW,SDT,CC,CW,CN,CNPAT,CNSTLNK,CSTAT ; done for speed see INIT
|
---|
16 | D INIT^SDAM10
|
---|
17 | S DFN=SDFN
|
---|
18 | F SDT=SDBEG:0 S SDT=$O(^DPT(DFN,"S",SDT)) Q:'SDT!($P(SDT,".",1)>SDEND) I $D(^(SDT,0)) S SDATA=^(0),SDCL=+SDATA,SDNAME=$P($G(^SC(SDCL,0)),U) D K:CNSTLNK="" CNSTLNK D BLD1 ;SD/478
|
---|
19 | .S CNSTLNK="",CN=0 F S CN=$O(^SC(SDCL,"S",SDT,1,CN)) Q:'+CN S CNPAT=$P($G(^SC(SDCL,"S",SDT,1,CN,0)),U) I CNPAT=DFN S CNSTLNK=$P($G(^SC(SDCL,"S",SDT,1,CN,"CONS")),U),CSTAT="" S:CNSTLNK'="" CSTAT=$P($G(^GMR(123,CNSTLNK,0)),U,12) Q ;SD/478
|
---|
20 | D NUL^SDAM10,LARGE^SDAM10:$D(SDLARGE)
|
---|
21 | S $P(^TMP("SDAM",$J,0),U,4)=VALMCNT
|
---|
22 | Q
|
---|
23 | ;
|
---|
24 | BLD1 ; -- build array
|
---|
25 | N SDX,X,Y,Y1,SDSTAT,SDELIG
|
---|
26 | S SDSTAT=$$STATUS(DFN,SDT,SDCL,SDATA,$S($D(SDDA):SDDA,1:""))
|
---|
27 | G BLD1Q:'$$CHK(DFN,SDT,SDCL,SDATA,.SDAMLIST,SDSTAT)
|
---|
28 | ;; Changes for GAF enhancement
|
---|
29 | S SDGAFREQ=" "
|
---|
30 | S SDELIG=$$ELSTAT^SDUTL2(DFN)
|
---|
31 | I $$MHCLIN^SDUTL2(SDCL),'($$COLLAT^SDUTL2(SDELIG)!$P(SDATA,U,11)) D
|
---|
32 | .S SDGAF=$$NEWGAF^SDUTL2(DFN),SDGAFST=$P(SDGAF,"^")
|
---|
33 | .S:SDGAFST SDGAFREQ="*"
|
---|
34 | S SDACNT=SDACNT+1,X="",$P(X," ",VALMWD+1)=""
|
---|
35 | W:(SDACNT#10)=0 "."
|
---|
36 | I SDACNT=SDMAX,$P(SDT,".")'=SDEND S SDEND=$P(SDT,"."),SDLARGE=""
|
---|
37 | S X=SDGAFREQ_$E(X,2,AC-1)_$E(SDACNT_BL,1,AW)_$E(X,AC+AW+1,VALMWD)
|
---|
38 | S X=$E(X,1,NC-1)_$E($$LOWER(SDNAME)_BL,1,NW)_$E(X,NC+NW+1,VALMWD)
|
---|
39 | S X=$E(X,1,XC-1)_$E($$FMTE^XLFDT(SDT,"5Z")_BL,1,XW)_$E(X,XC+XW+1,VALMWD) ;to make date field work for SD*5.3*189 - uses FM List Template
|
---|
40 | S:'$D(CSTAT) CSTAT="" ;SD/478
|
---|
41 | S X=$E(X,1,CC-1)_$E($S((CSTAT=1!(CSTAT=2)!(CSTAT=13)):" ",$G(CNSTLNK):"Consult",1:" ")_BL,1,CW)_$E(X,CC+CW+1,VALMWD) K CNSTLNK,CSTAT ;SD/478
|
---|
42 | S Y=$P(SDSTAT,";",3)
|
---|
43 | I Y'["FUTURE" S X=$E(X,1,SC-1)_$E($$LOWER(Y)_BL,1,SW)_$E(X,SC+SW+1,VALMWD)
|
---|
44 | I Y["FUTURE" S X=$E(X,1,SC-1)_$E($$LOWER(Y)_$$ANC_BL,1,SW+TW+1)
|
---|
45 | S Y1=$S($P(SDSTAT,";",5):$P(SDSTAT,";",5),1:$P(SDSTAT,";",4)),Y1=$S($P(Y1,".")=DT:$$TIME($P(Y1,".",2)),1:"")
|
---|
46 | S:Y1]"" X=$E(X,1,TC-1)_$E(Y1_BL,1,TW)_$E(X,TC+TW+1,VALMWD)
|
---|
47 | D SET(X)
|
---|
48 | I $D(SDAMBOLD(DFN,SDT,SDCL)) D FLDCTRL^VALM10(VALMCNT,"STAT",IOINHI,IOINORM),FLDCTRL^VALM10(VALMCNT,"TIME",IOINHI,IOINORM)
|
---|
49 | S ^TMP("SDAMIDX",$J,SDACNT)=VALMCNT_U_DFN_U_SDT_U_SDCL_U_$S($D(SDDA):SDDA,1:"")
|
---|
50 | BLD1Q Q
|
---|
51 | ;
|
---|
52 | ANC() ; -- set ancillary info
|
---|
53 | N I,Y,C
|
---|
54 | S Y="",C=0
|
---|
55 | F I=3:1:5 I $P(SDATA,U,I)]"" S Y=Y_" "_$P("^^Lab^XRay^EKG",U,I)_"@"_$$TIME($P($P(SDATA,U,I),".",2)),C=C+1 Q:C=2
|
---|
56 | I Y]"" S Y="/"_$E(Y,2,99)
|
---|
57 | Q Y
|
---|
58 | ;
|
---|
59 | SET(X) ;
|
---|
60 | S VALMCNT=VALMCNT+1,^TMP("SDAM",$J,VALMCNT,0)=X
|
---|
61 | S:SDACNT ^TMP("SDAM",$J,"IDX",VALMCNT,SDACNT)=""
|
---|
62 | Q
|
---|
63 | ;
|
---|
64 | CHK(DFN,SDT,SDCL,SDATA,SDAMLIST,SDSTAT,SDDA) ; -- does appt meet criteria
|
---|
65 | ; input: DFN := ifn of pat.
|
---|
66 | ; SDT := appt d/t
|
---|
67 | ; SDCL := ifn of clinic
|
---|
68 | ; SDATA := 0th node of pat appt entry
|
---|
69 | ; SDAMLIST := list definition
|
---|
70 | ; SDSTAT := appt status data from $$STATUS call
|
---|
71 | ; SDDA := ifn for ^SC(clinic,"S",date,1,ifn) {optional}
|
---|
72 | ; output: [returned] := meets criteria for list [0 - no | 1 - yes ]
|
---|
73 | ;
|
---|
74 | S Y=0
|
---|
75 | I $D(SDAMLIST(+SDSTAT)) S Y=1 G CHKQ
|
---|
76 | I $P(SDAMLIST,U)="ALL" S Y=1
|
---|
77 | I $P(SDAMLIST,U)="CHECKED IN" I $P(SDSTAT,";",3)="ACT REQ/CHECKED IN" S Y=1 ; - SD*5.3*445
|
---|
78 | CHKQ I Y,$D(SDAMLIST("SCR")) X SDAMLIST("SCR") S Y=$T
|
---|
79 | Q Y
|
---|
80 | ;
|
---|
81 | STATUS(DFN,SDT,SDCL,SDATA,SDDA) ; -- return appt status
|
---|
82 | ; input: DFN := ifn of pat.
|
---|
83 | ; SDT := appt d/t
|
---|
84 | ; SDCL := ifn of clinic
|
---|
85 | ; SDATA := 0th node of pat appt entry
|
---|
86 | ; SDDA := ifn for ^SC(clinic,"S",date,1,ifn) {optional}
|
---|
87 | ; output: [returned] := appt status ifn ^ status name ^ print status ^
|
---|
88 | ; check in d/t ^ check out d/t ^ adm mvt ifn
|
---|
89 | ;
|
---|
90 | ;S = status ; C = ci/co indicator ; Y = 'C' node ; P = print status
|
---|
91 | N S,C,Y,P,VADMVT,VAINDT
|
---|
92 | ;
|
---|
93 | ; -- get data for evaluation
|
---|
94 | S:'$G(SDDA) SDDA=+$$FIND^SDAM2(DFN,SDT,SDCL)
|
---|
95 | S Y=$G(^SC(SDCL,"S",SDT,1,SDDA,"C"))
|
---|
96 | ;
|
---|
97 | ; -- set initial status value ; non-count clinic?
|
---|
98 | S S=$S($P(SDATA,"^",2)]"":$P($P($P(^DD(2.98,3,0),"^",3),$P(SDATA,"^",2)_":",2),";"),$P($G(^SC(SDCL,0)),U,17)="Y":"NON-COUNT",1:"")
|
---|
99 | ;
|
---|
100 | ; -- inpatient?
|
---|
101 | S VAINDT=SDT D ADM^VADPT2
|
---|
102 | I S["INPATIENT",$S('VADMVT:1,'$P(^DG(43,1,0),U,21):0,1:$P($G(^DIC(42,+$P($G(^DGPM(VADMVT,0)),U,6),0)),U,3)="D") S S=""
|
---|
103 | ;
|
---|
104 | ; -- determine ci/co indicator
|
---|
105 | S C=$S($P(Y,"^",3):"CHECKED OUT",Y:"CHECKED IN",S]"":"",SDT>(DT+.2359):"FUTURE",1:"NO ACTION TAKEN") S:S="" S=C
|
---|
106 | I S="NO ACTION TAKEN",$P(SDT,".")=DT,C'["CHECKED" S C="TODAY"
|
---|
107 | ; -- $$REQ & $$COCMP in SDM1A not used for speed
|
---|
108 | I S="CHECKED OUT"!(S="CHECKED IN"),SDT'<$P(^DG(43,1,"SCLR"),U,23),'$P($G(^SCE(+$P(SDATA,U,20),0)),U,7) S S="NO ACTION TAKEN"
|
---|
109 | ;
|
---|
110 | ; -- determine print status
|
---|
111 | S P=$S(S=C!(C=""):S,1:"")
|
---|
112 | I P="" D
|
---|
113 | .I S["INPATIENT",$P($G(^SC(SDCL,0)),U,17)'="Y",$P($G(^SCE(+$P(SDATA,U,20),0)),U,7)="" S P=$P(S," ")_"/ACT REQ" Q
|
---|
114 | .I S="NO ACTION TAKEN",C="CHECKED OUT"!(C="CHECKED IN") S P="ACT REQ/"_C Q
|
---|
115 | .S P=$S(S="NO ACTION TAKEN":S,1:$P(S," "))_"/"_C
|
---|
116 | I S["INPATIENT",C="" D
|
---|
117 | .I SDT>(DT+.2359) S P=$P(S," ")_"/FUTURE" Q
|
---|
118 | .S P=$P(S," ")_"/NO ACT TAKN"
|
---|
119 | ;
|
---|
120 | STATUSQ Q +$O(^SD(409.63,"AC",S,0))_";"_S_";"_P_";"_$P(Y,"^")_";"_$P(Y,"^",3)_";"_+VADMVT
|
---|
121 | ;
|
---|
122 | ;
|
---|
123 | LOWER(X) ; convert to lowercase ; same as LOWER^VALM1 ; here for speed
|
---|
124 | N Y,C,I
|
---|
125 | S Y=$E(X)_$TR($E(X,2,999),"ABCDEFGHIJKLMNOPQRSTUVWXYZ@","abcdefghijklmnopqrstuvwxyz ")
|
---|
126 | F C=" ",",","/" S I=0 F S I=$F(Y,C,I) Q:'I S Y=$E(Y,1,I-1)_$TR($E(Y,I),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$E(Y,I+1,999)
|
---|
127 | Q Y
|
---|
128 | ;
|
---|
129 | TIME(X) ; -- format time only := hr:min
|
---|
130 | Q $E(X_"0000",1,2)_":"_$E(X_"0000",3,4)
|
---|