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

YS148IDX.m

Go to the documentation of this file.
  1. YS148IDX ;SLC/KCM - Re-index "AC" in MH RESULTS and MH ANSWERS ; 03/28/2019
  1. ;;5.01;MENTAL HEALTH;**148**;Dec 30, 1994;Build 8
  1. ;
  1. REIDX ; Re-indexing Task
  1. N YS148CNT,YS148MSG
  1. S YS148CNT=0
  1. K ^XTMP("YTS-RE-INDEX")
  1. S ^XTMP("YTS-RE-INDEX",0)=$$FMADD^XLFDT(DT,7)_U_DT_U_"MH Re-Index Results"
  1. D UPD("Removing bad nodes from MH RESULTS AC index"),FIX92
  1. D UPD("Removing bad nodes from MH ANSWERS AC index"),FIX85AC
  1. D UPD("Removing bad nodes from MH ANSWERS AD index"),FIX85AD
  1. D UPD("Adding missing nodes to MH RESULTS AC index"),RESET92
  1. D UPD("Adding missing nodes to MH ANSWERS AC index"),RESET85C
  1. D UPD("Adding missing nodes to MH ANSWERS AD index"),RESET85D
  1. S YS148MSG=$$FMTE^XLFDT($$NOW^XLFDT)
  1. S YS148MSG=YS148CNT_" index errors found & resolved on: "_YS148MSG
  1. D UPD(YS148MSG)
  1. D NOTIFY(YS148MSG)
  1. I $D(ZTQUEUED) S ZTREQ="@"
  1. Q
  1. ;
  1. ; -- these tags remove any index nodes that are incorrect
  1. ;
  1. FIX85AC ; Remove bad "AC" indexes from MH ANSWERS
  1. N ADMIN,QSTN,IEN,X0
  1. S ADMIN=0 F S ADMIN=$O(^YTT(601.85,"AC",ADMIN)) Q:'ADMIN D
  1. . S QSTN=0 F S QSTN=$O(^YTT(601.85,"AC",ADMIN,QSTN)) Q:'QSTN D
  1. . . S IEN=0 F S IEN=$O(^YTT(601.85,"AC",ADMIN,QSTN,IEN)) Q:'IEN D
  1. . . . ; if IEN doesn't exist, remove index
  1. . . . I '$D(^YTT(601.85,IEN,0)) D RM85AC(ADMIN,QSTN,IEN) QUIT
  1. . . . S X0=$G(^YTT(601.85,IEN,0))
  1. . . . ; if ADMIN doesn't match, remove index
  1. . . . I $P(X0,U,2)'=ADMIN D RM85AC(ADMIN,QSTN,IEN) QUIT
  1. . . . ; if QSTN doesn't match, remove index
  1. . . . I $P(X0,U,3)'=QSTN D RM85AC(ADMIN,QSTN,IEN) QUIT
  1. Q
  1. RM85AC(ADMIN,QSTN,IEN) ; remove bad index
  1. K ^YTT(601.85,"AC",ADMIN,QSTN,IEN)
  1. D LOG("85AC",ADMIN,QSTN,IEN)
  1. Q
  1. FIX85AD ; Remove bad "AD" indexes from MH ANSWERS
  1. N ADMIN,IEN,X0
  1. S ADMIN=0 F S ADMIN=$O(^YTT(601.85,"AD",ADMIN)) Q:'ADMIN D
  1. . S IEN=0 F S IEN=$O(^YTT(601.85,"AD",ADMIN,IEN)) Q:'IEN D
  1. . . ; if IEN doesn't exist, remove index
  1. . . I '$D(^YTT(601.85,IEN,0)) D RM85AD(ADMIN,IEN) QUIT
  1. . . S X0=$G(^YTT(601.85,IEN,0))
  1. . . ; if ADMIN doesn't match, remove index
  1. . . I $P(X0,U,2)'=ADMIN D RM85AD(ADMIN,IEN) QUIT
  1. Q
  1. RM85AD(ADMIN,IEN) ; remove bad index
  1. K ^YTT(601.85,"AD",ADMIN,IEN)
  1. D LOG("85AD",ADMIN,"",IEN)
  1. Q
  1. FIX92 ; Remove bad indexes from MH RESULTS
  1. N ADMIN,IEN
  1. S ADMIN=0 F S ADMIN=$O(^YTT(601.92,"AC",ADMIN)) Q:'ADMIN D
  1. . S IEN=0 F S IEN=$O(^YTT(601.92,"AC",ADMIN,IEN)) Q:'IEN D
  1. . . ; if IEN doesn't exist, remove index
  1. . . I '$D(^YTT(601.92,IEN,0)) D RM92AC(ADMIN,IEN) QUIT
  1. . . ; if ADMIN doesn't match, remove index
  1. . . I $P($G(^YTT(601.92,IEN,0)),U,2)'=ADMIN D RM92AC(ADMIN,IEN)
  1. Q
  1. RM92AC(ADMIN,IEN) ; remove bad index
  1. K ^YTT(601.92,"AC",ADMIN,IEN)
  1. D LOG("92AC",ADMIN,"",IEN)
  1. Q
  1. ;
  1. ; -- these tags set any index nodes that are missing
  1. ;
  1. RESET85C ; Rebuild the "AC" index for MH ANSWERS (601.85)
  1. N ADMIN,QSTN,IEN,X0
  1. S IEN=0 F S IEN=$O(^YTT(601.85,IEN)) Q:'IEN D
  1. . S X0=$G(^YTT(601.85,IEN,0)),ADMIN=$P(X0,U,2),QSTN=$P(X0,U,3)
  1. . I 'ADMIN!('QSTN) QUIT ; no index if missing data
  1. . I $D(^YTT(601.85,"AC",ADMIN,QSTN,IEN)) QUIT ; index is correct
  1. . N DIK,DA ; set new "AC" index
  1. . S DIK="^YTT(601.85,",DIK(1)="1^AC",DA=IEN
  1. . D EN^DIK
  1. . D LOG("85ACI",ADMIN,QSTN,IEN)
  1. Q
  1. RESET85D ; Rebuild the "AD" index for MH ANSWERS (601.85)
  1. N ADMIN,IEN,X0
  1. S IEN=0 F S IEN=$O(^YTT(601.85,IEN)) Q:'IEN D
  1. . S X0=$G(^YTT(601.85,IEN,0)),ADMIN=$P(X0,U,2)
  1. . I 'ADMIN QUIT ; no index if missing data
  1. . I $D(^YTT(601.85,"AD",ADMIN,IEN)) QUIT ; index is correct
  1. . N DIK,DA ; set new "AD" index
  1. . S DIK="^YTT(601.85,",DIK(1)="1^AD",DA=IEN
  1. . D EN^DIK
  1. . D LOG("85ADI",ADMIN,"",IEN)
  1. Q
  1. RESET92 ; Rebuild the "AC" index for MH RESULTS (601.92)
  1. N ADMIN,IEN
  1. S IEN=0 F S IEN=$O(^YTT(601.92,IEN)) Q:'IEN D
  1. . S ADMIN=+$P($G(^YTT(601.92,IEN,0)),U,2)
  1. . I 'ADMIN QUIT ; no index if admin missing
  1. . I $D(^YTT(601.92,"AC",ADMIN,IEN)) QUIT ; index is correct
  1. . N DIK,DA ; set new "AC" index
  1. . S DIK="^YTT(601.92,",DIK(1)="1^AC",DA=IEN
  1. . D EN^DIK
  1. . D LOG("92ACI",ADMIN,"",IEN)
  1. Q
  1. ;
  1. ; -- status notifications
  1. ;
  1. LOG(FIX,ADMIN,QSTN,IEN) ; Log fixes
  1. S YS148CNT=YS148CNT+1
  1. I '$D(ZTQUEUED) S ^XTMP("YTS-RE-INDEX",YS148CNT)=FIX_U_ADMIN_U_$G(QSTN)_U_IEN
  1. S ^XTMP("YTS-RE-INDEX","ERRS")=YS148CNT
  1. Q
  1. UPD(MSG) ; set parameter to current status
  1. D EN^XPAR("SYS","YS123 RE-INDEX STATUS",1,MSG)
  1. I '$D(ZTQUEUED) W !,MSG
  1. Q
  1. NOTIFY(MSG) ; send message to installer
  1. N XMDUZ,XMSUB,XMTEXT,XMY,XMZ,XMMG,DIFROM,YSTEXT
  1. S YSTEXT(1)="Re-indexing of the MH RESULTS and MH ANSWERS files has completed"
  1. S YSTEXT(2)="with the following status:"
  1. S YSTEXT(3)=" "
  1. S YSTEXT(4)=MSG
  1. S XMDUZ="YS*5.01*148 POST INSTALL"
  1. S XMSUB="Re-Index of Mental Health Results Completed"
  1. S:$G(DUZ) XMY(DUZ)="" S:$G(YS148IN) XMY(YS148IN)=""
  1. S XMTEXT="YSTEXT("
  1. D ^XMD
  1. Q
  1. ;
  1. ; YS123 RE-INDEX MONITOR option
  1. ;
  1. MONITOR ; Check status of re-index, allows re-queuing
  1. W !,"MH RESULTS and MH ANSWERS Re-Index Monitor"
  1. D STATUS
  1. N X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT
  1. S DIR(0)="YA^^"
  1. S DIR("A")="Do you want to queue re-indexing of MH RESULTS and MH ANSWERS? "
  1. S DIR("B")="NO"
  1. S DIR("?")="Answer YES to re-index (only needed if errors are occurring)."
  1. D ^DIR
  1. Q:$D(DIRUT) Q:$D(DIROUT) Q:'Y
  1. S DIR(0)="DA^::FR"
  1. S DIR("A")="Queue Re-Indexing to Run: "
  1. S DIR("B")="NOW"
  1. S DIR("?")="Enter the date/time when the re-indexing task should begin"
  1. D ^DIR
  1. Q:$D(DIRUT) Q:$D(DIROUT) Q:'Y
  1. D QTASK^YS148PST(Y)
  1. Q
  1. STATUS ; Loop showing status until done
  1. N X,Y,DIR,DTOUT,DUOUT,DIRUT,DIROUT
  1. F D Q:'Y
  1. . W !!," Status: ",$$GET^XPAR("SYS","YS123 RE-INDEX STATUS",1,"Q")
  1. . W !," Errors Repaired: ",+$G(^XTMP("YTS-RE-INDEX","ERRS")),!
  1. . S DIR(0)="YA^^"
  1. . S DIR("A")="Refresh? "
  1. . S DIR("B")="Yes"
  1. . D ^DIR
  1. . I $D(DIRUT)!$D(DIROUT) S Y=0
  1. Q