source: WorldVistAEHR/trunk/r/AUTOMATED_INFO_COLLECTION_SYS-IBD/IBDFU2.m@ 1005

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1IBDFU2 ;ALB/CJM - ENCOUNTER FORM - BUILD FORM(copying blocks) ; 08-JAN-1993
2 ;;3.0;AUTOMATED INFO COLLECTION SYS;**15**;APR 24, 1997
3 ;
4COPYBLK(OLDBLOCK,IBFORM,FROMFILE,TOFILE,ROW,COL,TKORDER,NAME,RECMPILE) ;copys OLDBLOCK in FROMFILE to IBFORM in TOFILE
5 ;makes the new block part of IBFORM if defined
6 ;places block at (ROW,COL) if defined
7 ;sets TOOL KIT ORDER TKORDER if defined and >0
8 ;sets the block name to NAME if defined
9 ;returns the ien of the new copy
10 ;RECMPILE means don't copy compiled block
11 ;
12 Q:(FROMFILE'=357.1)&(FROMFILE'=358.1) ""
13 Q:(TOFILE'=357.1)&(TOFILE'=358.1) ""
14 N NODE,LIST,FLD,LINE,TEXT,NEWBLOCK,FROM,TO,SUB,I
15 S NEWBLOCK=""
16 S NODE=$G(^IBE(FROMFILE,OLDBLOCK,0)) Q:NODE="" ""
17 S $P(NODE,"^",2)=$G(IBFORM)
18 S:$G(NAME)="" NAME=$P(NODE,"^")
19 S RECMPILE=+$G(RECMPILE)
20 ;there must be a name
21 Q:NAME="" ""
22 S $P(NODE,"^")=NAME
23 I $D(ROW),(ROW=+ROW) S $P(NODE,"^",4)=ROW
24 I $D(COL),(COL=+COL) S $P(NODE,"^",5)=COL
25 S:$D(TKORDER) $P(NODE,"^",14)=$S(TKORDER:TKORDER,1:"")
26 K DIC,DO,DD,DINUM S DIC="^IBE("_TOFILE_",",X=NAME,DIC(0)=""
27 D FILE^DICN K DIC,DIE,DA
28 S NEWBLOCK=$S(+Y<0:"",1:+Y)
29 Q:'NEWBLOCK ""
30 S ^IBE(TOFILE,NEWBLOCK,0)=NODE
31 S NODE=0 F S NODE=$O(^IBE(FROMFILE,OLDBLOCK,NODE)) Q:'NODE S ^IBE(TOFILE,NEWBLOCK,NODE)=$G(^IBE(FROMFILE,OLDBLOCK,NODE))
32 K DIK,DA S DIK="^IBE("_TOFILE_",",DA=NEWBLOCK
33 D IX1^DIK K DIK,DA
34 ;I ('RECMPILE),TOFILE=357.1,FROMFILE=357.1,$D(^IBE(357.1,OLDBLOCK,"V")),$D(^IBE(357.1,OLDBLOCK,"S")),$D(^IBE(357.1,OLDBLOCK,"B")),$D(^IBE(357.1,OLDBLOCK,"H")) D
35 ;.F SUB="S","V","B","H" S I=0 S ^IBE(357.1,NEWBLOCK,SUB,0)=$G(^IBE(357.1,OLDBLOCK,SUB,0)) F S I=$O(^IBE(357.1,OLDBLOCK,SUB,I)) Q:'I S ^IBE(357.1,NEWBLOCK,SUB,I,0)=$G(^IBE(357.1,OLDBLOCK,SUB,I,0))
36 ;before any new block component is created, make sure there is no garbage around with dangling pointer pointing to new block
37 D DLTCNTNT^IBDFU3(NEWBLOCK,TOFILE)
38 ;
39 ;now copy the old block's contents into the newblock
40 S (LIST,LINE,TEXT)=""
41 ;
42 ;copy selection lists
43 S FROM=$S(FROMFILE[358:358.2,1:357.2),TO=$S(TOFILE[358:358.2,1:357.2)
44 F S LIST=$O(^IBE(FROM,"C",OLDBLOCK,LIST)) Q:'LIST I $$COPYLIST(LIST,OLDBLOCK,NEWBLOCK,FROM,TO)
45 ;
46 ;copy data fields
47 S FROM=$S(FROMFILE[358:358.5,1:357.5),TO=$S(TOFILE[358:358.5,1:357.5)
48 S FLD=0 F S FLD=$O(^IBE(FROM,"C",OLDBLOCK,FLD)) Q:'FLD D COPYFLD^IBDFU2A(FLD,OLDBLOCK,NEWBLOCK,FROM,TO)
49 ;
50 ;copy multiple choice fields
51 S FROM=$S(FROMFILE[358:358.93,1:357.93),TO=$S(TOFILE[358:358.93,1:357.93)
52 S FLD=0 F S FLD=$O(^IBE(FROM,"C",OLDBLOCK,FLD)) Q:'FLD D COPYMFLD^IBDFU2A(FLD,OLDBLOCK,NEWBLOCK,FROM,TO)
53 ;
54 ;copy hand print fields
55 S FROM=$S(FROMFILE[358:358.94,1:359.94),TO=$S(TOFILE[358:358.94,1:359.94)
56 S FLD=0 F S FLD=$O(^IBE(FROM,"C",OLDBLOCK,FLD)) Q:'FLD D COPYHFLD^IBDFU2A(FLD,OLDBLOCK,NEWBLOCK,FROM,TO)
57 ;
58 ;copy lines
59 S FROM=$S(FROMFILE[358:358.7,1:357.7),TO=$S(TOFILE[358:358.7,1:357.7)
60 F S LINE=$O(^IBE(FROM,"C",OLDBLOCK,LINE)) Q:'LINE D COPYLINE^IBDFU2A(LINE,OLDBLOCK,NEWBLOCK,FROM,TO)
61 ;
62 ;copy text areas
63 S FROM=$S(FROMFILE[358:358.8,1:357.8),TO=$S(TOFILE[358:358.8,1:357.8)
64 F S TEXT=$O(^IBE(FROM,"C",OLDBLOCK,TEXT)) Q:'TEXT D COPYTEXT^IBDFU2A(TEXT,OLDBLOCK,NEWBLOCK,FROM,TO)
65 Q NEWBLOCK
66 ;
67COPYLIST(LIST,OLDBLOCK,NEWBLOCK,FROMFILE,TOFILE) ;
68 ;returns the new list copied from LIST
69 Q:'$G(LIST)!('$G(OLDBLOCK))!('$G(NEWBLOCK))!('$G(FROMFILE))!('$G(TOFILE)) 0
70 Q:(FROMFILE'=357.2)&(FROMFILE'=358.2) 0
71 Q:(TOFILE'=357.2)&(TOFILE'=358.2) 0
72 N NODE,NAME,NEWLIST,GRP,SLCTN,COL,TO,FROM,TOPI,FROMPI,DYNAMIC
73 S NEWLIST=""
74 S NODE=$G(^IBE(FROMFILE,LIST,0)) Q:NODE="" 0
75 S DYNAMIC=$P(NODE,"^",14)
76 ;make sure the list really belongs to the block being copied - if not re-index it
77 I $P(NODE,"^",2)='OLDBLOCK K DA S DA=LIST,DIK="^IBE("_FROMFILE_"," D IX^DIK K DIK Q 0
78 S NAME=$P(NODE,"^",1),$P(NODE,"^",2)=NEWBLOCK
79 S FROMPI=$P(NODE,"^",11)
80 S TOPI=$$GETPI^IBDFU2B(FROMPI,$S(FROMFILE[358:358.6,1:357.6),$S(TOFILE[358:358.6,1:357.6)),$P(NODE,"^",11)=TOPI
81 Q:NAME="" 0
82 K DIC,DD,DINUM,DO S DIC="^IBE("_TOFILE_",",X=NAME,DIC(0)=""
83 D FILE^DICN K DIC,DIE,DA
84 S NEWLIST=$S(+Y<0:"",1:+Y)
85 Q:'NEWLIST 0
86 D DLISTCNT^IBDFU3(NEWLIST,TOFILE) ;clean up any dangling pointers that may be now pointing to this new, supposedly empty list
87 ;
88 ;now copy
89 S ^IBE(TOFILE,NEWLIST,0)=NODE
90 ;
91 ;copy the column multiple
92 S NODE=$G(^IBE(FROMFILE,LIST,1,0))
93 I NODE'="" S $P(NODE,"^",2)=TOFILE_"1I",^IBE(TOFILE,NEWLIST,1,0)=NODE S COL=0 F S COL=$O(^IBE(FROMFILE,LIST,1,COL)) Q:'COL S NODE=$G(^IBE(FROMFILE,LIST,1,COL,0)) S:NODE'="" ^IBE(TOFILE,NEWLIST,1,COL,0)=NODE
94 ;
95 ;now copy the subcolumn multiple
96 S NODE=$G(^IBE(FROMFILE,LIST,2,0)) I NODE'="" S $P(NODE,"^",2)=TOFILE_"2I",^IBE(TOFILE,NEWLIST,2,0)=NODE S COL=0 F S COL=$O(^IBE(FROMFILE,LIST,2,COL)) Q:'COL S NODE=$G(^IBE(FROMFILE,LIST,2,COL,0)) I NODE'="" D
97 .S:$P(NODE,"^",6) $P(NODE,"^",6)=$$GETMA^IBDFU2B($P(NODE,"^",6),$S(FROMFILE[358:358.91,1:357.91),$S(TOFILE[358:358.91,1:357.91))
98 .S:$P(NODE,"^",9) $P(NODE,"^",9)=$$GETQLFR^IBDFU2B($P(NODE,"^",9),$S(FROMFILE[358:358.98,1:357.98),$S(TOFILE[358:358.98,1:357.98))
99 .S ^IBE(TOFILE,NEWLIST,2,COL,0)=NODE
100 ;
101 K DIK,DA S DIK="^IBE("_TOFILE_",",DA=NEWLIST
102 D IX1^DIK K DIK,DA
103 S FROM=$S(FROMFILE[358:358.4,1:357.4),TO=$S(TOFILE[358:358.4,1:357.4)
104 ;
105 ; -- don't want to copy groups and selections if the selections are
106 ; not exportable
107 I FROM'=TO,FROMPI,'$P($G(^IBE($S(FROM[358:358.6,1:357.6),FROMPI,2)),"^",18) Q NEWLIST
108 ;I 'DYNAMIC S GRP="" F S GRP=$O(^IBE(FROM,"D",LIST,GRP)) Q:'GRP D COPYGRP^IBDFU2A(GRP,LIST,NEWLIST,NEWBLOCK,FROM,TO)
109 S GRP="" F S GRP=$O(^IBE(FROM,"D",LIST,GRP)) Q:'GRP D COPYGRP^IBDFU2A(GRP,LIST,NEWLIST,NEWBLOCK,FROM,TO)
110 Q NEWLIST
Note: See TracBrowser for help on using the repository browser.