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

BQIPTRF.m

Go to the documentation of this file.
BQIPTRF ;PRXM/HC/ALA-Patient Referrals ; 23 Feb 2007  2:22 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 Q
 ;
REF(DATA,DFN,TMFRAME) ; EP -- BQI PATIENT REFERRALS
 ;
 ;Description - all the referrals that a patient has
 ;
 ;Input
 ;  DFN     - Patient internal entry number
 ;  TMFRAME - Timeframe
 ;
 NEW UID,II,HEADER,BN,ENDT,RFIEN,PTYP,RTYP,VEND,BGDT,BPCADAT,BPCDTA,BPCEDAT
 NEW BPCIDAT,BPCPIEN,BPCPNAM,BPCPURP,BPCRNUM,BQIPAT,NTMP,FLDS,NM,TMP,VAL,RSTAT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTRF",UID))
 K @DATA
 ;
 S TMFRAME=$G(TMFRAME,""),ENDT=""
 I TMFRAME'="" S ENDT=$$DATE^BQIUL1(TMFRAME)
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTRF D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S HEADER="I00010REF_IEN^T00013REF_NUMBER^T00080PURPOSE^T00035PROVIDER_NAME^I00010PROV_IEN^D00030INITIAL_DATE^D00030EXP_SERV_DATE^D00030ACT_SERV_DATE^"
 S HEADER=HEADER_"T00030PAT_TYPE^T00030REF_TYPE^T00030VENDOR^T00003REF_STAT"
 S @DATA@(II)=HEADER_$C(30)
 ;
 S BGDT=$S(ENDT="":"",1:ENDT-.0001)
 ;
 I $$PATCH^XPDUTL("BMC*4.0*4") D  G DONE
 . S FLDS=".02/E;1201/E;.06/E;.06/I;.01/I;1105/I;1106/I;.14/E;.04/E;.07/E;.15/I"
 . S TMP=$NA(^TMP(UID)),BQIPAT(DFN)=""
 . D API^BMCAPI1(.BQIPAT,BGDT,"",FLDS,TMP)
 . S RFIEN=""
 . F  S RFIEN=$O(@TMP@(DFN,RFIEN)) Q:RFIEN=""  D
 .. S NM="",II=II+1,$P(@DATA@(II),U,1)=RFIEN
 .. F  S NM=$O(@TMP@(DFN,RFIEN,NM)) Q:NM=""  D
 ... S NTMP=$Q(@TMP@(DFN,RFIEN,NM))
 ... I NTMP["E" S VAL=@NTMP
 ... I NTMP["I" S VAL=$$FMTE^BQIUL1(@NTMP)
 ... S $P(@DATA@(II),U,1+NM)=VAL
 .. S @DATA@(II)=@DATA@(II)_$C(30)
 . K @TMP
 ;
 F  S BGDT=$O(^BMCREF("AA",DFN,BGDT)) Q:BGDT=""  D
 . S RFIEN=""
 . F  S RFIEN=$O(^BMCREF("AA",DFN,BGDT,RFIEN)) Q:RFIEN=""  D
 .. S BPCRNUM=$$GET1^DIQ(90001,RFIEN_",",.02,"E")
 .. S BPCPIEN=$$GET1^DIQ(90001,RFIEN_",",.06,"I")
 .. S BPCPNAM=$$GET1^DIQ(90001,RFIEN_",",.06,"E")
 .. I BPCPNAM="" S BPCPNAM="NO PROVIDER INDICATED"
 .. S BPCIDAT=$$FMTE^BQIUL1($$GET1^DIQ(90001,RFIEN_",",.01,"I"))
 .. S BPCPURP=$$GET1^DIQ(90001,RFIEN_",",1201,"E")
 .. S PTYP=$$GET1^DIQ(90001,RFIEN_",",.14,"E")
 .. S RSTAT=$$GET1^DIQ(90001,RFIEN_",",.15,"I")
 .. S RTYP=$$GET1^DIQ(90001,RFIEN_",",.04,"E")
 .. S VEND=$$GET1^DIQ(90001,RFIEN_",",.07,"E")
 .. S BPCEDAT=$$FMTE^BQIUL1($$GET1^DIQ(90001,RFIEN_",",1105,"I"))
 .. S BPCADAT=$$FMTE^BQIUL1($$GET1^DIQ(90001,RFIEN_",",1106,"I"))
 .. S BPCDTA=RFIEN_U_BPCRNUM_U_BPCPURP_U_BPCPNAM_U_BPCPIEN_U_BPCIDAT_U_BPCEDAT_U_BPCADAT
 .. S II=II+1,@DATA@(II)=BPCDTA_U_PTYP_U_RTYP_U_VEND_U_RSTAT_$C(30)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 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