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

BPCPRBC.m

Go to the documentation of this file.
BPCPRBC ; IHS/OIT/MJL - ADD,DELETE, OR EDIT PROBLEM ;
 ;;1.5;BPC;;MAY 26, 2005
PRBEDIT(RESULT,BPCFLAG,BPCPARAM) ;EP CALL FROM REMOTE PROC: BPC EDITPROBLEM
EN ;
 S U="^",XWBWRAP=1 K RESULT
 I BPCFLAG="" S RESULT(1)=-1,RESULT(2)="NO EDIT FLAG RECEIVED!" D KILL Q
 I BPCPARAM="" S RESULT(1)=-1,RESULT(2)="NO PARAMETERS RECEIVED!" D KILL Q
 I $L(BPCPARAM,";")'=8 S RESULT(1)=-1,RESULT(2)="WRONG NUMBER OF DATA ITEMS SENT ("_$L(BPCPARAM,";")_"). 8 ITEMS EXPECTED!" D KILL Q
 I "AED"'[BPCFLAG  S RESULT(1)=-1,RESULT(2)="PROPER EDIT FLAG NOT SENT!" D KILL Q
 D:BPCFLAG="A" ADD D:BPCFLAG="E" EDIT D:BPCFLAG="D" DELETE D KILL
 Q
KILL ;
 K BPCDIEN,BPCNARR,BPCLOCN,BPCONSET,BPCCLS,BPCSTAT,BPCPIEN,BPCNIEN,BPCLOCN,BPCERR,BPCLIEN,BPCCTR,BPCDX,BPCX,BPCDENT,BPCDMOD,BPCPRBID,BPCPRIEN,BPCNARCK
 K BPCFLG
 Q
ADD ;
 S BPCDIEN=$P(BPCPARAM,";",1),BPCNARR=$P(BPCPARAM,";",2),BPCLOCN=$P(BPCPARAM,";",3),BPCONSET=$P(BPCPARAM,";",4),BPCCLS=$P(BPCPARAM,";",5),BPCSTAT=$P(BPCPARAM,";",6),BPCPIEN=$P(BPCPARAM,";",7)
 I '$D(^DPT(BPCPIEN,0)) S RESULT(1)=-1,RESULT(2)="PATIENT IEN NOT DEFINED!" Q
 I '$D(^ICD9(BPCDIEN,0)) S RESULT(1)=-1,RESULT(2)="DIAGNOSIS IEN NOT DEFINED!" Q
 S (BPCDMOD,BPCDENT)=DT,BPCLIEN=$O(^DIC(4,"B",BPCLOCN,""))
 I BPCONSET'="" S X=BPCONSET D ^%DT S BPCONSET=$S(Y'=-1:$P(Y,".",1),1:"")
 I BPCLIEN="" S RESULT(1)=-1,RESULT(2)="UNKNOWN LOCATION SENT!" Q
 S BPCNARCK=$E(BPCNARR,1,30)
 S BPCFLG=0
 I $D(^AUTNPOV("B",BPCNARCK)) D
 .S S1="" F  S S1=$O(^AUTNPOV("B",BPCNARCK,S1)) Q:S1=""  D  Q:BPCFLG
 ..S BPCNFLD=$P(^AUTNPOV(S1,0),U,1)
 ..I BPCNFLD=BPCNARR S BPCFLG=1,BPCNIEN=S1
 I '$D(^AUTNPOV("B",BPCNARCK))!('BPCFLG) S BPCERR=0 D SETNAR I BPCERR S RESULT(1)=-1,RESULT(2)="UNABLE TO ADD PROBLEM NARRATIVE!" Q
 S BPCCTR=0,BPCC="" F  S BPCC=$O(^AUPNPROB("AA",BPCPIEN,BPCLIEN,BPCC)) Q:BPCC=""  S BPCCTR=+($E(BPCC,2,999))
 S BPCCTR=BPCCTR+1,BPCERR=0 D ADDPROB I BPCERR S RESULT(1)=-1,RESULT(2)="UNABLE TO ADD PROBLEM!" Q
 D SETRES
 Q
SETRES ;
 S BPCLOCC=$P(^AUTTLOC(BPCLIEN,0),U,7)
 S BPCLOCC=$S(BPCLOCC="":"UK",1:BPCLOCC)
 S BPCPRBID=BPCLOCC_BPCCTR,BPCDX=$P(^ICD9(BPCDIEN,0),U,1)
 S RESULT(1)=1,RESULT(2)="PROB"_U_$G(BPCPRBID)_U_$G(BPCDX)_U_$G(BPCSTAT)_U_$G(BPCONSET)_U_$G(BPCNARR)_U_$G(BPCPRB)_U_$G(BPCDENT)_U_$G(BPCDMOD)
 Q
EDPROB ;
 L +^AUPNPROB(0):10 I '$T S BPCERR=1 Q
 K BPCFDA,BPCEMSG S BPCFDR="BPCFDA(1)",BPCPRIEN=BPCPRIEN_","
 S BPCFDA(1,9000011,BPCPRIEN,.01)=BPCDIEN
 S BPCFDA(1,9000011,BPCPRIEN,.03)=BPCDMOD
 S BPCFDA(1,9000011,BPCPRIEN,.04)=BPCCLS
 S BPCFDA(1,9000011,BPCPRIEN,.05)=BPCNIEN
 ;S BPCFDA(1,9000011,BPCPRIEN,.06)=BPCLIEN
 ;S BPCFDA(1,9000011,BPCPRIEN,.07)=BPCCTR
 S BPCFDA(1,9000011,BPCPRIEN,.12)=BPCSTAT
 S BPCFDA(1,9000011,BPCPRIEN,.13)=BPCONSET
 D FILE^DIE("",BPCFDR,"BPCEMSG")
 I $D(BPCEMSG("DIERR")) S BPCERR=1
 S BPCPRB=$P(BPCPRIEN,",",1)
 L -^AUPNPROB(0)
 Q
ADDPROB ;
 L +^AUPNPROB(0):10 I '$T S BPCERR=1 Q
 K BPCFDA,BPCEMSG S BPCFDR="BPCFDA(1)"
 S BPCFDA(1,9000011,"+1,",.01)=BPCDIEN
 S BPCFDA(1,9000011,"+1,",.02)=BPCPIEN
 S BPCFDA(1,9000011,"+1,",.03)=BPCDMOD
 S BPCFDA(1,9000011,"+1,",.04)=BPCCLS
 S BPCFDA(1,9000011,"+1,",.05)=BPCNIEN
 S BPCFDA(1,9000011,"+1,",.06)=BPCLIEN
 S BPCFDA(1,9000011,"+1,",.07)=BPCCTR
 S BPCFDA(1,9000011,"+1,",.08)=BPCDENT
 S BPCFDA(1,9000011,"+1,",.12)=BPCSTAT
 S BPCFDA(1,9000011,"+1,",.13)=BPCONSET
 D UPDATE^DIE("",BPCFDR,"","BPCEMSG")
 I $D(BPCEMSG("DIERR")) S BPCERR=1
 I 'BPCERR S BPCPRB=$P(^AUPNPROB(0),U,3)
 L -^AUPNPROB(0)
 Q
SETNAR ;
 K BPCFDA,BPCEMSG
 L +^AUTNPOV(0):10 I '$T S BPCERR=1 Q
 S BPCFDR="BPCFDA(1)"
 S BPCFDA(1,9999999.27,"+1,",.01)=BPCNARR D UPDATE^DIE("",BPCFDR,"","BPCEMSG")
 I $D(BPCEMSG("DIERR")) S BPCERR=1
 L -^AUTNPOV(0)
 I 'BPCERR S BPCNIEN=$P(^AUTNPOV(0),U,3)
 Q
EDIT ;
 S BPCDIEN=$P(BPCPARAM,";",1),BPCNARR=$P(BPCPARAM,";",2),BPCLOCN=$P(BPCPARAM,";",3),BPCONSET=$P(BPCPARAM,";",4),BPCCLS=$P(BPCPARAM,";",5),BPCSTAT=$P(BPCPARAM,";",6),BPCPIEN=$P(BPCPARAM,";",7),BPCPRIEN=$P(BPCPARAM,";",8)
 I '$D(^DPT(BPCPIEN,0)) S RESULT(1)=-1,RESULT(2)="PATIENT IEN NOT DEFINED!" Q
 I '$D(^ICD9(BPCDIEN,0)) S RESULT(1)=-1,RESULT(2)="DIAGNOSIS IEN NOT DEFINED!" Q
 S BPCDMOD=DT
 I BPCONSET'="" S X=BPCONSET D ^%DT S BPCONSET=$S(Y'=-1:$P(Y,".",1),1:"")
 S BPCLIEN=$O(^DIC(4,"B",BPCLOCN,""))
 I BPCPRIEN="" S RESULT(1)=-1,RESULT(2)="NO PROBLEM IEN PRESENT!" Q
 I '$D(^AUPNPROB(BPCPRIEN)) S RESULT(1)=-1,RESULT(2)="PROBLEM IEN DOES NOT MATCH A PROBLEM! IEN= "_BPCPRIEN Q
 S BPCCTR=$P(^AUPNPROB(BPCPRIEN,0),U,7)
 S BPCNARCK=$E(BPCNARR,1,30)
 S BPCFLG=0
 I $D(^AUTNPOV("B",BPCNARCK)) D
 .S S1="" F  S S1=$O(^AUTNPOV("B",BPCNARCK,S1)) Q:S1=""  D  Q:BPCFLG
 ..S BPCNFLD=$P(^AUTNPOV(S1,0),U,1)
 ..I BPCNFLD=BPCNARR S BPCFLG=1,BPCNIEN=S1
 I '$D(^AUTNPOV("B",BPCNARCK))!('BPCFLG) S BPCERR=0 D SETNAR I BPCERR S RESULT(1)=-1,RESULT(2)="UNABLE TO ADD PROBLEM NARRATIVE!" Q
 S BPCERR=0 D EDPROB I BPCERR S RESULT(1)=-1,RESULT(2)="UNABLE TO EDIT PROBLEM!" Q
 D SETRES
 Q
DELETE ;
 S BPCPRIEN=$P(BPCPARAM,";",8)
 I +BPCPRIEN=0 S RESULT(1)=-1,RESULT(2)="NO PROBLEM IEN!" Q
 I '$D(^AUPNPROB(BPCPRIEN,0)) S RESULT(1)=-1,RESULT(2)="PROBLEM DOES NOT EXIST!" Q
 S DIK="^AUPNPROB(",DA=BPCPRIEN D ^DIK
 S RESULT(1)=1,RESULT(2)="PROBLEM DELETED!"
 K DIK,DA
 Q