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

BPCPROB.m

Go to the documentation of this file.
BPCPROB ; IHS/OIT/MJL - GUI COLLECTS PROBLEM LIST DATA ;
 ;;1.5;BPC;;MAY 26, 2005
 ;
EN(RESULT,BPCIEN,BPCSDATE,BPCEDATE) ;EP CALL FROM REMOTE PROC: BPC GETPROBLEMS
 S U="^",XWBWRAP=1,BPCCTR=0,BPCSUB=$J,BPCIEN=$G(BPCIEN),BPCSDATE=$G(BPCSDATE),BPCEDATE=$G(BPCEDATE) K ^BGUTMP(BPCSUB),RESULT
 I BPCIEN="" S RESULT(1)="-1",RESULT(2)="NO PATIENT IEN DEFINED!" D KILL Q
 I BPCSDATE="" S RESULT(1)="-1",RESULT(2)="NO STARTING DATE DEFINED!" D KILL Q
 I BPCEDATE="" S RESULT(1)="-1",RESULT(2)="NO ENDING DATE DEFINED!" D KILL Q
 D DT^DILF("",BPCSDATE,.BPCSDAT)
 I BPCSDAT=-1 D
 .S BPCSDATE="1/1/1980"
 .D DT^DILF("",BPCSDATE,.BPCSDAT)
 D DT^DILF("",BPCEDATE,.BPCEDAT)
 I BPCEDAT=-1 D
 .S BPCEDATE="T"
 .D DT^DILF("",BPCEDATE,.BPCEDAT)
 S BPCPRB="" F  S BPCPRB=$O(^AUPNPROB("AC",BPCIEN,BPCPRB)) Q:BPCPRB=""  D PRB
 D SETRES,KILL
 Q
KILL ;
 K BPCCTR,BPCSUB,BPCPRB,BPCIEN,BPCCTR,BPCX,BPCDXP,BPCLOCP,BPCSTAT,BPCOSET,BPCNARP,BPCNBR,BPCDX,BPCPRBID,BPCNAR,BPCDTMOD,BPCDTENT,BPCCLS,BPCLOCC,BPCLOCN
 Q
PRB ;
 S BPCCTR=BPCCTR+1
 S BPCX=^AUPNPROB(BPCPRB,0)
 Q:$P($G(BPCX),U,3)<BPCSDATE
 S BPCDXP=$P(BPCX,U,1),B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