source: FOIAVistA/trunk/r/CMOP-PSX/PSXRXQU.m@ 1446

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

initial load of FOIAVistA 6/30/08 version

File size: 4.0 KB
Line 
1PSXRXQU ;BIR/BAB,WPB-CMOP RX QUEUE File Utility ;22 Feb 2002 3:24 PM
2 ;;2.0;CMOP;**7,12,25,33,40,41,54**;11 Apr 97;Build 6
3 ;
4 ;Reference to ^PS(55, supported by DBIA #2228
5PURGE ;Purge 550.1 of any entries w/Message Status "IN TRANSITION"
6 Q:'$D(^PSX(550.1,"AB")) S MSG="" F S MSG=$O(^PSX(550.1,"AB",MSG)) Q:'MSG S DIK=550.1,DA=MSG D ^DIK
7 K DIK,MSG,DA
8 Q
9 ;-------------------------------------------------------------
10NEWMSG ;Increment & create entry in RX QUEUE file, put pid/demog in 'T' ; return PSXMSG, PSX=3
11 ;550.1 has been dinumed
12 D NOW^%DTC
13 S PSXMSG=PSXMSG+1,X=PSXMSG
14 K DO,DD S DIC(0)="L",DIC="^PSX(550.1,",DIC("DR")="1///3;2////"_%_";3////^S X=PSXBAT",DLAYGO=550.1
15 D ^DIC K DIC,DUOUT,DTOUT
16MSH ; build patients MSH HL7 segment
17 ;D RX5502 ;load RX,Fill,Pat,Ord
18 D DEM^VADPT,ADD^VADPT,TSOUT^PSXUTL S ^PSX(550.1,PSXMSG,"T",1,0)="MSH|^~\&|VISTA||CMOP Automated System||"_PSXTS_"||ORM|"_PSXMSG_"|P|2.1|" K PSXTS ;*33
19 S X1=$P(VADM(2),"^")
20 S I="" F S I=$O(VAPA(I)) Q:I="" S VAPA(I)=$$STRIP(VAPA(I)) ; strip bad characters
21 F YT=1:1:4 S VAPA(YT)=$TR(VAPA(YT),"\","/")
22PID ; build patients PID HL7 segment
23 S ^PSX(550.1,PSXMSG,"T",2,0)="PID|||"_$P(VADM(2),"^")_"^"_(X1#11)_"^M11||"_$P(PSXNM,",")_"^"_$P(PSXNM,",",2)_"||||||"_VAPA(1)_"^"_VAPA(2)_"^"_VAPA(4)_"^"_$P($G(^DIC(5,+VAPA(5),0)),"^",2)_"^"_$P(VAPA(11),"^",2)
24 ; Telephone #
25 S XX=$$HLPHONE^HLFNC(VAPA(8)) S:XX["(" XX="("_$P(XX,"(",2,99)
26 S $P(^PSX(550.1,PSXMSG,"T",2,0),"|",14)=XX
27 ; Add other language flag
28 S PSXLANG=$P($G(^PS(55,DFN,"LAN")),"^",2)
29 I $G(PSXLANG)'>1 S PSXLANG=1
30 I PSXLANG>1,'$P($G(^PS(55,DFN,"LAN")),"^") S PSXLANG=1 ; DON'T MARK AS SPANISH IF NO SPANISH SIG
31 I $P($G(^PS(59.7,PSSWSITE,10)),"^",10)="N" S PSXLANG=$S(PSXLANG=1:"ENG",1:"SPA")
32 S $P(^PSX(550.1,PSXMSG,"T",2,0),"|",15)=$G(PSXLANG) K PSXLANG
33 ; GET PATIENT ICN - DON'T SEND IF LOCAL ICN ONLY
34 S PSXICN=$$MPINODE^MPIFAPI(DFN) D
35 .I PSXICN<0 S PSXICN="" Q
36 .I $P(PSXICN,"^",4)=1 S PSXICN="" Q
37 .S PSXICN=$P(PSXICN,"^")_"V"_$P(PSXICN,"^",2)
38 S $P(^PSX(550.1,PSXMSG,"T",2,0),"|",18)=$G(PSXICN) K PSXICN
39 S TDT=$P(VAPA(10),"^")
40 I $G(VAPA(3))]""!($G(TDT)]"") D
41 .I $G(TDT)>1 S TDT=TDT+17000000,TDT1=$E(TDT,1,4),TDT2=$E(TDT,5,6),TDT3=$E(TDT,7,8) S:TDT2'>0 TDT2="01" S:TDT3'>0 TDT3="01" S TDT=$G(TDT1)_$G(TDT2)_$G(TDT3)
42 .S ^PSX(550.1,PSXMSG,"T",3,0)="NTE|8||"_$S($G(TDT)>1:"1\F\"_TDT_"\F\"_VAPA(3),1:"\F\\F\"_VAPA(3))
43 K VADM,VAPA,X1,TDT,YT,TDT1,TDT2,TDT3
44 Q
45LOADMSG ; set RXs HL7 text into PSXMSG 'T', set PSXBAT 1////1
46 S PSX=3
47 S X="" F Q:'$D(PSXORD("M")) S X=$O(PSXORD("M",X)) Q:'X S PSX=PSX+1 S ^PSX(550.1,PSXMSG,"T",PSX,0)=$G(PSXORD("M",X))
48 K PSXORD("M"),X
49 S X="" F Q:'$D(PSXORD("E")) S X=$O(PSXORD("E",X)) Q:'X S PSX=PSX+1 S ^PSX(550.1,PSXMSG,"T",PSX,0)=$G(PSXORD("E",X))
50 K PSXORD("E"),X
51 I '$D(PSXORD) Q ;PSX*2*33
52 S X="" F S X=$O(PSXORD(X)) Q:'X S PSX=PSX+1 S ^PSX(550.1,PSXMSG,"T",PSX,0)=$G(PSXORD(X))
53 S ^PSX(550.1,PSXMSG,"T",0)="^550.11A^"_PSX_"^"_PSX
54 K X1,VAPA,VADM
55QMSG ;Queue message for transmission
56 S DA=PSXMSG,DIE="^PSX(550.1," S DR="1////1" L +^PSX(550.1,DA):600
57 D ^DIE L -^PSX(550.1,DA) K DA,DIE,DR,PSXORD
58 Q
59ACKN ;Flag message as Acknowledged
60 K BEG
61 G LOGACK^PSXPURG
62PROC ;Flag message as Processed
63 ;--------------------------------------------------------
64STAT ;Display status of CMOP RX QUEUE
65 N X,PSX1,PSX2 S PSX1=$G(^PSX(550.1,0)) Q:PSX1=""
66 S PSX1=+$P(PSX1,"^",3),PSX2=+$O(^PSX(550.1,"AS",0))
67 W !!,"Next Order Number to Transmit : ",$S(PSX2:PSX2,1:PSX1)
68 W !!,"Last Order Number Generated : ",PSX1
69 Q
70SUSP ; put RXs ien int 550.1 RX multiple
71RXMSG ; put RX ien into 550.1 RX multiple , returns PSXRXMDA DA within 'M'essage multiple
72 S:'$D(^PSX(550.1,PSXMSG,2,0)) ^PSX(550.1,PSXMSG,2,0)="^550.1101PA^^"
73SET ;
74 K DD,DO,DIC
75 S DA(1)=PSXMSG,(X,DA)=RX,DIC("DR")="1////"_RXF,DIC="^PSX(550.1,"_PSXMSG_",2,",DIC(0)="FZ"
76 D FILE^DICN G:$P(Y,"^",3)'=1 SET K DA,X,DIC,DIC("DR")
77 S PSXRXMDA=+Y
78 Q
79STRIP(X) ;EP Strip control characters out and replace with " "
80 ; $A(124) = Pipe Character '|'
81 N I,Z
82 F I=1:1:$L(X) S Z=$E(X,I),Z=$A(Z) I (Z<32)!(Z>126)!(Z=124) S X=$E(X,1,I-1)_" "_$E(X,I+1,999)
83 Q X
84 ;
Note: See TracBrowser for help on using the repository browser.