source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SDM.m@ 940

Last change on this file since 940 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1SDM ;SF/GFT,ALB/BOK - MAKE AN APPOINTMENT ; 4/21/05 10:22pm
2 ;;5.3;Scheduling;**15,32,38,41,44,79,94,167,168,218,223,250,254,296,380,478**;AUG 13, 1993
3 ; If defined...
4 ; appt mgt vars: SDFN := DFN of patient....will not be asked
5 ; SDCLN := ifn of clinic.....will not be asked
6 ; SDAMERR := returned if error occurs
7 ;
8 S:'$D(SDMM) SDMM=0
9EN1 L W !! D I^SDUTL I '$D(SDCLN) S DIC="^SC(",DIC(0)="AEMZQ",DIC("A")="Select CLINIC: ",DIC("S")="I $P(^(0),U,3)=""C"",'$G(^(""OOS""))" D ^DIC K DIC G:Y<0!'$D(^("SL")) END
10 N SDRES S:$D(SDCLN) Y=+SDCLN S SDRES=$$CLNCK^SDUTL2(+Y,1)
11 I 'SDRES W !,?5,"Clinic MUST be corrected before continuing." G END:$D(SDCLN),SDM
12 K SDAPTYP,SDIN,SDRE,SDXXX S:$D(SDCLN) Y=+SDCLN
13 S TMPYCLNC=Y,STPCOD=$P($G(^SC(+TMPYCLNC,0)),U,7) ;SD/478
14 I $D(^SC(+Y,"I")) S SDIN=+^("I"),SDRE=+$P(^("I"),U,2)
15 K SDINA I $D(SDIN),SDIN S SDINA=SDIN K SDIN
16 I $D(SD),$D(SC),+Y'=+SC K SD
17 S SL=$G(^SC(+Y,"SL")),X=$P(SL,U,3),STARTDAY=$S($L(X):X,1:8),SC=Y,SB=STARTDAY-1/100,X=$P(SL,U,6),HSI=$S(X=1:X,X:X,1:4),SI=$S(X="":4,X<3:4,X:X,1:4),STR="#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz",SDDIF=$S(HSI<3:8/HSI,1:2) K Y
18 I $D(^SC(+SC,"SDPROT")),$P(^("SDPROT"),U)="Y",'$D(^SC(+SC,"SDPRIV",DUZ)) W !,*7,"Access to ",$$CNAM(+SC)," is prohibited!",!,"Only users with a special code may access this clinic.",*7 S:$D(SDCLN) SDAMERR="" G END:$D(SDCLN),SDM
19 D CS^SDM1A S SDW="",WY="Y"
20 I '$D(ORACTION),'$D(SDFN) S (DIC,DIE)="^DPT(",DIC(0)="AQZME" D ^DIC S DFN=+Y G:Y<0 END:$D(SDCLN),^SDM0:X[U,SDM
21 S:$D(SDFN) DFN=SDFN
22 I $D(^DPT(DFN,.35)),$P(^(.35),U)]"" W !?10,*7,"PATIENT HAS DIED." S:$D(SDFN) SDAMERR="" G END:$D(SDFN),SDM
23 D ^SDM4 I $S('$D(COLLAT):1,COLLAT=7:1,1:0) G:$D(SDCLN) END G SDM
24 ;-- get sub-category for appointment type
25 S SDXSCAT=$$SUB^DGSAUTL(SDAPTYP,2,"")
26 K SDXXX D EN G END:$D(SDCLN),SDM
27EN K SDMLT1 W:$P(VAEL(9),U,2)]"" !!,?15,"MEANS TEST STATUS: ",$P(VAEL(9),U,2),!
28 ; *** sck, mt blocking removed
29 ;S X="EASMTCHK" X ^%ZOSF("TEST") I $T,$$MT^EASMTCHK(DFN,+$G(SDAPTYP),"M") S SDAMERR="" Q
30 S Y=DFN,Y(0)=^DPT(DFN,0) I VADM(7)]"" W !?3,*7,VADM(7)
31 I $D(^DGS(41.1,"B",DFN)) F I=0:0 S I=$O(^DGS(41.1,"B",DFN,I)) Q:I'>0 I $P(^DGS(41.1,I,0),U,2)'<DT&('$P(^DGS(41.1,I,0),U,13)) W !,"SCHEDULED FOR ADMISSION ON " S Y=$P(^(0),U,2) D DT^SDM0
32PEND S %="" W:$O(^DPT(DFN,"S",DT))'>DT !,"NO PENDING APPOINTMENTS"
33 I $O(^DPT(DFN,"S",DT))>DT D G END:%<0,HELP:'%
34 .S %=1 W !,"DISPLAY PENDING APPOINTMENTS:"
35 .D YN^DICN
36 .I %Y["^" S SDMLT1=1
37 D:%=1
38 .N DX,DY,SDXY,SDEND S SDXY="S DX=$X,DY=0"_$S($L($G(^%ZOSF("XY"))):" "_^("XY"),1:"") X SDXY
39 .S CN=1
40 .F Y=DT:0 S Y=$O(^DPT(DFN,"S",Y)) Q:Y'>0 I "I"[$P(^(Y,0),U,2) X:(($Y+4)>IOSL) "D OUT^SDUTL X SDXY" Q:$G(SDEND) D CHKSO W:$X>9 ! W CN,".",?4 D DT^SDM0 W ?23 S DA=+SSC W SDLN,$S($D(^SC(DA,0)):$P(^(0),U),1:"DELETED CLINIC "),COV," ",SDAT16 D
41 ..S CNIEN=0 F S CNIEN=$O(^SC(+SSC,"S",HY,1,CNIEN)) Q:'+CNIEN S CNPAT=$P($G(^SC(+SSC,"S",HY,1,CNIEN,0)),U) I CNPAT=DFN W:+$G(^SC(+SSC,"S",HY,1,CNIEN,"CONS")) " Consult Appt." S CN=CN+1 Q ;SD/478
42 ;Prompt for ETHNICITY if no value on file
43 I '$O(^DPT(DFN,.06,0)) D
44 .S DA=DFN,DR="6ETHNICITY",DIE="^DPT("
45 .S DR(2,2.06)=".01ETHNICITY"
46 .D ^DIE K DR
47 ;Prompt for RACE if no value on file
48 I '$O(^DPT(DFN,.02,0)) D
49 .S DA=DFN,DR="2RACE",DIE="^DPT("
50 .S DR(2,2.02)=".01RACE"
51 .D ^DIE K DR
52 S DA=DFN,DR=$S('$D(^DPT(DA,.11)):"[SDM1]",$P(^(.11),U)="":"[SDM1]",1:"")
53 S DIE="^DPT(" D ^DIE:DR]"" K DR Q:$D(SDXXX)
54E S Y=$P(SL,U,5)
55 S SDW="" I $D(^DPT(DFN,.1)) S SDW=^(.1) W !,"NOTE - PATIENT IS NOW IN WARD "_SDW
56 Q:$D(SDXXX)
57EN2 F X=0:0 S X=$O(^DPT(DFN,"DE",X)) Q:'$D(^(+X,0)) I ^(0)-SC=0!'(^(0)-Y) F XX=0:0 S XX=$O(^DPT(DFN,"DE",X,1,XX)) Q:XX<1 S SDDIS=$P(^(XX,0),U,3) I 'SDDIS D:'$D(SDMULT) A^SDCNSLT G ^SDM0
58 I '$D(^SC(+Y,0)) S Y=+SC
59 S Y=$P(^SC(Y,0),U)
60 ; SCRESTA = Array of pt's teams causing restricted consults
61 N SCRESTA
62 S SCREST=$$RESTPT^SCAPMCU4(DFN,DT,"SCRESTA")
63 IF SCREST D
64 .N SCTM
65 . S SCCLNM=Y
66 . W !,?5,"Patient has restricted consults due to team assignment(s):"
67 .S SCTM=0
68 .F S SCTM=$O(SCRESTA(SCTM)) Q:'SCTM W !,?10,SCRESTA(SCTM)
69 IF SCREST&'$G(SCOKCONS) D Q
70 .W !,?5,"This patient may only be given appointments and enrolled in clinics via"
71 .W !,?15,"Make Consult Appointment Option, and"
72 .W !,?15,"Edit Clinic Enrollment Data option"
73 D:$G(SCREST) MAIL^SCMCCON(DFN,.SCCLNM,2,DT,"SCRESTA")
74 K DR,SCREST,SCCLNM
75 D:'$D(SDMULT) ^SDCNSLT ;SD/478
76 G ^SDM0
77 ;
78CHKSO S COV=$S($P(^DPT(DFN,"S",Y,0),U,11)=1:" (COLLATERAL)",1:""),HY=Y,SSC=^(0),SDAT16=$S($D(^SD(409.1,+$P(SSC,U,16),0)):$P(^(0),U),1:"")
79 F SDJ=3,4,5 I $P(^DPT(DFN,"S",HY,0),U,SDJ)]"" S Y=$P(^(0),U,SDJ) W:$X>9 ! W ?10,"*" D DT^SDM0 W ?32,$S(SDJ=3:"LAB",SDJ=4:"XRAY",1:"EKG")
80 S SDLN="" F J=0:0 S J=$O(^SC(+SSC,"S",HY,1,J)) Q:'J I $D(^(J,0)),+^(0)=DFN S SDLN="("_$P(^(0),U,2)_" MIN) " Q
81 S Y=HY Q
82 ;
83END D KVAR^VADPT K SDAPTYP,SDSC,%,%DT,ASKC,COV,DA,DIC,DIE,DP,DR,HEY,HSI,HY,J,SB,SC,SDDIF,SDJ,SDLN,SD17,SDMAX,SDU,SDYC,SI,SL,SSC,STARTDAY,STR
84 K WY,X,XX,Y,S,SD,SDAP16,SDEDT,SDTY,SM,SS,ST,ARG,CCX,CCXN,HX,I,PXR,SDINA,SDW,COLLAT,SDDIS I $D(SDMM) K:'SDMM SDMM
85 K A,CC,CLNIEN,CN,CNIEN,CNPAT,CNSLTLNK,CNSULT,CNT,CONS,CPRSTAT,CW,DSH,DTENTR,DTIN,DTLMT,DTR,ND,P8,PROC,PT,PTIEN,PTNM,RTMP,NOSHOW,SCPTTM,SD1,SDAMSCN,SDATE,SDDOT,SDII,SDINC,SDINCM,SDLEN,SDNS,SDSI,SDST,SDSTR,SDSTRTDT
86 K SDXSCAT,SENDER,SERVICE,SRV,STATUS,STPCOD,TMP,TMPYCLNC,TYPE
87 I '$D(SDMLT) K SDMLT1
88 Q
89 ;
90OERR S XQORQUIT=1 Q:'$D(ORVP) S DFN=+ORVP G SDM
91 ;
92HELP W !,"YES - TO DISPLAY FUTURE APPOINTMENTS",!,"NO - FUTURE APPOINTMENTS NOT DISPLAYED" G PEND
93 ;
94CNAM(SDCL) ;Return clinic name
95 ;Input: SDCL=clinic ien
96 N SDX
97 S SDX=$P($G(^SC(+SDCL,0)),U)
98 Q $S($L(SDX):SDX,1:"this clinic")
Note: See TracBrowser for help on using the repository browser.