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

TIUP188.m

Go to the documentation of this file.
  1. TIUP188 ;SLC/RMO,TT - Post-Install for TIU*1*188 ; [5/19/04 1:26pm]
  1. ;;1.0;Text Integration Utilities;**188**;Jun 20, 1997
  1. ;
  1. EN ;Entry point to queue a job to automatically link the missing VISIT
  1. ;field for a date range of documents
  1. N TIUBEGDT,TIUENDT,ZTDESC,ZTIO,ZTRTN,ZTSAVE,ZTSK
  1. ;
  1. W !!,"PATCH TIU*1*188"
  1. W !!,"Automatically Link the missing VISIT field for a date range of documents"
  1. W !!,"Documents must meet the following criteria to be linked:"
  1. W !,"- Date range cannot be before 8/1/02 or after TODAY"
  1. W !,"- Entry Date/Time is within the selected date range"
  1. W !,"- No visit has been associated with the document"
  1. W !,"- A visit exists to be associated with the document"
  1. W !,"- The capture method is direct or remote"
  1. W !,"- The status is uncosigned or completed or amended"
  1. W !,"- The document is under the progress notes class or consults"
  1. W !,"- The document has a signature date/time"
  1. W !,"- Workload data should be collected for the document"
  1. W !!," Special Note about Parameters:",!
  1. W !," The 'ASK DX/CPT ON ALL OPT VISITS' TIU Document parameter"
  1. W !," is not date sensitive so collecting workload is based on"
  1. W !," the value of this parameter at the time this routine is"
  1. W !," invoked rather than at the time the visit was created."
  1. ;
  1. ;Ask date range
  1. I '$$ASKRNG(.TIUBEGDT,.TIUENDT) G ENQ
  1. ;
  1. ;Set variables
  1. S (ZTSAVE("TIUBEGDT"),ZTSAVE("TIUENDT"))=""
  1. S ZTRTN="LNKRNG^TIUP188",ZTIO="",ZTSAVE("DUZ")=""
  1. S ZTDESC="Automatically link missing VISIT field for File #8925 - Patch 188"
  1. W ! D ^%ZTLOAD
  1. I $G(ZTSK) D
  1. . W !!,"A task has been queued in the background and a bulletin will be sent"
  1. . W !,"to you upon completion of the task or if the task is stopped."
  1. . W !,"Please only run one date range at a time."
  1. . W !!,"The task number is "_$G(ZTSK)_"."
  1. ENQ Q
  1. ;
  1. ASKRNG(BEGDT,ENDT) ;Prompt for date range
  1. ; Input -- None
  1. ; Output -- 1=Successful and 0=Failure
  1. ; BEGDT Begin Date
  1. ; ENDT End Date
  1. N DIRUT,DTOUT,DUOUT,Y
  1. W !!,"Please specify a date range:"
  1. S BEGDT=+$$READ^TIUU("DA^"_3020801_":"_DT_":E"," Beginning: ")
  1. I +$D(DIRUT)!(BEGDT'>0) G ASKRNGQ
  1. S ENDT=+$$READ^TIUU("DA^"_BEGDT_":"_DT_":E"," Thru: ")_"."_235959
  1. I +$D(DIRUT)!(ENDT'>0) G ASKRNGQ
  1. S Y=1
  1. ASKRNGQ Q +$G(Y)
  1. ;
  1. LNKRNG ;Entry point to automatically link a document to a visit for
  1. ;a specified date range
  1. ; Input -- TIUBEGDT Begin Date
  1. ; TIUENDT End Date
  1. ; Output -- ^XTMP("TIUP188", Global
  1. N TIUDA,TIUDT,TIURSTDT,TIUS
  1. ;
  1. ;Exit if required variables are not defined
  1. I '$G(TIUBEGDT)!('$G(TIUENDT)) G LNKRNGQ
  1. ;
  1. ;Initialize re-start if check point exists
  1. I +$G(^XTMP("TIUP188","CHKPT")) D
  1. . S TIURSTDT=$P($G(^XTMP("TIUP188","CHKPT")),U,1)
  1. ELSE D
  1. . ;Initialize ^XTMP("TIUP188" if not re-start
  1. . S ^XTMP("TIUP188",0)=$$FMADD^XLFDT(DT,90)_U_DT
  1. . S ^XTMP("TIUP188","CNT","EX")=0 F TIUS=1:1:3 S ^XTMP("TIUP188","CNT","EX",TIUS)=0
  1. . S ^XTMP("TIUP188","CNT","LNK")=0
  1. . S ^XTMP("TIUP188","CNT","TOT")=0
  1. . S ^XTMP("TIUP188","CHKPT")=U_TIUBEGDT_U_TIUENDT
  1. K ^XTMP("TIUP188","STOP")
  1. S ^XTMP("TIUP188","T0")=$$NOW^XLFDT
  1. ;
  1. ;Loop through Entry Date/Time of documents by specified date range
  1. S TIUDT=$S($G(TIURSTDT):TIURSTDT,1:TIUBEGDT)
  1. F S TIUDT=$O(^TIU(8925,"F",TIUDT)) Q:'TIUDT!(TIUDT>TIUENDT)!($G(ZTSTOP)) D
  1. . ;Loop through documents for Entry Date/Time
  1. . S TIUDA=0
  1. . F S TIUDA=+$O(^TIU(8925,"F",TIUDT,TIUDA)) Q:'TIUDA D LNKONE(TIUDA)
  1. . ;Set check point for Entry Date/Time
  1. . S $P(^XTMP("TIUP188","CHKPT"),U,1)=TIUDT
  1. . ;Check if user requested to stop task
  1. . I $$S^%ZTLOAD S ZTSTOP=1
  1. ;
  1. LNKRNGQ ;Send bulletin, re-set check point and clean up variables
  1. I $G(ZTSTOP) S ^XTMP("TIUP188","STOP")=$$NOW^XLFDT
  1. S ^XTMP("TIUP188","T1")=$$NOW^XLFDT
  1. ;
  1. D MAIL^TIUP188P
  1. ;
  1. I '$G(ZTSTOP) S ^XTMP("TIUP188","CHKPT")=""
  1. K TIUBEGDT,TIUENDT,TIURSTDT
  1. Q
  1. ;
  1. LNKONE(TIUDA) ;Entry point to automatically link one document to visit
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; Output -- None
  1. N TIUEX,TIUMVSTF,TIUVSIT
  1. ;
  1. ;Check if document can be linked
  1. I $D(^TIU(8925,TIUDA,0)),$P(^(0),U,3)'>0,$$CHKDOC(TIUDA) D
  1. . ;Get visit to associate with document
  1. . D GETVST(TIUDA,.TIUVSIT,.TIUMVSTF)
  1. . ;If only one visit update the document with the visit
  1. . I $G(TIUVSIT)>0,'$G(TIUMVSTF) D
  1. . . I $G(TIUVSIT),$$UPDVST^TIUPXAP2(TIUDA,TIUVSIT) D
  1. . . . ;Document linked to visit
  1. . . . D SETXTMP(TIUDA,,TIUVSIT)
  1. . . . ;Update kids that are addenda
  1. . . . D UPDKIDS(TIUDA,TIUVSIT)
  1. . . ELSE D
  1. . . . ;Unable to automatically link - entry in use
  1. . . . D SETXTMP(TIUDA,2)
  1. . ELSE D
  1. . . ;Unable to automatically link - multiple visits or no matching visit
  1. . . S TIUEX=$S($G(TIUMVSTF):1,1:3)
  1. . . D SETXTMP(TIUDA,TIUEX)
  1. S ^XTMP("TIUP188","CNT","TOT")=+$G(^XTMP("TIUP188","CNT","TOT"))+1
  1. Q
  1. ;
  1. CHKDOC(TIUDA) ;Check if document can be auto-linked
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; Output -- 1=Can be linked and 0=Cannot be linked
  1. N TIUD0,TIUDPRM,Y
  1. ;
  1. ;Set variables
  1. S Y=0
  1. S TIUD0=$G(^TIU(8925,TIUDA,0))
  1. D DOCPRM^TIULC1(+TIUD0,.TIUDPRM)
  1. ;
  1. ;Capture method must be direct or remote
  1. I ("^D^R^")'[(U_$P($G(^TIU(8925,TIUDA,13)),U,3)_U) G CHKDOCQ
  1. ;
  1. ;Status must be uncosigned or completed or amended
  1. I ("^6^7^8^")'[(U_$P(TIUD0,U,5)_U) G CHKDOCQ
  1. ;
  1. ;Document must be signed
  1. I '+$G(^TIU(8925,TIUDA,15)) G CHKDOCQ
  1. ;
  1. ;Document cannot be a component
  1. I $P($G(TIUDPRM(0)),U,4)="CO" G CHKDOCQ
  1. ;
  1. ;Document cannot be associated with a disposition location
  1. I +$O(^PX(815,1,"DHL","B",+$P($G(^TIU(8925,TIUDA,12)),U,11),0)) G CHKDOCQ
  1. ;
  1. ;Document must be under progress notes class or consults
  1. I '+$$ISA^TIULX(+TIUD0,3),'+$$ISA^TIULX(+TIUD0,+$$CLASS^TIUCNSLT) G CHKDOCQ
  1. ;
  1. ;Check if workload should be entered and set auto-link flag to yes
  1. I $$WORKOK^TIUPXAP1(TIUDA),$$CHKWKL^TIUPXAP2(TIUDA,.TIUDPRM) S Y=1
  1. CHKDOCQ Q +$G(Y)
  1. ;
  1. GETVST(TIUDA,TIUVSIT,TIUMVSTF) ;Get visit to associate with document
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; Output -- TIUVSIT Visit file (#9000010) IEN
  1. ; TIUMVSTF Multiple Visit Flag
  1. ; 1=Multiple Visits
  1. ;
  1. N TIUD0,TIUDFN,TIUEDT,TIUHL,TIUVSITS,TIUVSTR
  1. ;
  1. ;Set variables
  1. S TIUD0=$G(^TIU(8925,TIUDA,0))
  1. S TIUDFN=$P(TIUD0,U,2),TIUEDT=$P(TIUD0,U,7)
  1. S TIUHL=$P($G(^TIU(8925,TIUDA,12)),U,11)
  1. S TIUVSTR=TIUHL_";"_TIUEDT_";"_$P(TIUD0,U,13)
  1. ;
  1. ;Check if document is an addendum, if it is use visit of parent
  1. I +$$ISADDNDM^TIULC1(TIUDA) D G GETVSTQ
  1. . I $D(^TIU(8925,+$P(TIUD0,U,6),0)),$P(^(0),U,3)>0 S TIUVSIT=$P(^(0),U,3)
  1. ;
  1. ;Check if a document has already been entered for the Vstring,
  1. ;if it has use the visit in the AVSTRV cross-reference
  1. I +$G(TIUVSTR),+$O(^TIU(8925,"AVSTRV",+TIUDFN,TIUVSTR,0))>0 D G GETVSTQ:$G(TIUVSIT)>0
  1. . S TIUVSIT=+$O(^TIU(8925,"AVSTRV",+TIUDFN,TIUVSTR,0))
  1. . I $P($G(^AUPNVSIT(+TIUVSIT,0)),U,5)'=TIUDFN S TIUVSIT=""
  1. ;
  1. ;Check PCE for a visit
  1. S TIUVSITS=$$GETENC^PXAPI(TIUDFN,TIUEDT,TIUHL)
  1. I TIUVSITS>0 S TIUVSIT=+TIUVSITS
  1. ;
  1. ;Set a flag if multiple visits
  1. I $P(TIUVSITS,U,2)'="" S TIUMVSTF=1
  1. K ^TMP("PXKENC",$J)
  1. GETVSTQ Q
  1. ;
  1. SETXTMP(TIUDA,TIUEX,TIUVSIT) ;Set ^XTMP for entries processed
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; TIUEX Unable to automatically link Exception types: (Optional)
  1. ; 1=Multiple Visits
  1. ; 2=Entry in Use
  1. ; 3=No Matching Visit
  1. ; TIUVSIT Visit file (#9000010) IEN (Optional)
  1. ; Output -- Set ^XTMP("TIUP188","LNK",TIUDA)=
  1. ; 1st piece= 1=Linked and 0=Not Linked
  1. ; 2nd piece= Exception type if not linked
  1. ; 3rd piece= Visit file (#9000010) IEN if linked
  1. I $G(TIUEX) D
  1. . S ^XTMP("TIUP188","LNK",TIUDA)=0_U_$G(TIUEX)
  1. . S ^XTMP("TIUP188","CNT","EX",TIUEX)=+$G(^XTMP("TIUP188","CNT","EX",TIUEX))+1
  1. . S ^XTMP("TIUP188","CNT","EX")=+$G(^XTMP("TIUP188","CNT","EX"))+1
  1. ELSE D
  1. . S ^XTMP("TIUP188","LNK",TIUDA)=1_U_U_$G(TIUVSIT)
  1. . S ^XTMP("TIUP188","CNT","LNK")=+$G(^XTMP("TIUP188","CNT","LNK"))+1
  1. Q
  1. ;
  1. UPDKIDS(TIUDA,TIUVSIT) ;Update visit for kids that are addenda
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; TIUVSIT Visit file (#9000010) IEN
  1. ; Output -- None
  1. N TIUKID
  1. S TIUKID=0
  1. F S TIUKID=$O(^TIU(8925,"DAD",TIUDA,TIUKID)) Q:'TIUKID D
  1. . I +$$ISADDNDM^TIULC1(TIUKID),$P($G(^TIU(8925,TIUKID,0)),U,3)'>0 D
  1. . . I $$UPDVST^TIUPXAP2(TIUKID,TIUVSIT) D
  1. . . . D SETXTMP(TIUKID,,TIUVSIT)
  1. . . ELSE D
  1. . . . D SETXTMP(TIUKID,2)
  1. Q