PXRMMATH ;SLC/PKR - Math utility routines. ;07/30/2010
;;2.0;CLINICAL REMINDERS;**18**;Feb 04, 2005;Build 152
;
;=================================
RANDOM(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
;VA-RANDOM NUMBER computed finding.
N DIV,IND,LB,OFFSET,NDD,NOW,RANGE,UB
S LB=+$P(TEST,U,1),UB=+$P(TEST,U,2),NDD=+$P(TEST,U,3)
I (LB[".")!(UB[".") S NFOUND=0 Q
I UB<LB S NFOUND=0 Q
S NOW=$$NOW^PXRMDATE
S NFOUND=NGET
S OFFSET=-LB
S DIV=10**NDD
S RANGE=DIV*(UB+OFFSET)+1
S TEXT(1)="Lower bound = "_LB_" Upper bound = "_UB_", "_NDD_" decimal digits"
F IND=1:1:NGET D
. S TEST(IND)=1
. S DATA(IND,"VALUE")=($R(RANGE)/DIV)-OFFSET
. S DATE(IND)=NOW
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXRMMATH 690 printed Nov 22, 2024@16:56:52 Page 2
PXRMMATH ;SLC/PKR - Math utility routines. ;07/30/2010
+1 ;;2.0;CLINICAL REMINDERS;**18**;Feb 04, 2005;Build 152
+2 ;
+3 ;=================================
RANDOM(DFN,NGET,BDT,EDT,NFOUND,TEST,DATE,DATA,TEXT) ;
+1 ;VA-RANDOM NUMBER computed finding.
+2 NEW DIV,IND,LB,OFFSET,NDD,NOW,RANGE,UB
+3 SET LB=+$PIECE(TEST,U,1)
SET UB=+$PIECE(TEST,U,2)
SET NDD=+$PIECE(TEST,U,3)
+4 IF (LB[".")!(UB[".")
SET NFOUND=0
QUIT
+5 IF UB<LB
SET NFOUND=0
QUIT
+6 SET NOW=$$NOW^PXRMDATE
+7 SET NFOUND=NGET
+8 SET OFFSET=-LB
+9 SET DIV=10**NDD
+10 SET RANGE=DIV*(UB+OFFSET)+1
+11 SET TEXT(1)="Lower bound = "_LB_" Upper bound = "_UB_", "_NDD_" decimal digits"
+12 FOR IND=1:1:NGET
Begin DoDot:1
+13 SET TEST(IND)=1
+14 SET DATA(IND,"VALUE")=($RANDOM(RANGE)/DIV)-OFFSET
+15 SET DATE(IND)=NOW
End DoDot:1
+16 QUIT
+17 ;