source: FOIAVistA/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBCSUTY.m@ 1800

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

initial load of FOIAVistA 6/30/08 version

File size: 6.9 KB
Line 
1PSBCSUTY ;BIRMINGHAM/TEJ- BCMA-HSC COVER SHEET UTILITIES 3 ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;**16,32**;Mar 2004;Build 32
3 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
4 ;
5 ; Reference/IA
6 ; $$GET1^DIQ/2056
7 ; File 200/10060
8CMT ; Comment per admin.
9 S (PSBIENX,PSBPRNRE)="",PSBIENX=+$P(PSBADMS(PSBONMBR,PSBSCHTM),U,3),PSBPRNRE=$P(PSBADMS(PSBONMBR,PSBSCHTM),U,8)
10 D:+$O(^PSB(53.79,PSBIENX,.3,""),-1)>0
11 .S PSBI2=0 F S PSBI2=$O(^PSB(53.79,PSBIENX,.3,PSBI2)) Q:PSBI2="" D
12 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U)="CMT",$P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,2)=$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U)
13 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,4)=$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U,2)
14 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,5)=$$GET1^DIQ(200,$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U,2)_",","INITIAL")
15 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,6)=$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U,3),PSBCNT2=PSBCNT2+1
16 D:($G(PSBPRNRE)]"")&($$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS")]"")
17 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U)="CMT",$P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,3)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS")
18 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,4)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS ENTERED BY","I")
19 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,5)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS ENTERED BY:INITIAL")
20 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,6)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS ENTERED AT","I"),PSBCNT2=PSBCNT2+1
21 Q
22XFERBAGS ;
23 ; Logic to "move IV bags"
24 ; Construct Temp arrays PSBADMX,PSBDONE
25 Q:PSBPONX']""
26 K PSBCHKED
27 S PSBNX2=PSBONX,PSBDFN2=PSBDFN,PSBPNX2=PSBPONX,PSBFN2=PSBFON F Q:PSBFN2]"" D Q:PSBPONX']"" S PSBPNX2=PSBPONX I $G(PSBCHKED(PSBPONX))=1 K PSBCHKED Q
28 .D CLEAN^PSBVT S PSBPONX=PSBPNX2,PSBCHKED(PSBPONX)=1 D PSJ1^PSBVT(PSBDFN2,PSBPONX)
29 .S (PSBXX,PSBXXX)="" F S PSBXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX)) Q:PSBXX="" D
30 ..S PSBXXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX="" Q:$P(^PSB(53.79,PSBXXX,0),U,9)="C" S:'$D(PSBDONE(PSBXXX)) (PSBADMX(PSBNX2,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
31 ; Refresh data
32 D CLEAN^PSBVT,PSJ1^PSBVT(PSBDFN2,PSBNX2)
33 K PSBNX2,PSBDFN2,PSBPNX2,PSBFN2
34 Q
35GETADMX ;
36 S (PSBXX,PSBXXX)="" F S PSBXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX)) Q:PSBXX="" D
37 .Q:(PSBXX<PSBMHBCK)&'PSBLVIV
38 .F S PSBXXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX="" Q:(PSBFON]"")&($P(^PSB(53.79,PSBXXX,0),U,9)'="C")&(PSBLVIV) D
39 ..S (PSBADMX(PSBONX,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
40 ; Check "actions" that DO NOT get filed into AORDX !!
41 S (PSBXX,PSBXXX)="" F S PSBXX=$O(^PSB(53.79,"AORD",PSBDFN,PSBONX,PSBXX)) Q:PSBXX="" D
42 .F S PSBXXX=$O(^PSB(53.79,"AORD",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX="" D
43 ..S:('$D(PSBDONE(PSBXXX)))&($P(^PSB(53.79,PSBXXX,0),U,6)'<PSBMHBCK) PSBADMX(PSBONX,PSBXX,PSBXXX)=""
44 K PSBXX,PSBXXX,PSBDONE
45 Q
46LVIV ;
47 ; Set up variables to later extract LVIV data
48 ; Add all LVIVs that have been active with in the window!!
49 I (PSBOSP'<PSBWBEG)&(PSBOSP'>PSBWEND) D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1_".",PSBDDS,PSBSOLS,PSBADDS,"CVRSHT")
50 S PSBEXPRD=0 I (PSBFON']"")&(PSBOSP<PSBNOW) S PSBEXPRD=1
51 S (PSBXX,PSBXXX)="" F S PSBXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX)) Q:PSBXX="" D
52 .S PSBXXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""
53 .I "IS"[$P(^PSB(53.79,PSBXXX,0),U,9)&(PSBFON']"") S PSBEXPRD=0
54 .S:'$D(PSBDONE(PSBXXX))&(PSBFON="") (PSBADMX(PSBONX,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
55 S (PSBXX,PSBXXX)="" F S PSBXX=$O(PSBADMX(PSBONX,PSBXX)) Q:PSBXX="" D
56 .S PSBXXX=$O(PSBADMX(PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""
57 .I "IS"[$P(^PSB(53.79,PSBXXX,0),U,9)&(PSBFON']"") S PSBEXPRD=0
58 .S:'$D(PSBDONE(PSBXXX))&(PSBFON="") (PSBADMX(PSBONX,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
59 Q
60QUT() ;
61 S QUT=0
62 I PSBOST>($$FMADD^XLFDT($$NOW^XLFDT,,,$$GET^XPAR("DIV","PSB ADMIN BEFORE"))) S QUT=1 Q QUT
63 I '(($F("ED",PSBOSTS)'>1)&(PSBOSP'<%)) S QUT=1 Q QUT
64 Q QUT
65USED() ;
66 S (PSBXIEN,PSBUSD,USED)=0,PSBBAGX=$P(PSBXREC,U,2)
67 I $$QUT() S (PSBUSD,USED)=1 Q PSBUSD
68 S PSBXXX="" F S PSBXXX=$O(^PSB(53.79,"AUID",PSBDFNX,PSBXXX)) Q:PSBXXX="" D Q:PSBUSD
69 .I $D(^PSB(53.79,"AUID",PSBDFNX,PSBXXX,PSBBAGX)) S PSBXIEN=$O(^PSB(53.79,"AUID",PSBDFNX,PSBXXX,PSBBAGX,"")) S:$F("GICSHRM",$P(^PSB(53.79,PSBXIEN,0),U,9))>1 (PSBUSD,USED)=1,PSBOBAG(PSBONMBR)=""
70 Q USED
71ORC ; Ord cmmnts
72 S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORC",$P(^TMP("PSB",$J,"CVRSHT2",PSBCNT2),U,2)=^TMP("PSB",$J,PSBTAB,PSBI1),PSBRECHD="ORF"
73 Q
74ORF ; Ordr flag "ORF^FLAG^Flg Comment"
75 K ^TMP("PSJ1",$J),PSBNOX
76 D EN^PSJBCMA1(PSBDFN,PSBONMBR,1)
77 ;Set STAT FLAG
78 I $P(^TMP("PSJ1",$J,7),U,1) S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORF^STAT"
79 ;Set IM/CPRS ord flg and cmment
80 I $P(^TMP("PSJ1",$J,7),U,2) D
81 .S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORF^CPRS^"_$P(^TMP("PSJ1",$J,7),U,3)_U_$P(^TMP("PSJ1",$J,7),U,4)
82 .I $P(^TMP("PSJ1",$J,7),U,3)']"" D
83 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBCNT2),U,2)="CPRS"
84 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBCNT2),U,3)="*PSJ DATA ERROR* ^ PSJ Order Flag Error"
85 K ^TMP("PSJ1",$J)
86 ;Set No Act Flag
87 I ('$D(^PSB(53.79,"AORDX",PSBDFN,PSBONMBR))) I (PSBLRGIV) I '$D(PSBADMX(PSBONMBR)) I $P(PSBORREC,U,26)>$G(%,PSBNOW) D
88 .S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORF^NOX^No Action Taken On Order"
89 .S PSBNOX(PSBONMBR,PSBCNT2)=""
90 S PSBRECHD="MED"
91 Q
92MED ; Cnstr DD,ADD,SOL,ID
93 F I=PSBI1:1 S PSBXREC=^TMP("PSB",$J,PSBTAB,I) Q:PSBXREC="END" D
94 .I $P(PSBXREC,U)="ID" S PSBUSED=$$USED() Q:PSBUSED
95 .S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)=PSBXREC
96 S PSBI1=I-1
97 Q
98FINALPAS ;
99 S PSBI1="^TMP(""PSB"",$J,""CVRSHT"")",PSBCNT1=0
100 F S PSBI1=$Q(@PSBI1) Q:PSBI1["CVRSHT2" D
101 .I $QS(PSBI1,4)'>1 S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=@PSBI1,PSBCNT1=PSBCNT1+1 Q
102 .K PSBX2 M PSBX2=^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4))
103 .I $QS(PSBI1,5)="" S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=@PSBI1,PSBCNT1=PSBCNT1+1 Q
104 .K PSBDONE
105 .I '$D(PSBX2(1)) S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=@PSBI1,PSBCNT1=PSBCNT1+1 Q
106 .F PSBI2=1:1 Q:'$D(PSBX2(PSBI2)) D ;sort actn/cmmnt rev. chrono
107 ..Q:$D(PSBDONE(PSBI2))
108 ..S PSBXDTTM=(-1*($P(PSBX2(PSBI2),U,6)))_+($E($P(PSBX2(PSBI2),U,4),$L($P(PSBX2(PSBI2),U,4))-6,999)),PSBMCODE=$P(PSBX2(PSBI2),U)
109 ..D:(+PSBXDTTM<0)&(PSBMCODE["ADM")
110 ...S PSBX3(+PSBXDTTM,-999)=PSBX2(PSBI2),PSBDONE(PSBI2)="" K ^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4),PSBI2)
111 ...F PSBI3=1:1 Q:'$D(PSBX2(PSBI2+PSBI3)) Q:$P(PSBX2(PSBI2+PSBI3),U)'["CMT" D
112 ....S PSBX3(+PSBXDTTM,-1*PSBI3)=PSBX2(PSBI2+PSBI3),PSBDONE(PSBI2+PSBI3)="" K ^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4),PSBI2+PSBI3)
113 ..D:(+PSBXDTTM=0)&(PSBMCODE["ADM")
114 ...S PSBX3(PSBI2,0)=PSBX2(PSBI2),PSBDONE(PSBI2)="" K ^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4),PSBI2)
115 .I $D(PSBX3) D K PSBX3
116 ..S PSBI2="" F S PSBI2=$O(PSBX3(PSBI2)) Q:PSBI2="" S PSBI3="" F S PSBI3=$O(PSBX3(PSBI2,PSBI3)) Q:PSBI3="" D
117 ...S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=PSBX3(PSBI2,PSBI3),PSBCNT1=PSBCNT1+1
118 S $P(^TMP("PSB",$J,"CVRSHT2",0),U)=PSBCNT1-1
119 Q
Note: See TracBrowser for help on using the repository browser.