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

TIUPS165.m

Go to the documentation of this file.
  1. TIUPS165 ; SLC/MAM - After installing TIU*1*165;6/26/03
  1. ;;1.0;Text Integration Utilities;**165**;Jun 20, 1997
  1. ; Run this after installing patch 165.
  1. ;Use option: TIU165 DDEFS & RULES, PRF
  1. ; External References
  1. ; DBIA 4127 MAIN^USRPS24
  1. BEGIN ; Create DDEFS
  1. W !!,"This option creates Document Definitions, a User Class, and"
  1. W !,"a Business Rule for Patient Record Flags."
  1. W ! K IOP S %ZIS="Q" D ^%ZIS I POP K POP Q
  1. I $D(IO("Q")) K IO("Q") D Q
  1. .S ZTRTN="MAIN^TIUPS165"
  1. .S ZTDESC="Create DDefs, User Class, Rules for Patient Record Flags - TIU*1*165"
  1. .D ^%ZTLOAD W !,$S($D(ZTSK):"Request Queued!",1:"Request Canceled!")
  1. .K ZTSK,ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE
  1. .D HOME^%ZIS
  1. U IO D MAIN,^%ZISC
  1. Q
  1. ;
  1. MAIN ; Create DDEFS for Patient Record Flags
  1. ; -- Check for dups created after the install but before this option:
  1. K ^XTMP("TIU165","DUPS"),^TMP("TIU165",$J)
  1. D SETXTMP^TIUEN165
  1. N TIUDUPS,TMPCNT,SILENT S TMPCNT=0
  1. S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=""
  1. S TMPCNT=1,^TMP("TIU165",$J,TMPCNT)=" ***** Document Definitions for PATIENT RECORD FLAGS *****"
  1. S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=""
  1. S SILENT=1
  1. D TIUDUPS^TIUEN165(.TIUDUPS,SILENT)
  1. ; -- If potential duplicates exist, quit:
  1. I $G(TIUDUPS) D G MAINX
  1. . S ^XTMP("TIU165","DUPS")=1
  1. . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)="Duplicate problem. See description for patch TIU*1*165,"
  1. . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)="in the National Patch Module."
  1. ; -- Set file data, other data for DDEFS:
  1. D SETDATA^TIU165D
  1. N NUM S NUM=0
  1. F S NUM=$O(^XTMP("TIU165","BASICS",NUM)) Q:'NUM D
  1. . N IEN,YDDEF,TIUDA
  1. . ; -- If DDEF was previously created by this patch,
  1. . ; say so and quit:
  1. . S IEN=+$G(^XTMP("TIU165","BASICS",NUM,"DONE"))
  1. . I IEN D Q
  1. . . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=^XTMP("TIU165","FILEDATA",NUM,.04)_" "_^XTMP("TIU165","BASICS",NUM,"NAME")
  1. . . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" was already created in a previous install."
  1. . . K ^XTMP("TIU165","FILEDATA",NUM)
  1. . . K ^XTMP("TIU165","DATA",NUM)
  1. . ; -- If not, create new DDEF:
  1. . S YDDEF=$$CREATE(NUM)
  1. . I +YDDEF'>0!($P(YDDEF,U,3)'=1) D Q
  1. . . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)="Couldn't create a "_^XTMP("TIU165","FILEDATA",NUM,.04)_" named "_^XTMP("TIU165","BASICS",NUM,"NAME")_".",TMPCNT=TMPCNT+1
  1. . . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" Please contact National VistA Support for help."
  1. . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=^XTMP("TIU165","FILEDATA",NUM,.04)_" named "_^XTMP("TIU165","BASICS",NUM,"NAME")
  1. . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" created successfully."
  1. . S TIUDA=+YDDEF
  1. . ; -- File field data:
  1. . D FILE(NUM,TIUDA,.TMPCNT)
  1. . K ^XTMP("TIU165","FILEDATA",NUM)
  1. . ; -- Add item to parent:
  1. . D ADDITEM(NUM,TIUDA,.TMPCNT)
  1. . K ^XTMP("TIU165","DATA",NUM)
  1. MAINX ;Exit
  1. S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=""
  1. S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" *************"
  1. I '$G(^XTMP("TIU165","DUPS")) D MAIN^USRPS24
  1. D PRINT
  1. K ^TMP("TIU165",$J),^TMP("USR24",$J)
  1. Q
  1. ;
  1. PRINT ; Print out results
  1. N TIUCNT,TIUCONT
  1. I $D(ZTQUEUED) S ZTREQ="@" ; Tell TaskMan to delete Task log entry
  1. I $E(IOST)="C" W @IOF,!
  1. S TIUCNT="",TIUCONT=1
  1. F S TIUCNT=$O(^TMP("TIU165",$J,TIUCNT)) Q:TIUCNT="" D Q:'TIUCONT
  1. . S TIUCONT=$$SETCONT Q:'TIUCONT
  1. . W ^TMP("TIU165",$J,TIUCNT),!
  1. Q:'TIUCONT
  1. S TIUCNT=""
  1. F S TIUCNT=$O(^TMP("USR24",$J,TIUCNT)) Q:TIUCNT="" D Q:'TIUCONT
  1. . S TIUCONT=$$SETCONT Q:'TIUCONT
  1. . W ^TMP("USR24",$J,TIUCNT),!
  1. PRINTX Q
  1. ;
  1. STOP() ;on screen paging check
  1. ; quits TIUCONT=1 if cont. ELSE quits TIUCONT=0
  1. N DIR,Y,TIUCONT
  1. S DIR(0)="E" D ^DIR
  1. S TIUCONT=Y
  1. I TIUCONT W @IOF,!
  1. Q TIUCONT
  1. ;
  1. SETCONT() ; D form feed, Set TIUCONT
  1. N TIUCONT
  1. S TIUCONT=1
  1. I $E(IOST)="C" G SETX:$Y+5<IOSL
  1. I $E(IOST)="C" S TIUCONT=$$STOP G SETX
  1. G:$Y+8<IOSL SETX
  1. W @IOF
  1. SETX Q TIUCONT
  1. ;
  1. PARENT(NUM) ; Return IEN of parent new DDEF should be added to
  1. N PIEN,PNUM
  1. ; Parent node has form:
  1. ; -- PIEN node = IEN of parent if known, or if not,
  1. ; PNUM node = DDEF# of parent
  1. S PIEN=$G(^XTMP("TIU165","DATA",NUM,"PIEN"))
  1. ; -- If parent IEN is known, we're done:
  1. I +PIEN G PARENTX
  1. ; -- If not, get DDEF# of parent
  1. S PNUM=$G(^XTMP("TIU165","DATA",NUM,"PNUM"))
  1. I 'PNUM Q 0
  1. ; -- Get Parent IEN from "DONE" node, which was set
  1. ; when parent was created:
  1. S PIEN=+$G(^XTMP("TIU165","BASICS",PNUM,"DONE"))
  1. PARENTX Q PIEN
  1. ;
  1. ADDITEM(NUM,TIUDA,TMPCNT) ; Add DDEF to Parent; Set item fields
  1. N PIEN,MENUTXT,TIUFPRIV,TIUFISCR
  1. N DIE,DR
  1. S TIUFPRIV=1
  1. S PIEN=$$PARENT(NUM)
  1. I 'PIEN!'$D(^TIU(8925.1,PIEN,0))!'$D(^TIU(8925.1,TIUDA,0)) K PIEN G ADDX
  1. N DA,DIC,DLAYGO,X,Y
  1. N I,DIY
  1. S DA(1)=PIEN
  1. S DIC="^TIU(8925.1,"_DA(1)_",10,",DIC(0)="LX"
  1. S DLAYGO=8925.14
  1. ;S X="`"_TIUDA
  1. ; -- If TIUDA is say, x, and Parent has x as IFN in Item subfile,
  1. ; code finds item x under parent instead of creating a new item,
  1. ; so don't use "`"_TIUDA:
  1. S X=^XTMP("TIU165","BASICS",NUM,"NAME")
  1. ; -- Make sure the DDEF it adds is TIUDA and not another w same name:
  1. S TIUFISCR=TIUDA ; activates screen on fld 10, Subfld .01 in DD
  1. D ^DIC I Y'>0!($P(Y,U,3)'=1) K PIEN G ADDX
  1. ; -- Set Menu Text:
  1. S MENUTXT=$G(^XTMP("TIU165","DATA",NUM,"MENUTXT"))
  1. I $L(MENUTXT) D
  1. . N DA,DIE,DR
  1. . N D,D0,DI,DQ
  1. . S DA(1)=PIEN
  1. . S DA=+Y,DIE=DIC
  1. . S DR="4////^S X=MENUTXT"
  1. . D ^DIE
  1. ADDX ; -- Tell user about adding to parent:
  1. I '$G(PIEN) D
  1. . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" Couldn't add entry to parent. Please contact National VistA Support"
  1. . S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" for help."
  1. E S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" Entry added to parent."
  1. Q
  1. ;
  1. FILE(NUM,TIUDA,TMPCNT) ; File fields for new entry TIUDA
  1. ; Files ALL FIELDS set in "FILEDATA" nodes of ^XTMP:
  1. ; ^XTMP("TIU165","FILEDATA",NUM,Field#)
  1. N TIUFPRIV,FDA,TIUERR
  1. S TIUFPRIV=1
  1. M FDA(8925.1,TIUDA_",")=^XTMP("TIU165","FILEDATA",NUM)
  1. D FILE^DIE("TE","FDA","TIUERR")
  1. I $D(TIUERR) S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" Problem filing data for entry. Please contact National VistA Support."
  1. E S TMPCNT=TMPCNT+1,^TMP("TIU165",$J,TMPCNT)=" Data for entry filed successfully."
  1. Q
  1. ;
  1. CREATE(NUM) ; Create new DDEF entry
  1. N DIC,DLAYGO,DA,X,Y,TIUFPRIV
  1. S TIUFPRIV=1
  1. ;S (DIC,DLAYGO)="^TIU(8925.1,"
  1. ;CACHE won't take global root for DLAYGO; use file number:
  1. S DIC="^TIU(8925.1,",DLAYGO=8925.1
  1. S DIC(0)="LX",X=^XTMP("TIU165","BASICS",NUM,"NAME")
  1. S DIC("S")="I $P(^(0),U,4)="_""""_^XTMP("TIU165","BASICS",NUM,"INTTYPE")_""""
  1. D ^DIC
  1. ; -- If DDEF was just created, set "DONE" node = IEN
  1. I $P(Y,U,3)=1 S ^XTMP("TIU165","BASICS",NUM,"DONE")=+$G(Y)
  1. Q $G(Y)