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

BNIGE.m

Go to the documentation of this file.
BNIGE ; IHS/CMI/LAB - BNI GUI Save Utilities 2/3/2006 8:53:46 AM ; 
 ;;1.0;BNI CPHD ACTIVITY DATASYSTEM;;DEC 20, 2006
 ;
 ;
 ;
 ;
 ;
 ;this routine will save off the data from the GUI client
 ;
DEBUG(BNIRET,BNISTR) ;-- call the serenji debugger for testing
 D DEBUG^%Serenji("GEN^BNIGE(.BNIRET,.BNISTR)")
 Q
 ;
FILE(BNIRET,BNISTR) ;-- file generic data
 S X="MERR^BNIU",@^%ZOSF("TRAP") ; m error trap
 N P,BNIFL,BNIDAS,BNIFLDS,BNII,BNIMOD,R,BNIPAT,BNIIA
 S P="|",R="~"
 K ^BNITMP($J)
 S BNIRET="^BNITMP("_$J_")"
 S BNII=0
 S ^BNITMP($J,BNII)="T00007Error^T00080Return String"_$C(30)
 S BNII=BNII+1
 I $G(BNISTR)="" D CATSTR^BNIGU(.BNISTR,.BNISTR)
 S BNIMOD=$P($P(BNISTR,P),R)
 ;S BNIFL=$P($P(BNISTR,P),R,2)
 S BNIPAT=$P($P(BNISTR,P),R,3)
 S BNIIA=$P($P(BNISTR,P),R,4)
 I BNIPAT]"" S DFN=BNIPAT
 S BNIDAS=$P(BNISTR,P,2)
 S BNIFLDS=$P(BNISTR,P,3,999)
 N BNIIENS,BNIFDA,BNIERR
 S BNILV=$L(BNIIA,",")
 I BNILV>1 D
 . Q:BNIMOD="D"
 . N J
 . F J=1:1 D  Q:$P(BNIIA,",",(J))=""
 .. Q:$P(BNIIA,",",(J))=""
 .. Q:(BNILV-J)=0
 .. S BNIIENS(BNILV-J)=$P(BNIIA,",",J)
 I BNIMOD="D" D  Q
 . D DIK(BNIFL,BNIDAS)
 . S ^BNITMP($J,BNII)="1^Data Filed Successfully For File "_BNIFL_$C(30)
 . S ^BNITMP($J,BNII+1)=$C(31)_$G(BNIERR)
 S BNIIENS=BNIDAS
 F I=1:1 D  Q:$P(BNIFLDS,"|",I)=""
 . Q:$P(BNIFLDS,"|",I)=""
 . N BNIFLD,BNIVAL,BNITYP,BNIS
 . S BNIS=$P(BNIFLDS,P,I)
 . S BNIFL=$P(BNIS,R)
 . S BNIFLD=$P(BNIS,R,2)
 . S BNIVAL=$P(BNIS,R,3)
 . ;I $P(BNIS,R,5)]"" S BNIIENS=$P(BNIS,R,5)
 . I $P(BNIS,R,4)="E" D
 .. S BNIVAL=$$LOOK(BNIFL,BNIFLD,BNIVAL)
 . S BNIFDA(BNIFL,$S($P(BNIS,R,5)]"":$P(BNIS,R,5),1:BNIIENS),BNIFLD)=BNIVAL
 I BNIMOD="A" D
 . D UPDATE^DIE("","BNIFDA","BNIIENS","BNIERR(1)")
 I BNIMOD="E" D
 . D FILE^DIE("K","BNIFDA","BNIERR(1)")
 I $D(BNIERR(1)) D  Q
 . S ^BNITMP($J,BNII)="0^Error Filing Data For File "_BNIFL_$C(30)
 . S ^BNITMP($J,BNII+1)=$C(31)_$G(BNIERR)
 S ^BNITMP($J,BNII)=$S($G(BNIIENS(1)):BNIIENS(1),1:+$G(BNIIENS))_"^Data Filed Successfully For File "_BNIFL_$C(30)
 S ^BNITMP($J,BNII+1)=$C(31)_$G(BNIERR)
 Q
 ;
LOOK(FL,FLD,VAL) ;-- get the file pointed to
 I VAL="" Q ""
 N PTR
 S PTR=$P($G(^DD(FL,FLD,0)),U,3)
 S PTR="^"_PTR_"""B"")"
 Q $O(@PTR@(VAL,0))
 ;
DIK(FL,DAS) ;-- remove an entry from the file
 S LVLS=$L(DAS,",")
 S DFN=$P(DAS,",")
 I LVLS>1 F I=1:1:LVLS D  I DAS="ERR" S OUT="Invalid DAS string" Q  ; MAKE DAS ARRAY.  MIRRORS THE DA() ARRAY
 . I I=LVLS S DAS=$P(DAS,",",I) Q  ; SET DAS OF SUBFILE
 . S %=$P(DAS,",",I) I '% S DAS="ERR" Q
 . S DAS(LVLS-I)=% ; SET DAS(S) OF PARENT FILE(S). LIKE DA(), THE LARGER THE DAS SUBSCRIPT, THE HIGHER THE LEVEL
 . Q
 S %=$$REF^BMXADOF(FL,.DAS)
 S OREF=$P(%,"|",2)
 S FILE=FL
 D DIK^BMXADOF(OREF,.DAS)
 ;
CMT(BNIRET,BNISTR) ;-- save additional comments
 S X="MERR^BNIGU",@^%ZOSF("TRAP") ; m error trap
 N P,BNIREC,BNIFL,BNITXT
 S P="|"
 K ^BNITMP($J)
 S BNIRET="^BNITMP("_$J_")"
 S BNII=0
 S ^BNITMP($J,BNII)="T00007Error^T00080Return String"_$C(30)
 S BNII=BNII+1
 I $G(BNISTR)]"" D
 . S BNIREC=$P(BNISTR,P)
 . S BNIFL=$P(BNISTR,P,2)
 . S BNITXT(1)=$P(BNISTR,P,3)
 I $G(BNISTR)="" D
 . S BPHTXT(1)=""
 . D CATSTR^BNIGU(.BNISTR,.BNISTR)
 . S BNIREC=$P($G(BNISTR),P)
 . S BNIFL=$P(BNISTR,P,2)
 . S BNITXT(1)=$P($G(BNISTR),P,3)
 N BNIIENS,BNIFLD,BNIERR
 S BNIIENS=BNIREC_","
 S BNIFLD=1400
 D WP^DIE(BNIFL,BNIIENS,BNIFLD,,"BNITXT","BNIERR")
 I $D(BNIERR(1)) D  Q
 . S ^BNITMP($J,BNII)="0^Error Saving Additional Comments"_$C(30)
 . S ^BNITMP($J,BNII+1)=$C(31)
 S ^BNITMP($J,BNII)=$G(BNIIENS(1))_U_$C(30)
 S ^BNITMP($J,BNII+1)=$C(31)
 Q
 ;
DELREC(BNIRET,BNISTR) ;-- delete records
 S X="MERR^BNIGU",@^%ZOSF("TRAP") ; m error trap
 N P,I,BNII,R
 S P="|",R="~"
 S BNIRET="^BNITMP("_$J_")"
 K ^BNITMP($J)
 S BNII=0
 S ^BNITMP($J,BNII)="T00001Error"_$C(30)
 F I=1:1 D  Q:$P(BNISTR,R,I)=""
 . Q:$P(BNISTR,R,I)=""
 . S DA=$P(BNISTR,R,I)
 . S DIK="^BNIREC("
 . D ^DIK
 S ^BNITMP($J,BNII+1)=$C(31)
 Q
 ;
GEN(RETVAL,BNISTR) ;-- save general retrieval then queue
 N P,R,A,C
 S P="|",R="~",A="*",C=","
 S RETVAL="^BNITMP("_$J_")"
 I $G(BNISTR)="" D CATSTR^BNIGU(.BNISTR,.BNISTR)
 K ^BNITMP($J)
 N BNII
 S BNII=0
 S ^BNITMP($J,BNII)="T00080Error"_$C(30)
 N BNINM,BNIPERM,BNINOR,BNISP,BNITYP,BNISRT,BNISRTE,BNIFL,BNIDUZ,BNIREC,BNIPRT,BNIPR
 S BNIDUZ=$P(BNISTR,P,13)
 S BNINM=$P($G(^VA(200,BNIDUZ,0)),U)_"-"_$$FMTE^XLFDT($$NOW^XLFDT)
 S BNIPERM=$P(BNISTR,P,2)
 S BNINOR=$P(BNISTR,P,3)
 S BNISP=$P(BNISTR,P,4)
 S BNITYP=$P(BNISTR,P,5)
 S BNISRT=$P(BNISTR,P,7)
 S BNISRTE=$P(BNISTR,P,8)
 S BNIFL=$P(BNISTR,P,12)
 S BNIREC=$P(BNISTR,P,14)
 S BNIPRT=$P(BNISTR,P,15)
 N BNIBG,BNIED,BNICUST
 S BNIBG=$P(BNISTR,P,16)
 S BNIED=$P(BNISTR,P,17)
 S BNICUST=$P(BNISTR,P,18)
 S BNIPR=$P(BNISTR,P,19)
 I $G(BNIPR)]"" D  Q
 . S BNIIEN1=$O(^BNIRTMP("C",BNIPR,0))
 . D BDMG^BNIGVL(BNIBG,BNIED,BNIIEN1,BNICUST)
 . I '$G(BNIIEN) D  Q
 .. S ^BNITMP($J,1)=0_$C(30)
 .. S ^BNITMP($J,2)=$C(31)
 . S ^BNITMP($J,1)=$G(BNIIEN)_$C(30)
 . S ^BNITMP($J,2)=$C(31)
 N BNIFDA,BNIIENS,BNIERR
 S BNIIENS=""
 S BNIFDA(90512.88,"+1,",.01)=BNINM
 S BNIFDA(90512.88,"+1,",.02)=BNIPERM
 S BNIFDA(90512.88,"+1,",.03)=BNINOR
 S BNIFDA(90512.88,"+1,",.04)=BNISP
 S BNIFDA(90512.88,"+1,",.05)=BNITYP
 S BNIFDA(90512.88,"+1,",.06)="R"
 S BNIFDA(90512.88,"+1,",.07)=BNISRT
 S BNIFDA(90512.88,"+1,",.08)=BNISRTE
 S BNIFDA(90512.88,"+1,",.12)=BNIFL
 S BNIFDA(90512.88,"+1,",.13)=BNIDUZ
 D UPDATE^DIE("","BNIFDA","BNIIENS","BNIERR(1)")
 I $G(BNIERR(1)) D  Q
 . S ^BNITMP($J,1)=0_$C(30)
 . S ^BNITMP($J,2)=$C(31)
 S BNIIEN1=$G(BNIIENS(1))
 N BNIJ
 F BNIJ=1:1 D  Q:$P(BNIREC,R,BNIJ)=""
 . Q:$P(BNIREC,R,BNIJ)=""
 . N BNIITM,BNIFITM
 . S BNIITM=$P(BNIREC,R,BNIJ)
 . S BNIFITM=$P(BNIITM,A,1)
 . N BNIFDA,BNIIENS,BNIERR
 . S BNIIENS(1)=BNIIEN1
 . S BNIIENS(2)=BNIFITM
 . S BNIIENS="+2,"_BNIIEN1_","
 . S BNIFDA(90512.89101,BNIIENS,.01)=BNIFITM
 . D UPDATE^DIE("","BNIFDA","BNIIENS","BNIERR(1)")
 . I $G(BNIERR(1)) D  Q
 .. S ^BNITMP($J,1)=0_$C(30)
 .. S ^BNITMP($J,2)=$C(31)
 . S BNIIEN2=$G(BNIIENS(2))
 . N BNIK
 . F BNIK=2:1 D  Q:$P(BNIITM,A,BNIK)=""
 .. Q:$P(BNIITM,A,BNIK)=""
 .. N BNISITM,BNISITM2
 .. S BNISITM=$P(BNIITM,A,BNIK)
 .. I $G(BNISITM)["," S BNISITM2=$P(BNISITM,",",2),BNISITM=$P(BNISITM,",",1)
 .. N BNIFDA,BNIIENS,BNIERR
 .. S BNIIENS(1)=BNIIEN1
 .. S BNIIENS(2)=BNIIEN2
 .. S BNIIENS="+3,"_BNIIEN2_","_BNIIEN1_","
 .. S BNIFDA(90512.8910101,BNIIENS,.01)=BNISITM
 .. S BNIFDA(90512.8910101,BNIIENS,.02)=$G(BNISITM2)
 .. D UPDATE^DIE("","BNIFDA","BNIIENS","BNIERR(1)")
 .. I $G(BNIERR(1)) D  Q
 ... S ^BNITMP($J,1)=0_$C(30)
 ... S ^BNITMP($J,2)=$C(31)
 .. S BNIIENS3=$G(BNIIENS(3))
 N BNIL
 F BNIL=1:1 D  Q:$P(BNIPRT,R,BNIL)=""
 . Q:$P(BNIPRT,R,BNIL)=""
 . N BNIPREC,BNIPITM,BNILNG
 . S BNIPREC=$P(BNIPRT,R,BNIL)
 . S BNIPITM=$P(BNIPREC,A,1)
 . S BNILNG=$P(BNIPREC,A,2)
 . N BNIFDA,BNIIENS,BNIERR
 . S BNIIENS(1)=BNIIEN1
 . S BNIIENS="+2,"_BNIIEN1_","
 . S BNIFDA(90512.89102,BNIIENS,.01)=BNIPITM
 . S BNIFDA(90512.89102,BNIIENS,.02)=BNILNG
 . D UPDATE^DIE("","BNIFDA","BNIIENS","BNIERR(1)")
 . I $G(BNIERR(1)) D  Q
 .. S ^BNITMP($J,1)=0_$C(30)
 .. S ^BNITMP($J,2)=$C(31)
 . S BNIIENP2=$G(BNIIENS(2))
 ;call loris stuff if we get this far
 D BDMG^BNIGVL(BNIBG,BNIED,BNIIEN1,BNICUST)
 I '$G(BNIIEN) D  Q
 . S ^BNITMP($J,1)=0_$C(30)
 . S ^BNITMP($J,2)=$C(31)
 S ^BNITMP($J,1)=$G(BNIIEN)_$C(30)
 S ^BNITMP($J,2)=$C(31)
 Q
 ;