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

BQIPTUPD.m

Go to the documentation of this file.
BQIPTUPD ;VNGT/HS/ALA-Update Patient Data ; 01 Dec 2008  12:22 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 ;
UPD(DATA,DFN,PARMS) ; EP - BQI UPDATE PATIENT
 NEW UID,II,BN,LIST,PDATA,NAME,VALUE,VFIEN,FILE,PTYP,CHIEN,FIELD,EXEC
 NEW BQIDATA,ERROR,RESULT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTUPD",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTFHS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T001024ERROR"_$C(30)
 ;
 S VFIEN=$O(^BQI(90506.3,"B","Patient Edit",""))
 I VFIEN="" S BMXSEC="RPC Call Failed: Patient Edit Definition does not exist." Q
 S FILE=$P(^BQI(90506.3,VFIEN,0),U,2)
 ;
 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
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1),VALUE=$P(PDATA,"=",2,99)
 . I VALUE="" S VALUE="@"
 . ;I VALUE="" Q
 . S PFIEN=$O(^BQI(90506.3,VFIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S PTYP=$P($G(^BQI(90506.3,VFIEN,10,PFIEN,1)),U,1)
 . I PTYP="D" S VALUE=$$DATE^BQIUL1(VALUE)
 . ;I PTYP="T" S VALUE=VALUE
 . I PTYP="C" D
 .. S CHIEN=$O(^BQI(90506.3,VFIEN,10,PFIEN,5,"B",VALUE,"")) I CHIEN="" Q
 .. S VALUE=$P(^BQI(90506.3,VFIEN,10,PFIEN,5,CHIEN,0),U,2)
 . S @NAME=VALUE
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1)
 . S PFIEN=$O(^BQI(90506.3,VFIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S FIELD=$P($G(^BQI(90506.3,VFIEN,10,PFIEN,3)),U,1)
 . S EXEC=$G(^BQI(90506.3,VFIEN,10,PFIEN,7))
 . I EXEC'="" X EXEC Q
 . I FIELD="" Q
 . S BQIDATA(FILE,DFN_",",FIELD)=@NAME
 ;
 S RESULT=1_U
 I $D(ERROR)>0 S RESULT=-1_U
 K ERROR
 I $D(BQIDATA)>0 D FILE^DIE("","BQIDATA","ERROR")
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 I $P(RESULT,U,1)'=-1 S RESULT=1_U
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ETHN(AGDFN,AGETH,AGMETH) ;EP - Update Ethnicity
 NEW OK,ERROR
 ; First delete the entry
 S OK=$$DETH^AGAPIPAT(AGDFN,"",.ERROR)
 ;I OK="ENTRY NOT FOUND" S OK=0
 I AGETH="@" S RESULT=1_U Q
 S AGMETH=$P(^DIC(10.3,AGMETH,0),U,1)
 S AGETH=$P(^DIC(10.2,AGETH,0),U,1)
 ; If no errors, OK=0, then add the new ethnicity
 S OK=$$AETH^AGAPIPAT(AGDFN,AGETH,AGMETH,.ERROR)
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1)) Q
 S RESULT=1_U
 Q
 ;
SRACE(AGDFN,AGRACE,AGRMET) ;EP - Update Race
 NEW OK,ERROR,BQIRDA,RACE,MET
 I $G(AGRMET)="" S MET="UNKNOWN"
 ; First delete the entry
 S BQIRDA=0
 F  S BQIRDA=$O(^DPT(AGDFN,.02,BQIRDA)) Q:'BQIRDA  D DRACE^AGAPIPAT(AGDFN,BQIRDA,.ERROR)
 ;
 I AGRACE="@" S RESULT=1_U Q
 S RACE=$P(^DIC(10,AGRACE,0),U,1)
 ;S MET=$P(^DIC(10.3,AGRMET,0),U,1)
 D ARACE^AGAPIPAT(AGDFN,RACE,MET,.ERROR)
 ;
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 S RESULT=1_U
 Q
 ;
PFLG(AGDFN,AGLNG) ;EP - Update preferred language
 NEW ERROR,RESULT,OK
 I '$$PATCH^XPDUTL("AG*7.1*9") Q -1_U_"Patch AG*7.1*9 has not been installed"
 S OK=$$PREF^AGAPIPAT(AGDFN,AGLNG)
 I 'OK S RESULT=-1_U_$P(OK,U,2) Q
 S RESULT=1_U
 Q
 ;
PMETH(AGDFN,AGMETH) ;EP - Update preferred method
 NEW ERROR,RESULT,OK
 I '$$PATCH^XPDUTL("AG*7.1*9") Q -1_U_"Patch AG*7.1*9 has not been installed"
 S OK=$$PMETH^AGAPIPAT(AGDFN,AGMETH)
 I 'OK S RESULT=-1_U_$P(OK,U,2) Q
 S RESULT=1_U
 Q
 ;
EMAIL(AGDFN,AGEMAIL,AGUPDATE) ;EP - Update email address
 NEW ERROR,RESULT,OK
 S AGUPDATE=+$G(AGUPDATE)
 I '$$PATCH^XPDUTL("AG*7.1*9") Q -1_U_"Patch AG*7.1*9 has not been installed"
 S OK=$$EMAIL^AGAPIPAT(AGDFN,AGEMAIL,AGUPDATE)
 I 'OK S RESULT=-1_U_$P(OK,U,2) Q
 S RESULT=1_U
 Q
 ;
RACE(DATA,DFN,TYPE,BQIRDA,AGRACE,AGRMET,PARMS) ; EP -- BQI UPDATE PAT RACE
 ; Updates for multiple races
 ;Input Parameters
 ;  DFN    - Patient internal entry number
 ;  TYPE   - 'A' to add or 'D' to delete
 ;  BQIRDA - Race record IEN needed in order to delete
 ;  AGRACE - Race value
 ;  AGRMET - Method of Collection value
 ;  PARMS  - List of parameters
 ;  
 NEW UID,II,ERROR,RESULT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTRCE",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRPL D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T01024MSG"_$C(30)
 ;
 S RESULT=1_U
 ;
 I TYPE="D" D DRACE^AGAPIPAT(DFN,BQIRDA,.ERROR)
 ;
 I TYPE="A" D
 . NEW RACE,MET
 . S RACE=$P(^DIC(10,AGRACE,0),U,1)
 . S MET=$P(^DIC(10.3,AGRMET,0),U,1)
 . D ARACE^AGAPIPAT(DFN,RACE,MET,.ERROR)
 ;
 I $D(ERROR)>0 S RESULT=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q