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

TIUFLF4.m

Go to the documentation of this file.
  1. TIUFLF4 ; SLC/MAM - Lib; ANCESTOR(FILEDA,NODE0,ANCESTOR,DOCFLAG), ORPHAN(FILEDA,NODE0,ANCESTOR), STUFFLDS(FILEDA,PFILEDA), ADDTEN(PFILEDA,FILEDA,NODE0,TENDA),NUMITEMS(FILEDA), MISSITEM(FILEDA) ;4/23/97 11:02
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**11,43,236,232**;Jun 20, 1997;Build 19
  1. ;
  1. NUMITEMS(FILEDA) ; Function returns Number of Items of FILEDA; Possibly 0
  1. N ITEMSANS,TIUFI
  1. S (ITEMSANS,TIUFI)=0
  1. F S TIUFI=$O(^TIU(8925.1,FILEDA,10,TIUFI)) G:'TIUFI NUMIX S ITEMSANS=ITEMSANS+1
  1. NUMIX Q ITEMSANS
  1. ;
  1. MISSITEM(FILEDA) ; Function Checks FILEDA Items (doesn't check subitems etc.) for existence only. Returns IFN of first missing item it finds, else 0.
  1. ; Requires FILEDA.
  1. N TIUI,IFILEDA,MISSANS
  1. S TIUI=0,MISSANS=0
  1. F S TIUI=$O(^TIU(8925.1,FILEDA,10,TIUI)) Q:'TIUI!MISSANS D
  1. . S IFILEDA=+^TIU(8925.1,FILEDA,10,TIUI,0)
  1. . I '$D(^TIU(8925.1,IFILEDA,0)) S MISSANS=IFILEDA
  1. Q MISSANS
  1. ;
  1. ANCESTOR(FILEDA,NODE0,ANCESTOR,DOCFLAG) ; Module traces ancestors of FILEDA,
  1. ;creates array ANCESTOR,
  1. ; where ANCESTOR(0)=FILEDA,
  1. ; where ANCESTOR(1)=Parent IFN of FILEDA,
  1. ; ANCESTOR(2)=Parent IFN of ANCESTOR(1)
  1. ; ...
  1. ; ANCESTOR(last subscript)=IFN of oldest ancestor of FILEDA if
  1. ; '$G(DOCFLAG)
  1. ; OR
  1. ; IFN of oldest ancestor of FILEDA NOT
  1. ; OF TYPE DC OR CL if $G(DOCFLAG)
  1. ; Don't stop the array for problems like bad type, no type, type object.
  1. ; If DOCFLAG, DON'T GET DC or CL; don't want array to mistakenly
  1. ;go all the way to CLinical Documents.
  1. ; Array may not EXIST if DOCFLAG
  1. ; Requires FILEDA, NODE0= 0 Node;
  1. ; DOCFLAG optional, 0 or 1
  1. N TIUI,QUIT,ANODE0
  1. S DOCFLAG=+$G(DOCFLAG)
  1. I DOCFLAG,($P(NODE0,U,4)="DC")!($P(NODE0,U,4)="CL") G ANCEX
  1. S TIUI=0,ANCESTOR(0)=FILEDA
  1. F D Q:$G(QUIT)
  1. . S ANCESTOR(TIUI+1)=$O(^TIU(8925.1,"AD",ANCESTOR(TIUI),0))
  1. . I 'ANCESTOR(TIUI+1) K ANCESTOR(TIUI+1) S QUIT=1 Q
  1. . I DOCFLAG S ANODE0=^TIU(8925.1,ANCESTOR(TIUI+1),0) I ($P(ANODE0,U,4)="DC")!($P(ANODE0,U,4)="CL") K ANCESTOR(TIUI+1) S QUIT=1 Q
  1. . S TIUI=TIUI+1
  1. ANCEX Q
  1. ;
  1. ORPHAN(FILEDA,NODE0,ANCESTOR) ; Function traces ancestors of FILEDA,
  1. ; Returns NA if FILEDA is Object or Shared Component,
  1. ; NO if NOT NA AND FILEDA belongs to Clinical Docmts Hierarchy,
  1. ; YES if NOT NA, AND doesn't belong.
  1. ; Requires FILEDA, NODE0= 0 Node;
  1. N ORPHAN,LAST
  1. I $P(NODE0,U,4)="O" S ORPHAN="NA" G ORPHX
  1. I '$D(ANCESTOR) D ANCESTOR(FILEDA,NODE0,.ANCESTOR)
  1. I '$D(^TMP("TIUF",$J,"CLINDOC")) D G:Y=-1 ORPHX
  1. . N DIC,X,Y
  1. . S DIC=8925.1,DIC(0)="X",X="CLINICAL DOCUMENTS" D ^DIC
  1. . I Y=-1 S ORPHAN="UNKNOWN" Q
  1. . S ^TMP("TIUF",$J,"CLINDOC")=+Y
  1. S LAST=$O(ANCESTOR(100),-1) I ANCESTOR(LAST)=^TMP("TIUF",$J,"CLINDOC") S ORPHAN="NO" G ORPHX
  1. S ORPHAN="YES"
  1. ORPHX Q ORPHAN
  1. ;
  1. STUFFLDS(FILEDA,PFILEDA) ; Stuff fields .03, .04 (tries), .07, [.1]
  1. ;for 8925.1 entry FILEDA.
  1. ; Requires FILEDA.
  1. ; Requires TIUFTLST as set in TYPELIST^TIUFLF7
  1. ; Requires PFILEDA if entry has prospective (as in Create and Add Item)
  1. ;or actual parent in order to try to stuff Type.
  1. ; Stuffs .03 Print Name = First 60 chars of .01 Name if not from copy
  1. ;action.
  1. ; Stuffs .04 Type if only 1 possible type in TIUFTLST (because of parent
  1. ;or duplicates or option e.g. create objects).
  1. ; Stuffs .07 Status = Inactive.
  1. ; If receives parent PFILEDA, parent is Shared, then
  1. ;stuffs .1 Shared = 1
  1. ; Should Lock FILEDA before calling STUFFLDS.
  1. N DIE,DA,DR,Y,NAME,PRINTDR,TYPEDR,STATUSDR,SHAREDR
  1. N NATL,NATLDR,NODE0,TYPE
  1. I '$G(PFILEDA) S PFILEDA=0
  1. S DIE=8925.1,DA=FILEDA
  1. S NODE0=^TIU(8925.1,FILEDA,0),NAME=$P(NODE0,U),PRINTDR=".03///^S X=NAME"
  1. I $L(TIUFTLST,U)=3 S TYPE=$P(TIUFTLST,U,2),TYPEDR=".04////^S X=TYPE"
  1. S STATUSDR=".07///INACTIVE"
  1. S SHAREDR=".1////1"
  1. I $G(XQORNOD(0))'["Copy" S DR=PRINTDR
  1. ;VMP/ELR P232. On a copy set print name equal title if not an object menu.
  1. I $G(TIUFXNOD)["Copy",$G(ACTION)="C",$P($G(NODE0),U,4)'="O" S DR=PRINTDR
  1. I $G(TYPEDR) S DR=$S($D(DR):DR_";"_TYPEDR,1:TYPEDR)
  1. S DR=$S($D(DR):DR_";"_STATUSDR,1:STATUSDR)
  1. I $P($G(^TIU(8925.1,PFILEDA,0)),U,10) S DR=DR_";"_SHAREDR
  1. D ^DIE
  1. STUFFX Q
  1. ;
  1. ADDTEN(PFILEDA,FILEDA,NODE0,TENDA) ; Add item FILEDA to 10 NODE of
  1. ;File 8925.1 entry PFILEDA. Stuff item Menu Text
  1. ; Requires PFILEDA = 8925.1 IFN of parent of FILEDA.
  1. ; Requires FILEDA, Requires NODE0 = ^TIU(8925.1,FILEDA,0)
  1. ; Returns TENDA = 10 node DA of new item.
  1. ; Returns TENDA="" if fails lookup. Screen on fld 10, subfld .01
  1. ;prevents lookup failure due to duplicate names by allowing only
  1. ;FILEDA to pass screen.
  1. ;Should Lock PFILEDA before calling ADDTEN.
  1. N X,Y,DIE,DR,NAME,DA,DIC,DLAYGO,TIUFISCR,MSG,DUPITEM
  1. S TENDA=""
  1. I ('$G(PFILEDA))!('$G(FILEDA)) G ADDTX
  1. S NAME=$P(NODE0,U)
  1. I '$D(TIUFTLST) S DUPITEM=0,DUPITEM=$$DUPITEM^TIUFLF7(NAME,PFILEDA) I DUPITEM S MSG=" Can't add Item; Parent already has Item with the same Name" W !!,MSG,! G ADDTX ; possibly needed when called from TIU rather than from TIUF.
  1. S X=""""_NAME_""""
  1. S DA(1)=PFILEDA,DLAYGO=8925.1
  1. S TIUFISCR=FILEDA ; activates screen on fld 10, Subfld .01 in DD
  1. S DIC="^TIU(8925.1,DA(1),10,",DIC(0)="L",DIC("P")=$P(^DD(8925.1,10,0),U,2)
  1. D ^DIC S TENDA=+Y I Y=-1 S TENDA="" G ADDTX
  1. K DIC
  1. S DA=TENDA,DA(1)=PFILEDA D MTXTCHEC^TIUFT1(.DA,FILEDA,1)
  1. ADDTX Q
  1. ;