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

SD53105A.m

Go to the documentation of this file.
  1. SD53105A ;ALB/JRP - XMIT, DELETE, AND ERROR FILE CLEAN UP;12-MAR-1997
  1. ;;5.3;Scheduling;**105,1015**;Aug 13, 1993;Build 21
  1. ;
  1. SCAN ;Entry point to scan only (prints what would have been deleted)
  1. N ZTRTN,ZTDESC
  1. D INTRO
  1. W !
  1. W !,"You are running this routine in scan mode, which will only identify"
  1. W !,"the problems corrected. Please select a device (queueing allowed) so"
  1. W !,"that a listing of what would have been done can be obtained."
  1. W !!
  1. S ZTRTN="EN^SD53105A(1)"
  1. S ZTDESC="ACRP cleanup of files 409.73, 409.74, and 409.75"
  1. D EN^XUTMDEVQ(ZTRTN,ZTDESC)
  1. Q
  1. ;
  1. FIX ;Entry point to schedule clean up
  1. N ZTRTN,ZTDESC,ZTDTH,ZTIO,ZTSK,TXT
  1. D INTRO
  1. W !
  1. W !,"Please enter the date/time that you would like this clean up queued to"
  1. W !,"run. A summary of what was done will be sent to you and the"
  1. W !,"recipients of the SCDX AMBCARE TO NPCDB SUMMARY bulletin."
  1. W !!
  1. S ZTRTN="EN^SD53105A(0)"
  1. S ZTDESC="ACRP cleanup of files 409.73, 409.74, and 409.75"
  1. S ZTDTH=""
  1. S ZTIO=""
  1. D ^%ZTLOAD
  1. W:(+$G(ZTSK)) !,"Scheduled as task number ",ZTSK
  1. W:('$G(ZTSK)) !,"** Unable to schedule correction **"
  1. Q
  1. ;
  1. INTRO ;Print intro text
  1. W !!,"This routine will clean up dangling pointers and orphan entries within"
  1. W !,"the ACRP transmission files. The following actions/checks will be"
  1. W !,"performed:"
  1. W !
  1. W !,"(1) Entries in the Transmitted Outpatient Encounter file (409.73)"
  1. W !," that do not have a valid pointer to the Outpatient Encounter"
  1. W !," file (#409.68) or the Deleted Outpatient Encounter file"
  1. W !," (#409.74) are deleted."
  1. W !
  1. W !,"(2) Entries in the Transmitted Outpatient Encounter file that have"
  1. W !," been rejected by the Austin Automation Center and do not have an"
  1. W !," entry in the Transmitted Outpatient Encounter Error file"
  1. W !," (#409.75) are marked for re-transmission."
  1. W !
  1. W !,"(3) Entries in the Deleted Outpatient Encounter file that do not"
  1. W !," have a corresponding entry in the Transmitted Outpatient"
  1. W !," Encounter file are deleted."
  1. W !
  1. W !,"(4) Entries in the Transmitted Outpatient Encounter Error file that"
  1. W !," do not have a valid pointer to the Transmitted Outpatient"
  1. W !," Encounter file are deleted."
  1. Q
  1. ;
  1. EN(SCANMODE) ;Main entry point
  1. ; Routine deletes entries in the Transmitted Outpatient Encounter file
  1. ; (409.73) that do not have a valid pointer to the Outpatient Encounter
  1. ; file (#409.68) or the Deleted Outpatient Encounter file (#409.74).
  1. ;
  1. ; Routine marks entries in the Transmitted Outpatient Encounter file
  1. ; that have been rejected by the Austin Automation Center and do not
  1. ; have an entry in the Transmitted Outpatient Encounter Error file
  1. ; (#409.75) for re-transmission.
  1. ;
  1. ; Routine deletes entries in the Deleted Outpatient Encounter file that
  1. ; do not have a corresponding entry in the Transmitted Outpatient
  1. ; Encounter file.
  1. ;
  1. ; Routine deletes entries in the Transmitted Outpatient Encounter Error
  1. ; file that do not have a valid pointer to the Transmitted Outpatient
  1. ; Encounter file.
  1. ;
  1. ;Input : SCANMODE - Flag denoting if routine should only scan
  1. ; for errors and not fix them
  1. ; 0 = No - scan and fix (default)
  1. ; 1 = Yes - scan but don't fix
  1. ;Output : None
  1. ;Notes : A completion/summary bulletin will be sent to the current
  1. ; user and the recipients of the SCDX AMBCARE TO NPCDB SUMMARY
  1. ; bulletin. This bulletin will not be sent if in scan mode.
  1. ;
  1. ;Declare variables
  1. N XMITPTR,XMITTOT,XMITDEL,XMITXMIT,ENCPTR,DELPTR,DELTOT,DELDEL,ERRPTR
  1. N ERRTOT,ERRDEL,NODE,TMP,DIK,DA,X,Y
  1. S SCANMODE=+$G(SCANMODE)
  1. ;Initialize counters
  1. S (XMITTOT,XMITDELE,XMITDELD,XMITXMIT,DELTOT,DELDEL,ERRTOT,ERRDEL)=0
  1. ;Initialize summary location
  1. K ^TMP($J,"SD53105A")
  1. S ^TMP($J,"SD53105A","XMIT")="^^^"
  1. S ^TMP($J,"SD53105A","DEL")="^"
  1. S ^TMP($J,"SD53105A","ERR")="^"
  1. S ^TMP($J,"SD53105A","STOP")=0
  1. ;Remember starting time
  1. S ^TMP($J,"SD53105A","TIME")=$$NOW^XLFDT()
  1. I (SCANMODE) D
  1. .W !
  1. .W !,"Scanning of the Transmitted Outpatient Encounter, Deleted Outpatient"
  1. .W !,"Encounter, and Transmitted Outpatient Encounter Error files for known"
  1. .W !,"problems started on "_$$FMTE^XLFDT($$NOW^XLFDT())
  1. .W !
  1. ;Loop through Transmitted Outpatient Encounter file (#409.73)
  1. I (SCANMODE) D
  1. .W !!
  1. .W !,"The following entries in the Transmitted Outpatient Encounter"
  1. .W !,"file (#409.73) will be acted upon when run in fix mode"
  1. .W !,$$REPEAT^SCDXUTL1("=",70)
  1. S XMITPTR=0
  1. F S XMITPTR=+$O(^SD(409.73,XMITPTR)) Q:('XMITPTR) D Q:($G(ZTSTOP))
  1. .;Increment total entries checked
  1. .S XMITTOT=XMITTOT+1
  1. .;Grab zero node
  1. .S NODE=$G(^SD(409.73,XMITPTR,0))
  1. .;Get Outpatient Encounter & Deleted Outpatient Encounter pointers
  1. .S ENCPTR=+$P(NODE,"^",2)
  1. .S DELPTR=+$P(NODE,"^",3)
  1. .;Validate pointer to Outpatient Encounter
  1. .I (ENCPTR) D
  1. ..Q:($D(^SCE(ENCPTR,0)))
  1. ..;Invalid - delete entry and increment deletion count
  1. ..S:('SCANMODE) TMP=$$DELXMIT^SCDXFU03(XMITPTR,0)
  1. ..W:(SCANMODE) !,"^SD(409.73,",XMITPTR,",0) has bad pointer to Outpatient Encounter file"
  1. ..S XMITDELE=XMITDELE+1
  1. .;Validate pointer to Deleted Outpatient Encounter
  1. .I (DELPTR) D
  1. ..Q:($D(^SD(409.74,DELPTR,0)))
  1. ..;Invalid - delete entry and increment deletion count
  1. ..S:('SCANMODE) TMP=$$DELXMIT^SCDXFU03(XMITPTR,0)
  1. ..W:(SCANMODE) !,"^SD(409.73,",XMITPTR,",0) has bad pointer to Deleted Outpatient Encounter file"
  1. ..S XMITDELD=XMITDELD+1
  1. .;Check for rejection without entry in Transmitted Outpatient Encounter
  1. .; Error file (#409.75)
  1. .S TMP=$G(^SD(409.73,XMITPTR,1))
  1. .I ($P(TMP,"^",5)="R") D:('$D(^SD(409.75,"B",XMITPTR)))
  1. ..;Mark for retransmission
  1. ..D:('SCANMODE) STREEVNT^SCDXFU01(XMITPTR)
  1. ..D:('SCANMODE) XMITFLAG^SCDXFU01(XMITPTR)
  1. ..W:(SCANMODE) !,"^SD(409.73,",XMITPTR,",0) rejected with no reason on file (entry in 409.75)"
  1. ..;Increment retransmission counter
  1. ..S XMITXMIT=XMITXMIT+1
  1. .;Check for request to stop
  1. .S:($$S^%ZTLOAD("Last entry in Transmitted Outpatient Encounter file checked >> "_XMITPTR)) ZTSTOP=1
  1. ;Remember totals
  1. S ^TMP($J,"SD53105A","XMIT")=XMITTOT_"^"_XMITDELE_"^"_XMITDELD_"^"_XMITXMIT
  1. I (SCANMODE) D
  1. .W !
  1. .W !,XMITTOT," entries where checked"
  1. .W !,?2,XMITXMIT," would have been marked for retransmission"
  1. .W !,?2,(XMITDELE+XMITDELD)," would have been deleted"
  1. .W !,?4,(XMITDELE)," have bad Outpatient Encounter pointers"
  1. .W !,?4,(XMITDELD)," have bad Deleted Outpatient Encounter pointers"
  1. ;Asked to stop
  1. I $G(ZTSTOP) G EN1
  1. ;Loop through Deleted Outpatient Encounter file (#409.74)
  1. I (SCANMODE) D
  1. .W !!!
  1. .W !,"The following entries in the Deleted Outpatient Encounter"
  1. .W !,"file (#409.74) will be deleted when run in fix mode"
  1. .W !,$$REPEAT^SCDXUTL1("=",70)
  1. S DELPTR=0
  1. F S DELPTR=+$O(^SD(409.74,DELPTR)) Q:('DELPTR) D Q:($G(ZTSTOP))
  1. .;Increment total entries checked
  1. .S DELTOT=DELTOT+1
  1. .;Check for entry in Transmitted Outpatient Encounter file
  1. .I ('$D(^SD(409.73,"ADEL",DELPTR))) D
  1. ..;Not found - delete entry and increment deletion count
  1. ..I ('SCANMODE) S DA=DELPTR,DIK="^SD(409.74," D ^DIK K DA,DIK,X,Y
  1. ..W:(SCANMODE) !,"^SD(409.74,",DELPTR,",0) not in Transmitted Outpatient Encounter file"
  1. ..S DELDEL=DELDEL+1
  1. .;Check for request to stop
  1. .S:($$S^%ZTLOAD("Last entry in Deleted Outpatient Encounter file checked >> "_DELPTR)) ZTSTOP=1
  1. ;Remember totals
  1. S ^TMP($J,"SD53105A","DEL")=DELTOT_"^"_DELDEL
  1. W:(SCANMODE) !!,DELTOT," entries where checked and ",DELDEL," would have been deleted"
  1. ;Asked to stop
  1. I $G(ZTSTOP) G EN1
  1. ;Loop through Transmitted Outpatient Encounter Error file (#409.75)
  1. I (SCANMODE) D
  1. .W !!!
  1. .W !,"The following entries in the Transmitted Outpatient Encounter"
  1. .W !,"Error file (#409.75) will be deleted when run in fix mode"
  1. .W !,$$REPEAT^SCDXUTL1("=",70)
  1. S ERRPTR=0
  1. F S ERRPTR=+$O(^SD(409.75,ERRPTR)) Q:('ERRPTR) D Q:($G(ZTSTOP))
  1. .;Increment total entries checked
  1. .S ERRTOT=ERRTOT+1
  1. .;Get pointer to Transmitted Outpatient Encounter file
  1. .S XMITPTR=+$G(^SD(409.75,ERRPTR,0))
  1. .;Validate pointer
  1. .I ('$D(^SD(409.73,XMITPTR,0))) D
  1. ..;Invalid - delete entry and increment deletion count
  1. ..S:('SCANMODE) TMP=$$DELERR^SCDXFU02(ERRPTR)
  1. ..W:(SCANMODE) !,"^SD(409.75,",ERRPTR,",0) has bad pointer to Transmitted Outpatient Encounter file"
  1. ..S ERRDEL=ERRDEL+1
  1. .;Check for request to stop
  1. .S:($$S^%ZTLOAD("Last entry in Transmitted Outpatient Encounter Error file checked >> "_ERRPTR)) ZTSTOP=1
  1. ;Remember totals
  1. S ^TMP($J,"SD53105A","ERR")=ERRTOT_"^"_ERRDEL
  1. W:(SCANMODE) !!,ERRTOT," entries where checked and ",ERRDEL," would have been deleted"
  1. EN1 ;Remember ending time
  1. S $P(^TMP($J,"SD53105A","TIME"),"^",2)=$$NOW^XLFDT()
  1. I (SCANMODE) D
  1. .W !!!,"Scan ended on ",$$FMTE^XLFDT($$NOW^XLFDT())
  1. .W !!!,"Use the entry point FIX^SD53105A to run in fix mode"
  1. .W !,"Use the entry point SCAN^SD53105A to re-run in scan mode"
  1. ;Remember if requested to stop
  1. S ^TMP($J,"SD53105A","STOP")=+$G(ZTSTOP)
  1. ;Send completion/summary bulletin
  1. D:('SCANMODE) BULL1^SD53105C
  1. ;Done - clean up and quit
  1. K ^TMP($J,"SD53105A")
  1. S:($D(ZTQUEUED)) ZTREQ="@"
  1. Q