source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DDMP1.m@ 1361

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

initial load of WorldVistAEHR

File size: 5.8 KB
RevLine 
[613]1DDMP1 ;SFISC/DPC-ASCII IMPORT UTIILTIES ;9/19/96 14:58
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4GETFMT(DDMPFMT) ;
5 ; Sets up format info.
6 ;DDMPFMT passed by reference.
7 N DDMPFRMT
8 I '($D(DDMPFMT)\10) D Q:'($D(DDMPFMT)\10)
9 . D FIND^DIC(.44,"","1;5;8","X",DDMPFMT,"","","","","DDMPFRMT")
10 . I 'DDMPFRMT("DILIST",0) D BLD^DIALOG(1820,DDMPFMT,DDMPFMT) Q
11 . S DDMPFMT("IEN")=DDMPFRMT("DILIST",2,1)
12 . S DDMPFMT("FDELIM")=DDMPFRMT("DILIST","ID",1,1)
13 . S DDMPFMT("FIXED")=DDMPFRMT("DILIST","ID",1,5)
14 . S DDMPFMT("QUOTED")=DDMPFRMT("DILIST","ID",1,8)
15 S DDMPFMT("FDELIM")=$G(DDMPFMT("FDELIM"))
16 I DDMPFMT("FDELIM") D
17 . N DDMPI,DDMPPC,DDMPASCI S DDMPASCI=""
18 . F DDMPI=1:1 S DDMPPC=$P(DDMPFMT("FDELIM"),",",DDMPI) Q:'DDMPPC S DDMPASCI=DDMPASCI_$C(DDMPPC)
19 . S DDMPFMT("FDELIM")=DDMPASCI
20 S DDMPFMT("QUOTED")=$G(DDMPFMT("QUOTED"),"NO")
21 S DDMPFMT("FIXED")=$G(DDMPFMT("FIXED"),"NO")
22 I ((DDMPFMT("FIXED")="YES")&(DDMPFMT("FDELIM")'=""))!((DDMPFMT("FIXED")'="YES")&(DDMPFMT("FDELIM")="")) D BLD^DIALOG(1821)
23 Q
24 ;
25GETSRC(DDMPFSRC) ;
26 ;Moves data from source file into global.
27 N DDMPIMWK
28 K ^TMP($J,"DDMP")
29 S DDMPIMWK=$$FTG^%ZISH(DDMPFSRC("PATH"),DDMPFSRC("FILE"),$NA(^TMP($J,"DDMP",0)),3)
30 I 'DDMPIMWK D BLD^DIALOG(1810,DDMPFSRC("FILE"),DDMPFSRC("FILE")) Q
31 I '$D(^TMP($J,"DDMP")) D BLD^DIALOG(1812,DDMPFSRC("FILE"),DDMPFSRC("FILE"))
32 Q
33 ;
34RQIDOK(DDMPFLDS) ;
35 ;Verifies that required identifiers present in fields being imported.
36 N DDMPF,DDMPRIDS,DDMPRID,DDMPERCT S DDMPF=0,DDMPERCT=$G(DIERR)
37 F S DDMPF=$O(DDMPFLDS(DDMPF)) Q:DDMPF="" D
38 . D REQIDS^DICU(DDMPF,"DDMPRIDS")
39 . S DDMPRID=0
40 . F S DDMPRID=$O(DDMPRIDS("REQUIRED IDENTIFIERS",DDMPRID)) Q:DDMPRID="" D
41 . . I ";"_DDMPFLDS(DDMPF)_";"'[(";"_DDMPRID_";"),";"_DDMPFLDS(DDMPF)'[(";"_DDMPRID_"[") D
42 . . . N DDMPP S DDMPP("FILE")=DDMPF
43 . . . D BLD^DIALOG(312,.DDMPP,.DDMPP)
44 Q DDMPERCT=$G(DIERR)
45 ;
46INFILE(DDMPINAR,DDMPFMT,DDMPFBCK,DDMPDR,DDMPNCNT) ;
47 N DDMPDELM,DDMPFLDS,DDMPF,DDMPFSTR,DDMPI,DDMPJ,DDMPVAL,DDMPDONE
48 S DDMPNCNT=""
49 I DDMPFMT("FIXED")="YES" S DDMPDELM=","
50 E S DDMPDELM=DDMPFMT("FDELIM")
51 F S DDMPNCNT=$O(@DDMPINAR@(DDMPNCNT)) Q:DDMPNCNT=""!$G(DDMPDONE) S DDMPVAL=^(DDMPNCNT) D Q:$G(DIERR)
52 . I DDMPVAL="" Q
53 . I '$D(DDMPF) D Q
54 . . S DDMPF=$P(DDMPVAL,"FILE=",2)
55 . . I DDMPF="" D BLD^DIALOG(1831) Q
56 . . S DDMPF=$$FILENUM(DDMPF)
57 . F DDMPI=1:1 S DDMPFSTR=$P(DDMPVAL,DDMPDELM,DDMPI) Q:DDMPFSTR="" D
58 . . N DDMPFDF,DDMPDPTH,DDMPFLD
59 . . S DDMPDPTH=$L(DDMPFSTR,":")
60 . . S DDMPFDF=DDMPF
61 . . F DDMPJ=1:1:DDMPDPTH S DDMPFLD=$P(DDMPFSTR,":",DDMPJ) D Q:$G(DIERR)
62 . . . N DDMP0P2
63 . . . D FLDVAL Q:$G(DIERR)
64 . . . S $P(DDMPFSTR,":",DDMPJ)=DDMPFLD_U_DDMPFDF
65 . . . S DDMPFDF=+DDMP0P2
66 . . S DDMPFLDS(DDMPI)=DDMPFSTR
67 . S DDMPDONE=1
68 I $O(@DDMPINAR@(DDMPNCNT))="" S DDMPNCNT=""
69 I $G(DIERR)!(DDMPNCNT="") Q
70 S DDMPFLDS=1
71 D TODR(DDMPF,.DDMPFLDS,.DDMPDR)
72 S DDMPFBCK=DDMPF
73 Q
74 ;
75FILENUM(DDMPF) ;
76 I DDMPF,$$VFILE^DILFD(DDMPF) Q DDMPF
77 I $D(^DIC("B",DDMPF))=10 Q $O(^(DDMPF,""))
78 D BLD^DIALOG(409,DDMPF,DDMPF)
79 Q 0
80FLDVAL ;
81 N DDMP0
82 I 'DDMPFLD S DDMPFLD=$$FLDNUM^DILFD(DDMPFDF,DDMPFLD) Q:$G(DIERR)
83 S DDMP0=$G(^DD(DDMPFDF,DDMPFLD,0))
84 I DDMP0="" D Q
85 . N DDMPP S DDMPP("FILE")=DDMPFDF,DDMPP(1)=DDMPFLD
86 . D BLD^DIALOG(501,.DDMPP,.DDMPP)
87 S DDMP0P2=$P(DDMP0,U,2)
88 I 'DDMP0P2 D
89 . I DDMPJ<DDMPDPTH D BLD^DIALOG(1841)
90 E D
91 . I DDMPJ=DDMPDPTH D BLD^DIALOG(1842)
92 . I $P($G(^DD(+DDMP0P2,.01,0)),U,2)["W" D
93 . . N DDMPP
94 . . S DDMPP("FILE")=DDMPFDF,DDMPP("FIELD")=DDMPFLD,DDMPP(1)="word processing"
95 . . D BLD^DIALOG(520,.DDMPP,.DDMPP)
96 I DDMPI>1,$P($P(DDMPFLDS(DDMPI-1),":",DDMPJ-1),U,2)'=$P($P(DDMPFSTR,":",DDMPJ-1),U,2) D
97 . D BLD^DIALOG(1844)
98 Q
99 ;
100TMPL2DR(DDMPF,DDMPFLDS) ;
101 N DDMPDR
102 N DDMPERR S DDMPERR=$G(DIERR)
103 D TMPL2SQ(DDMPF,.DDMPFLDS)
104 I DDMPERR'=$G(DIERR) Q
105 S DDMPFLDS=1
106 D TODR(DDMPF,.DDMPFLDS,.DDMPDR)
107 K DDMPFLDS
108 M DDMPFLDS=DDMPDR
109 Q
110 ;
111TMPL2SQ(DDMPF,DDMPFLSQ) ;
112 N DDMPTPNM,DDMPTPNO,DDMPSQ,DDMPPATH
113 S DDMPTPNM=$S($E(DDMPFLSQ)="[":$P($P(DDMPFLSQ,"[",2),"]"),1:DDMPFLSQ)
114 S DDMPTPNO=$O(^DIST(.46,"F"_DDMPF,DDMPTPNM,""))
115 I 'DDMPTPNO D Q ;Template does not exist.
116 . N DDMPARAM
117 . S DDMPARAM(1)=DDMPTPNM,DDMPARAM("FILE")=DDMPF
118 . D BLD^DIALOG(1870,.DDMPARAM,.DDMPARAM)
119 D LIST^DIC(.463,","_DDMPTPNO_",","1;2;3;10","I")
120 I '$D(^TMP("DILIST",$J,0)) Q
121 F DDMPSQ=1:1:+^TMP("DILIST",$J,0) D
122 . S DDMPPATH=^TMP("DILIST",$J,"ID",DDMPSQ,10)
123 . S DDMPFLSQ(DDMPSQ)=$S(DDMPPATH]"":DDMPPATH_":",1:"")_^(2)_U_^(1) ;naked set on prior line.
124 . I ^(3) S DDMPFLSQ("LN",DDMPSQ)=^(3) ;naked set 2 lines above.
125 K ^TMP("DILIST",$J)
126 Q
127 ;
128TODR(DDMPF,DDMPFLDS,DDMPDR,DDMPDRTP) ;
129 N DDMPPPTH,DDMPCPTH,DDMPDPTH,DDMPFDWN,DDMPDONE,DDMPODTH
130 F D Q:$G(DDMPDONE)!$G(DIERR)
131 . I '$D(DDMPFLDS(DDMPFLDS)) D TMP2DR Q
132 . I '$D(DDMPDPTH) S DDMPODTH=$L(DDMPFLDS(DDMPFLDS),":")
133 . S DDMPDPTH=$L(DDMPFLDS(DDMPFLDS),":")
134 . I '$D(DDMPCPTH) S DDMPPPTH=$P(DDMPFLDS(DDMPFLDS),":",1,DDMPDPTH-1)
135 . S DDMPCPTH=$P(DDMPFLDS(DDMPFLDS),":",1,DDMPDPTH-1)
136 . I DDMPCPTH=DDMPPPTH D
137 . . I $G(DDMPDRTP(DDMPF))[(";"_+$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH)_";") D Q
138 . . . I +$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH)=$P(DDMPDRTP(DDMPF),";",2),DDMPDPTH>1 D
139 . . . . D TMP2DR
140 . . . E D BLD^DIALOG(1845)
141 . . S DDMPDRTP(DDMPF)=$G(DDMPDRTP(DDMPF),";")_+$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH)_$S('$D(DDMPFLDS("LN")):"",1:"["_DDMPFLDS("LN",DDMPFLDS)_"]")_";"
142 . . S DDMPFLDS=DDMPFLDS+1
143 . . S DDMPPPTH=DDMPCPTH
144 . . S DDMPODTH=DDMPDPTH
145 . E I DDMPDPTH'>DDMPODTH D
146 . . D TMP2DR
147 . E D
148 . . S DDMPDRTP(DDMPF)=DDMPDRTP(DDMPF)_+$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH-1)_";"
149 . . S DDMPFDWN=$P($P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH),U,2)
150 . . D TODR(DDMPFDWN,.DDMPFLDS,.DDMPDR,.DDMPDRTP)
151 Q
152 ;
153TMP2DR ;
154 S DDMPDONE=1
155 I '$D(DDMPDR(DDMPF)) S DDMPDR(DDMPF)=$E(DDMPDRTP(DDMPF),2,$L(DDMPDRTP(DDMPF))-1)
156 E I DDMPDR(DDMPF)'=$E(DDMPDRTP(DDMPF),2,$L(DDMPDRTP(DDMPF))-1) D
157 . D BLD^DIALOG(1846,DDMPF,DDMPF)
158 K DDMPDRTP(DDMPF)
159 Q
160 ;
Note: See TracBrowser for help on using the repository browser.