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

BQITIULS.m

Go to the documentation of this file.
BQITIULS ;VNGT/HS/ALA-Build List of Documents for a Patient ; 30 Jan 2009  12:50 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
LST(DATA,DFN,TMFRAME) ; EP -- BQI GET DOC LIST BY PAT
 ; Input Variables
 ;   DFN     - Patient Internal entry Number
 ;   TMFRAME - Date time frame (a set of values e.g. 3 months = T-3M)
 ;
 NEW UID,II,HDR,AUTHOR,CLASS,IXDT,STATUS,TITLE,TIUDA,TITN,SUBJ,SRTCT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQITIULS",UID))
 K @DATA
 K ^TMP("BQITIULS_1",$J)
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITIULS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S HDR="T00060CLASS^T00060TITLE^T00080SUBJECT^D00030DATETIME^T00030STATUS^T00035AUTHOR^I00010TIUDA"
 S @DATA@(II)=HDR_$C(30)
 ;
 S TMFRAME=$$DATE^BQIUL1($G(TMFRAME))
 I TMFRAME'="" S BDT=(9999999-DT)-.001,EDT=(9999999-TMFRAME)
 I TMFRAME="" S BDT="",EDT=""
 ;
 I BDT="",EDT="" D  G SORT
 . S TIUDA=""
 . F  S TIUDA=$O(^TIU(8925,"C",DFN,TIUDA)) Q:TIUDA=""  D REC(TIUDA)
 ;
 F  S BDT=$O(^TIU(8925,"AE",DFN,BDT)) Q:BDT=""!(BDT>EDT)  D
 . S TITN=""
 . F  S TITN=$O(^TIU(8925,"AE",DFN,BDT,TITN)) Q:TITN=""  D
 .. S TIUDA=""
 .. F  S TIUDA=$O(^TIU(8925,"AE",DFN,BDT,TITN,TIUDA)) Q:TIUDA=""  D REC(TIUDA)
 ;
SORT ;
 S IXDT="" F  S IXDT=$O(^TMP("BQITIULS_1",$J,IXDT),-1) Q:IXDT=""  S SRTCT="" F  S SRTCT=$O(^TMP("BQITIULS_1",$J,IXDT,SRTCT)) Q:SRTCT=""  S II=II+1,@DATA@(II)=$G(^TMP("BQITIULS_1",$J,IXDT,SRTCT))
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 K ^TMP("BQITIULS_1",$J)
 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
 ;
REC(TIUDA) ;
 ;
 NEW TDTNTD,TDTCRT
 ;
 ;Pull CLASS - Do not return ADDENDUM records
 S CLASS=$$GET1^DIQ(8925,TIUDA_",",.04,"E")
 Q:CLASS="ADDENDUM"
 ;
 S TITLE=$$GET1^DIQ(8925,TIUDA_",",.01,"I")
 S:TITLE]"" TITLE=$P($G(^TIU(8925.1,TITLE,0)),U)
 Q:TITLE=""  ;Skip corrupted entries
 ;
 S AUTHOR=$$GET1^DIQ(8925,TIUDA_",",1202,"E")
 ;
 S TDTCRT=$$GET1^DIQ(8925,TIUDA_",",1201,"I")
 S (TDTNTD,IXDT)=$$GET1^DIQ(8925,TIUDA_",",1301,"I")
 I IXDT="" S IXDT=$S(TDTCRT]"":TDTCRT,1:"~")
 ;
 S STATUS=$$GET1^DIQ(8925,TIUDA_",",.05,"E")
 I STATUS'="COMPLETED" Q
 S SUBJ=$$GET1^DIQ(8925,TIUDA_",",1701,"E")
 ;
 S SRTCT=$G(SRTCT)+1
 S ^TMP("BQITIULS_1",$J,IXDT,SRTCT)=CLASS_U_TITLE_U_SUBJ_U_$$FMTE^BQIUL1(TDTNTD)_U_STATUS_U_AUTHOR_U_TIUDA_$C(30)
 Q
 ;
CNT(DATA,DFN) ; EP -- BQI DOC COUNT BY PAT
 ; Input Variables
 ;   DFN   - Patient Internal entry Number
 ;
 NEW UID,II,HDR,TIUDA,TDTCRT,ARRAY,CT,EDT,BDT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQITIUCT",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITIULS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S HDR="D00015FROM_DATE^D00015THRU_DATE^I00010NUM"
 S @DATA@(II)=HDR_$C(30)
 ;
 ;
 K ARRAY
 S TIUDA="",CT=0
 F  S TIUDA=$O(^TIU(8925,"C",DFN,TIUDA)) Q:TIUDA=""  D
 . S TDTCRT=$$GET1^DIQ(8925,TIUDA_",",1201,"I")\1
 . I TDTCRT=0 Q
 . S ARRAY(TDTCRT)="",CT=CT+1
 S BDT=$O(ARRAY("")),EDT=$O(ARRAY(""),-1)
 I CT>0 S II=II+1,@DATA@(II)=$$FMTE^BQIUL1(BDT)_U_$$FMTE^BQIUL1(EDT)_U_CT_$C(30)
 G DONE