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

AGDICLK.m

Go to the documentation of this file.
AGDICLK ; IHS/ASDS/EFG - DICTIONARY ENTRY LOOK-UP UTILITY ;  
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 ;
L1 ;
 K AGPCC,AG("LKPRINT"),AG("LKDATA"),AG("LKERR"),AGL,AG("AGDENT"),AGNEW
 G END:'$D(DR)!'$D(DIC)!'$D(DA)
 S AGLK("I")=1
 S DIC(1)=DIC
 S DR(1)=DR
 G END:+DR<.01!(+DIC<1)!(+DA<1)
 I $D(^DD(DIC,DR,0)) S G=^DD(DIC,DR,0) G COMP:$P(G,"^",2)["C" I +$P(G,"^",2)>0 S AG("LKERR")=5 G END
L2 ;
 I '$D(^DD(DIC(AGLK("I")),DR(AGLK("I")),0)) D  G END
 . S AG("LKERR")=3
 S AGSUB=$P(^DD(DIC(AGLK("I")),DR(AGLK("I")),0),"^",4)
 S AGPC(AGLK("I"))=$P(AGSUB,";",2)
 S AGSUB(AGLK("I"))=$P(AGSUB,";",1)
 I '$D(^DD(DIC(AGLK("I")),0,"UP")) G L4
L3 ;
 S AG("LKERR")=4
 S:$D(AG("DRENT1")) AG("DRENT")=0
 G END:'$D(AG("DRENT"))
 G END:AG("DRENT")'="0"&(+AG("DRENT")<0)
 G END:AG("DRENT")\1'=AG("DRENT")
 S:AG("DRENT")=0 AGNEW=""
 K AG("LKERR")
 S AGLK("I")=AGLK("I")+1
 S DIC(AGLK("I"))=^DD(DIC(AGLK("I")-1),0,"UP")
 S DR(AGLK("I"))=0
 S DR(AGLK("I"))=$O(^DD(DIC(AGLK("I")),"SB",DIC(AGLK("I")-1),DR(AGLK("I"))))
 G L2
L4 ;
 S AGL=^DIC(DIC(AGLK("I")),0,"GL")_DA
 S AGL(1)=AGL_",0)"
 I '$D(@AGL(1)) D  G END
 . S AG("LKERR")=1
 I AGLK("I")=1 D  G L5
 . K AG("DRENT")
 F AGLK("J")=AGLK("I"):-1:2 D
 . S AGL=AGL_","_AGSUB(AGLK("J"))
 . S:AGLK("J")>2 AGL=AGL_",1"
L5 ;
 S AGPCC=AGPC(1) I '$D(AG("DRENT")) S AG("DRENT")="" G L6
L5A ;
 S AGL(0)=AGL_",0)" I '$D(@AGL(0)) S AG("LKERR")=6,AGL=AGL_",1,0)" G END
L5B ;
 S AGDENT=$P(@AGL(0),"^",4) S:AGDENT="" AGDENT=0 I AGDENT=0!(AG("DRENT")>AGDENT) S AG("LKERR")=2 G END
L5BB ;
 I $D(AG("DRENT1")) D DNT4 G L5E:AGDNT'="" S AG("LKERR")=2 G END
L5C ;
 I AG("DRENT")>0 D DNT2 S AG("DRENT")=AGDNT G L5E:AGDNTT>0 S AG("LKERR")=2 G END
L5D ;
 S AGL(0)=AGL_",0)" D DNT
L5E ;
 S AG("DRENT")=","_AG("DRENT")
L6 ;
 S AGL=AGL_AG("DRENT")_","_AGSUB(1)_")" I AGL[",," S AG("LKERR")=2,AGNEW="" G END
 I '$D(@AGL) S AG("LKERR")=2,AGNEW="" G END
L6A ;
 S (AG("LKPRINT"),AG("LKDATA"))=$P(@AGL,"^",AGPC(1)) G END:AG("LKPRINT")=""
L7 ;
 S AGG=$P(G,"^",2),AGLK("H")=$P(G,"^",3) G SET:AGG["S",DATE:AGG["D",PTR:AGG["P",TRX:$D(^DD(DIC(1),DR(1),2))
END ;
 K AG("DRENT"),AG("DRENT1"),D0
 K AGDNT,AGDNTT,AGLK,AGLKH,AGG,AGGG,AGLL,AGSUB,AGPC
 S:'$D(AG("LKPRINT"))&'$D(AG("LKERR")) AG("LKERR")=0
 Q
DNT ;
 S AGDNT=0
DNT1 ;
 S AGLL=AGL_",AGDNT)",AGDNT=$O(@AGLL) Q:AGDNT'=+AGDNT  S AG("DRENT")=AGDNT G DNT1
DNT2 ;
 S (AGDNT,AGDNTT)=0
DNT3 ;
 S AGLL=AGL_",AGDNT)",AGDNT=$O(@AGLL) Q:AGDNT=""  S AGDNTT=AGDNTT+1 Q:AGDNTT=AG("DRENT")  G DNT3
DNT4 ;
 S AGDNT=0
DNT5 ;
 S AGLL=AGL_",AGDNT)",AGDNT=$O(@AGLL) Q:AGDNT=""  S:AGDNT=AG("DRENT1") AG("DRENT")=AGDNT Q:AG("DRENT")=AGDNT  G DNT5
SET ;
 F AGLK("I")=1:1 S AGGG=$P(AGLK("H"),";",AGLK("I")) G END:AGGG="" S:$P(AGGG,":",1)=AG("LKDATA") AG("LKPRINT")=$P(AGGG,":",2)
 G END
DATE ;
 S Y=AG("LKDATA")
 D DD^%DT
 S AG("LKPRINT")=Y
 G END
PTR ;
 S AGGG="^"_AGLK("H")_AG("LKDATA")_",0)" I '$D(@AGGG) S AG("LKERR")=7 G END
 S AG("LKPRINT")=$P(@AGGG,"^",1) G END
COMP ;
 S AGLKH=$E($P(G,";",2),3,999),D0=DA X AGLKH S AG("LKPRINT")=X G END
TRX ;
 S Y=AG("LKDATA") X ^DD(DIC(1),DR(1),2) S AG("LKPRINT")=Y G END