DIFROM3 ;SFISC/XAK-CREATES RTN ENDING IN 'INIT2' (HELP FRAMES) ;6 DEC 2012
;;22.2;VA FileMan;;Jan 05, 2016;Build 42
;;Per VA Directive 6402, this routine should not be modified.
;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
;;Licensed under the terms of the Apache License, Version 2.0.
;
S DIRS=" S DIFQ=1"
S DNAME=E_2,DL=0,(DH,Q)=" ;" K ^UTILITY($J) F DD=1:1 S X=$T(TEXT+DD) Q:X="" S ^UTILITY($J,DD,0)=$E(X,4,999) S:$E(X,4)="U" ^(0)=^(0)_DIRS
S DIFROM=2 D ZI G ^DIFROM4
;
FILE ;
D:'$D(DISYS) OS^DII S DL=0,Q="Q Q",S=" ;;"
NAME S D=0
I DRN>12959 K DRN Q
S DNAME=DN_$$B36(DRN)
ZI ;
I '$D(DIFROM(1)) S %H=+$H D YX^%DTC S DIFROM(1)=$E(Y,5,6)_"-"_$E(Y,1,3)_"-"_$E(Y,9,12)
2 K ^UTILITY($J,0)
S ^(0,1)=DNAME_" ; ; "_DIFROM(1),D=$L(^(1))+2 ; (2 = CR/LF)
S ^(1.1)=DILN2,D=D+$L(^(1.1))+2 ; (2 = CR/LF)
S ^UTILITY($J,0,2)=DH,D=D+$L(^(2))+2 ; (2 ditto)
S ^UTILITY($J,0,3)=Q,D=D+$L(^(3))+2 ; (2 ditto)
F L=4:1 D Q:DL'>0 I D+257>DIFRM,$E(^(L),4)'="^",$E(^(L),4)'=$C(126) Q ; 255 for a line extra in M95 + 2 CR/LF
. S DL=$O(^UTILITY($J,DL))
. Q:DL'>0
. S ^UTILITY($J,0,L)=S_^(DL,0)
. S D=$L(^(L))+D+2 ; VEN/SMH - Add 2 charcaters for CR/LF
S DRN=DRN+1,X=DNAME X ^DD("OS",DISYS,"ZS") W !,X_" HAS BEEN FILED..." G NAME:DL>0
K K %A,%B,%C,%Z,^UTILITY($J) S DL=0 Q
;
B36(X) ;Calculate base 36 number from 0 (000) to 46,655 (ZZZ).
S X=$G(X) I X>46655 Q ""
Q $$N(X\(36*36)#36+1)_$$N(X\36#36+1)_$$N(X#36+1)
N(%) Q $E("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",%)
;
TEXT ;
;; K ^UTILITY("DIFROM",$J),DIC S DIDUZ=0 S:$D(DUZ)#2 DIDUZ=DUZ S DUZ=.5
;; I $D(^DIC(9.2,0))#2,^(0)?1"HEL".E S (DIC,DLAYGO)=9.2,N="HEL",DIC(0)="LX" G ADD
;; Q
;; ;
;;ADD F R=0:0 S R=$O(^UTILITY(U,$J,N,R)) Q:R'>0 S X=$P(^(R,0),U,1) W "." K DA D ^DIC I Y>0,'$D(DIFQ(N))!$P(Y,U,3) S ^UTILITY("DIFROM",$J,N,X)=+Y K ^DIC(9.2,+Y,1),^(2),^(3),^(10) S %X="^UTILITY(U,$J,N,R,",%Y=DIC_"+Y,",DA=+Y D %XY^%RCR
;; S DIK=DIC
;;HELP S R=$O(^UTILITY("DIFROM",$J,N,R)) Q:R="" W !,"'"_R_"' Help Frame filed." S DA=^(R)
;; F X=0:0 S X=$O(^DIC(9.2,DA,2,X)) Q:'X S I=$S($D(^(X,0)):^(0),1:0),Y=$P(I,U,2) S:Y]"" Y=$O(^DIC(9.2,"B",Y,0)) S ^(0)=$P(^DIC(9.2,DA,2,X,0),U,1)_U_$S(Y>0:Y,1:"")_U_$P(^(0),U,3,99)
;; S I=0 F X=0:0 S X=$O(^DIC(9.2,DA,10,X)) Q:'X I $D(^(X,0)) S Y=$P(^(0),U),Y=$S(Y]"":$O(^MAG("B",Y,0)),1:0) S:Y $P(^DIC(9.2,DA,10,X,0),U)=Y,I=I+1,%=X I 'Y K ^DIC(9.2,DA,10,X,0)
;; I I S $P(^DIC(9.2,DA,10,0),U,3,4)=%_U_I
;;IX D IX1^DIK G HELP
;; ;
;;U I $D(DIRUT)
;; W ! Q
;;REP S DIR(0)="Y",DIR("A")="Shall I change the NAME of the file to "_DIF
;; S DIR("??")="^D REP^DIFROMH1",DIR("B")="NO" D ^DIR G U:$D(DIRUT)
;; I Y S DIE=1,DIFQ=0,DA=N,DR=".01////"_DIF D ^DIE Q
;; S DIR("A")="Shall I replace your file with mine"
;; S DIR("??")="^D AG^DIFROMH1" D ^DIR G U:$D(DIRUT)!'Y
;; S DIU(0)="E",DIR("A")="Do you want to keep the Data"
;; S DIR("??")="^D CHG^DIFROMH1" D ^DIR G U:$D(DIRUT)
;; S:'Y DIU(0)=DIU(0)_"D"
;; S DIR("A")="Do you want to keep the Templates"
;; S DIR("??")="^D TEMP^DIFROMH1" D ^DIR G U:$D(DIRUT) S:'Y DIU(0)=DIU(0)_"T"
;; S DIFQ(N)=1,DIFKEP(N)=DIU(0) W !?15," (",DIF,") " Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDIFROM3 3231 printed Dec 13, 2024@02:48:03 Page 2
DIFROM3 ;SFISC/XAK-CREATES RTN ENDING IN 'INIT2' (HELP FRAMES) ;6 DEC 2012
+1 ;;22.2;VA FileMan;;Jan 05, 2016;Build 42
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
+4 ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
+5 ;;Licensed under the terms of the Apache License, Version 2.0.
+6 ;
+7 SET DIRS=" S DIFQ=1"
+8 SET DNAME=E_2
SET DL=0
SET (DH,Q)=" ;"
KILL ^UTILITY($JOB)
FOR DD=1:1
SET X=$TEXT(TEXT+DD)
if X=""
QUIT
SET ^UTILITY($JOB,DD,0)=$EXTRACT(X,4,999)
if $EXTRACT(X,4)="U"
SET ^(0)=^(0)_DIRS
+9 SET DIFROM=2
DO ZI
GOTO ^DIFROM4
+10 ;
FILE ;
+1 if '$DATA(DISYS)
DO OS^DII
SET DL=0
SET Q="Q Q"
SET S=" ;;"
NAME SET D=0
+1 IF DRN>12959
KILL DRN
QUIT
+2 SET DNAME=DN_$$B36(DRN)
ZI ;
+1 IF '$DATA(DIFROM(1))
SET %H=+$HOROLOG
DO YX^%DTC
SET DIFROM(1)=$EXTRACT(Y,5,6)_"-"_$EXTRACT(Y,1,3)_"-"_$EXTRACT(Y,9,12)
2 KILL ^UTILITY($JOB,0)
+1 ; (2 = CR/LF)
SET ^(0,1)=DNAME_" ; ; "_DIFROM(1)
SET D=$LENGTH(^(1))+2
+2 ; (2 = CR/LF)
SET ^(1.1)=DILN2
SET D=D+$LENGTH(^(1.1))+2
+3 ; (2 ditto)
SET ^UTILITY($JOB,0,2)=DH
SET D=D+$LENGTH(^(2))+2
+4 ; (2 ditto)
SET ^UTILITY($JOB,0,3)=Q
SET D=D+$LENGTH(^(3))+2
+5 ; 255 for a line extra in M95 + 2 CR/LF
FOR L=4:1
Begin DoDot:1
+6 SET DL=$ORDER(^UTILITY($JOB,DL))
+7 if DL'>0
QUIT
+8 SET ^UTILITY($JOB,0,L)=S_^(DL,0)
+9 ; VEN/SMH - Add 2 charcaters for CR/LF
SET D=$LENGTH(^(L))+D+2
End DoDot:1
if DL'>0
QUIT
IF D+257>DIFRM
IF $EXTRACT(^(L),4)'="^"
IF $EXTRACT(^(L),4)'=$CHAR(126)
QUIT
+10 SET DRN=DRN+1
SET X=DNAME
XECUTE ^DD("OS",DISYS,"ZS")
WRITE !,X_" HAS BEEN FILED..."
if DL>0
GOTO NAME
K KILL %A,%B,%C,%Z,^UTILITY($JOB)
SET DL=0
QUIT
+1 ;
B36(X) ;Calculate base 36 number from 0 (000) to 46,655 (ZZZ).
+1 SET X=$GET(X)
IF X>46655
QUIT ""
+2 QUIT $$N(X\(36*36)#36+1)_$$N(X\36#36+1)_$$N(X#36+1)
N(%) QUIT $EXTRACT("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",%)
+1 ;
TEXT ;
+1 ;; K ^UTILITY("DIFROM",$J),DIC S DIDUZ=0 S:$D(DUZ)#2 DIDUZ=DUZ S DUZ=.5
+2 ;; I $D(^DIC(9.2,0))#2,^(0)?1"HEL".E S (DIC,DLAYGO)=9.2,N="HEL",DIC(0)="LX" G ADD
+3 ;; Q
+4 ;; ;
+5 ;;ADD F R=0:0 S R=$O(^UTILITY(U,$J,N,R)) Q:R'>0 S X=$P(^(R,0),U,1) W "." K DA D ^DIC I Y>0,'$D(DIFQ(N))!$P(Y,U,3) S ^UTILITY("DIFROM",$J,N,X)=+Y K ^DIC(9.2,+Y,1),^(2),^(3),^(10) S %X="^UTILITY(U,$J,N,R,",%Y=DIC_"+Y,",DA=+Y D %XY^%RCR
+6 ;; S DIK=DIC
+7 ;;HELP S R=$O(^UTILITY("DIFROM",$J,N,R)) Q:R="" W !,"'"_R_"' Help Frame filed." S DA=^(R)
+8 ;; F X=0:0 S X=$O(^DIC(9.2,DA,2,X)) Q:'X S I=$S($D(^(X,0)):^(0),1:0),Y=$P(I,U,2) S:Y]"" Y=$O(^DIC(9.2,"B",Y,0)) S ^(0)=$P(^DIC(9.2,DA,2,X,0),U,1)_U_$S(Y>0:Y,1:"")_U_$P(^(0),U,3,99)
+9 ;; S I=0 F X=0:0 S X=$O(^DIC(9.2,DA,10,X)) Q:'X I $D(^(X,0)) S Y=$P(^(0),U),Y=$S(Y]"":$O(^MAG("B",Y,0)),1:0) S:Y $P(^DIC(9.2,DA,10,X,0),U)=Y,I=I+1,%=X I 'Y K ^DIC(9.2,DA,10,X,0)
+10 ;; I I S $P(^DIC(9.2,DA,10,0),U,3,4)=%_U_I
+11 ;;IX D IX1^DIK G HELP
+12 ;; ;
+13 ;;U I $D(DIRUT)
+14 ;; W ! Q
+15 ;;REP S DIR(0)="Y",DIR("A")="Shall I change the NAME of the file to "_DIF
+16 ;; S DIR("??")="^D REP^DIFROMH1",DIR("B")="NO" D ^DIR G U:$D(DIRUT)
+17 ;; I Y S DIE=1,DIFQ=0,DA=N,DR=".01////"_DIF D ^DIE Q
+18 ;; S DIR("A")="Shall I replace your file with mine"
+19 ;; S DIR("??")="^D AG^DIFROMH1" D ^DIR G U:$D(DIRUT)!'Y
+20 ;; S DIU(0)="E",DIR("A")="Do you want to keep the Data"
+21 ;; S DIR("??")="^D CHG^DIFROMH1" D ^DIR G U:$D(DIRUT)
+22 ;; S:'Y DIU(0)=DIU(0)_"D"
+23 ;; S DIR("A")="Do you want to keep the Templates"
+24 ;; S DIR("??")="^D TEMP^DIFROMH1" D ^DIR G U:$D(DIRUT) S:'Y DIU(0)=DIU(0)_"T"
+25 ;; S DIFQ(N)=1,DIFKEP(N)=DIU(0) W !?15," (",DIF,") " Q