PSIVBCID ;BIR/JLC - BAR CODE ID SUBROUTINES ;16 FEB 01
;;5.0;INPATIENT MEDICATIONS;**58,80,146,397**;16 DEC 97;Build 7
;
; Reference to ^PS(55 supported by DBIA 2191.
;
BCMA(PSJDFN,PSJON,PSIVCTD,PSIV1,PSIV2,PSIVNOL) ;determine unique ID# for bar code labels and update initial data for bar code ID
;Input: PSJDFN - patient's DFN
; PSJON - patient's ON - order number
; PSJBCID - bar code ID to be filed
; PSIVCTD - the $D(PSIVCT) from the calling routine, if PSIVCT was defined, then the labels won't be counted
; PSIV1 - current label number
; PSIV2 -
; PSIVNOL - total number of labels
;
;Output: PSJBCID - unique ID# for this label
; format: DFN_"A"_ON"_seq#
; If unable to calculate ID #, return "ERROR"
;
S PSIV1=$G(PSIV1),PSIV2=$G(PSIV2),PSIVNOL=$G(PSIVNOL)
L +^PS(55,PSJDFN,"IVBCMA"):10
E W "Waiting for lock..." F L +^PS(55,PSJDFN,"IVBCMA"):5 Q:$T W "."
S SEQ=$O(^PS(55,PSJDFN,"IVBCMA"," "),-1)
S PSJBCID=PSJDFN_"V"_(SEQ+1)
D UP1^PSIVBCID(DFN,ON,PSJBCID,PSIVCTD,PSIV1,PSIV2,PSIVNOL)
L -^PS(55,PSJDFN,"IVBCMA")
Q PSJBCID
;
UP1(DFN,ON,PSJBCID,PSIVCTD,PSIV1,PSIV2,PSIVNOL) ;update initial data for bar code ID
;Input: DFN - patient's IEN
; ON - Order number for this bar code ID
; PSJBCID - bar code ID to be filed
; PSIVCTD - the $D(PSIVCT) from the calling routine, if PSIVCT was defined, then the labels won't be counted
; PSIV1 - current label number
; PSIV2 -
; PSIVNOL - total number of labels
;
;Output: PSJBLN - label sequence number
;
S PSIV1=$G(PSIV1),PSIV2=$G(PSIV2),PSIVNOL=$G(PSIVNOL)
K DIC,DIE,DO S DIC(0)="L",DA(1)=DFN,X=PSJBCID,DIC="^PS(55,"_DA(1)_",""IVBCMA""," D FILE^DICN
K DA,DR,DIE S DIE=DIC,DA=+Y,DA(1)=DFN,PSJBLN=DA D NOW^%DTC
S DR=".02////"_+ON_";3////"_$S(PSIVCTD:0,1:1)_";4////"_%_";6////"_PSIV1_"["_$S(PSIV1:PSIVNOL,1:PSIV2)_"]" D ^DIE
K DIC,DIE,D0,DA,DR
Q
UP2(DFN,PSJBLN,PSIV,YY) ;update additive data for bar code ID
;
;Input: DFN - Patient's IEN
; PSJBLN - The IEN for the bar code ID
; PSIV - the sequence number for this additive
; YY - ADDITIVE ^ STRENGTH ^ BOTTLE
;
K DA,DR,DIC,DO S DIC(0)="L",DA(1)=DFN,DA(2)=PSJBLN,X=PSIV,DIC="^PS(55,"_DA(1)_",""IVBCMA"","_DA(2)_",""AD""," D FILE^DICN
K DA,DR,DIE S DIE=DIC,DA=+Y,DA(1)=PSJBLN,DA(2)=DFN S DR=".01////"_$P(YY,U)_";1////"_$P(YY,U,2)_";2////"_$P(YY,U,3) D ^DIE
K DA,DR,DIC,D0,DIE
Q
;
UP3(DFN,PSJBLN,PSIV,YY) ;update solution data for bar code ID
;
;Input: DFN - Patient's IEN
; PSJBLN - The IEN for the bar code ID
; PSIV - the sequence number for this solution
; YY - SOLUTION ^ VOLUME
;
K DA,DR,DIC,DO S DIC(0)="L",DA(1)=DFN,DA(2)=PSJBLN,X=$P(PSIV,U),DIC="^PS(55,"_DA(1)_",""IVBCMA"","_DA(2)_",""SOL""," D FILE^DICN
K DA,DR,DIE S DIE=DIC,DA=+Y,DA(1)=PSJBLN,DA(2)=DFN S DR=".01////"_$P(YY,U)_";1////"_$P(YY,U,2) D ^DIE
K DA,DR,DIC,D0,DIE
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSIVBCID 3065 printed Dec 13, 2024@02:03:55 Page 2
PSIVBCID ;BIR/JLC - BAR CODE ID SUBROUTINES ;16 FEB 01
+1 ;;5.0;INPATIENT MEDICATIONS;**58,80,146,397**;16 DEC 97;Build 7
+2 ;
+3 ; Reference to ^PS(55 supported by DBIA 2191.
+4 ;
BCMA(PSJDFN,PSJON,PSIVCTD,PSIV1,PSIV2,PSIVNOL) ;determine unique ID# for bar code labels and update initial data for bar code ID
+1 ;Input: PSJDFN - patient's DFN
+2 ; PSJON - patient's ON - order number
+3 ; PSJBCID - bar code ID to be filed
+4 ; PSIVCTD - the $D(PSIVCT) from the calling routine, if PSIVCT was defined, then the labels won't be counted
+5 ; PSIV1 - current label number
+6 ; PSIV2 -
+7 ; PSIVNOL - total number of labels
+8 ;
+9 ;Output: PSJBCID - unique ID# for this label
+10 ; format: DFN_"A"_ON"_seq#
+11 ; If unable to calculate ID #, return "ERROR"
+12 ;
+13 SET PSIV1=$GET(PSIV1)
SET PSIV2=$GET(PSIV2)
SET PSIVNOL=$GET(PSIVNOL)
+14 LOCK +^PS(55,PSJDFN,"IVBCMA"):10
+15 IF '$TEST
WRITE "Waiting for lock..."
FOR
LOCK +^PS(55,PSJDFN,"IVBCMA"):5
if $TEST
QUIT
WRITE "."
+16 SET SEQ=$ORDER(^PS(55,PSJDFN,"IVBCMA"," "),-1)
+17 SET PSJBCID=PSJDFN_"V"_(SEQ+1)
+18 DO UP1^PSIVBCID(DFN,ON,PSJBCID,PSIVCTD,PSIV1,PSIV2,PSIVNOL)
+19 LOCK -^PS(55,PSJDFN,"IVBCMA")
+20 QUIT PSJBCID
+21 ;
UP1(DFN,ON,PSJBCID,PSIVCTD,PSIV1,PSIV2,PSIVNOL) ;update initial data for bar code ID
+1 ;Input: DFN - patient's IEN
+2 ; ON - Order number for this bar code ID
+3 ; PSJBCID - bar code ID to be filed
+4 ; PSIVCTD - the $D(PSIVCT) from the calling routine, if PSIVCT was defined, then the labels won't be counted
+5 ; PSIV1 - current label number
+6 ; PSIV2 -
+7 ; PSIVNOL - total number of labels
+8 ;
+9 ;Output: PSJBLN - label sequence number
+10 ;
+11 SET PSIV1=$GET(PSIV1)
SET PSIV2=$GET(PSIV2)
SET PSIVNOL=$GET(PSIVNOL)
+12 KILL DIC,DIE,DO
SET DIC(0)="L"
SET DA(1)=DFN
SET X=PSJBCID
SET DIC="^PS(55,"_DA(1)_",""IVBCMA"","
DO FILE^DICN
+13 KILL DA,DR,DIE
SET DIE=DIC
SET DA=+Y
SET DA(1)=DFN
SET PSJBLN=DA
DO NOW^%DTC
+14 SET DR=".02////"_+ON_";3////"_$SELECT(PSIVCTD:0,1:1)_";4////"_%_";6////"_PSIV1_"["_$SELECT(PSIV1:PSIVNOL,1:PSIV2)_"]"
DO ^DIE
+15 KILL DIC,DIE,D0,DA,DR
+16 QUIT
UP2(DFN,PSJBLN,PSIV,YY) ;update additive data for bar code ID
+1 ;
+2 ;Input: DFN - Patient's IEN
+3 ; PSJBLN - The IEN for the bar code ID
+4 ; PSIV - the sequence number for this additive
+5 ; YY - ADDITIVE ^ STRENGTH ^ BOTTLE
+6 ;
+7 KILL DA,DR,DIC,DO
SET DIC(0)="L"
SET DA(1)=DFN
SET DA(2)=PSJBLN
SET X=PSIV
SET DIC="^PS(55,"_DA(1)_",""IVBCMA"","_DA(2)_",""AD"","
DO FILE^DICN
+8 KILL DA,DR,DIE
SET DIE=DIC
SET DA=+Y
SET DA(1)=PSJBLN
SET DA(2)=DFN
SET DR=".01////"_$PIECE(YY,U)_";1////"_$PIECE(YY,U,2)_";2////"_$PIECE(YY,U,3)
DO ^DIE
+9 KILL DA,DR,DIC,D0,DIE
+10 QUIT
+11 ;
UP3(DFN,PSJBLN,PSIV,YY) ;update solution data for bar code ID
+1 ;
+2 ;Input: DFN - Patient's IEN
+3 ; PSJBLN - The IEN for the bar code ID
+4 ; PSIV - the sequence number for this solution
+5 ; YY - SOLUTION ^ VOLUME
+6 ;
+7 KILL DA,DR,DIC,DO
SET DIC(0)="L"
SET DA(1)=DFN
SET DA(2)=PSJBLN
SET X=$PIECE(PSIV,U)
SET DIC="^PS(55,"_DA(1)_",""IVBCMA"","_DA(2)_",""SOL"","
DO FILE^DICN
+8 KILL DA,DR,DIE
SET DIE=DIC
SET DA=+Y
SET DA(1)=PSJBLN
SET DA(2)=DFN
SET DR=".01////"_$PIECE(YY,U)_";1////"_$PIECE(YY,U,2)
DO ^DIE
+9 KILL DA,DR,DIC,D0,DIE
+10 QUIT