PSBOPM1 ;BIRMINGHAM/BSR-BCMA OIT HISTORY API ;Oct 2005
;;3.0;BAR CODE MED ADMIN;**17,81**;Mar 2004;Build 6
;;Per VA Directive 6402, this routine should not be modified.
;
; Reference/IA
; FILE 53.79
; X-REF AOIP
; X-REF AOIP3
; X-REF AOIP4
;
;
GETORD(PSBORDNM) ;
N XA,NDE
S PSBORD=0,XA=PSBORDNM,PSBDT=$P($G(PSBSTRT),"."),NDE=.1 ;start with orders from start date/time of report, PSB*3*81
Q:PSBORDNM="" PSBORD
Q:'$D(^PSB(53.79,"AOIP",DFN,XA)) PSBORD
F S PSBDT=$O(^PSB(53.79,"AOIP",DFN,XA,PSBDT)) Q:PSBDT="" D
.S PSBIEN="" F S PSBIEN=$O(^PSB(53.79,"AOIP",DFN,XA,PSBDT,PSBIEN)) Q:PSBIEN="" D
..Q:$P($G(^PSB(53.79,PSBIEN,0)),U,9)="N"
..Q:'$D(^PSB(53.79,PSBIEN,NDE))
..S PSBORD=$P(^PSB(53.79,PSBIEN,NDE),U)
..I PSBORD S PSBORDNM=PSBORD
..S:'PSBORD!(PSBORD="") PSBORD=0,TMP("PSBOIS",$J,XA)=""
Q PSBORD
;
FINDIENS ; USE PSBOIS,PSBADDS AND PSBSOLS TO FIND ALL IENS FOR THE RPT
;SEARCH FOR UNIT DOSE IENS
I $D(TMP("PSBOIS",$J)) S XA="" F S XA=$O(TMP("PSBOIS",$J,XA)) Q:XA="" D
.S PSBDT="" F S PSBDT=$O(^PSB(53.79,"AOIP",DFN,XA,PSBDT)) Q:PSBDT="" D
..Q:PSBDT>PSBSTOP
..Q:PSBDT<PSBSTRT
..S PSBIEN="" F S PSBIEN=$O(^PSB(53.79,"AOIP",DFN,XA,PSBDT,PSBIEN)) Q:PSBIEN="" D
...Q:$P(^PSB(53.79,PSBIEN,0),U,9)="N"
...S TMP("PSBIENS",$J,"UD",$$GET1^DIQ(53.79,PSBIEN_",",.06,"I"),PSBIEN)=""
;
;SEARCH FOR ADDITIVES
I $D(TMP("PSBADDS",$J)) S XA="" F S XA=$O(TMP("PSBADDS",$J,XA)) Q:XA="" D
.S PSBIEN="" F S PSBIEN=$O(^PSB(53.79,"AOIP3",DFN,PSBIEN)) Q:PSBIEN="" D
..S XB="" F S XB=$O(^PSB(53.79,"AOIP3",DFN,PSBIEN,XB)) Q:XB="" D
...Q:XB'=XA
...Q:$P(^PSB(53.79,PSBIEN,0),U,9)="N"
...I $P(^PSB(53.79,PSBIEN,0),"^",6)>PSBSTRT,$P(^PSB(53.79,PSBIEN,0),"^",6)<PSBSTOP D
....S TMP("PSBIENS",$J,"ADD",$$GET1^DIQ(53.79,PSBIEN_",",.06,"I"),PSBIEN)=""
....S TMP("PSBADDS",$J,XA)=1
;
;SEARCH FOR SOLUTIONS
I $D(TMP("PSBSOLS",$J)) S XA="" F S XA=$O(TMP("PSBSOLS",$J,XA)) Q:XA="" D
.S PSBIEN="" F S PSBIEN=$O(^PSB(53.79,"AOIP4",DFN,PSBIEN)) Q:PSBIEN="" D
..S XB="" F S XB=$O(^PSB(53.79,"AOIP4",DFN,PSBIEN,XB)) Q:XB="" D
...Q:XB'=XA
...Q:$P(^PSB(53.79,PSBIEN,0),U,9)="N"
...I $P(^PSB(53.79,PSBIEN,0),"^",6)>PSBSTRT,$P(^PSB(53.79,PSBIEN,0),"^",6)<PSBSTOP D
....S TMP("PSBIENS",$J,"SOL",$$GET1^DIQ(53.79,PSBIEN_",",.06,"I"),PSBIEN)=""
....S TMP("PSBSOLS",$J,XA)=1
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSBOPM1 2359 printed Nov 22, 2024@16:51:05 Page 2
PSBOPM1 ;BIRMINGHAM/BSR-BCMA OIT HISTORY API ;Oct 2005
+1 ;;3.0;BAR CODE MED ADMIN;**17,81**;Mar 2004;Build 6
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; Reference/IA
+5 ; FILE 53.79
+6 ; X-REF AOIP
+7 ; X-REF AOIP3
+8 ; X-REF AOIP4
+9 ;
+10 ;
GETORD(PSBORDNM) ;
+1 NEW XA,NDE
+2 ;start with orders from start date/time of report, PSB*3*81
SET PSBORD=0
SET XA=PSBORDNM
SET PSBDT=$PIECE($GET(PSBSTRT),".")
SET NDE=.1
+3 if PSBORDNM=""
QUIT PSBORD
+4 if '$DATA(^PSB(53.79,"AOIP",DFN,XA))
QUIT PSBORD
+5 FOR
SET PSBDT=$ORDER(^PSB(53.79,"AOIP",DFN,XA,PSBDT))
if PSBDT=""
QUIT
Begin DoDot:1
+6 SET PSBIEN=""
FOR
SET PSBIEN=$ORDER(^PSB(53.79,"AOIP",DFN,XA,PSBDT,PSBIEN))
if PSBIEN=""
QUIT
Begin DoDot:2
+7 if $PIECE($GET(^PSB(53.79,PSBIEN,0)),U,9)="N"
QUIT
+8 if '$DATA(^PSB(53.79,PSBIEN,NDE))
QUIT
+9 SET PSBORD=$PIECE(^PSB(53.79,PSBIEN,NDE),U)
+10 IF PSBORD
SET PSBORDNM=PSBORD
+11 if 'PSBORD!(PSBORD="")
SET PSBORD=0
SET TMP("PSBOIS",$JOB,XA)=""
End DoDot:2
End DoDot:1
+12 QUIT PSBORD
+13 ;
FINDIENS ; USE PSBOIS,PSBADDS AND PSBSOLS TO FIND ALL IENS FOR THE RPT
+1 ;SEARCH FOR UNIT DOSE IENS
+2 IF $DATA(TMP("PSBOIS",$JOB))
SET XA=""
FOR
SET XA=$ORDER(TMP("PSBOIS",$JOB,XA))
if XA=""
QUIT
Begin DoDot:1
+3 SET PSBDT=""
FOR
SET PSBDT=$ORDER(^PSB(53.79,"AOIP",DFN,XA,PSBDT))
if PSBDT=""
QUIT
Begin DoDot:2
+4 if PSBDT>PSBSTOP
QUIT
+5 if PSBDT<PSBSTRT
QUIT
+6 SET PSBIEN=""
FOR
SET PSBIEN=$ORDER(^PSB(53.79,"AOIP",DFN,XA,PSBDT,PSBIEN))
if PSBIEN=""
QUIT
Begin DoDot:3
+7 if $PIECE(^PSB(53.79,PSBIEN,0),U,9)="N"
QUIT
+8 SET TMP("PSBIENS",$JOB,"UD",$$GET1^DIQ(53.79,PSBIEN_",",.06,"I"),PSBIEN)=""
End DoDot:3
End DoDot:2
End DoDot:1
+9 ;
+10 ;SEARCH FOR ADDITIVES
+11 IF $DATA(TMP("PSBADDS",$JOB))
SET XA=""
FOR
SET XA=$ORDER(TMP("PSBADDS",$JOB,XA))
if XA=""
QUIT
Begin DoDot:1
+12 SET PSBIEN=""
FOR
SET PSBIEN=$ORDER(^PSB(53.79,"AOIP3",DFN,PSBIEN))
if PSBIEN=""
QUIT
Begin DoDot:2
+13 SET XB=""
FOR
SET XB=$ORDER(^PSB(53.79,"AOIP3",DFN,PSBIEN,XB))
if XB=""
QUIT
Begin DoDot:3
+14 if XB'=XA
QUIT
+15 if $PIECE(^PSB(53.79,PSBIEN,0),U,9)="N"
QUIT
+16 IF $PIECE(^PSB(53.79,PSBIEN,0),"^",6)>PSBSTRT
IF $PIECE(^PSB(53.79,PSBIEN,0),"^",6)<PSBSTOP
Begin DoDot:4
+17 SET TMP("PSBIENS",$JOB,"ADD",$$GET1^DIQ(53.79,PSBIEN_",",.06,"I"),PSBIEN)=""
+18 SET TMP("PSBADDS",$JOB,XA)=1
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+19 ;
+20 ;SEARCH FOR SOLUTIONS
+21 IF $DATA(TMP("PSBSOLS",$JOB))
SET XA=""
FOR
SET XA=$ORDER(TMP("PSBSOLS",$JOB,XA))
if XA=""
QUIT
Begin DoDot:1
+22 SET PSBIEN=""
FOR
SET PSBIEN=$ORDER(^PSB(53.79,"AOIP4",DFN,PSBIEN))
if PSBIEN=""
QUIT
Begin DoDot:2
+23 SET XB=""
FOR
SET XB=$ORDER(^PSB(53.79,"AOIP4",DFN,PSBIEN,XB))
if XB=""
QUIT
Begin DoDot:3
+24 if XB'=XA
QUIT
+25 if $PIECE(^PSB(53.79,PSBIEN,0),U,9)="N"
QUIT
+26 IF $PIECE(^PSB(53.79,PSBIEN,0),"^",6)>PSBSTRT
IF $PIECE(^PSB(53.79,PSBIEN,0),"^",6)<PSBSTOP
Begin DoDot:4
+27 SET TMP("PSBIENS",$JOB,"SOL",$$GET1^DIQ(53.79,PSBIEN_",",.06,"I"),PSBIEN)=""
+28 SET TMP("PSBSOLS",$JOB,XA)=1
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+29 QUIT
+30 ;