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

RGI15PST.m

Go to the documentation of this file.
  1. RGI15PST ;Hines OI/GJC-POST-INIT FOR RG*1.0*15 ;01/03/01
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**15**;30 Apr 99
  1. ;
  1. N RGC
  1. S RGC=$$NEWCP^XPDUTL("POST1","EN1^RGI15PST")
  1. ; Check to see the patient has had a check out event
  1. ; due to a completion of a Rad/Nuc Med, Surgery or Lab
  1. ; procedure. Checkpoint for patient's ICN while traversing
  1. ; the AICN cross reference in the Patient (#2) file.
  1. ;
  1. S RGC=$$NEWCP^XPDUTL("POST2")
  1. ; Checkpoint for patient's dfn while traversing
  1. ; the AICN cross reference in the Patient (#2) file.
  1. ;
  1. Q
  1. EN1 ; entry point to check the TREATING FACILITY LIST (TFL-391.91) file
  1. ; for the proper LAST TREATMENT DATE. This code is part of the post
  1. ; init for RG*1*15.
  1. ;
  1. ; Integration Agreements (IAs) utilized in this application:
  1. ; #2988-IAs for VAFCTFU utilities
  1. ; #2911-Treating Facility List (TFL-391.91) relationship with MPI/PD
  1. ; #2070-use of Integration Control Number (ICN) 'AICN' cross reference
  1. ;
  1. S:$D(ZTQUEUED) ZTREQ="@"
  1. N RGDT S RGDT=$P($G(^RGSITE(991.8,1,1)),"^",3)
  1. I RGDT D Q
  1. .N RGTXT
  1. .S RGTXT(1)="Data comparison ran on "_$$FMTE^XLFDT($E(RGDT,1,12),"1P")
  1. .S RGTXT(2)="Data comparison process exiting..."
  1. .D BMES^XPDUTL(.RGTXT)
  1. .Q
  1. S (RGCNT,RGCNT(0),RGXIT)=0
  1. S RGSTART=$$FMTE^XLFDT($E($$NOW^XLFDT(),1,12),"1P") ; start time
  1. S U="^",RGSITE=$$KSP^XUPARAM("INST") ;defines the local facility
  1. ; checkpoints for RGICN (POST1) & RGDFN (POST2)
  1. S RGICN=+$$PARCP^XPDUTL("POST1")
  1. ; check ALL patients with an Integration Control Number (ICN) for a
  1. ; given facility, make sure the DATE LAST TREATED field in the
  1. ; TREATING FACILITY LIST (#391.91-TFL) file is correct.
  1. F S RGICN=$O(^DPT("AICN",RGICN)) Q:RGICN'>0 D Q:RGXIT
  1. .S RGDFN=+$$PARCP^XPDUTL("POST2")
  1. .F S RGDFN=$O(^DPT("AICN",RGICN,RGDFN)) Q:RGDFN'>0 D Q:RGXIT
  1. ..D EN2(RGDFN)
  1. ..S RGS=$$UPCP^XPDUTL("POST2",RGDFN)
  1. ..S RGCNT=RGCNT+1
  1. ..Q:(RGCNT#250) ; every 250 patients, check if process stopped
  1. ..D:'$D(ZTQUEUED) EN^DDIOL(".",,"?0") ; print dots (process active)
  1. ..S RGXIT=$$S^%ZTLOAD() ; return 1 if user stopped the task, else 0
  1. ..S:RGXIT ZTSTOP=1 ; informs submgr to set task status to 'stopped'
  1. ..Q
  1. .S RGS=$$UPCP^XPDUTL("POST1",RGICN)
  1. .S RGS=$$UPCP^XPDUTL("POST2",RGDFN)
  1. .Q
  1. S RGFIN=$$FMTE^XLFDT($E($$NOW^XLFDT(),1,12),"1P") ; finish time
  1. D EMAIL
  1. I '$G(ZTSTOP) D ; only if the process runs to completion
  1. .K RGFDA S RGFDA(991.8,"1,",13)=$$NOW^XLFDT()
  1. .D FILE^DIE("K","RGFDA")
  1. .Q
  1. D KILL
  1. QUIT
  1. ;
  1. EN2(RGDFN) ; determine the LAST TREATMENT DATE for a single
  1. ; patient called from our seeding process above.
  1. ; input: RGDFN - the dfn of the patient
  1. ;
  1. Q:$$LOCICN^RGADT2(RGDFN,$G(RGICN)) ; local ICN
  1. ; find the date last treated for this patient at this facility.
  1. ; check the Outpatient Encounter (OE) file for a date
  1. ; chronologically after the date/time filed in the TFL (#391.91)
  1. ; file. If a date/time exists that falls after the date/time on file
  1. ; update the CMOR/subscribers.
  1. S RGCNT(0)=RGCNT(0)+1
  1. S RGTFL=+$O(^DGCN(391.91,"APAT",RGDFN,RGSITE,0))
  1. S RGDLT=$P($G(^DGCN(391.91,RGTFL,0)),U,3) ; a date/time or null
  1. S RGDATE=$$ENCDT(RGDFN,RGDLT) ; patient's OE date/time (if any)
  1. I $L(RGDATE),RGDATE>RGDLT D FILE^VAFCTFU(RGDFN,RGSITE_U_RGDATE_U_"A3",$G(RGSUP))
  1. ; update the TFL file for the site running the Outpatient Encounter
  1. ; check. Build the HL7 message with the new DATE LAST TREATED &
  1. ; ADT/HL7 EVENT REASON values & send them to our CMOR/subscribers.
  1. Q
  1. ;
  1. KILL ; kill and quit
  1. K RGCNT,RGDATE,RGDFN,RGDLT,RGFIN,RGICN,RGPARSE,RGS,RGSITE,RGSTART
  1. K RGTFL,RGXIT
  1. Q
  1. ;
  1. ENCDT(DFN,INPDT) ; find the last patient check out date/time. 'ADFN'
  1. ; cross-reference accessed through DBIA: 2953
  1. ; Input: DFN - ien of the patient (file 2)
  1. ; INPDT - date (if any) obtained from the DATE LAST TREATED
  1. ; (#.03) field on the TFL (#391.91) file.
  1. ;Output: a valid check out date/time -or- null
  1. ;
  1. K RGDATA,RGPURGE,RGX,RGX1,RGX2 N RGX3
  1. S RGX=$C(32),RGX2=0,RGX3=""
  1. F S RGX=$O(^SCE("ADFN",DFN,RGX),-1) Q:'RGX!(INPDT>RGX) D Q:RGX2
  1. .S RGX1=0
  1. .F S RGX1=$O(^SCE("ADFN",DFN,RGX,RGX1)) Q:'RGX1 D Q:RGX2
  1. ..D GETGEN^SDOE(RGX1,"RGDATA"),PARSE^SDOE(.RGDATA,"EXTERNAL","RGPARSE")
  1. ..I $G(RGPARSE(.12))="CHECKED OUT" S RGX2=1,RGX3=RGX
  1. ..K RGDATA,RGPARSE
  1. ..Q
  1. .Q
  1. K RGDATA,RGPURGE,RGX,RGX1,RGX2
  1. Q RGX3 ; X is either null or the date/time of the check out
  1. ;
  1. EMAIL ; Send a completion email message to the user who installed this patch.
  1. ; Show the number of patient records processed, elapsed time and the
  1. ; number of patient records processed per minute.
  1. N DIFROM,RGARY S XMDUZ=.5,XMY(DUZ)="",XMTEXT="RGARY(1,"
  1. S XMY("G.MPIF EXCEPTIONS")="" ; keep us updated...
  1. S XMSUB="MPI/PD-determine the correct DATE LAST TREATED"
  1. S RGARY(1,1)="Data compare between the DATE field in the OUTPATIENT ENCOUNTER"
  1. S RGARY(1,2)="(#409.68) file and the DATE LAST TREATED field in the TREATING"
  1. S RGARY(1,3)="FACILITY LIST (#391.91) file"
  1. S RGARY(1,4)="process start time: "_RGSTART
  1. S RGARY(1,5)="process completion time: "_RGFIN
  1. S RGARY(1,6)=" "
  1. S RGARY(1,7)="# of processed patients, in the PATIENT (#2) file with"
  1. S RGARY(1,8)="an ICN: "_RGCNT
  1. S RGARY(1,9)="# of processed patients, in the PATIENT (#2) file with"
  1. S RGARY(1,10)="a non-local ICN: "_RGCNT(0)
  1. I $G(ZTSTOP) S RGARY(1,11)=" ",RGARY(1,12)="Note: task stopped by user intervention"
  1. D ^XMD K XMDUZ,XMSUB,XMTEXT,XMY
  1. Q