118 lines
5.2 KiB
Mathematica
118 lines
5.2 KiB
Mathematica
TIUFLA ; SLC/MAM - Library; Template A Related: SELSTART, MATCH(FILEDA), TYPMATCH(FILEDA,ATYPE), OWNMATCH(FILEDA,AOWN), STTMATCH(FILEDA,ASTAT), USEMATCH(FILEDA,AUSE), STRMATCH(FILEDA,NODE0), PARMATCH(FILEDA,APARE) ;4/23/97 11:02
|
|
;;1.0;TEXT INTEGRATION UTILITIES;;Jun 20, 1997
|
|
;
|
|
SELSTART ; Select Docmt Def to Start with and to Go To
|
|
; Sets TIUFSTRT = Start^Stop where Start and Stop are characters to
|
|
;start and stop display with.
|
|
N DIR,X,Y,START,GOTO
|
|
W !! S DIR(0)="FO^1:60^S:$L($T(^TIULS)) X=$$UPPER^TIULS(X) K:'(X'?1P.E) X",(DIR("?"),DIR("??"))="^D HELP^TIUFLA(""start"")"
|
|
S DIR("A")="START WITH DOCUMENT DEFINITION",DIR("B")="FIRST"
|
|
I TIUFTMPL="J" S DIR("A")="START DISPLAY WITH OBJECT"
|
|
D ^DIR I $D(DIRUT),'$D(TIUFSTRT) G SELSX
|
|
S START=Y,START=$$UPPER^TIULS(START)
|
|
I START="FIRST" S TIUFSTRT=" ^ZZZZZZZZ" G SELSX
|
|
S DIR("A")="GO TO DOCUMENT DEFINITION",DIR("B")="LAST"
|
|
I TIUFTMPL="J" S DIR("A")="GO TO OBJECT"
|
|
S (DIR("?"),DIR("??"))="^D HELP^TIUFLA(""end"")"
|
|
D ^DIR I $D(DIRUT) G SELSX
|
|
S GOTO=$S(Y="LAST":"ZZZZZZZZ",1:Y),GOTO=$$UPPER^TIULS(GOTO)
|
|
S TIUFSTRT=START_U_GOTO
|
|
SELSX Q
|
|
;
|
|
HELP(STRTEND) ; Writes help for SELSTART
|
|
N DDEFOBJ S DDEFOBJ=$S(TIUFTMPL'="J":"Document Definition",1:"Object")
|
|
W !,"What ",DDEFOBJ," would you like to ",STRTEND," the display with? Enter a",!,"partial/whole ",DDEFOBJ," name, or just enter some letters."
|
|
Q
|
|
;
|
|
MATCH(FILEDA) ; Function returns 1 if FILEDA matches Template A Sort
|
|
;Attribute, and Sort Attribute Value.
|
|
;Else Returns e.g. 0^TYPE if Type is where match fails.
|
|
; Requires TIUFATTR, TIUFAVAL. See HDR^TIUFA
|
|
N ANS,ATTR1 S ANS=0
|
|
S ATTR1=$P(TIUFATTR,U)
|
|
I ATTR1="T" S ANS=$S($$TYPMATCH(FILEDA,TIUFAVAL):1,1:"0^TYPE")
|
|
I ATTR1="O" S ANS=$S($$OWNMATCH(FILEDA,TIUFAVAL):1,1:"0^OWNER")
|
|
I ATTR1="S" S ANS=$S($$STTMATCH(FILEDA,TIUFAVAL):1,1:"0^STATUS")
|
|
I ATTR1="U" S ANS=$S($$USEMATCH(FILEDA,TIUFAVAL):1,1:"0^WAY USED")
|
|
I ATTR1="P" S ANS=$S($$PARMATCH(FILEDA,TIUFAVAL):1,1:"0^PARENTAGE")
|
|
I ATTR1="A" S ANS=1
|
|
Q ANS
|
|
;
|
|
TYPMATCH(FILEDA,ATYPE) ; Function returns 1 if Type of FILEDA matches
|
|
;Template A Type Value, else 0.
|
|
; Requires FILEDA; Requires ATYPE=TIUFAVAL when TIUFATTR="T^TYPE".
|
|
;See HDR^TIUFA. Requires TIUFATTR.
|
|
N MATCH
|
|
I '$G(FILEDA)!'$D(ATYPE)!(TIUFATTR'="T^TYPE") S MATCH="ERR" G TYPMX
|
|
S MATCH=0,ATYPE=$P(ATYPE,U) I ATYPE="TL" S ATYPE="DOC"
|
|
I ATYPE="NONE" S:($P(^TIU(8925.1,FILEDA,0),U,4)="") MATCH=1 G TYPMX
|
|
I '$D(^TIU(8925.1,"AT",ATYPE,FILEDA)) G TYPMX
|
|
S MATCH=1
|
|
TYPMX Q MATCH
|
|
;
|
|
OWNMATCH(FILEDA,AOWN) ; Function returns 1 if FILEDA matches Template A Owner
|
|
;Value, Else 0.
|
|
; Requires FILEDA; Requires AOWN=TIUFAVAL when TIUFATTR="O^OWNER".
|
|
;See HDR^TIUFA. Requires TIUFATTR.
|
|
N MATCH,PERSOWNS,NODE0
|
|
S MATCH=0
|
|
I '$G(FILEDA)!'$D(AOWN) G OWNMX
|
|
I $P(AOWN,U,3)="P"!($P(AOWN,U,3)="I")!(TIUFATTR'="O^OWNER") D G OWNMX
|
|
. S PERSOWNS=$$PERSOWNS^TIUFLF2(FILEDA,+AOWN)
|
|
. I $P(AOWN,U,3)="P",$P(PERSOWNS,U,2)'="P" Q
|
|
. I $P(AOWN,U,3)="I",'PERSOWNS Q
|
|
. S MATCH=1
|
|
. Q
|
|
I $P(AOWN,U,3)="C",'$D(^TIU(8925.1,"AC",+AOWN,FILEDA)) G OWNMX
|
|
I $P(AOWN,U,2)="NONE" S NODE0=^TIU(8925.1,FILEDA,0) I $L($P(NODE0,U,5))!$L($P(NODE0,U,6)) G OWNMX
|
|
S MATCH=1
|
|
OWNMX Q MATCH
|
|
;
|
|
STTMATCH(FILEDA,ASTAT) ; Function returns 1 if Status of FILEDA matches
|
|
;Template A STatus Value ASTAT, else 0.
|
|
; Fudge: If ASTAT is A, I, or T, don't match a shared Component no matter what its .07 fld value is. However, if ASTAT=0 (NONE), match Shared Component no matter what its .07 fld value is.
|
|
; Requires FILEDA; Requires ASTAT=TIUFAVAL when TIUFATTR="S^STATUS".
|
|
;See HDR^TIUFA. Requires TIUFATTR.
|
|
N MATCH,NODE0
|
|
S MATCH=0,ASTAT=$P(ASTAT,U)
|
|
I '$G(FILEDA)!'$D(ASTAT)!(TIUFATTR'="S^STATUS") S MATCH="ERR" G STTMX
|
|
I $D(^TIU(8925.1,"AS",ASTAT,FILEDA)) S NODE0=^TIU(8925.1,FILEDA,0) I '$P(NODE0,U,10) S MATCH=1 G STTMX
|
|
I (ASTAT=0),'$P(^TIU(8925.1,FILEDA,0),U,7) S MATCH=1 G STTMX
|
|
I (ASTAT=0) S NODE0=^TIU(8925.1,FILEDA,0) I $P(NODE0,U,10) S MATCH=1
|
|
STTMX Q MATCH
|
|
;
|
|
USEMATCH(FILEDA,AUSE) ; Function returns 1 if Way Used By Docmts of
|
|
;FILEDA matches Template A Way Used Value, else 0.
|
|
; Requires FILEDA; Requires AUSE=TIUFAVAL when TIUFATTR="U^WAY USED",
|
|
;=YES,NO,NA or UNKNOWN.
|
|
;See HDR^TIUFA. Requires TIUFATTR.
|
|
N MATCH,DDEFUSED
|
|
I '$G(FILEDA)!'$D(AUSE)!(TIUFATTR'="U^WAY USED") S MATCH="ERR" G USEMX
|
|
S MATCH=0,DDEFUSED=$$DDEFUSED^TIUFLF(FILEDA)
|
|
I DDEFUSED["UNKNOWN",AUSE="UNKNOWN" S MATCH=1 G USEMX ; UNKNOWN[NO!!!
|
|
I DDEFUSED=AUSE S MATCH=1 G USEMX
|
|
USEMX Q MATCH
|
|
;
|
|
PARMATCH(FILEDA,APARE) ; Function returns 1 if Parentage of FILEDA matches
|
|
;Template A Parentage Value, else 0.
|
|
; Requires FILEDA; Requires APARE=TIUFAVAL when TIUFATTR="P^PARENTAGE".
|
|
;See HDR^TIUFA. Requires TIUFATTR.
|
|
N MATCH,ORPHAN,NODE0
|
|
S MATCH=0,APARE=$P(APARE,U)
|
|
I '$G(FILEDA)!'$D(APARE)!(TIUFATTR'="P^PARENTAGE") S MATCH="ERR" G PARMX
|
|
S NODE0=^TIU(8925.1,FILEDA,0),ORPHAN=$$ORPHAN^TIUFLF4(FILEDA,NODE0)
|
|
I ORPHAN="YES",$P(APARE,U)="O" S MATCH=1
|
|
I ORPHAN="NO",$P(APARE,U)="N" S MATCH=1
|
|
PARMX Q MATCH
|
|
;
|
|
STRMATCH(FILEDA,NODE0) ; Function returns 1 if FILEDA Name matches Template A
|
|
;Start With/Go To Value, Else 0.
|
|
; Requires FILEDA, NODE0= ^TIU(8925.1,FILEDA,0).
|
|
; Requires TIUFSTRT as set in SELSTART^TIUFLA.
|
|
N NAME,ANS
|
|
S NAME=$P(NODE0,U)
|
|
I $P(TIUFSTRT,U)']NAME,NAME']$P(TIUFSTRT,U,2) S ANS=1 G STRMX
|
|
S ANS=0
|
|
STRMX Q ANS
|
|
;
|