source: FOIAVistA/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIULC.m@ 1397

Last change on this file since 1397 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.0 KB
Line 
1TIULC ; SLC/JER - Computational functions ;8/23/04
2 ;;1.0;TEXT INTEGRATION UTILITIES;**3,9,19,23,53,93,109,182**;Jun 20, 1997
3LINECNT(DA) ; Compute line count for document record
4 N CPL,CCNT S CPL=$S(+$P($G(TIUPRM0),U,3)>0:$P(TIUPRM0,U,3),1:60)
5 Q $$CHARCNT(DA)\CPL
6CHARCNT(DA) ; Compute character count for a record
7 N TIUI
8 N:'$D(CCNT) CCNT ; Character count is static
9 S TIUI=0 F S TIUI=$O(^TIU(8925,DA,"TEXT",TIUI)) Q:+TIUI'>0 D
10 . S CCNT=+$G(CCNT)+$L($$STRIP^TIULS(^TIU(8925,DA,"TEXT",TIUI,0)))
11 S TIUI=0
12 F S TIUI=$O(^TIU(8925,"DAD",DA,TIUI)) Q:+TIUI'>0!+$$ISADDNDM^TIULC1(+TIUI) S CCNT=$$CHARCNT(TIUI)
13 Q +$G(CCNT)
14STATUS(DA) ; Evaluate Status of Reports
15 N NODE12,NODE13,NODE15,NODE16,AMENDED,STATUS,SIGNED,COSIGNED,PURGED
16 N VERIFIED,RELEASED,SIGNER,COSIGNER,SIGSTAT,TYPE,REQVER,REQREL,REQCOS
17 N DELETED,TIUDPARM,ADMINCL
18 S STATUS=""
19 S TYPE=$S($D(TIUTYP(1)):$P(TIUTYP(1),U,2),1:+$G(^TIU(8925,+DA,0)))
20 D DOCPRM^TIULC1(TYPE,.TIUDPARM,DA)
21 S REQVER=$$REQVER(+DA,+$P($G(TIUDPARM(0)),U,3))
22 S REQREL=+$P($G(TIUDPARM(0)),U,2)
23 S NODE12=$G(^TIU(8925,+DA,12)),NODE13=$G(^TIU(8925,+DA,13))
24 S NODE15=$G(^TIU(8925,+DA,15)),NODE16=$G(^TIU(8925,+DA,16))
25 S SIGNED=+$P(NODE15,U),COSIGNED=+$P(NODE15,U,7),REQCOS=+$P(NODE15,U,6)
26 S SIGNER=+$P(NODE12,U,2),COSIGNER=+$P(NODE12,U,4)
27 S ADMINCL=+$P(NODE16,U,6) ;P182
28 S AMENDED=+$P(NODE16,U),PURGED=+$P(NODE16,U,9),DELETED=+$P(NODE16,U,11)
29 S RELEASED=+$P(NODE13,U,4),VERIFIED=+$P(NODE13,U,5)
30 I PURGED S STATUS="purged" G STATUSX
31 I DELETED S STATUS="deleted" G STATUSX
32 I AMENDED S STATUS="amended" G STATUSX
33 I +$$ISA^TIULX(+TYPE,+$$CLASS^TIUCP),'SIGNER S STATUS="undictated" G STATUSX
34 I '+NODE12,+NODE13 S STATUS="untranscribed" G STATUSX
35 I REQREL,'RELEASED S STATUS="unreleased" G STATUSX
36 I REQVER,'VERIFIED S STATUS="unverified" G STATUSX
37 I SIGNED,$S('REQCOS:1,COSIGNED:1,1:0) S STATUS="completed" G STATUSX
38 I ADMINCL S STATUS="completed" G STATUSX
39 I 'SIGNED S STATUS="unsigned" G STATUSX
40 I REQCOS,'COSIGNED S STATUS="uncosigned"
41STATUSX Q STATUS
42REQVER(TIUDA,TIUVPRM) ; Evaluate conditions of verification requirement
43 N TIUD0,TIUD13,TIUD15,TIUY
44 S TIUD0=$G(^TIU(8925,+TIUDA,0)),TIUD13=$G(^(13)),TIUD15=$G(^(15))
45 I +$G(TIUVPRM)'>0!(+$P(TIUD13,U,5)>0) S TIUY=0 G REQVX
46 I +$G(TIUVPRM)>0,+$G(TIUD15) S TIUY=0 G REQVX
47 I +$G(TIUVPRM)=1 S TIUY=1 G REQVX
48 I +$G(TIUVPRM)=2,($P(TIUD13,U,3)="U") S TIUY=1 G REQVX
49 I +$G(TIUVPRM)=3,($P(TIUD13,U,3)="D") S TIUY=1
50REQVX Q +$G(TIUY)
51PRCDNC(DA,SCREEN) ; Determine sort precedence of each record
52 N SIGNED,URGENCY
53 S URGENCY=$P($G(^TIU(8925,+DA,0)),U,9)
54 I +$$SIGNED(DA,.SCREEN)'>0 S Y=$S(URGENCY="P":1,1:2)
55 E S Y=3
56 Q Y
57PURGE(TIUDA) ; Checks whether or not a given Document should be purged
58 N TIUEDT,TIUY S TIUY=0
59 ; if parameters not in symbol table, get them
60 I '$D(TIUPRM0) D SETPARM^TIULE
61 ; exit if no Archive/purge grace period defined
62 I +$P(TIUPRM0,U,4)'>0 G PURGEX
63 S TIUEDT=$P($G(^TIU(8925,TIUDA,12)),U)
64 I +TIUEDT'>0 G PURGEX ;Transcription date blank
65 I +$$ISPN^TIULX(+$G(^TIU(8925,+TIUDA,0))) G PURGEX ; PN's exempt
66 I +$$ISADDNDM^TIULC1(+TIUDA),+$$ISPN^TIULX(+$G(^TIU(8925,+$P(^TIU(8925,+TIUDA,0),U,6),0))) G PURGEX ; Addenda to Progress Notes exempt
67 I +$P($G(^TIU(8925,+TIUDA,0)),U,5)<7 G PURGEX ;Incomplete--don't purge
68 I +$P($G(^TIU(8925,TIUDA,16)),U,4)>0 G PURGEX ;Document already purged
69 I $$FMDIFF^XLFDT(DT,TIUEDT)>+$P(TIUPRM0,U,4) S TIUY=1
70PURGEX Q TIUY
71OVERDUE(TIUDA) ; Checks whether or not a given document is overdue
72 N TIUD0,TIUDATE,TIUY,TIUDPRM S TIUY=0,TIUD0=$G(^TIU(8925,TIUDA,0))
73 ; if parameters not in symbol table, get them
74 I '$D(TIUPRM0) D SETPARM^TIULE
75 D DOCPRM^TIULC1(+TIUD0,.TIUDPRM,TIUDA)
76 ; exit if no signature grace period defined
77 I +$P(TIUPRM0,U,5)'>0 G OVERX
78 I '$D(TIUDPRM) G OVERX
79 S TIUDATE=$S($$REQVER(TIUDA,+$P(TIUDPRM(0),U,3)):$P($G(^TIU(8925,+TIUDA,13)),U,5),$P(TIUDPRM(0),U,2):$P($G(^TIU(8925,+TIUDA,13)),U,4),1:$P($G(^TIU(8925,+TIUDA,12)),U))
80 G:+TIUDATE'>0 OVERX
81 I $$FMDIFF^XLFDT(DT,TIUDATE)>$P(TIUPRM0,U,5),(+$P($G(^TIU(8925,+TIUDA,0)),U,5)>4),(+$P($G(^TIU(8925,+TIUDA,0)),U,5)<7) S TIUY=1
82OVERX Q TIUY
83NOW() ; Extrinsic function returning current date/time to nearest .01 second
84 N %,%H,%I,X
85 D NOW^%DTC
86 Q %
87IDATE(X) ; Recieves date in external format, returns internal format
88 N %DT,Y
89 I ($L(X," ")=2),(X?1.2N1P1.2N1P1.2N1" "1.2N.E) S X=$TR(X," ","@")
90 S %DT="TSP" D ^%DT
91 Q Y
92SIGNED(TIUDA,SCREEN) ; Check whether document requires signature or
93 ; cosignature on user-sensitive basis
94 N Y S Y=0 ; Initialize return value to FALSE
95 ; If archived/purged return TRUE
96 I +$P($G(^TIU(8925,+TIUDA,16)),U,9) S Y=1 G SIGNEDX
97 ; If OPTION is Act on MY Unsigned Documents, check
98 ; whether his/her signature is present
99 I $P($G(SCREEN(1)),U)="AAU",($P($G(SCREEN(2)),U)="ASUP") D G SIGNEDX
100 . ; If dictated by user and signed return TRUE
101 . I $P($G(^TIU(8925,+TIUDA,12)),U,4)=DUZ,(+$P($G(^(15)),U)>0) S Y=1
102 . ; If user is Expected Cosigner and cosigned, return TRUE
103 . I $P($G(^TIU(8925,+TIUDA,12)),U,8)=DUZ,(+$P($G(^(15)),U,7)>0) S Y=1
104 ; Otherwise check search criteria to determine signature status
105 I $P($G(SCREEN(1)),U)="AAU",+$P($G(^TIU(8925,+TIUDA,15)),U) S Y=1 G SIGNEDX
106 I $P($G(SCREEN(1)),U)="ASUP",+$P($G(^TIU(8925,+TIUDA,15)),U,7) S Y=1 G SIGNEDX
107 I +$P($G(^TIU(8925,+TIUDA,15)),U),+$P($G(^(15)),U,7) S Y=1
108SIGNEDX Q Y
109BLANK(TIUDA) ; Reads a given document for blank lines
110 ; Returns: 1:Record contains 1 or more blanks
111 ; 0:Record contains no blanks
112 N BLANK,TIUI,Y S (TIUI,Y)=0
113 I '$D(TIUPRM1) D SETPARM^TIULE
114 I $P($G(TIUPRM1),U,6)']"" G BLANKX
115 S BLANK=$P(TIUPRM1,U,6)
116 F S TIUI=$O(^TIU(8925,TIUDA,"TEXT",TIUI)) Q:+TIUI'>0 D
117 . I $G(^TIU(8925,TIUDA,"TEXT",TIUI,0))[BLANK S Y=1
118BLANKX Q Y
119CHKSUM(TIUROOT,TIUY) ; Calculates checksum for a record
120 N TIUI,X S TIUI=0,TIUY=+$G(TIUY)
121 F S TIUI=$O(@TIUROOT@(TIUI)) Q:+TIUI'>0 D
122 . S X=$G(@TIUROOT@(TIUI,0))
123 . N TIUJ
124 . F TIUJ=1:1:$L(X) S TIUY=+$G(TIUY)+(($A(X,TIUJ)*TIUI)*TIUJ)
125 S TIUI=0
126 F S TIUI=$O(^TIU(8925,"DAD",+$P(TIUROOT,",",2),TIUI)) Q:+TIUI'>0 D
127 . I +$$ISADDNDM^TIULC1(+TIUI) Q
128 . S TIUY=+$G(TIUY)+$$CHKSUM("^TIU(8925,"_+TIUI_",""TEXT"")",TIUY)
129 Q +$G(TIUY)
Note: See TracBrowser for help on using the repository browser.