source: FOIAVistA/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUVISIT.m@ 1783

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

initial load of FOIAVistA 6/30/08 version

File size: 4.9 KB
Line 
1TIUVISIT ; SLC/JER - Visit File look-up ;4/28/99@09:47:44 [1/27/05 12:36pm]
2 ;;1.0;TEXT INTEGRATION UTILITIES;**39,124,190**;Jun 20, 1997;Build 1
3MAIN(TIUY,DFN,TIUSSN,TIUVDT,TIULDT,TIUDFLT,TIUMODE,TIULOC,TIUOCC,LETNEW,FILTER,UNSONLY,TIUFUTUR) ;Control
4AGN K ^TMP("TIUVN",$J),^TMP("TIUVD",$J),^TMP("TIUVDA",$J)
5 N C,I,N,TIUI,TIUII,TIUVDA,TIUER,TIUOK,TIUX,X,TIUNVIS,TIUVDATE
6 S LETNEW=$G(LETNEW,1),UNSONLY=+$G(UNSONLY)
7 S:+$G(DFN)'>0 DFN=+$$PATIENT^TIULA($G(TIUSSN)) I +DFN'>0 S TIUOUT=1 Q
8 S TIUMODE=$G(TIUMODE,1),TIUOCC=$G(TIUOCC,20)
9 S TIULOC=$S(+$G(TIULOC):TIULOC,$G(TIULOC)]"":+$O(^SC("B",TIULOC,0)),1:"")
10 I +$G(TIUVDT) S TIUVDATE=(9999999-$P(TIUVDT,"."))_"."_$P(TIUVDT,".",2)
11 S TIULDT=$S(+$G(TIULDT)>0:(9999999-$P(TIULDT,"."))_$S($L(TIULDT,".")>1:"."_$P(TIULDT,".",2),1:""),+$G(TIUVDT):(9999999-$P(TIUVDT,"."))_"."_$P($$FMADD^XLFDT(TIUVDT,"","","",-1),".",2),1:0)
12 I '+$G(TIUVDT) S TIUVDT=$S(+$G(TIULDT):(9999999-$P(+$G(TIUVDT),"."))_"."_$P($$FMADD^XLFDT(+$G(TIUVDT),"",23,59,59),".",2),+$G(TIUVDT)>0:(9999999-$P(TIUVDT,"."))_"."_$P($$FMADD^XLFDT(TIUVDT,"","","",1),".",2),1:9999999) I 1
13 E S TIUVDT=$G(TIUVDATE)
14 I '$D(^AUPNVSIT("AA",DFN)) W !,"No UNSCHEDULED VISITS on file",! Q
15 S I=TIULDT F S I=$O(^AUPNVSIT("AA",DFN,I)) Q:+I'>0!(+I>TIUVDT) D
16 . N N S N=0
17 . F S N=$O(^AUPNVSIT("AA",DFN,I,N)) Q:+N'>0 D
18 . . N D
19 . . S:$G(FILTER)'["XD" FILTER=$G(FILTER)_"XD"
20 . . Q:'$D(^AUPNVSIT(+N,0))!(FILTER[$P($G(^AUPNVSIT(+N,0)),U,7))
21 . . ; If unscheduled visits only, then omit scheduled visits
22 . . I +UNSONLY,$$CHKAPPT^TIUPXAP2(N) Q
23 . . S D=^AUPNVSIT(+N,0)
24 . . I +$G(TIULOC)>0,($P(D,U,22)'=TIULOC) Q
25 . . S ^TMP("TIUVD",$J,(9999999-+D))=N_U_D
26 S (C,I)=0 F S I=$O(^TMP("TIUVD",$J,I)) Q:+I'>0 D
27 . S C=C+1,^TMP("TIUVN",$J,C)=$G(^TMP("TIUVD",$J,I))
28 . S ^TMP("TIUVDA",$J,+$G(^TMP("TIUVD",$J,I)))=C
29 I '+TIUMODE,'$D(^TMP("TIUVN",$J)) Q
30 I '$D(^TMP("TIUVN",$J)) Q
31 I '+TIUMODE,$G(TIUDFLT)="LAST" D Q:'+TIUX G VADPT
32 . N TIUI S TIUI=+$O(^TMP("TIUVN",$J,0))
33 . S TIUX=$G(^TMP("TIUVN",$J,+TIUI))
34 S (TIUER,TIUOK,TIUI)=0
35 W !!,"The following",$S(FILTER["H":" UNSCHEDULED",1:"")," VISITS are available:",!
36 F S TIUI=$O(^TMP("TIUVN",$J,TIUI)) Q:+TIUI'>0 D Q:+TIUER!+TIUOK!+$G(TIUOUT)
37 . N TIUVR
38 . S TIUII=TIUI,TIUVR=$P(^TMP("TIUVN",$J,TIUI),"^",2,20),TIUVDA=+^(TIUI)
39 . D WRITE
40 . I '(TIUI#5) D BREAK I +$G(TIUX),($L($G(TIUX),";")=3) D VADPT^TIUVSIT S TIUOUT=1 Q
41 . I $G(X)["?" S X="",TIUI=TIUI-5
42 G:$D(TIUOUT) CLEAN
43 G AGN:TIUER
44 I +$G(TIUII)#5 D BREAK I +$G(TIUX),($L($G(TIUX),";")=3) D VADPT^TIUVSIT G CLEAN
45 I +$G(TIUOUT) G CLEAN
46 I +TIUER!($G(X)["?") G AGN
47 I +TIUOK,'+$G(TIUNVIS) D
48 . S TIUX=$G(^TMP("TIUVN",$J,+TIUOK)),^DISV(DUZ,"^AUPNVSIT(")=+TIUX
49 . W " ",$$DATE^TIULS(+$P(TIUX,U,2),"AMTH DD CCYY@HR:MIN")
50VADPT ; Call PATVADPT^TIULV to fill TIUY array
51 N TIUVSTR
52 S TIUVSTR=$P(TIUX,U,23)_";"_$P(TIUX,U,2)_";"_$P(TIUX,U,8)
53 D PATVADPT^TIULV(.TIUY,DFN,"",TIUVSTR)
54CLEAN K ^TMP("TIUVN",$J),^TMP("TIUVD",$J),^TMP("TIUVDA",$J)
55 Q
56BREAK ; Handle prompting
57 N TIUARR,TIUAPT
58 I TIUII=1 S (TIUOK,X)=1
59 W !,"CHOOSE 1-",TIUII," or"
60 S TIUARR("FLDS")="1;",TIUARR(4)=DFN,TIUARR("MAX")=1
61 S TIUAPT=$$SDAPI^SDAMA301(.TIUARR)
62 I TIUAPT=-1 D Q
63 . W !,"An error occurred while accessing the appointments database"
64 . W !," Please contact IRM!",!
65 . S (TIUER,TIUOUT)=1
66 . N X,X1,X2,TIUERR
67 . S X1=DT,X2=90 D C^%DTC
68 . S ^XTMP("TIUSDAMA",0)=X_"^"_DT_"^"
69 . S TIUERR=$O(^TMP($J,"SDAMA301",""))
70 . S:TIUERR ^XTMP("TIUSDAMA",$$NOW^XLFDT,TIUERR)=$G(^TMP($J,"SDAMA301",TIUERR))
71 . K ^TMP($J,"SDAMA301")
72 K ^TMP($J,"SDAMA301")
73 W:TIUAPT !,"<F>UTURE VISITS, or" W:+LETNEW " <N>EW VISIT"
74 W:$D(^TMP("TIUVN",$J,TIUII+1)) !,"<RETURN> TO CONTINUE",!,"OR '^' TO QUIT"
75 W ": " W:$D(TIUPICK) $P(^TMP("TIUVN",$J,TIUPICK),U),"// " R X:DTIME
76 S X=$$UP^XLFSTR(X)
77 I $S('$T:1,X["^":1,1:0) S (TIUER,TIUOUT)=1 Q
78 S:X=""&$D(TIUPICK) X=TIUPICK
79 I X["?" D HELP(X) Q
80 I $E(X)="F" S (TIUFUTUR,TIUOUT)=1 Q
81 I +LETNEW'>0,(X=""),'$D(^TMP("TIUVN",$J,TIUII+1)) S (TIUER,TIUOUT)=1 Q
82 I +LETNEW,$S(X="N":1,X="NEW":1,X=""&'$D(^TMP("TIUVN",$J,TIUII+1)):1,1:0) D ADD^TIUVSIT(DFN,.TIUX,$S(X="N":0,X="NEW":0,1:1),.TIUSDC) S TIUVTRY=1 I +$G(TIUX)'>0 S (TIUER,TIUOUT)=1 Q
83 I $S(X="":1,X="N":1,X="NEW":1,1:0) Q
84 I X'=+X!'$D(^TMP("TIUVN",$J,+X)) W !!,$C(7),"INVALID RESPONSE",! G BREAK
85 S TIUOK=X
86 Q
87HELP(X) ; Offer help
88 W !!?3,"Indicate the visit with which the document is associated by choosing"
89 W !?3,"the corresponding number. To add a new visit (e.g., for unscheduled or"
90 W !?3,"telephone contacts), enter ""N"".",!!
91 Q
92WRITE ; Writes each list element
93 N DIC,DIQ,DA,DR,TIUVISIT,I,J,X,Y
94 S DIC="^AUPNVSIT(",DIQ="TIUVISIT(",DIQ(0)="IE",DA=+TIUVDA
95 S DR=".07;.08;.16;.21;.22" D EN^DIQ1
96 W !,$J(TIUI,4),"> ",$$DATE^TIULS(+TIUVR,"AMTH DD, CCYY@HR:MIN")
97 W ?27,$E($G(TIUVISIT(9000010,DA,.07,"E")),1,18)
98 W ?47,$E($S(TIUVISIT(9000010,DA,.22,"E")]"":TIUVISIT(9000010,DA,.22,"E"),1:TIUVISIT(9000010,DA,.08,"E")),1,18)
99 ;W ?67,$E($G(TIUVISIT(9000010,DA,.22,"E")),1,12) I $G(TIUVISIT(9000010,DA,.21,"E"))]"" W !?23,TIUVISIT(9000010,DA,.21,"E")
100 Q
Note: See TracBrowser for help on using the repository browser.