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

BQIPTRPU.m

Go to the documentation of this file.
BQIPTRPU ;VNGT/HC/KML-REPRODUCTIVE FACTORS UPDATE ; 02 Jan 2008  12:27 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;;Apr 18, 2012;Build 59
 ;
 Q
 ;
UPD(DATA,DFN,RPARMS) ;EP - BQI UPDATE REPRODUCTIVE FACTORS
 ;Input
 ;  DFN    - Patient internal entry number
 ;  RPARMS  - Data values
 ;
 N UID,II,VFIEN,RPFILE,API,BQINT,RPFIEN,BQIAPCD
 N BQIDATA,ERROR,RESULT,DIC,DR,DA
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTRPU",UID))
 K @DATA
 ;
 S II=0
 N $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTRPU D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T01024ERROR"_$C(30)
 ;
 S VFIEN=$O(^BQI(90506.3,"B","Reproductive Factors",""))
 I VFIEN="" S BMXSEC="RPC Call Failed: Reproductive Factors Definition does not exist." Q
 S RPFILE=$P(^BQI(90506.3,VFIEN,0),U,2)
 S API=0 I $T(^APCDRF)'="" S API=1
 ;
 I $G(^AUPNREP(DFN,0))="" S RPFIEN=$$NREC(DFN) Q:$G(BMXSEC)]""  ; create new record if RPFIEN is null
 ;
 D GETS^DIQ(9000017,DFN_",","*","I","BQINT")
 ;
 D COLLECT(RPFILE,RPARMS,.BQIDATA,.BQIAPCD)
 ;
 S RESULT=$$FILEDATA(.BQIDATA,.BQIAPCD)
 ;
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
UPDFPM(DATA,DFN,FPMIEN,PARMS) ; EP - BQI UPDATE FAMILY PLANNING METHOD
 ;Input
 ;  DFN    - Patient internal entry number
 ;  FPMIEN - FAMILY PLANNING METHOD IEN if null create a new one 
 ;  PARMS  - Data values
 ;
 N UID,II,VFIEN,FILE,LIST,BN,BQ,PDATA,NAME,VALUE,PFIEN,PTYP,CHIEN,FIELD
 N BQIDATA,ERROR,RESULT,DIC,DR,DA,BQINT,BQEXT,BQIAPCD
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("UPDFPM-BQIPTRPU",UID))
 K @DATA
 ;
 S II=0
 N $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTRPU D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T001024ERROR"_$C(30)
 ;
 S RPFIEN=$G(RPFIEN,"")
 ;
 S VFIEN=$O(^BQI(90506.3,"B","Family Planning Method",""))
 I VFIEN="" S BMXSEC="RPC Call Failed: Family Planning Method Definition does not exist." Q
 S FILE=$P(^BQI(90506.3,VFIEN,0),U,2)
 ;
 ;
 D COLLECT(RPFILE,RPARMS,.BQIDATA,.BQIAPCD)
 ;
 S RESULT=$$FILEDATA(.BQIDATA,.BQIAPCD)
 ;
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
NREC(BQIDFN) ; Create new record in file 9000017
 N RPFY
 ; call IHS PCC Package to file new entry if API program exists
 I $T(^APCDRF)'="" S RPFY=$$RFADD^APCDRF(DFN) I RPFY=1 S RPFY=DFN
 I '$D(RPFY)  D
 . N X,DIC,DD,D0,DO,Y,DINUM
 . I $P(^DPT(DFN,0),U,2)'="F" S RPFY="0^Patient not female." Q
 . I $G(^AUPNREP(DFN,0))'="" S RPFY=DFN Q  ; Entry already exists
 . S DIC="^AUPNREP(",DIC(0)="L",(DINUM,X)=DFN
 . K DO,DD D FILE^DICN
 . K DIC,DR,DA
 . S RPFY=+Y
 S:RPFY=-1 BMXSEC="RPC Call Failed: Error encountered while filing new entry in REPRODUCTIVE FACTORS file."
 I +RPFY=0 S BMXSEC="RPC Call Failed: "_$P(RPFY,U,2)
 Q RPFY
 ;
COLLECT(FILE,PARMS,ARRAYBQI,ARRYAPCD) ;
 N LIST,BN,PDATA,NAME,VALUE,PFIEN,PTYPE,CHIEN,FIELD
 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)
 . S PFIEN=$O(^BQI(90506.3,VFIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC="RPC Call Failed: "_NAME_" not a valid parameter for this update" Q
 . ;I $P(^BQI(90506.3,VFIEN,10,PFIEN,0),U,11)=1 S PFIEN=$O(^BQI(90506.3,VFIEN,10,"AC",NAME,PFIEN))
 . S PTYP=$P($G(^BQI(90506.3,VFIEN,10,PFIEN,1)),U) ; code type could be 'D' date, 'N' numeric, 'C' choice, 'X' text
 . I NAME="RFLMP"!(NAME="RFCFPMDT")!(NAME="RFEDCDT") S VALUE=$$DATE^BQIUL1(VALUE)
 . I PTYP="D" S VALUE=$$DATE^BQIUL1(VALUE)
 . I PTYP="C" D
 .. I VALUE="" Q
 .. S CHIEN=$O(^BQI(90506.3,VFIEN,10,PFIEN,5,"B",VALUE,""))
 .. I CHIEN="" S CHIEN=$O(^BQI(90506.3,VFIEN,10,PFIEN,5,"C",VALUE,""))
 .. I CHIEN="" Q
 .. S VALUE=$P(^BQI(90506.3,VFIEN,10,PFIEN,5,CHIEN,0),U,2)
 .. ;I API S VALUE=$P(^BQI(90506.3,VFIEN,10,PFIEN,5,CHIEN,0),U,1)
 . S FIELD=$P($G(^BQI(90506.3,VFIEN,10,PFIEN,3)),U)
 . ;S (ARRAYBQI(FILE,DFN_",",FIELD),ARRYAPCD(FIELD))=VALUE
 . ;S @NAME=VALUE
 . I $G(BQINT(FILE,DFN_",",FIELD,"I"))'="",VALUE="" S VALUE="@"
 . I VALUE'="" D UP
 . I FIELD=3,VALUE'="" S FIELD=3.1,VALUE=DT D UP
 . I FIELD=3.05,VALUE'="" S VALUE=$$DATE^BQIUL1(VALUE) D UP
 . I FIELD=4,VALUE'="" S FIELD=4.1,VALUE=DT D UP
 . I FIELD=4.05,VALUE'="" S FIELD=4.1,VALUE=DT D UP
 . I FIELD=2.01,VALUE'="" S FIELD=2.02,VALUE=DT D UP
 . ;I VALUE="" S VALUE="@"
 Q
 ;
FILEDATA(ARRAYBQI,ARYAPCD) ; update existing record with data returned from CMET
 N BQIRET,RETVAL
 K ERROR
 I API,$D(ARYAPCD)>0 S BQIRET=0 D RHEDIT^APCDRF("I",DFN,.ARYAPCD,BQIRET)
 I 'API,$D(ARRAYBQI)>0 D FILE^DIE("","ARRAYBQI","ERROR")
 S RETVAL=1_U
 I $D(ERROR)>0 S RETVAL=-1_U_$G(ERROR("DIERR",1,"TEXT",1))
 Q RETVAL
 ;
INIT(DATA,DFN) ; EP - BQI REP FAC INIT TRIG
 NEW UID,II,VALUE,SOURCE,HELP,ABLE,REQ,CLEAR,TYPE,CPS,CLFLAG
 ;
 S DFN=$G(DFN,"")
 ;
 ;Pull Current Pregnancy Status
 S CPS=$$GET1^DIQ(9000017,DFN_",",1101,"I")
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTRPU",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTRPU D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 ;Define Header
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00030PROP_VALUE^T00001ABLE_FLAG^T00001REQ_OPT^T00200HELP_TEXT^T01024CLEAR_FIELDS^T00001CLEAR_FLAG"_$C(30)
 ;
 S ABLE="Y"
 I CPS'="Y" S ABLE="N"
 S SOURCE="RFDFEDD",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDLMP",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDULT",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDCLP",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDUNK",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDDPV",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDLPV",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDUPV",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDCPV",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 S SOURCE="RFEDDMPV",VALUE="",HELP="",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
 ;Set up entry
REC S II=II+1,@DATA@(II)=$G(SOURCE)_U_$G(TYPE)_U_$G(VALUE)_U_U_$G(ABLE)_U_$G(REQ)_U_$G(HELP)_U_$G(CLEAR)_U_$G(CLFLAG)_$C(30)
 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
 ;
UP ;
 S (ARRAYBQI(FILE,DFN_",",FIELD),ARRYAPCD(FIELD))=VALUE
 Q