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

BQIPLPM.m

Go to the documentation of this file.
BQIPLPM ;PRXM/HC/ALA-Get Panel Parameters ; 13 Nov 2008  3:07 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;**3,4**;Apr 18, 2012;Build 66
 ;
 Q
 ;
RET(DATA,OWNR,PLIEN) ; EP -- BQI GET PANEL PARAMS
 ;
 ;Description - Retrieves the panel parameters for a specific panel
 ;
 ;Input
 ;  OWNR - Owner of the panel internal entry number
 ;  PLIEN - Panel internal entry number
 ;Output
 ;  DATA  - name of global (passed by reference) in which the data
 ;          is stored
 ;Assumes
 ;  DUZ - User who signed onto iCare
 ;
 NEW UID,II,X
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPLPM",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLPM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T03200PARMS"_$C(30)
 ;
 NEW DA,IENS,EXEC,SOURCE,TYPE,PPIEN,PTYP,N,NN,PARMS,MPARMS,MMAP,MPFL,MPNAME
 S DA(1)=OWNR,DA=PLIEN,IENS=$$IENS^DILF(.DA),EXEC=""
 S SOURCE=$$GET1^DIQ(90505.01,IENS,.11,"E")
 S TYPE=$$GET1^DIQ(90505.01,IENS,.03,"I")
 ;
 I TYPE'="P" G DONE
 ;
 ; Find predefined panel
 I SOURCE="" G DONE
 S PPIEN=$$PP^BQIDCDF(SOURCE) I PPIEN=-1 S BMXSEC="Pre-defined panel type "_SOURCE_" was not found" Q
 ;
 S N=0,PARMS="",MPARMS=""
 F  S N=$O(^BQICARE(OWNR,1,PLIEN,10,N)) Q:'N  D
 . NEW DA,IENS,NAME,VALUE
 . S DA(2)=OWNR,DA(1)=PLIEN,DA=N,IENS=$$IENS^DILF(.DA)
 . S NAME=$$GET1^DIQ(90505.02,IENS,.01,"E")
 . S VALUE=$$GET1^DIQ(90505.02,IENS,.03,"E")
 . I VALUE="" S VALUE=$$GET1^DIQ(90505.02,IENS,.02,"E")
 . S PTYP=$$PTYP^BQIDCDF(SOURCE,NAME)
 . S MPFL=$$MPF^BQIDCDF(SOURCE,NAME)
 . I MPFL D  Q
 .. S MPNAME=$$MPN^BQIDCDF(SOURCE,NAME)
 .. I $G(VALUE)'="" D MLMP Q
 .. ;
 .. S NN=0
 .. F  S NN=$O(^BQICARE(OWNR,1,PLIEN,10,N,1,NN)) Q:'NN  D
 ... NEW DA,IENS
 ... S DA(3)=OWNR,DA(2)=PLIEN,DA(1)=N,DA=NN,IENS=$$IENS^DILF(.DA)
 ... S VALUE=$$GET1^DIQ(90505.21,IENS,.02,"E")
 ... I VALUE="" S VALUE=$$GET1^DIQ(90505.21,IENS,.01,"E")
 ... I PTYP="D" S VALUE=$$FMTE^BQIUL1(VALUE)
 ... D MLMP
 . I 'MPFL S MPARMS=NAME_"="
 . ;
 . ;S MPARMS=NAME_"="
 . I PTYP="D" S VALUE=$$FMTE^BQIUL1(VALUE)
 . I '$D(^BQICARE(OWNR,1,PLIEN,10,N,1)) S MPARMS=MPARMS_VALUE
 . I $D(^BQICARE(OWNR,1,PLIEN,10,N,1)) D
 .. S NN=0
 .. F  S NN=$O(^BQICARE(OWNR,1,PLIEN,10,N,1,NN)) Q:'NN  D
 ... NEW DA,IENS
 ... S DA(3)=OWNR,DA(2)=PLIEN,DA(1)=N,DA=NN,IENS=$$IENS^DILF(.DA)
 ... S VALUE=$$GET1^DIQ(90505.21,IENS,.02,"E")
 ... I VALUE="" S VALUE=$$GET1^DIQ(90505.21,IENS,.01,"E")
 ... I PTYP="D" S VALUE=$$FMTE^BQIUL1(VALUE)
 ... S MPARMS=MPARMS_VALUE_$C(29)
 .. S MPARMS=$$TKO^BQIUL1(MPARMS,$C(29))
 . S PARMS=PARMS_MPARMS_$C(28)
 ; Check on mapping values
 I $D(MMAP)>0 D
 . S PNAME=""
 . F  S PNAME=$O(MMAP(PNAME)) Q:PNAME=""  D
 .. S PRIEN=$O(^BQI(90506,PPIEN,3,"B",PNAME,"")) I PRIEN="" Q
 .. S VALUE=MMAP(PNAME)
 .. S VLIEN=$O(^BQI(90506,PPIEN,3,PRIEN,3,"AC",VALUE,"")) I VLIEN="" Q
 .. S PARMS=PARMS_PNAME_"="_$P(^BQI(90506,PPIEN,3,PRIEN,3,VLIEN,0),U,1)_$C(28)
 S II=II+1
 S PARMS=$$TKO^BQIUL1(PARMS,$C(28))
 S @DATA@(II)=PARMS_$C(30)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
MLMP ; Map the values
 I '$D(MMAP(MPNAME)) S MMAP(MPNAME)=NAME_"="_VALUE Q
 ;S $P(MMAP(MPNAME),"~",2)=NAME_"="_VALUE
 S MMAP(MPNAME)=MMAP(MPNAME)_"~"_NAME_"="_VALUE
 D CKMP(MPNAME)
 I $A($E(PARMS,$L(PARMS),$L(PARMS)))'=28 S PARMS=PARMS_$C(28)
 Q
 ;
CKMP(PNAME) ;EP - Check mapping
 S PRIEN=$O(^BQI(90506,PPIEN,3,"B",PNAME,"")) I PRIEN="" Q
 S VALUE=MMAP(PNAME)
 S VLIEN=$O(^BQI(90506,PPIEN,3,PRIEN,3,"AC",VALUE,"")) I VLIEN="" Q
 I PARMS[VALUE Q
 I PARMS[PNAME D  Q
 . S PARMS=$$TKO^BQIUL1(PARMS,$C(28))
 . S PARMS=PARMS_$C(29)_$P(^BQI(90506,PPIEN,3,PRIEN,3,VLIEN,0),U,1)
 . K MMAP(PNAME)
 S PARMS=PARMS_PNAME_"="_$P(^BQI(90506,PPIEN,3,PRIEN,3,VLIEN,0),U,1)
 K MMAP(PNAME)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
UPD(DATA,OWNR,PLIEN,PARMS) ; EP -- BQI SET PANEL PARAMS
 ;
 ;Description
 ;  Update or set the panel parameters
 ;Input
 ;  OWNR - Owner of panel IEN
 ;  PLIEN - Panel internal entry number
 ;  PARMS - Parameters (if NULL, deletes ALL)
 ;         if PARMS contain a $C(29), then that is
 ;         a multiple value parameter
 ;
 NEW UID,II,BN,RESULT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPLPM",UID))
 K @DATA
 ;
 ; Check if share and has write access
 I '$$CKSHR^BQIPLSH(OWNR,PLIEN) S BMXSEC="You do not have write access" Q
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLPM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S PARMS=$G(PARMS,"")
 S @DATA@(II)="I00010RESULT"_$C(30)
 S RESULT=1 ; Initialize value
 ;
 D DEL(.OWNR,.PLIEN)
 ;
 NEW DA,IENS,EXEC,SOURCE,TYPE,PPIEN,PTYP,BQ,BQIUPD,BQVAL,BI,NVAL
 NEW PDATA,MVAL,PDA,QFL,BQII,ERROR,PQ,BN,LIST
 S DA(1)=OWNR,DA=PLIEN,IENS=$$IENS^DILF(.DA),EXEC=""
 S SOURCE=$$GET1^DIQ(90505.01,IENS,.11,"E")
 S TYPE=$$GET1^DIQ(90505.01,IENS,.03,"I")
 ;
 I SOURCE="" D  G DONE
 . D DSC
 . S II=II+1,@DATA@(II)="1"_$C(30)
 ;
 I TYPE'="P" D  G DONE
 . D DSC
 . S II=II+1,@DATA@(II)="1"_$C(30)
 ;
 ; Find predefined panel
 S PPIEN=$$PP^BQIDCDF(SOURCE) I PPIEN=-1 S BMXSEC="Pre-defined panel type "_SOURCE_" was not found" Q
 ;
 S PARMS=$G(PARMS,"")
 I PARMS="" D
 . S LIST="",BN=""
 . F  S BN=$O(PARMS(BN)) Q:BN=""  S LIST=LIST_PARMS(BN)
 . K PARMS
 . S PARMS=LIST
 . K LIST
 ;
 S QFL=0
 F BQ=1:1:$L(PARMS,$C(28)) D  G DONE:QFL
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1),VALUE=$P(PDATA,"=",2,99)
 . S PTYP=$$PTYP^BQIDCDF(SOURCE,NAME)
 . I PTYP="C" S PQ=0 D  Q:PQ
 .. NEW PRIEN,VLIEN,VDATA,BJ,CPARM,CNAME,CVAL
 .. S PRIEN=$O(^BQI(90506,PPIEN,3,"B",NAME,"")) I PRIEN="" Q
 .. I VALUE[$C(29) D
 ... F BI=1:1:$L(VALUE,$C(29)) S BQVAL=$P(VALUE,$C(29),BI) D PARS(BQVAL)
 .. I VALUE'[$C(29) D PARS(VALUE)
 .. S II=II+1,@DATA@(II)=RESULT_$C(30),PQ=1
 . ;
 . ; Create a new parameter record
 . S (DA,PDA)=$$ANP(OWNR,PLIEN,NAME)
 . I DA=-1 S II=II+1,@DATA@(II)="-1"_$C(30),QFL=1 Q
 . ;
 . ; Update the parameter with the values
 . S RESULT=$$UPP(OWNR,PLIEN,PDA,VALUE,PTYP)
 . I RESULT=-1 S II=II+1,@DATA@(II)="-1"_$C(30),QFL=1 Q
 ;
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 ;
DSC ; Generate special panel description
 NEW DA,IENS
 S DA(1)=OWNR,DA=PLIEN,IENS=$$IENS^DILF(.DA)
 K DESC
 D DESC^BQIPDSCM(OWNR,PLIEN,.DESC)
 ;D PEN^BQIPLDSC(OWNR,PLIEN,.DESC)
 D WP^DIE(90505.01,IENS,5,"","DESC")
 K DESC
 Q
 ;
DEL(OWNR,PLIEN) ;EP - Remove the previous parameters
 NEW DA,IENS,DIK
 S DA(2)=OWNR,DA(1)=PLIEN,DA=0
 S DIK="^BQICARE("_DA(2)_",1,"_DA(1)_",10,"
 F  S DA=$O(^BQICARE(OWNR,1,PLIEN,10,DA)) Q:'DA  D ^DIK
 Q
 ;
ANP(OWNR,PLIEN,NAME) ; EP - Add new parameter
 NEW DA,IENS,DIC,DLAYGO
 S DA(2)=OWNR,DA(1)=PLIEN,X=NAME
 S DLAYGO=90505.02,DIC(0)="L",DIC("P")=DLAYGO
 S DIC="^BQICARE("_DA(2)_",1,"_DA(1)_",10,"
 I '$D(^BQICARE(DA(2),1,DA(1),10,0)) S ^BQICARE(DA(2),1,DA(1),10,0)="^90505.02^^"
 K DO,DD D FILE^DICN
 Q +Y
 ;
UPP(OWNR,PLIEN,PDA,VALUE,PTYP) ;EP - Update values for a parameter
 NEW DA,IENS,RESULT
 S RESULT=1
 S DA(2)=OWNR,DA(1)=PLIEN,DA=PDA
 S IENS=$$IENS^DILF(.DA)
 I VALUE'[$C(29) D
 . I PTYP="D" S VALUE=$$DATE^BQIUL1(VALUE)
 . I PTYP="T" S BQIUPD(90505.02,IENS,.03)=VALUE
 . I PTYP'="T" S BQIUPD(90505.02,IENS,.02)=VALUE
 . D FILE^DIE("","BQIUPD","ERROR")
 . K BQIUPD
 . I $D(ERROR) S RESULT=-1
 ;
 I VALUE[$C(29) D
 . I '$D(^BQICARE(DA(2),1,DA(1),10,DA,1,0)) S ^BQICARE(DA(2),1,DA(1),10,DA,1,0)="^90505.21^^"
 . F BQII=1:1:$L(VALUE,$C(29)) D
 .. S MVAL=$P(VALUE,$C(29),BQII)
 .. NEW DA,IENS
 .. S DA(3)=OWNR,DA(2)=PLIEN,DA(1)=PDA,X=MVAL
 .. S DLAYGO=90505.21,DIC(0)="L",DIC("P")=DLAYGO
 .. S DIC="^BQICARE("_DA(3)_",1,"_DA(2)_",10,"_DA(1)_",1,"
 .. K DO,DD D FILE^DICN
 .. I +Y=-1 S RESULT=-1
 .. I PTYP="D" S MVAL=$$DATE^BQIUL1(MVAL)
 .. S DA=+Y,IENS=$$IENS^DILF(.DA)
 .. I PTYP="T" S BQIUPD(90505.21,IENS,.02)=MVAL
 .. I PTYP'="T" S BQIUPD(90505.21,IENS,.01)=MVAL
 .. D FILE^DIE("","BQIUPD","ERROR")
 .. K BQIUPD
 .. I $D(ERROR) S RESULT=-1
 Q RESULT
 ;
PARS(NVAL) ;EP
 N PRDATA,PRMN
 S VLIEN=$O(^BQI(90506,PPIEN,3,PRIEN,3,"B",NVAL,"")) I VLIEN="" Q
 S VDATA=$P(^BQI(90506,PPIEN,3,PRIEN,3,VLIEN,0),U,2)
 S PVAL="",PRMN=$L(VDATA,"~")
 F BJ=1:1 S CPARM=$P(VDATA,"~",BJ) Q:CPARM=""  D
 . S CNAME=$P(CPARM,"=",1),CVAL=$P(CPARM,"=",2)
 . S PRDATA=$P(VDATA,"~",BJ+1)
 . I $P(PRDATA,"=",1)'=CNAME,PVAL="" D  Q
 .. S (DA,PDA)=$$ANP(OWNR,PLIEN,CNAME)
 .. I DA=-1 S II=II+1,@DATA@(II)="-1"_$C(30) Q
 .. S RESULT=$$UPP(OWNR,PLIEN,PDA,CVAL,PTYP)
 .. I RESULT=-1 S II=II+1,@DATA@(II)=RESULT_$C(30) Q
 . S PVAL=PVAL_CVAL_$C(29)
 I PVAL'="" D
 . S (DA,PDA)=$$ANP(OWNR,PLIEN,CNAME)
 . I DA=-1 S II=II+1,@DATA@(II)="-1"_$C(30) Q
 . S CVAL=$$TKO^BQIUL1(PVAL,$C(29))
 . S RESULT=$$UPP(OWNR,PLIEN,PDA,CVAL,PTYP)
 . I RESULT=-1 S II=II+1,@DATA@(II)=RESULT_$C(30) Q
 Q
 ;
CRMP ;
 S (DA,PDA)=$$ANP(OWNR,PLIEN,CNAME)
 I DA=-1 S II=II+1,@DATA@(II)="-1"_$C(30),QFL=1 Q
 S CVAL=$$TKO^BQIUL1(PVAL,$C(29))
 S RESULT=$$UPP(OWNR,PLIEN,PDA,CVAL,PTYP)
 I RESULT=-1 S II=II+1,@DATA@(II)=RESULT_$C(30),QFL=1 Q
 Q