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

BTPWTINT.m

Go to the documentation of this file.
BTPWTINT ;VNGT/HS/ALA-TIU Note Text ; 28 Mar 2010  6:59 PM
 ;;1.1;CARE MANAGEMENT EVENT TRACKING;**2**;Apr 01, 2015;Build 17
 ;
 ;
EN(NDATA,BTPWDFN,BTPWVIEN,BTPWTIT,SUBJ,SIGN,TIUDA,BTPWNOT,TEXT) ; EP - BTPW SET NOTE
 ; Input
 ;   BTPWDFN  = Patient IEN
 ;   BTPWVIEN = Visit IEN
 ;   BTPWTIT  = Document Title IEN
 ;   SUBJ     = Subject header
 ;   SIGN     = Electronic Signature
 ;   TIUDA    = Existing Note IEN
 ;   BTPWNOT  = Notification type
 ;   TEXT     = Note text
 ;
 NEW II,UID,MORE,BN,LINE,CT,NBN
 ; Create chart review visit
 ;   BTPWVIEN = Visit IEN
 S II=0
 ;
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWTINT D UNWIND^%ZTER" ; SAC 2006 2.2.3
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S NDATA=$NA(^TMP("BTPWTINT",UID)),TEMP=$NA(^TMP("BTPWNOTE",UID))
 K @NDATA,@TEMP
 ;
 I $D(TEXT)>1 D
 . S BN="",LINE="",CT=0
 . F  S BN=$O(TEXT(BN)) Q:BN=""  D
 .. S NBN=$O(TEXT(BN))
 .. S LINE=LINE_TEXT(BN) I NBN'="" S LINE=LINE_TEXT(NBN)
 .. I NBN'="" D
 ... F BQ=1:1:$L(LINE,$C(10))-1 S CT=CT+1,@TEMP@(CT)=$P(LINE,$C(10),BQ)
 ... S LINE=$P(LINE,$C(10),BQ+1,$L(LINE,$C(10)))
 ... S BN=NBN
 .. I NBN="" D
 ... F BQ=1:1:$L(LINE,$C(10)) S CT=CT+1,@TEMP@(CT)=$P(LINE,$C(10),BQ)
 I $D(TEXT)=1 D
 . S LINE=TEXT,CT=0
 . F BQ=1:1:$L(LINE,$C(10)) S CT=CT+1,@TEMP@(CT)=$P(LINE,$C(10),BQ)
 ;
 I $G(TIUDA)'="" D  Q
 . NEW TIUX,BN,RESULT,MSG,ERROR
 . K TIUX
 . S TIUX("HDR")="1^1"
 . S BN=0 F  S BN=$O(@TEMP@(BN)) Q:BN=""  S TIUX("TEXT",BN,0)=@TEMP@(BN)
 . D UPDATE^TIUSRVP(.ERROR,TIUDA,.TIUX,1)
 . S RESULT=1,MSG=""
 . I $P($G(ERROR),U,1)=0 S RESULT=-1,MSG=$P($G(ERROR),U,2)
 . S @NDATA@(II)="I00010RESULT^T00080MESSAGE^I00010BTPWVIEN^I00010TIUDA"_$C(30)
 . S II=II+1,@NDATA@(II)=RESULT_U_MSG_U_BTPWVIEN_U_TIUDA_$C(30)
 . S II=II+1,@NDATA@(II)=$C(31)
 . K @TEMP
 ;
 S MORE=$S($G(BTPWVIEN)'="":"",1:1)
 S NOTTYP=$S($G(BTPWNOT)="P":4,$G(BTPWNOT)="L":1,1:$G(BTPWNOT))
 S APCDCAT=$S($G(BTPWNOT)=4:"T",$G(BTPWNOT)="P":"T",1:"C")
 ;
 ; Create Chart Review
 I $G(BTPWVIEN)="" D
 . S BTPWVIEN=$$EN^BTPWPCHT($G(NOTTYP),BTPWDFN,1)
 I BTPWVIEN=-1 D  Q
 . S @NDATA@(II)="I00010RESULT^T00080MESSAGE^I00010BTPWVIEN"_$C(30)
 . S II=II+1,@NDATA@(II)="-1^Unable to create Visit Record^"_$C(30)
 . S II=II+1,@NDATA@(II)=$C(31)
 ; Get visit data
 NEW TIUDA,N,BTPWVIS,TIUX,RESULT
 S DATA="BTPWVIS"
 D LOAD^BEHOENP1(.DATA,BTPWDFN,BTPWVIEN)
 ;
 I $G(SUBJ)="" S SUBJ="CMET Notification"
 ;
 S N=0
 F  S N=$O(BTPWVIS(N)) Q:N=""  D
 . I $P(BTPWVIS(N),U,1)="VST",$P(BTPWVIS(N),U,2)="HL" S TIUX(1205)=$P(BTPWVIS(4),U,3) Q
 . I $P(BTPWVIS(N),U,1)="HDR" S VSTR=$P(BTPWVIS(N),U,4)
 S TIUX(1202)=DUZ
 S TIUX(1301)=$$NOW^XLFDT()
 ; Subject (may need to be passed)
 S TIUX(1701)=SUBJ
 S TIUX("VISIT")=BTPWVIEN
 ; Create TIU record
 D MAKE^TIUSRVP(.RESULT,BTPWDFN,BTPWTIT,"","",BTPWVIEN,.TIUX,"",1,"")
 S TIUDA=RESULT
 ; Save document RPC - TIU SET DOCUMENT TEXT
 ;                TIUX("HDR")=<# of Current Page>^<Total # of Pages>
 ;                TIUX("TEXT",1,0)=<Line 1 of document body>
 ;                TIUX("TEXT",2,0)=<Line 2 of document body>
 ;                TIUX("TEXT",3,0)=<Line 3 of document body>
 K TIUX
 S TIUX("HDR")="1^1"
 S BN=0 F  S BN=$O(@TEMP@(BN)) Q:BN=""  S TIUX("TEXT",BN,0)=@TEMP@(BN)
 D SETTEXT^TIUSRVPT(.TIUY,TIUDA,.TIUX,1)
 ;
 ; Set the Chart Review with provider, dx and note
 I MORE D
 . K APCDALVR
 . S APCDALVR("APCDATMP")="[APCDALVR 9000010.06 (ADD)]"
 . S APCDALVR("APCDTPS")="PRIMARY",APCDALVR("APCDTPRO")=$P(^VA(200,DUZ,0),U,1)
 . S APCDALVR("APCDPAT")=BTPWDFN,APCDALVR("APCDVSIT")=BTPWVIEN
 . S RESULT=$$ADD^BTPWPCHT(BTPWDFN,BTPWVIEN,.APCDALVR)
 . ;
 . K APCDALVR
 . S APCDALVR("APCDATMP")="[APCDALVR 9000010.07 (ADD)]"
 . S AUPNS=107728002
 . S APCDALVR("APCDTPOV")=$S($G(APCDCAT)="T":"Z71.9",1:$$CRPOV^BTPWPBTH())
 . S APCDALVR("APCDTPS")="PRIMARY"
 . S APCDALVR("APCDTNQ")=$S($G(APCDCAT)="T":"iCare Telephone Note|185317003",1:"iCare Chart Review|107728002")
 . S APCDALVR("APCDPAT")=BTPWDFN,APCDALVR("APCDVSIT")=BTPWVIEN
 . S RESULT=$$ADD^BTPWPCHT(BTPWDFN,BTPWVIEN,.APCDALVR)
 . ;
 . K APCDALVR
 . S APCDALVR("APCDATMP")="[APCDALVR 9000010.28 (ADD)]"
 . S APCDALVR("APCDTDOC")=TIUDA
 . S APCDALVR("APCDPAT")=BTPWDFN,APCDALVR("APCDVSIT")=BTPWVIEN
 . S RESULT=$$ADD^BTPWPCHT(BTPWDFN,BTPWVIEN,.APCDALVR)
 . ;
 S RESULT=1
 ;
DONE ;
 K @TEMP
 S @NDATA@(II)="T00001RESULT^T01024MSG^I00010BTPWVIEN^I00010TIUDA"_$C(30)
 S II=II+1,@NDATA@(II)=RESULT_U_U_$G(BTPWVIEN)_U_$G(TIUDA)_$C(30)
 S II=II+1,@NDATA@(II)=$C(31)
 Q
 ;
NAR(TEXT) ; EP
 NEW SOURCE,VALUE,DIC,DLAYGO,X,Y,IEN
 S DIC(0)="LX",DIC="^AUTNPOV(",DLAYGO=9999999.27,X=TEXT
 D ^DIC
 S IEN=+Y
 I IEN=-1 K DO,DD D FILE^DICN S IEN=+Y
 Q IEN
 ;
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
 S II=II+1,@NDATA@(II)=$C(31)
 Q
 ;
TXT(NDATA,TLIST) ; EP -- BTPW GET NOTE TEXT
 NEW UID,II,LIST,BN,BTP,TIUDA,HSTEXT
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWTINT D UNWIND^%ZTER" ; SAC 2006 2.2.3
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S II=0
 ;
 S NDATA=$NA(^TMP("BTPWNTTXT",UID)) K @NDATA
 S @NDATA@(II)="T01024REPORT_TEXT"_$C(30)
 ;
 I $D(TLIST)>1 D
 . S LIST="",BN=""
 . F  S BN=$O(TLIST(BN)) Q:BN=""  S LIST=LIST_TLIST(BN)
 . K TLIST S TLIST=LIST
 ;
 F BTP=1:1 S TIUDA=$P(TLIST,$C(28),BTP) Q:TIUDA=""  D
 . ;D TGET^TIUSRVR1(.DATA,TIUDA)
 . D GET^BQITIUTX(.DATA,TIUDA)
 . S BN=$S($G(@DATA@(1))["TITLE:":6,1:0)
 . F  S BN=$O(@DATA@(BN)) Q:BN=""  D
 .. S HSTEXT=@DATA@(BN)
 .. S HSTEXT=$$STRIP^XLFSTR(HSTEXT,"^"),HSTEXT=$$CTRL^BQIUL1(HSTEXT)
 .. S II=II+1,@NDATA@(II)=HSTEXT_$C(10)
 . S II=II+1,@NDATA@(II)=$C(12)
 S II=II+1,@NDATA@(II)=$C(30)
 S II=II+1,@NDATA@(II)=$C(31)
 K @DATA
 Q