Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PSXRTR

PSXRTR.m

Go to the documentation of this file.
  1. PSXRTR ;BIR/BAB,WPB,PWC-Transmit Data to CMOP Host System ;14 Dec 2001
  1. ;;2.0;CMOP;**18,23,27,31,28,41,51**;11 Apr 97
  1. ;Reference to ^DIC(4.2 supported by DBIA #1966
  1. ;Reference to ^PS(59 supported by DBIA #1976
  1. ;Reference to File #200 supported by DBIA #10060
  1. ;Requires PSXHDR,PSXORD (A B C D) arrays
  1. Q
  1. EN ;Entry point for data transmission, load mailman message and send
  1. S PSXJOB=1,PSXRTRN=0 K ERR
  1. I $E(IOST)="C" W !,"EN^PSXRTR DIV: ",PSOSITE," ",+$G(PSXBAT)
  1. I (($G(PSXBAT)="")!('$D(^PSX(550.1,"C",PSXBAT)))) G EXIT
  1. S (PSXMSG,PSXMFLAG,PSXEND,PSXSTART)=0
  1. F S PSXMSG=$O(^PSX(550.1,"C",PSXBAT,PSXMSG)) Q:PSXMSG'>0 S PSXEND=PSXMSG S:PSXSTART=0 PSXSTART=PSXMSG
  1. S PSXSITE=$P($G(PSXSYS),U,3),PSXSENDR=$$GET1^DIQ(200,DUZ,.01),SITENUM=$P($G(PSXSYS),U,2),PSXDIV=$P($G(^PS(59,+PSOSITE,0)),U,1),XSITE=$P($G(^PS(59,+PSOSITE,0)),U,6)
  1. S PSXHDR=PSXSITE_U_+PSXSYS_U_SITENUM_U_PSXTDT_U_PSXSENDR_U_PSXSTART_U_PSXEND_U_PSXDIV_U_XSITE,PSXREF=SITENUM_"-"_$$GET1^DIQ(550.2,PSXBAT,.01)
  1. N DOMAIN,LCNT,XMDUZ,XMSUB,XMZ,ORD
  1. S (LCNT,PSXMSGCT,PSXRXCT)=0
  1. S X=$$KSP^XUPARAM("INST"),DIC="4",DIC(0)="XMZO" D ^DIC S SITEX=$P(Y,"^",2) K DIC,X,Y
  1. S XMSUB="CMOP"_$S($G(PSXCS)=1:" Controlled Substances",1:"")_" Transmission from "_SITEX,XMDUZ=.5
  1. XMZ D XMZ^XMA2
  1. I XMZ'>0 G XMZ
  1. K SITEX
  1. HDR ;Gather data from header, load NTE1 - NTE5 into mailmessage from PSXORD( array
  1. S ORD="$$XMIT"_U_$$GET1^DIQ(550.2,PSXBAT,.01)_U_PSXHDR D TXT
  1. S ORD=$G(PSXORD("A")) D TXT
  1. ;If not any data in the refill/nonrefill/copay instructions set
  1. ;set array equal to NTE...+3 spaces
  1. S:$G(PSXORD("B",1))="" PSXORD("B",1)="NTE|2|| "
  1. S:$G(PSXORD("C",1))="" PSXORD("C",1)="NTE|3|| "
  1. S:$G(PSXORD("D",1))="" PSXORD("D",1)="NTE|4|| "
  1. F ZZ="B","C","D" S Z=0 F S Z=$O(PSXORD(ZZ,Z)) Q:Z'>0 S ORD=$G(PSXORD(ZZ,Z)) D TXT
  1. ;Gather data for individual patient orders
  1. LOCK ;
  1. D NOW^%DTC S DTTM=%,(MSG,ZCNT)=0
  1. ; load patients' 550.1 "T" nodes into the mail message
  1. F S MSG=$O(^PSX(550.1,"C",PSXBAT,MSG)) Q:MSG="" S PSXMSGCT=PSXMSGCT+1,LNTX=+$P(^PSX(550.1,MSG,"T",0),U,4) D
  1. .S ORD="$MSG^"_+$G(^PSX(550.1,MSG,0))_U_LNTX D TXT
  1. .F PSX=1:1:LNTX I $G(^PSX(550.1,MSG,"T",PSX,0))]"" S ORD=$G(^(0)) S:$E(ORD,1,7)="ORC|NW|" PSXRXCT=PSXRXCT+1 D TXT
  1. .K DA,DIE,DR S DA=MSG L +^PSX(550.1,DA)
  1. .S DIE="^PSX(550.1,",DR="1///2;5////"_DTTM_";3////"_PSXBAT
  1. .D ^DIE L -^PSX(550.1,DA) K DA,DIE,DR ;update msgs in 550.1
  1. S ORD="$$ENDXMIT^"_U_PSXFAC_U_PSXBAT_U_PSXMSGCT_U_PSXRXCT D TXT K ORD
  1. S ^XMB(3.9,XMZ,2,0)="^3.92A^"_LCNT_U_LCNT_U_DT,XMDUN="CMOP Manager"
  1. S XMDUZ=.5
  1. S RECV=$P($G(^PSX(550,+PSXSYS,0)),U,4),DOMAIN="@"_$$GET1^DIQ(4.2,RECV,.01)
  1. ;code to divert patient transmissions for testing
  1. I '$D(^XTMP("PSXDIVERTCMOP")) S XMY("S.PSXX CMOP SERVER"_DOMAIN)="" I 1 ;****TESTING
  1. E S XX=^XTMP("PSXDIVERTCMOP",1) S XMY(XX)="" H 1 ;****TESTING S.PSXX
  1. D ENT1^XMD
  1. D XMIT
  1. S PSXFLAG=1 D EN^PSXNOTE
  1. K DIE,DA,DR,BAT,PSX,PSXORD,MSG,LNTX,LCNT,DOMAIN,RECV,SITENUM,Z,ZZ,XMDUN,XMDUZ,XMSUB,XMY,XMZ,PSXDIV,XSITE
  1. Q
  1. XMIT ;Update 550.2 # of ORDs, RXs; rxS IN 52, 52.5: 550.2 to Transmitted
  1. ;Update 550 with batch
  1. N PSXTRDTM D NOW^%DTC S PSXTRDTM=%
  1. L +^PSX(550.2,PSXBAT):600 I '$T S XQAMSG="CMOP Transmission file in use. Entry for trans "_PSXBAT_" not complete. Contact IRM." D GRP1^PSXNOTE,SETUP^XQALERT K XQAMSG,XQA Q
  1. S DA=PSXBAT,DIE="^PSX(550.2,",DR="1////2;11////"_PSXSTART_";12////"_PSXEND_";13////"_PSXMSGCT_";14////"_PSXRXCT_";5////"_PSXTRDTM
  1. D ^DIE K DA,DIE,DR
  1. L -^PSX(550.2,PSXBAT)
  1. S PSXMFLAG=1
  1. D ^PSXRXU ; update RXs in 52 52.5
  1. L +^PSX(550,+PSXSYS):600 Q:'$T
  1. S DA=+PSXSYS,DIE="^PSX(550,",DR="6////"_PSXBAT D ^DIE K DIE,DA,DR
  1. L -^PSX(550,+PSXSYS)
  1. Q
  1. TXT ;
  1. I $G(ORD)]"" S LCNT=LCNT+1,^XMB(3.9,XMZ,2,LCNT,0)=ORD
  1. Q
  1. EXIT K %,ERROR,PSXRTRN,PSXJOB,PSXER,PSXHDR,PSXFAC,PSXBAT,PSXEND,PSXMFLAG,PSXMSG,PSXMSGCT,PSXRXCT,PSXSENDR,PSXSITE,PSXTDT,N Q
  1. Q
  1. DIVERT ; divert transmissions from CMOP to the user evoking the divert
  1. W !,"This will divert CMOP Patient transmissions to the user evoking the divert",!,"for one day or until 'D RESET^PSXRTR' is executed.",!
  1. K DIR S DIR(0)="YO",DIR("B")="N" D ^DIR
  1. I 'Y W !,"CMOP Patient transmissions >>NOT DIVERTED<<",! Q
  1. S ^XTMP("PSXDIVERTCMOP",0)=DT_U_DT_U_"Divert CMOP Transmissions"
  1. S ^XTMP("PSXDIVERTCMOP",1)=DUZ
  1. W !!,"CMOP Patient transmissions >>DIVERTED<< to ",$$GET1^DIQ(200,DUZ,.01),!!,"Use 'D RESET^PSXRTR' to restore normal CMOP Patient transmissions.",!
  1. K DIR S DIR(0)="E",DIR("A")="<CR> Continue" D ^DIR
  1. Q
  1. RESET ; reset normal CMOP Patient transmissions
  1. S XX=$D(^XTMP("PSXDIVERTCMOP"))
  1. S N=$S(XX>0:"HAD BEEN",1:"HAD NOT BEEN")
  1. W !,"CMOP Patient transmissions >>",N,"<< diverted"
  1. I XX S XX=^XTMP("PSXDIVERTCMOP",1) W " to ",$$GET1^DIQ(200,XX,.01)
  1. W ".",!,"CMOP Patient transmissions are set to go to the CMOP.",!
  1. K ^XTMP("PSXDIVERTCMOP")
  1. Q