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

TIUPRF2.m

Go to the documentation of this file.
  1. TIUPRF2 ; SLC/JMH - RPCs for Patient Record Flags ; 11/3/05
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**184**;Jun 20, 1997
  1. ;
  1. ; $$GETACT^DGPFAPI: IA# 3860
  1. ; $$GETHTIU^DGPFAPI1: IA# 4383
  1. ; $$STOTIU^DGPFAPI2: IA# 4384
  1. ;
  1. GETTITLE(TIUY,PTDFN,FLAGID) ; RPC Gets Note Title associated with FLAGID for PTDFN
  1. ;Receives TIUY by ref; passes back
  1. ; TIUY = TitleIEN^Title
  1. ; 0 if no title is associated or flg assignmt is not active
  1. ;Requires PTDFN
  1. ;Requires FLAGID - identifier for particular flag assignment
  1. ; for patient PTDFN. Set as subscript in GETACT^DGPFAPI.
  1. ; See GETFLG^ORPRF.
  1. N PRFARR K TIUY S TIUY=0
  1. Q:'$G(PTDFN) Q:'$G(FLAGID)
  1. S TIUY=$$GETACT^DGPFAPI(PTDFN,"PRFARR") ;Get ACTive flag info
  1. Q:'TIUY
  1. S TIUY=$G(PRFARR(FLAGID,"TIUTITLE"))
  1. I TIUY'>0 S TIUY=0
  1. Q
  1. ;
  1. GETNOTES(TIUY,PTDFN,TIUTTL,REVERSE) ; RPC gets SIGNED, LINKED PRF
  1. ;notes titled TIUTTL for patient PTDFN
  1. ; Excludes Notes linked to Entered in Error (EIE) actions and
  1. ;notes linked to Erroneous actions (actions taken prior to
  1. ;EIE actions).
  1. ; Receives TIUY by ref; passes back
  1. ; TIUY = # of notes
  1. ; TIUY([Reverse][Incremented]InternalNoteDate) =
  1. ; NoteIEN^ActionName^ExternalNoteDate^AuthorName
  1. ; Requires PTDFN,TIUTTL
  1. ; Includes status Uncosigned, Completed, & Amended only.
  1. ; Optional REVERSE - Boolean Flag:
  1. ; 1 - Sort notes by reverse chronological order
  1. ; 0 (default) - Sort notes by chronological order
  1. N TIUDG,ACTID,TIUIDATE,TIUEDATE,TIUIEN,TIUACT,STATUS
  1. N TIUAUTH,DTARRAY,HASERR,ARRAYNM
  1. K TIUY ; Initialize array in case caller hasn't done so.
  1. S (TIUY,ACTID)=0
  1. ; -- Get Assgn Hist info (GETHTIU initializes array
  1. ; so we don't need to):
  1. S ARRAYNM="^TMP(""TIUPRFH"",$J)"
  1. S TIUDG=$$GETHTIU^DGPFAPI1(PTDFN,TIUTTL,ARRAYNM)
  1. G:'TIUDG GETNOTEX
  1. S HASERR=$$HASERR^TIUPRFL(ARRAYNM)
  1. F S ACTID=$O(@ARRAYNM@("HISTORY",ACTID)) Q:'ACTID D
  1. . I ACTID=+HASERR Q ;Entered in Error
  1. . I HASERR>0,$$ISERR^TIUPRFL(ARRAYNM,ACTID,$P(HASERR,U,2)) Q ;erroneous
  1. . S TIUIEN=+@ARRAYNM@("HISTORY",ACTID,"TIUIEN")
  1. . Q:TIUIEN'>0 ;TMP node may be just ^
  1. . ; -- Include only complete or amended or uncosigned notes:
  1. . S STATUS=$P($G(^TIU(8925,TIUIEN,0)),U,5) I '((STATUS=6)!(STATUS=7)!(STATUS=8)) Q
  1. . S TIUACT=$P(@ARRAYNM@("HISTORY",ACTID,"ACTION"),U,2)
  1. . N TIUFLDS,TIUERR D GETS^DIQ(8925,TIUIEN_",","1202;1301","IE","TIUFLDS","TIUERR")
  1. . S TIUIDATE=TIUFLDS(8925,TIUIEN_",",1301,"I")
  1. . ; -- Increment date if there are multiple notes w/ same exact date:
  1. . F S:$D(DTARRAY(TIUIDATE)) TIUIDATE=TIUIDATE+.0000001 I '$D(DTARRAY(TIUIDATE)) S DTARRAY(TIUIDATE)="" Q
  1. . I $G(REVERSE) S TIUIDATE=9999999-TIUIDATE
  1. . S TIUEDATE=$E(TIUFLDS(8925,TIUIEN_",",1301,"E"),1,18)
  1. . I TIUEDATE="" S TIUEDATE="No Ref Date"
  1. . S TIUAUTH=TIUFLDS(8925,TIUIEN_",",1202,"E")
  1. . I TIUAUTH="" S TIUAUTH="No Author"
  1. . S TIUY=TIUY+1
  1. . S TIUY(TIUIDATE)=TIUIEN_U_TIUACT_U_TIUEDATE_U_TIUAUTH
  1. GETNOTEX ;
  1. K ^TMP("TIUPRFH",$J)
  1. Q
  1. ;
  1. GETACTS(TIUY,TIUTTL,DFN) ;RPC Gets PRF Action info
  1. ;"Action" is shorthand for Assignment History entry
  1. ;Returns data in the following format for each Action:
  1. ;TIUY(ACTID) =
  1. ; FLAGNAME^ASSGNIEN^ACTIONNAME^ACTIONIEN^ACTIONDATEI^ACTIONDATEE^TIUIEN
  1. ; where Integer ACTID = subscript after "HISTORY" in array returned
  1. ; by GETHTIU^DGPFAPI1
  1. ;Returns linkable actions (whether linked or not) for Patient DFN
  1. ; and flag assoc w/ TIUTTL.
  1. ;Excludes UNLINKABLE actions = Entered in Error actions (EIE) or
  1. ; actions taken prior to an EIE action.
  1. ;Erroneous and EIE actions may be for the wrong patient, etc.
  1. N TIUDG,ACTID,TIUFLAG,UNLINKBL,ARRAYNM
  1. S TIUY=1,ARRAYNM="^TMP(""TIUPRFH"",$J)"
  1. S TIUDG=$$GETHTIU^DGPFAPI1(DFN,TIUTTL,ARRAYNM)
  1. I 'TIUDG S TIUY="0^"_$P(TIUDG,U,2) G GETACTX
  1. ; -- If no unlinked, linkable actions exist, say so but go on:
  1. I '$$AVAILACT^TIUPRFL("^TMP(""TIUPRFH"",$J)",,.UNLINKBL) S TIUY="0^All linkable Flag actions are already linked"
  1. ; -- Return ALL linkable actions (linked or not):
  1. S TIUFLAG=$P(^TMP("TIUPRFH",$J,"FLAG"),U,2)_U_$P(^TMP("TIUPRFH",$J,"ASSIGNIEN"),U)
  1. S ACTID=0
  1. F S ACTID=$O(^TMP("TIUPRFH",$J,"HISTORY",ACTID)) Q:'+ACTID D
  1. . Q:$G(UNLINKBL(ACTID))
  1. . S TIUY(ACTID)=TIUFLAG
  1. . S TIUY(ACTID)=TIUY(ACTID)_U_$P(^TMP("TIUPRFH",$J,"HISTORY",ACTID,"ACTION"),U,2)
  1. . S TIUY(ACTID)=TIUY(ACTID)_U_$P(^TMP("TIUPRFH",$J,"HISTORY",ACTID,"HISTIEN"),U,1)
  1. . S TIUY(ACTID)=TIUY(ACTID)_U_$P(^TMP("TIUPRFH",$J,"HISTORY",ACTID,"DATETIME"),U,1)
  1. . S TIUY(ACTID)=TIUY(ACTID)_U_$P(^TMP("TIUPRFH",$J,"HISTORY",ACTID,"DATETIME"),U,2)
  1. . S TIUY(ACTID)=TIUY(ACTID)_U_$P(^TMP("TIUPRFH",$J,"HISTORY",ACTID,"TIUIEN"),U,1)
  1. GETACTX ;
  1. K ^TMP("TIUPRFH",$J)
  1. Q
  1. ;
  1. ; the PRF action
  1. N TIUTTL
  1. S TIUTTL=+$G(^TIU(8925,TIUIEN,0))
  1. I 'TIUTTL S TIUY="0^Document does not exist" Q
  1. ; Remove any links before making new link
  1. D UNLINK^TIUPRF1(TIUIEN)
  1. S TIUY=$$STOTIU^DGPFAPI2(DFN,ASSGNDA,ACTIEN,TIUIEN)
  1. Q
  1. GETSTAT(TIUY,TIUIEN) ;RPC Gets the status of TIU Doc TIUIEN
  1. ;Returns STATIEN^STATNAME
  1. N TIUTTL
  1. S TIUTTL=+$G(^TIU(8925,TIUIEN,0))
  1. I 'TIUTTL S TIUY="0^Document does not exist" Q
  1. S TIUY=$P(^TIU(8925,TIUIEN,0),U,5)
  1. S TIUY=TIUY_U_$P($G(^TIU(8925.6,TIUY,0)),U,1)
  1. Q
  1. ISPRFTTL(TIUY,TIUDA) ;RPC Takes as input 8925.1 IEN
  1. ; and checks if it is a PRF title
  1. ; Cf ISPFTTL^TIUPRFL. which is a FUNCTION
  1. N TIUCAT1,TIUCAT2,TIUD1
  1. S TIUY=0,TIUD1=""
  1. S TIUCAT1=+$$DDEFIEN^TIUFLF7("PATIENT RECORD FLAG CAT I","DC")
  1. S TIUCAT2=+$$DDEFIEN^TIUFLF7("PATIENT RECORD FLAG CAT II","DC")
  1. S TIUD1=$O(^TIU(8925.1,"AD",TIUDA,TIUD1))
  1. I TIUD1=TIUCAT1!(TIUD1=TIUCAT2) S TIUY=1
  1. Q