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

PSXDODNT.m

Go to the documentation of this file.
  1. PSXDODNT ;CMC/WPB Utility to watch DoD directories ;04/01/02 16:52:42
  1. ;;2.0;CMOP;**38,45**;11 Apr 97
  1. ;this routine will watch the incoming directories for files from DoD
  1. ;facilities and direct processing to the appropriate routine.
  1. ;
  1. ;create an option to call the routine, then schedule the option to run
  1. ;every 15 minutes using the TaskMan scheduler
  1. ;
  1. ;files extensions:
  1. ; .trn - transmission of dispense request from Outside Agency to VistA
  1. ; .ack - acknowledgement of dispense requests from VistA to Outside Agency
  1. ; .qry - prescription fulfillment data from VistA to Outside Agency
  1. ; .qac - acknowledgement of receipt of fulfillment data from Outside Agency to VistA
  1. ; .sit - activation/deactivation from Outside Agency to VistA
  1. ; .sac - acknowledgement of activation/deactivation message from VistA to Outside Agency
  1. ; .sch - auto transmission schedule/unscheduled message from Outside Agency to VistA
  1. ; .hac - acknowledgement of auto transmission schedule/unscheduled message from VistA to Outside Agency
  1. ;
  1. ;the path must be setup before this routine can run:
  1. ; path = \\SERVERNAME\CMOP\INBOX
  1. ;for testing the servername = vhacmcdhc3
  1. ;
  1. ; VARIABLES
  1. ; FILELIST the type of files to look for. this is set to all files in the directory
  1. ; FILE stores the list of files
  1. ; PATH the path to the directory where the files are stored
  1. ;
  1. EN ;reads the directory for files
  1. K FILELIST,FILE,PSXERCNT
  1. ; test if previous job still running
  1. S PREVJOB=$O(^XTMP("PSXDODNT")),PSXJOB="PSXDODNT-"_$J
  1. I PREVJOB'="",PREVJOB["PSXDODNT-",PREVJOB'=PSXJOB D I PSXQUIT W !,"STOPPING" Q
  1. . S PSXQUIT=1
  1. . D NOW^%DTC S X1=%,X2=^XTMP(PREVJOB,1) S DIF=$$FMDIFF^XLFDT(X1,X2,2)
  1. . I DIF<1200 Q ; if less than 20 minutes quit
  1. . ;if > 20 minutes, store off previous trail and start new
  1. . D NOW^%DTC
  1. . M ^XTMP("PSXDODERR",%,PREVJOB)=^XTMP(PREVJOB) K ^XTMP(PREVJOB)
  1. . S X=$$FMADD^XLFDT(DT,3) S ^XTMP("PSXDODERR",0)=X_U_DT_U_"DOD CMOP PROCESS ERROR CAPTURE"
  1. . K ^XTMP(PREVJOB) S PSXQUIT=0
  1. . D NOW^%DTC S XX=$$FMTE^XLFDT(%)
  1. . S XMSUB="DOD CMOP INTERFACE STOPPED IRREGULARLY "_XX,XMTEXT="TXT("
  1. . K TXT
  1. . S TXT(1,0)="The DOD CMOP Interface has been idle more than 20 minutes "_XX
  1. . S TXT(2,0)="The XTMP audit trail has been stored in ^XTMP(""PSXDODERR"","_%
  1. . S TXT(3,0)="If this message is appearing frequently contact your CMOP IRM support"
  1. . D ^XMD
  1. ; proceeding to process files
  1. D RESEND
  1. S X1=DT,X2=1 D C^%DTC S PSXDT=X
  1. D NOW^%DTC
  1. K ^XTMP(PSXJOB)
  1. S ^XTMP(PSXJOB,0)=PSXDT_U_%_U_"DOD PSXDODNT LOGGER"
  1. S ^XTMP(PSXJOB,1)=%
  1. ;S FILELIST("*.*")=""
  1. F EXT="*.trn","*.sit","*.sch","*.qac" S FILELIST(EXT)="" ;****testing
  1. ; SET PATH=INBOX DIRECTORY PATH
  1. S PATH=$$GET1^DIQ(554,1,20),FILE=""
  1. S Y=$$LIST^%ZISH(PATH,"FILELIST","FILE")
  1. I Y'=1 D Q ;if Y doesn't equal 1 there weren't any files to get, the routine will stop until called by TaskMan
  1. . D KVAR
  1. . K ^XTMP(PSXJOB) ;****TESTING
  1. ;
  1. DIRECT ;reads the FILE variable to see what types files are available for processing and then sends process to the appropriate routine
  1. I $E(IOST)="C" W !,"Processing Files:" S FILENM="" F S FILENM=$O(FILE(FILENM)) Q:FILENM="" W !,?5,FILENM
  1. S FILENM=""
  1. ; re-entry for next file if error encountered
  1. ;W !,"nxtfile3"
  1. ;F W !,"Nxtfile3a ",FILENM S FILENM=$O(FILE(FILENM)) W !,"nxtfile3b ",FILENM Q:FILENM="" D
  1. F S FILENM=$O(FILE(FILENM)) Q:FILENM="" D
  1. . I '$G(^XTMP("PSXNTSTOP-1",0)) N $ETRAP,$ESTACK S $ETRAP="D ZTER^PSXDODNT"
  1. . S EXT=$$UP^XLFSTR($P(FILENM,".",2))
  1. . ; the following line to be used with Vitria BusinessWare
  1. . S ROU=$S(EXT["SIT":"ACT^PSXDODAC(PATH,FILENM)",EXT["SCH":"EN^PSXDODAT(PATH,FILENM)",EXT["TRN":"EN^PSXDODB(PATH,FILENM)",EXT["QAC":"EN^PSXDODAK(PATH,FILENM)",1:"")
  1. . ;the following line to be used when Vitrai BusinessWare is not being used
  1. . ;S ROU=$S(EXT["SIT":"ACT^PSXDODAC(PATH,FILENM)",EXT["SCH":"EN^PSXDODAT(PATH,FILENM)",EXT["TRN":"EN^PSXDODH(PATH,FILENM)",EXT["QAC":"EN^PSXDODAK(PATH,FILENM)",1:"")
  1. . H 2 D NOW^%DTC S ^XTMP(PSXJOB,%)=FILENM,^XTMP(PSXJOB,1)=%,JOBBEG=% ;I $E(IOST)="C" W !,JOBBEG,?20,^XTMP(PSXJOB,JOBBEG)
  1. . D ROU
  1. . D FINISH
  1. . H 2 D NOW^%DTC S $P(^XTMP(PSXJOB,JOBBEG),U,3)=%,^XTMP(PSXJOB,1)=% ;I $E(IOST)="C" W !,%,?20,^XTMP(PSXJOB,JOBBEG)
  1. K I,INC,Y,ROU
  1. D KVAR
  1. G EN ;loop to see if any other files came in to pickup
  1. ;
  1. FINISH ;
  1. I $E(IOST)="C" W !,"nxtfile4 Finish of ",FILENM
  1. K ^TMP($J,"PSXDODNT")
  1. PULL S PATH=$$GET1^DIQ(554,1,20) S Y=$$FTG^%ZISH(PATH,FILENM,$NA(^TMP($J,"PSXDODNT",1)),3)
  1. ARCHIVE ;
  1. S FILENMAR=FILENM
  1. I FILENM[".TRN" S FILENMAR=FILENM_".BW"
  1. S PATH=$$GET1^DIQ(554,1,22) F XX=1:1:5 S Y=$$GTF^%ZISH($NA(^TMP($J,"PSXDODNT",1)),3,PATH,FILENMAR) Q:Y=1 H 4
  1. I Y'=1 S GBL=$NA(^TMP($J,"PSXDODNT")) D FALERT(FILENMAR,PATH,GBL)
  1. REMOVE I $L($G(FILENM)) K PSXL S PSXL(FILENM)="",PATH=$$GET1^DIQ(554,1,20),Y=$$DEL^%ZISH(PATH,"PSXL")
  1. Q
  1. KVAR ;K FILELIST,FILE,Y,PATH,BADFILE
  1. Q
  1. ROU ; nest the new command so variables will be protected
  1. N FILE,JOBBEG,JOBEND,PSXJOB
  1. I $E(IOST)="C" W !,FILENM," ",ROU
  1. D @ROU
  1. Q
  1. ZTER ;Friendly RE-cycle error and move to next file
  1. S XXERR=$$EC^%ZOSV
  1. S XMSUB="DOD CMOP Error on File "_FILENM
  1. S BADFILE=FILENM
  1. S XMTEXT="TEXT("
  1. S TEXT(1,0)="DOD CMOP encountered the following error. Please investigate"
  1. S TEXT(2,0)="File: "_FILENM
  1. S TEXT(3,0)="Error: "_XXERR
  1. S TEXT(4,0)="The file has been moved into the Hold directory "_$$GET1^DIQ(554,1,23)
  1. D GRP1^PSXNOTE
  1. D ^%ZTER ;log error into Kernel K8SYS pg 183
  1. D ^XMD
  1. I $E(IOST)="C" W !,"zter2:Error Finish & Removal of ",FILENM
  1. K ^TMP($J,"PSXDODNT"),TEXT
  1. PULL2 S PATH=$$GET1^DIQ(554,1,20),Y=$$FTG^%ZISH(PATH,FILENM,$NA(^TMP($J,"PSXDODNT",1)),3)
  1. HOLD S PATH=$$GET1^DIQ(554,1,23) F XX=1:1:5 S Y=$$GTF^%ZISH($NA(^TMP($J,"PSXDODNT",1)),3,PATH,FILENM) Q:Y=1 H 4
  1. I Y'=1 S GBL=$NA(^TMP($J,"PSXDODNT")) D FALERT(FILENM,PATH,GBL)
  1. ARCHIVE2 S PATH=$$GET1^DIQ(554,1,22) F XX=1:1:5 S Y=$$GTF^%ZISH($NA(^TMP($J,"PSXDODNT",1)),3,PATH,FILENM) Q:Y=1 H 4
  1. I Y'=1 S GBL=$NA(^TMP($J,"PSXDODNT")) D FALERT(FILENM,PATH,GBL)
  1. REMOVE2 K PSXL S PSXL(FILENM)="",PATH=$$GET1^DIQ(554,1,20),Y=$$DEL^%ZISH(PATH,"PSXL")
  1. D NOW^%DTC S Y=% X ^DD("DD")
  1. S XQAMSG="PLEASE INVESTIGATE - CMOP/DOD error "_XXERR_" "_Y,XQAID="PSXDODNT"
  1. D GRP1^PSXNOTE M XQA=XMY D SETUP^XQALERT
  1. H 10
  1. G UNWIND^%ZTER ; return to code 1 level above where $ETRAP set ie the F Loop
  1. Q
  1. FALERT(FILE,PATH,GBL) ;fail to pass file into target directory, send alert, store for later
  1. D NOW^%DTC S Y=% X ^DD("DD")
  1. S XQAMSG="DOD: "_FILE_" failed placement into: "_PATH_" "_Y,XQAID="PSXDODNT"
  1. D GRP1^PSXNOTE M XQA=XMY ;****TESTING
  1. ;S XQA(DUZ)="" ;****TESTING
  1. D SETUP^XQALERT
  1. STORE ; store file intO XTMP if GBL PROVIDED
  1. Q:$G(GBL)=""
  1. D NOW^%DTC S NMSPACE="PSXFILE"_"-"_%
  1. S DTPRG=$$FMADD^XLFDT(DT,7) ; save for 7 days
  1. K ^XTMP(NMSPACE)
  1. S ^XTMP(NMSPACE,0)=DTPRG_U_DT_U_"DOD FILE TO SEND"
  1. S ^XTMP(NMSPACE,1)=FILE,^XTMP(NMSPACE,2)=PATH
  1. M ^XTMP(NMSPACE,"T")=@GBL ; GBL IN FORM OF S GBL=$NA(^TMP($J,"PSXDODNT"))
  1. Q
  1. RESEND ; SCAN XTMP and if entries put the files into the boxes
  1. S NMSPACE="PSXFILE"
  1. F S NMSPACE=$O(^XTMP(NMSPACE)) Q:$E(NMSPACE,1,7)'="PSXFILE" D
  1. .S FILE=^XTMP(NMSPACE,1),PATH=^XTMP(NMSPACE,2)
  1. .;W !,FILE," ",PATH
  1. .S Y=$$GTF^%ZISH($NA(^XTMP(NMSPACE,"T",1)),3,PATH,FILE)
  1. .I Y'=1 D FALERT("Resending DOD files ",PATH) S NMSPACE="XX" Q
  1. .K ^XTMP(NMSPACE)
  1. .D NOW^%DTC S Y=% X ^DD("DD")
  1. .S XQAMSG="DOD: "_FILE_" DID PLACE into: "_PATH_" "_Y,XQAID="PSXDODNT"
  1. .;W !,XQAMSG
  1. .D GRP1^PSXNOTE M XQA=XMY ;****TESTING
  1. .;S XQA(DUZ)="" ;****TESTING
  1. .D SETUP^XQALERT
  1. .Q
  1. CLEAR ; CLEAR PREVIOUS NODES history nodes
  1. S X="PSXDODNT" F S X=$O(^XTMP(X)) Q:X'["PSXDODNT" W !,X K ^XTMP(X)
  1. Q
  1. KILLERR ; kill the error LOG ^XTMP("PSXDODERR", )
  1. K ^XTMP("PSXDODERR")
  1. Q
  1. START ;enable/start auto error trapping
  1. K ^XTMP("PSXNTSTOP-1")
  1. Q
  1. STOP ;disable auto error trapping
  1. S ^XTMP("PSXNTSTOP-1",0)=DT_U_DT_U_"disable PSXDODNT auto error trapping"
  1. Q
  1. EDIT ; edit the PSX DODNT option K8 SYS pg 342
  1. D EDIT^XUTMOPT("PSX DOD CMOP INTERFACE")
  1. Q
  1. DISP ; display schedule
  1. D DISP^XUTMOPT("PSX DOD CMOP INTERFACE")
  1. Q
  1. CLEARALL ; clear boxes out, archive, hold of all files
  1. F XX=21,22,23 D CLEARFLS^PSXDODH(XX,"*.*")
  1. Q