FSCUC ;SLC/STAFF-NOIS Utilities Count ;1/17/98 14:29
;;1.1;NOIS;;Sep 06, 1998
;
CALLNUM(SITE0,DATE,CALLREF,OK) ; from FSCELID, FSCRPCNC
; constructs call number from (site,date)
N COUNT S OK=0
S CALLREF=""
I '$L(SITE0) Q
I 'DATE Q
D COUNT(DATE,.COUNT,.OK)
I 'OK Q
S CALLREF=$S($L($P(SITE0,U,3)):$P(SITE0,U,3),1:"ZZZ")_"-"_$E(DATE,4,5)_$E(DATE,2,3)_"-"_$S($P(SITE0,U,11):$P(SITE0,U,11),1:"N")_COUNT
Q
;
COUNT(DATE,COUNT,OK) ;returns the next available counting number for
N DA,DIK,NUM S OK=1
S DATE=$E(DATE,1,5),NUM=+$O(^FSCD("COUNT","B",DATE,0))
D
.I 'NUM D Q
..L +^FSCD("COUNT"):30 I '$T S OK=0 Q
..S COUNT=1,NUM=1+$P(^FSCD("COUNT",0),U,3)
..F Q:'$D(^FSCD("COUNT",NUM)) S NUM=NUM+1
..S $P(^FSCD("COUNT",0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1,^(NUM,0)=DATE_U_1
..S DA=NUM,DIK="^FSCD(""COUNT""," D IX1^DIK
..L -^FSCD("COUNT")
.L +^FSCD("COUNT",NUM):30 I '$T S OK=0 Q
.S COUNT=$P(^FSCD("COUNT",NUM,0),U,2)+1,$P(^(0),U,2)=COUNT
.L -^FSCD("COUNT",NUM)
I 'OK Q
S COUNT=$TR($J(COUNT,4)," ",0)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HFSCUC 1053 printed Dec 13, 2024@02:20:22 Page 2
FSCUC ;SLC/STAFF-NOIS Utilities Count ;1/17/98 14:29
+1 ;;1.1;NOIS;;Sep 06, 1998
+2 ;
CALLNUM(SITE0,DATE,CALLREF,OK) ; from FSCELID, FSCRPCNC
+1 ; constructs call number from (site,date)
+2 NEW COUNT
SET OK=0
+3 SET CALLREF=""
+4 IF '$LENGTH(SITE0)
QUIT
+5 IF 'DATE
QUIT
+6 DO COUNT(DATE,.COUNT,.OK)
+7 IF 'OK
QUIT
+8 SET CALLREF=$SELECT($LENGTH($PIECE(SITE0,U,3)):$PIECE(SITE0,U,3),1:"ZZZ")_"-"_$EXTRACT(DATE,4,5)_$EXTRACT(DATE,2,3)_"-"_$SELECT($PIECE(SITE0,U,11):$PIECE(SITE0,U,11),1:"N")_COUNT
+9 QUIT
+10 ;
COUNT(DATE,COUNT,OK) ;returns the next available counting number for
+1 NEW DA,DIK,NUM
SET OK=1
+2 SET DATE=$EXTRACT(DATE,1,5)
SET NUM=+$ORDER(^FSCD("COUNT","B",DATE,0))
+3 Begin DoDot:1
+4 IF 'NUM
Begin DoDot:2
+5 LOCK +^FSCD("COUNT"):30
IF '$TEST
SET OK=0
QUIT
+6 SET COUNT=1
SET NUM=1+$PIECE(^FSCD("COUNT",0),U,3)
+7 FOR
if '$DATA(^FSCD("COUNT",NUM))
QUIT
SET NUM=NUM+1
+8 SET $PIECE(^FSCD("COUNT",0),U,3)=NUM
SET $PIECE(^(0),U,4)=$PIECE(^(0),U,4)+1
SET ^(NUM,0)=DATE_U_1
+9 SET DA=NUM
SET DIK="^FSCD(""COUNT"","
DO IX1^DIK
+10 LOCK -^FSCD("COUNT")
End DoDot:2
QUIT
+11 LOCK +^FSCD("COUNT",NUM):30
IF '$TEST
SET OK=0
QUIT
+12 SET COUNT=$PIECE(^FSCD("COUNT",NUM,0),U,2)+1
SET $PIECE(^(0),U,2)=COUNT
+13 LOCK -^FSCD("COUNT",NUM)
End DoDot:1
+14 IF 'OK
QUIT
+15 SET COUNT=$TRANSLATE($JUSTIFY(COUNT,4)," ",0)
+16 QUIT