Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DDMP1

DDMP1.m

Go to the documentation of this file.
DDMP1 ;SFISC/DPC-ASCII IMPORT UTIILTIES ;9/19/96  14:58
 ;;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.
 ;
GETFMT(DDMPFMT) ;
 ; Sets up format info.
 ;DDMPFMT passed by reference.
 N DDMPFRMT
 I '($D(DDMPFMT)\10) D  Q:'($D(DDMPFMT)\10)
 . D FIND^DIC(.44,"","1;5;8","X",DDMPFMT,"","","","","DDMPFRMT")
 . I 'DDMPFRMT("DILIST",0) D BLD^DIALOG(1820,DDMPFMT,DDMPFMT) Q
 . S DDMPFMT("IEN")=DDMPFRMT("DILIST",2,1)
 . S DDMPFMT("FDELIM")=DDMPFRMT("DILIST","ID",1,1)
 . S DDMPFMT("FIXED")=DDMPFRMT("DILIST","ID",1,5)
 . S DDMPFMT("QUOTED")=DDMPFRMT("DILIST","ID",1,8)
 S DDMPFMT("FDELIM")=$G(DDMPFMT("FDELIM"))
 I DDMPFMT("FDELIM") D
 . N DDMPI,DDMPPC,DDMPASCI S DDMPASCI=""
 . F DDMPI=1:1 S DDMPPC=$P(DDMPFMT("FDELIM"),",",DDMPI) Q:'DDMPPC  S DDMPASCI=DDMPASCI_$C(DDMPPC)
 . S DDMPFMT("FDELIM")=DDMPASCI
 S DDMPFMT("QUOTED")=$G(DDMPFMT("QUOTED"),"NO")
 S DDMPFMT("FIXED")=$G(DDMPFMT("FIXED"),"NO")
 I ((DDMPFMT("FIXED")="YES")&(DDMPFMT("FDELIM")'=""))!((DDMPFMT("FIXED")'="YES")&(DDMPFMT("FDELIM")="")) D BLD^DIALOG(1821)
 Q
 ;
GETSRC(DDMPFSRC) ;
 ;Moves data from source file into global.
 N DDMPIMWK
 K ^TMP($J,"DDMP")
 S DDMPIMWK=$$FTG^%ZISH(DDMPFSRC("PATH"),DDMPFSRC("FILE"),$NA(^TMP($J,"DDMP",0)),3)
 I 'DDMPIMWK D BLD^DIALOG(1810,DDMPFSRC("FILE"),DDMPFSRC("FILE")) Q
 I '$D(^TMP($J,"DDMP")) D BLD^DIALOG(1812,DDMPFSRC("FILE"),DDMPFSRC("FILE"))
 Q
 ;
RQIDOK(DDMPFLDS) ;
 ;Verifies that required identifiers present in fields being imported.
 N DDMPF,DDMPRIDS,DDMPRID,DDMPERCT S DDMPF=0,DDMPERCT=$G(DIERR)
 F  S DDMPF=$O(DDMPFLDS(DDMPF)) Q:DDMPF=""  D
 . D REQIDS^DICU(DDMPF,"DDMPRIDS")
 . S DDMPRID=0
 . F  S DDMPRID=$O(DDMPRIDS("REQUIRED IDENTIFIERS",DDMPRID)) Q:DDMPRID=""  D
 . . I ";"_DDMPFLDS(DDMPF)_";"'[(";"_DDMPRID_";"),";"_DDMPFLDS(DDMPF)'[(";"_DDMPRID_"[") D
 . . . N DDMPP S DDMPP("FILE")=DDMPF
 . . . D BLD^DIALOG(312,.DDMPP,.DDMPP)
 Q DDMPERCT=$G(DIERR)
 ;
INFILE(DDMPINAR,DDMPFMT,DDMPFBCK,DDMPDR,DDMPNCNT) ;
 N DDMPDELM,DDMPFLDS,DDMPF,DDMPFSTR,DDMPI,DDMPJ,DDMPVAL,DDMPDONE
 S DDMPNCNT=""
 I DDMPFMT("FIXED")="YES" S DDMPDELM=","
 E  S DDMPDELM=DDMPFMT("FDELIM")
 F  S DDMPNCNT=$O(@DDMPINAR@(DDMPNCNT)) Q:DDMPNCNT=""!$G(DDMPDONE)  S DDMPVAL=^(DDMPNCNT) D  Q:$G(DIERR)
 . I DDMPVAL="" Q
 . I '$D(DDMPF) D  Q
 . . S DDMPF=$P(DDMPVAL,"FILE=",2)
 . . I DDMPF="" D BLD^DIALOG(1831) Q
 . . S DDMPF=$$FILENUM(DDMPF)
 . F DDMPI=1:1 S DDMPFSTR=$P(DDMPVAL,DDMPDELM,DDMPI) Q:DDMPFSTR=""  D
 . . N DDMPFDF,DDMPDPTH,DDMPFLD
 . . S DDMPDPTH=$L(DDMPFSTR,":")
 . . S DDMPFDF=DDMPF
 . . F DDMPJ=1:1:DDMPDPTH S DDMPFLD=$P(DDMPFSTR,":",DDMPJ) D  Q:$G(DIERR)
 . . . N DDMP0P2
 . . . D FLDVAL Q:$G(DIERR)
 . . . S $P(DDMPFSTR,":",DDMPJ)=DDMPFLD_U_DDMPFDF
 . . . S DDMPFDF=+DDMP0P2
 . . S DDMPFLDS(DDMPI)=DDMPFSTR
 . S DDMPDONE=1
 I $O(@DDMPINAR@(DDMPNCNT))="" S DDMPNCNT=""
 I $G(DIERR)!(DDMPNCNT="") Q
 S DDMPFLDS=1
 D TODR(DDMPF,.DDMPFLDS,.DDMPDR)
 S DDMPFBCK=DDMPF
 Q
 ;
FILENUM(DDMPF) ;
 I DDMPF,$$VFILE^DILFD(DDMPF) Q DDMPF
 I $D(^DIC("B",DDMPF))=10 Q $O(^(DDMPF,""))
 D BLD^DIALOG(409,DDMPF,DDMPF)
 Q 0
FLDVAL ;
 N DDMP0
 I 'DDMPFLD S DDMPFLD=$$FLDNUM^DILFD(DDMPFDF,DDMPFLD) Q:$G(DIERR)
 S DDMP0=$G(^DD(DDMPFDF,DDMPFLD,0))
 I DDMP0="" D  Q
 . N DDMPP S DDMPP("FILE")=DDMPFDF,DDMPP(1)=DDMPFLD
 . D BLD^DIALOG(501,.DDMPP,.DDMPP)
 S DDMP0P2=$P(DDMP0,U,2)
 I 'DDMP0P2 D
 . I DDMPJ<DDMPDPTH D BLD^DIALOG(1841)
 E  D
 . I DDMPJ=DDMPDPTH D BLD^DIALOG(1842)
 . I $P($G(^DD(+DDMP0P2,.01,0)),U,2)["W" D
 . . N DDMPP
 . . S DDMPP("FILE")=DDMPFDF,DDMPP("FIELD")=DDMPFLD,DDMPP(1)="word processing"
 . . D BLD^DIALOG(520,.DDMPP,.DDMPP)
 I DDMPI>1,$P($P(DDMPFLDS(DDMPI-1),":",DDMPJ-1),U,2)'=$P($P(DDMPFSTR,":",DDMPJ-1),U,2) D
 . D BLD^DIALOG(1844)
 Q
 ;
TMPL2DR(DDMPF,DDMPFLDS) ;
 N DDMPDR
 N DDMPERR S DDMPERR=$G(DIERR)
 D TMPL2SQ(DDMPF,.DDMPFLDS)
 I DDMPERR'=$G(DIERR) Q
 S DDMPFLDS=1
 D TODR(DDMPF,.DDMPFLDS,.DDMPDR)
 K DDMPFLDS
 M DDMPFLDS=DDMPDR
 Q
 ;
TMPL2SQ(DDMPF,DDMPFLSQ) ;
 N DDMPTPNM,DDMPTPNO,DDMPSQ,DDMPPATH
 S DDMPTPNM=$S($E(DDMPFLSQ)="[":$P($P(DDMPFLSQ,"[",2),"]"),1:DDMPFLSQ)
 S DDMPTPNO=$O(^DIST(.46,"F"_DDMPF,DDMPTPNM,""))
 I 'DDMPTPNO D  Q  ;Template does not exist.
 . N DDMPARAM
 . S DDMPARAM(1)=DDMPTPNM,DDMPARAM("FILE")=DDMPF
 . D BLD^DIALOG(1870,.DDMPARAM,.DDMPARAM)
 D LIST^DIC(.463,","_DDMPTPNO_",","1;2;3;10","I")
 I '$D(^TMP("DILIST",$J,0)) Q
 F DDMPSQ=1:1:+^TMP("DILIST",$J,0) D
 . S DDMPPATH=^TMP("DILIST",$J,"ID",DDMPSQ,10)
 . S DDMPFLSQ(DDMPSQ)=$S(DDMPPATH]"":DDMPPATH_":",1:"")_^(2)_U_^(1) ;naked set on prior line.
 . I ^(3) S DDMPFLSQ("LN",DDMPSQ)=^(3) ;naked set 2 lines above.
 K ^TMP("DILIST",$J)
 Q
 ;
TODR(DDMPF,DDMPFLDS,DDMPDR,DDMPDRTP) ;
 N DDMPPPTH,DDMPCPTH,DDMPDPTH,DDMPFDWN,DDMPDONE,DDMPODTH
 F  D  Q:$G(DDMPDONE)!$G(DIERR)
 . I '$D(DDMPFLDS(DDMPFLDS)) D TMP2DR Q
 . I '$D(DDMPDPTH) S DDMPODTH=$L(DDMPFLDS(DDMPFLDS),":")
 . S DDMPDPTH=$L(DDMPFLDS(DDMPFLDS),":")
 . I '$D(DDMPCPTH) S DDMPPPTH=$P(DDMPFLDS(DDMPFLDS),":",1,DDMPDPTH-1)
 . S DDMPCPTH=$P(DDMPFLDS(DDMPFLDS),":",1,DDMPDPTH-1)
 . I DDMPCPTH=DDMPPPTH D
 . . I $G(DDMPDRTP(DDMPF))[(";"_+$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH)_";") D  Q
 . . . I +$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH)=$P(DDMPDRTP(DDMPF),";",2),DDMPDPTH>1 D
 . . . . D TMP2DR
 . . . E  D BLD^DIALOG(1845)
 . . S DDMPDRTP(DDMPF)=$G(DDMPDRTP(DDMPF),";")_+$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH)_$S('$D(DDMPFLDS("LN")):"",1:"["_DDMPFLDS("LN",DDMPFLDS)_"]")_";"
 . . S DDMPFLDS=DDMPFLDS+1
 . . S DDMPPPTH=DDMPCPTH
 . . S DDMPODTH=DDMPDPTH
 . E  I DDMPDPTH'>DDMPODTH D
 . . D TMP2DR
 . E  D
 . . S DDMPDRTP(DDMPF)=DDMPDRTP(DDMPF)_+$P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH-1)_";"
 . . S DDMPFDWN=$P($P(DDMPFLDS(DDMPFLDS),":",DDMPDPTH),U,2)
 . . D TODR(DDMPFDWN,.DDMPFLDS,.DDMPDR,.DDMPDRTP)
 Q
 ;
TMP2DR ;
 S DDMPDONE=1
 I '$D(DDMPDR(DDMPF)) S DDMPDR(DDMPF)=$E(DDMPDRTP(DDMPF),2,$L(DDMPDRTP(DDMPF))-1)
 E  I DDMPDR(DDMPF)'=$E(DDMPDRTP(DDMPF),2,$L(DDMPDRTP(DDMPF))-1) D
 . D BLD^DIALOG(1846,DDMPF,DDMPF)
 K DDMPDRTP(DDMPF)
 Q
 ;