PXRMTIU ;SLC/RMS,PKR - Clinical Reminder TIU routines. ; 06/03/2013
;;2.0;CLINICAL REMINDERS;**4,12,26**;Feb 04, 2005;Build 404
;==========================================================
NOTE(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;Computed finding
;for note title.
S NFOUND=0
Q:(TEST="")!(NGET=0)
N ADDDATA,AUTH,DONE,EDTT,ECOSIGN,ESIGN,INVDATE,NGETABS,PIEN
N SDIR,STATUS,TEMP,TIEN,TITLE,TYPE
S TITLE=$P(TEST,U),STATUS=$P(TEST,U,2),ADDDATA=+$P(TEST,U,3)
I STATUS="" S STATUS=7 ;COMPLETED IS THE DEFAULT
S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
;Invert and switch beginning and ending dates because the TIU index
;uses inverse dates.
S INVDATE=BDT,BDT=9999999-EDTT,EDTT=9999999-INVDATE
S SDIR=$S(NGET>0:1,1:-1)
S INVDATE=$S(SDIR=+1:BDT-.000001,1:EDTT)
S NGETABS=$S(NGET<0:-NGET,1:NGET)
;See if the note is passed as a title or an IEN.
S (DONE,TIEN)=0
I $E(TITLE,1)="`" D
. S TIEN=$P(TITLE,"`",2)
.;DBIA #2321
. S TYPE=$P(^TIU(8925.1,TIEN,0),U,4)
. I TYPE="DOC" S DONE=1,TITLE=$P(^TIU(8925.1,TIEN,0),U,1)
E D
.;Find the ien for the title.
.;DBIA #2321
. F Q:DONE S TIEN=$O(^TIU(8925.1,"B",TITLE,TIEN)) Q:TIEN="" D
.. S TYPE=$P(^TIU(8925.1,TIEN,0),U,4)
.. I TYPE="DOC" S DONE=1
I 'DONE Q
;DBIA #2937
F S INVDATE=$O(^TIU(8925,"APT",DFN,TIEN,STATUS,INVDATE),SDIR) Q:$S(INVDATE=0:1,NFOUND=NGETABS:1,INVDATE<BDT:1,INVDATE>EDTT:1,1:0) D
. S PIEN=$O(^TIU(8925,"APT",DFN,TIEN,STATUS,INVDATE,0)) Q:'+PIEN
. S NFOUND=NFOUND+1
. S TEST(NFOUND)=1
. S DATE(NFOUND)=$P(^TIU(8925,PIEN,13),U)
. S DATA(NFOUND,"VALUE")=TITLE
. S DATA(NFOUND,"TITLE")=TITLE
. S TEMP=$G(^TIU(8925,PIEN,12))
. S AUTH=+$P(TEMP,U,2)
. S AUTH=$S(AUTH>0:$$GET1^DIQ(200,AUTH,.01),1:"MISSING")
. S DATA(NFOUND,"AUTH")=AUTH
. S TEXT(NFOUND)="Author: "_AUTH
. S ESIGN=$P(TEMP,U,4)
. S ESIGN=$S(ESIGN>0:$$GET1^DIQ(200,ESIGN,.01),1:"")
. S DATA(NFOUND,"EXPECTED SIGNER")=ESIGN
. S ECOSIGN=$P(TEMP,U,8)
. S ECOSIGN=$S(ECOSIGN>0:$$GET1^DIQ(200,ECOSIGN,.01),1:"")
. S DATA(NFOUND,"EXPECTED COSIGNER")=ECOSIGN
. I ADDDATA D
..;DBIA #2834
.. S TEMP=$$RESOLVE^TIUSRVLO(PIEN)
.. S DATA(NFOUND,"DISPLAY NAME")=$P(TEMP,U,1)
.. S DATA(NFOUND,"HOSPITAL LOCATION")=$P(TEMP,U,5)
.. S DATA(NFOUND,"EPISODE BEGIN DATE/TIME")=$P(TEMP,U,7)
.. S DATA(NFOUND,"EPISODE END DATE/TIME")=$P(TEMP,U,8)
.. S DATA(NFOUND,"REQUESTING PACKAGE")=$P(TEMP,U,9)
.. S DATA(NFOUND,"NUMBER OF IMAGES")=$P(TEMP,U,10)
.. S DATA(NFOUND,"SUBJECT")=$P(TEMP,U,11)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMTIU 2522 printed Dec 13, 2024@01:49:27 Page 2
PXRMTIU ;SLC/RMS,PKR - Clinical Reminder TIU routines. ; 06/03/2013
+1 ;;2.0;CLINICAL REMINDERS;**4,12,26**;Feb 04, 2005;Build 404
+2 ;==========================================================
NOTE(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;Computed finding
+1 ;for note title.
+2 SET NFOUND=0
+3 if (TEST="")!(NGET=0)
QUIT
+4 NEW ADDDATA,AUTH,DONE,EDTT,ECOSIGN,ESIGN,INVDATE,NGETABS,PIEN
+5 NEW SDIR,STATUS,TEMP,TIEN,TITLE,TYPE
+6 SET TITLE=$PIECE(TEST,U)
SET STATUS=$PIECE(TEST,U,2)
SET ADDDATA=+$PIECE(TEST,U,3)
+7 ;COMPLETED IS THE DEFAULT
IF STATUS=""
SET STATUS=7
+8 SET EDTT=$SELECT(EDT[".":EDT+.0000001,1:EDT+.240001)
+9 ;Invert and switch beginning and ending dates because the TIU index
+10 ;uses inverse dates.
+11 SET INVDATE=BDT
SET BDT=9999999-EDTT
SET EDTT=9999999-INVDATE
+12 SET SDIR=$SELECT(NGET>0:1,1:-1)
+13 SET INVDATE=$SELECT(SDIR=+1:BDT-.000001,1:EDTT)
+14 SET NGETABS=$SELECT(NGET<0:-NGET,1:NGET)
+15 ;See if the note is passed as a title or an IEN.
+16 SET (DONE,TIEN)=0
+17 IF $EXTRACT(TITLE,1)="`"
Begin DoDot:1
+18 SET TIEN=$PIECE(TITLE,"`",2)
+19 ;DBIA #2321
+20 SET TYPE=$PIECE(^TIU(8925.1,TIEN,0),U,4)
+21 IF TYPE="DOC"
SET DONE=1
SET TITLE=$PIECE(^TIU(8925.1,TIEN,0),U,1)
End DoDot:1
+22 IF '$TEST
Begin DoDot:1
+23 ;Find the ien for the title.
+24 ;DBIA #2321
+25 FOR
if DONE
QUIT
SET TIEN=$ORDER(^TIU(8925.1,"B",TITLE,TIEN))
if TIEN=""
QUIT
Begin DoDot:2
+26 SET TYPE=$PIECE(^TIU(8925.1,TIEN,0),U,4)
+27 IF TYPE="DOC"
SET DONE=1
End DoDot:2
End DoDot:1
+28 IF 'DONE
QUIT
+29 ;DBIA #2937
+30 FOR
SET INVDATE=$ORDER(^TIU(8925,"APT",DFN,TIEN,STATUS,INVDATE),SDIR)
if $SELECT(INVDATE=0
QUIT
Begin DoDot:1
+31 SET PIEN=$ORDER(^TIU(8925,"APT",DFN,TIEN,STATUS,INVDATE,0))
if '+PIEN
QUIT
+32 SET NFOUND=NFOUND+1
+33 SET TEST(NFOUND)=1
+34 SET DATE(NFOUND)=$PIECE(^TIU(8925,PIEN,13),U)
+35 SET DATA(NFOUND,"VALUE")=TITLE
+36 SET DATA(NFOUND,"TITLE")=TITLE
+37 SET TEMP=$GET(^TIU(8925,PIEN,12))
+38 SET AUTH=+$PIECE(TEMP,U,2)
+39 SET AUTH=$SELECT(AUTH>0:$$GET1^DIQ(200,AUTH,.01),1:"MISSING")
+40 SET DATA(NFOUND,"AUTH")=AUTH
+41 SET TEXT(NFOUND)="Author: "_AUTH
+42 SET ESIGN=$PIECE(TEMP,U,4)
+43 SET ESIGN=$SELECT(ESIGN>0:$$GET1^DIQ(200,ESIGN,.01),1:"")
+44 SET DATA(NFOUND,"EXPECTED SIGNER")=ESIGN
+45 SET ECOSIGN=$PIECE(TEMP,U,8)
+46 SET ECOSIGN=$SELECT(ECOSIGN>0:$$GET1^DIQ(200,ECOSIGN,.01),1:"")
+47 SET DATA(NFOUND,"EXPECTED COSIGNER")=ECOSIGN
+48 IF ADDDATA
Begin DoDot:2
+49 ;DBIA #2834
+50 SET TEMP=$$RESOLVE^TIUSRVLO(PIEN)
+51 SET DATA(NFOUND,"DISPLAY NAME")=$PIECE(TEMP,U,1)
+52 SET DATA(NFOUND,"HOSPITAL LOCATION")=$PIECE(TEMP,U,5)
+53 SET DATA(NFOUND,"EPISODE BEGIN DATE/TIME")=$PIECE(TEMP,U,7)
+54 SET DATA(NFOUND,"EPISODE END DATE/TIME")=$PIECE(TEMP,U,8)
+55 SET DATA(NFOUND,"REQUESTING PACKAGE")=$PIECE(TEMP,U,9)
+56 SET DATA(NFOUND,"NUMBER OF IMAGES")=$PIECE(TEMP,U,10)
+57 SET DATA(NFOUND,"SUBJECT")=$PIECE(TEMP,U,11)
End DoDot:2
End DoDot:1
+58 QUIT
+59 ;