ORDV02C ;SLC/DCM - OE/RR REPORT EXTRACTS ;MAY 17, 2024@15:40
;;3.0;ORDER ENTRY/RESULTS REPORTING;**350,423,377,534,603,610**;Dec 17, 1997;Build 11
;
; Reference to GCPR^OMGCOAS1 in ICR #3486
; Reference to ^TMP("60" in ICR #3486
; Reference to ^LAB(60 in ICR #2387
;
OV(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Lab Overview
I '$D(ORDEND) S ORDEND=9999999 ;Acknowledging parameter input value in ORDEND DM-610
S OROMEGA=ORDEND
I $L($T(GCPR^OMGCOAS1)) D ; Call if FHIE station 200
. N BEG,END,MAX
. Q:'$G(ORALPHA) Q:'$G(OROMEGA)
. S MAX=$S(+$G(ORMAX)>0:ORMAX,1:999)
. S BEG=9999999-OROMEGA,END=9999999-ORALPHA
. D GCPR^OMGCOAS1(DFN,"LRO",BEG,END,MAX)
N D,SN,ORX0,MAX,GMTS1,GMTS2,GMTSBEG,GMTSEND,GMTSMERG,ORSITE,SITE,GO,SORT,STATUS,S,LST,RSLT,Y,IVSDT,IVEDT,I,X,ORCTR,ORSTOP
Q:'$L(OREXT)
S GO=$P(OREXT,";")_"^"_$P(OREXT,";",2)
Q:'$L($T(@GO))
S GMTSBEG=0,GMTSEND=9999999,MAX=9999,GMTSMERG=1
S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
K ^TMP("ORDATA",$J)
I '$L($T(GCPR^OMGCOAS1)) D
. K ^TMP("LRO",$J),^TMP("ORTXT",$J),^TMP("ORSORT",$J),^TMP("ORXPND",$J)
. D @GO
S D=ORDBEG,IVSDT=ORDBEG,IVEDT=(9999999-ORDEND),ORCTR=1,ORSTOP=0 ;IVEDT change to reverse date order DM-603
F S D=$O(^TMP("ORSORT",$J,D)) Q:'D!(D<IVEDT)!ORSTOP D
. S S=0 F S S=$O(^TMP("ORSORT",$J,D,S)) Q:'S!ORSTOP S SN=0 F S SN=$O(^TMP("ORSORT",$J,D,S,SN)) S:ORCTR>ORMAX ORSTOP=1 Q:'SN!ORSTOP S ORX0=^(SN),ORCTR=ORCTR+1 D
.. S SITE=$S($L($G(^TMP("LRO",$J,D,SN,"facility"))):^("facility"),1:ORSITE)
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",1)="1^"_SITE ;Station ID*1*1
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",2)="2^"_$P(ORX0,U) ;collection date*2*2
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",3)="3^"_$P($P(ORX0,U,2),";",2) ;test name*3*3
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",4)="4^"_$P($P(ORX0,U,2),";") ;test ien*3*4
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",5)="5^"_"" ;critical value field (calculated)
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",6)="6^"_$P($P(ORX0,U,3),";",2) ;specimen name*6*6
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",7)="7^"_$P($P(ORX0,U,3),";") ;specimen ien*7*7
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",8)="8^"_$P($P(ORX0,U,6),";",2) ;provider name*9*8
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",9)="9^"_$P($P(ORX0,U,6),";") ;provider ien*10*9
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",10)="10^"_$P(ORX0,U,5) ;status*8*10
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",11)="11^"_$P(ORX0,U,9) ;available date/time*11*YES
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",12)="12^"_$P(ORX0,U,12) ;OE/RR order #*12*
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",13)="13^"_$P(ORX0,U,4) ;urgency*13* (not needed in any reports/can be deleted)
.. S ^TMP("ORDATA",$J,D,S,SN,"WP",14)="14^"_$P(ORX0,U,8) ;accession number*14* ((not needed in any reports/can be deleted)
.. K ^TMP("ORXPND",$J)
.. S RSLT="^TMP(""ORXPND"",$J)" D RESULT^ORWOR(.RSLT,DFN,$P(ORX0,U,12),$P(ORX0,U,12))
.. D SPMRG^ORDVU("^TMP(""ORXPND"","_$J_")","^TMP(""ORDATA"","_$J_","_D_","_S_","_SN_",""WP"",15)",15) ;Test Results*15*
.. K ^TMP("ORTXT",$J) S LST="^TMP(""ORTXT"",$J)" D DETAIL^ORWOR(.LST,$P(ORX0,U,12),DFN)
.. D SPMRG^ORDVU("^TMP(""ORTXT"","_$J_")","^TMP(""ORDATA"","_$J_","_D_","_S_","_SN_",""WP"",16)",16) ;order details*16*
.. I $O(@LST@(0))!($O(@RSLT@(0))) S ^TMP("ORDATA",$J,D,S,SN,"WP",17)="17^[+]" ;flag for details*17*YES
.. N TSTNM,TSTIEN,GOTIT,T,TT,STOP,FLAG
.. S TSTNM=$P($P(ORX0,U,2),";",2),TSTIEN=$P($P(ORX0,U,2),";")
.. S TSTNM=$S($L($P(^LAB(60,+TSTIEN,0),U))>25:$S($L($P($G(^(.1)),U)):$P(^(.1),U),1:$E($P(^(0),U),1,25)),1:$E($P(^(0),U),1,25))
.. S (I,GOTIT,STOP)=0,T="",TT=""
.. I '$O(^LAB(60,+TSTIEN,2,0)) D Q ;***Test is NOT a panel
... F S I=$O(^TMP("ORXPND",$J,I)) Q:'I S X=^(I,0) I X["H*"!(X["L*") D Q:GOTIT
.... I $P(X," ")=TSTNM S GOTIT=1,^TMP("ORDATA",$J,D,S,SN,"WP",5)="5^"_$S(X["H*":"H*",X["L*":"L*",1:"") Q
.. S (I,GOTIT)=0,(Y,FLAG)=""
.. I $O(^LAB(60,+TSTIEN,2,0)) S T=$O(^(0)),TT=$G(^(T,0)) D Q ;***Test is a panel
... I '$O(^LAB(60,+TSTIEN,2,T)) D Q ;If panel only has 1 test, treat like a cosmic test
.... N TSTNM S STOP=1
.... S TSTNM=$S($L($P(^LAB(60,+TT,0),U))>25:$S($L($P($G(^(.1)),U)):$P(^(.1),U),1:$E($P(^(0),U),1,25)),1:$E($P(^(0),U),1,25))
.... F S I=$O(^TMP("ORXPND",$J,I)) Q:'I S X=^(I,0) I X["H*"!(X["L*") D Q:GOTIT
..... I $P(X," ")=TSTNM S GOTIT=1,^TMP("ORDATA",$J,D,S,SN,"WP",5)="5^"_$S(X["H*":"H*",X["L*":"L*",1:"") Q
... Q:STOP
... D PANEL(TSTIEN)
... S ^TMP("ORDATA",$J,D,S,SN,"WP",5)="5^"_FLAG Q
;The following set of comments is for the Overview report
;Critical Value Flag **5
;Flags for Partial Results **11
;Details is test results **YES in same format as "All Tests By Date" with Release Date/Time, Reporting site, Site Code (facility) added
K ^TMP("LRO",$J),^TMP("ORTXT",$J),^TMP("ORSORT",$J),^TMP("ORXPND",$J)
S ROOT=$NA(^TMP("ORDATA",$J))
Q
PANEL(TEST) ;Check sub-panels for a match
;OR*3.0*534 - modified this section so that comment lines containing
;an L* and/or H* wouldn't flag as critical
N T,TT,TSTNM,X,I
S T=0
F S T=$O(^LAB(60,TEST,2,T)) Q:'T Q:FLAG="H* L*" S TT=+$G(^(T,0)) D
. I $O(^LAB(60,TT,2,0)) D PANEL(TT) Q:GOTIT
. S I=0,TSTNM=$S($L($P(^LAB(60,+TT,0),U))>25:$S($L($P($G(^(.1)),U)):$P(^(.1),U),1:$E($P(^(0),U),1,25)),1:$E($P(^(0),U),1,25))
. F S I=$O(^TMP("ORXPND",$J,I)) Q:'I S X=^(I,0) I $P(X," ")=TSTNM&(X["H*"!(X["L*")) D
.. S FLAG=$S(FLAG="H*"&(X["L*"):"H* L*",FLAG="L*"&(X["H*"):"H* L*",X["H*":"H*",X["L*":"L*",1:"*")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HORDV02C 5479 printed Oct 16, 2024@18:30:41 Page 2
ORDV02C ;SLC/DCM - OE/RR REPORT EXTRACTS ;MAY 17, 2024@15:40
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**350,423,377,534,603,610**;Dec 17, 1997;Build 11
+2 ;
+3 ; Reference to GCPR^OMGCOAS1 in ICR #3486
+4 ; Reference to ^TMP("60" in ICR #3486
+5 ; Reference to ^LAB(60 in ICR #2387
+6 ;
OV(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Lab Overview
+1 ;Acknowledging parameter input value in ORDEND DM-610
IF '$DATA(ORDEND)
SET ORDEND=9999999
+2 SET OROMEGA=ORDEND
+3 ; Call if FHIE station 200
IF $LENGTH($TEXT(GCPR^OMGCOAS1))
Begin DoDot:1
+4 NEW BEG,END,MAX
+5 if '$GET(ORALPHA)
QUIT
if '$GET(OROMEGA)
QUIT
+6 SET MAX=$SELECT(+$GET(ORMAX)>0:ORMAX,1:999)
+7 SET BEG=9999999-OROMEGA
SET END=9999999-ORALPHA
+8 DO GCPR^OMGCOAS1(DFN,"LRO",BEG,END,MAX)
End DoDot:1
+9 NEW D,SN,ORX0,MAX,GMTS1,GMTS2,GMTSBEG,GMTSEND,GMTSMERG,ORSITE,SITE,GO,SORT,STATUS,S,LST,RSLT,Y,IVSDT,IVEDT,I,X,ORCTR,ORSTOP
+10 if '$LENGTH(OREXT)
QUIT
+11 SET GO=$PIECE(OREXT,";")_"^"_$PIECE(OREXT,";",2)
+12 if '$LENGTH($TEXT(@GO))
QUIT
+13 SET GMTSBEG=0
SET GMTSEND=9999999
SET MAX=9999
SET GMTSMERG=1
+14 SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+15 KILL ^TMP("ORDATA",$JOB)
+16 IF '$LENGTH($TEXT(GCPR^OMGCOAS1))
Begin DoDot:1
+17 KILL ^TMP("LRO",$JOB),^TMP("ORTXT",$JOB),^TMP("ORSORT",$JOB),^TMP("ORXPND",$JOB)
+18 DO @GO
End DoDot:1
+19 ;IVEDT change to reverse date order DM-603
SET D=ORDBEG
SET IVSDT=ORDBEG
SET IVEDT=(9999999-ORDEND)
SET ORCTR=1
SET ORSTOP=0
+20 FOR
SET D=$ORDER(^TMP("ORSORT",$JOB,D))
if 'D!(D<IVEDT)!ORSTOP
QUIT
Begin DoDot:1
+21 SET S=0
FOR
SET S=$ORDER(^TMP("ORSORT",$JOB,D,S))
if 'S!ORSTOP
QUIT
SET SN=0
FOR
SET SN=$ORDER(^TMP("ORSORT",$JOB,D,S,SN))
if ORCTR>ORMAX
SET ORSTOP=1
if 'SN!ORSTOP
QUIT
SET ORX0=^(SN)
SET ORCTR=ORCTR+1
Begin DoDot:2
+22 SET SITE=$SELECT($LENGTH($GET(^TMP("LRO",$JOB,D,SN,"facility"))):^("facility"),1:ORSITE)
+23 ;Station ID*1*1
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",1)="1^"_SITE
+24 ;collection date*2*2
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",2)="2^"_$PIECE(ORX0,U)
+25 ;test name*3*3
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",3)="3^"_$PIECE($PIECE(ORX0,U,2),";",2)
+26 ;test ien*3*4
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",4)="4^"_$PIECE($PIECE(ORX0,U,2),";")
+27 ;critical value field (calculated)
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",5)="5^"_""
+28 ;specimen name*6*6
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",6)="6^"_$PIECE($PIECE(ORX0,U,3),";",2)
+29 ;specimen ien*7*7
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",7)="7^"_$PIECE($PIECE(ORX0,U,3),";")
+30 ;provider name*9*8
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",8)="8^"_$PIECE($PIECE(ORX0,U,6),";",2)
+31 ;provider ien*10*9
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",9)="9^"_$PIECE($PIECE(ORX0,U,6),";")
+32 ;status*8*10
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",10)="10^"_$PIECE(ORX0,U,5)
+33 ;available date/time*11*YES
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",11)="11^"_$PIECE(ORX0,U,9)
+34 ;OE/RR order #*12*
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",12)="12^"_$PIECE(ORX0,U,12)
+35 ;urgency*13* (not needed in any reports/can be deleted)
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",13)="13^"_$PIECE(ORX0,U,4)
+36 ;accession number*14* ((not needed in any reports/can be deleted)
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",14)="14^"_$PIECE(ORX0,U,8)
+37 KILL ^TMP("ORXPND",$JOB)
+38 SET RSLT="^TMP(""ORXPND"",$J)"
DO RESULT^ORWOR(.RSLT,DFN,$PIECE(ORX0,U,12),$PIECE(ORX0,U,12))
+39 ;Test Results*15*
DO SPMRG^ORDVU("^TMP(""ORXPND"","_$JOB_")","^TMP(""ORDATA"","_$JOB_","_D_","_S_","_SN_",""WP"",15)",15)
+40 KILL ^TMP("ORTXT",$JOB)
SET LST="^TMP(""ORTXT"",$J)"
DO DETAIL^ORWOR(.LST,$PIECE(ORX0,U,12),DFN)
+41 ;order details*16*
DO SPMRG^ORDVU("^TMP(""ORTXT"","_$JOB_")","^TMP(""ORDATA"","_$JOB_","_D_","_S_","_SN_",""WP"",16)",16)
+42 ;flag for details*17*YES
IF $ORDER(@LST@(0))!($ORDER(@RSLT@(0)))
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",17)="17^[+]"
+43 NEW TSTNM,TSTIEN,GOTIT,T,TT,STOP,FLAG
+44 SET TSTNM=$PIECE($PIECE(ORX0,U,2),";",2)
SET TSTIEN=$PIECE($PIECE(ORX0,U,2),";")
+45 SET TSTNM=$SELECT($LENGTH($PIECE(^LAB(60,+TSTIEN,0),U))>25:$SELECT($LENGTH($PIECE($GET(^(.1)),U)):$PIECE(^(.1),U),1:$EXTRACT($PIECE(^(0),U),1,25)),1:$EXTRACT($PIECE(^(0),U),1,25))
+46 SET (I,GOTIT,STOP)=0
SET T=""
SET TT=""
+47 ;***Test is NOT a panel
IF '$ORDER(^LAB(60,+TSTIEN,2,0))
Begin DoDot:3
+48 FOR
SET I=$ORDER(^TMP("ORXPND",$JOB,I))
if 'I
QUIT
SET X=^(I,0)
IF X["H*"!(X["L*")
Begin DoDot:4
+49 IF $PIECE(X," ")=TSTNM
SET GOTIT=1
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",5)="5^"_$SELECT(X["H*":"H*",X["L*":"L*",1:"")
QUIT
End DoDot:4
if GOTIT
QUIT
End DoDot:3
QUIT
+50 SET (I,GOTIT)=0
SET (Y,FLAG)=""
+51 ;***Test is a panel
IF $ORDER(^LAB(60,+TSTIEN,2,0))
SET T=$ORDER(^(0))
SET TT=$GET(^(T,0))
Begin DoDot:3
+52 ;If panel only has 1 test, treat like a cosmic test
IF '$ORDER(^LAB(60,+TSTIEN,2,T))
Begin DoDot:4
+53 NEW TSTNM
SET STOP=1
+54 SET TSTNM=$SELECT($LENGTH($PIECE(^LAB(60,+TT,0),U))>25:$SELECT($LENGTH($PIECE($GET(^(.1)),U)):$PIECE(^(.1),U),1:$EXTRACT($PIECE(^(0),U),1,25)),1:$EXTRACT($PIECE(^(0),U),1,25))
+55 FOR
SET I=$ORDER(^TMP("ORXPND",$JOB,I))
if 'I
QUIT
SET X=^(I,0)
IF X["H*"!(X["L*")
Begin DoDot:5
+56 IF $PIECE(X," ")=TSTNM
SET GOTIT=1
SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",5)="5^"_$SELECT(X["H*":"H*",X["L*":"L*",1:"")
QUIT
End DoDot:5
if GOTIT
QUIT
End DoDot:4
QUIT
+57 if STOP
QUIT
+58 DO PANEL(TSTIEN)
+59 SET ^TMP("ORDATA",$JOB,D,S,SN,"WP",5)="5^"_FLAG
QUIT
End DoDot:3
QUIT
End DoDot:2
End DoDot:1
+60 ;The following set of comments is for the Overview report
+61 ;Critical Value Flag **5
+62 ;Flags for Partial Results **11
+63 ;Details is test results **YES in same format as "All Tests By Date" with Release Date/Time, Reporting site, Site Code (facility) added
+64 KILL ^TMP("LRO",$JOB),^TMP("ORTXT",$JOB),^TMP("ORSORT",$JOB),^TMP("ORXPND",$JOB)
+65 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+66 QUIT
PANEL(TEST) ;Check sub-panels for a match
+1 ;OR*3.0*534 - modified this section so that comment lines containing
+2 ;an L* and/or H* wouldn't flag as critical
+3 NEW T,TT,TSTNM,X,I
+4 SET T=0
+5 FOR
SET T=$ORDER(^LAB(60,TEST,2,T))
if 'T
QUIT
if FLAG="H* L*"
QUIT
SET TT=+$GET(^(T,0))
Begin DoDot:1
+6 IF $ORDER(^LAB(60,TT,2,0))
DO PANEL(TT)
if GOTIT
QUIT
+7 SET I=0
SET TSTNM=$SELECT($LENGTH($PIECE(^LAB(60,+TT,0),U))>25:$SELECT($LENGTH($PIECE($GET(^(.1)),U)):$PIECE(^(.1),U),1:$EXTRACT($PIECE(^(0),U),1,25)),1:$EXTRACT($PIECE(^(0),U),1,25))
+8 FOR
SET I=$ORDER(^TMP("ORXPND",$JOB,I))
if 'I
QUIT
SET X=^(I,0)
IF $PIECE(X," ")=TSTNM&(X["H*"!(X["L*"))
Begin DoDot:2
+9 SET FLAG=$SELECT(FLAG="H*"&(X["L*"):"H* L*",FLAG="L*"&(X["H*"):"H* L*",X["H*":"H*",X["L*":"L*",1:"*")
End DoDot:2
End DoDot:1
+10 QUIT