source: WorldVistAEHR/trunk/r/NOIS-FSC/FSCUC.m@ 1361

Last change on this file since 1361 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 1022 bytes
RevLine 
[613]1FSCUC ;SLC/STAFF-NOIS Utilities Count ;1/17/98 14:29
2 ;;1.1;NOIS;;Sep 06, 1998
3 ;
4CALLNUM(SITE0,DATE,CALLREF,OK) ; from FSCELID, FSCRPCNC
5 ; constructs call number from (site,date)
6 N COUNT S OK=0
7 S CALLREF=""
8 I '$L(SITE0) Q
9 I 'DATE Q
10 D COUNT(DATE,.COUNT,.OK)
11 I 'OK Q
12 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
13 Q
14 ;
15COUNT(DATE,COUNT,OK) ;returns the next available counting number for
16 N DA,DIK,NUM S OK=1
17 S DATE=$E(DATE,1,5),NUM=+$O(^FSCD("COUNT","B",DATE,0))
18 D
19 .I 'NUM D Q
20 ..L +^FSCD("COUNT"):30 I '$T S OK=0 Q
21 ..S COUNT=1,NUM=1+$P(^FSCD("COUNT",0),U,3)
22 ..F Q:'$D(^FSCD("COUNT",NUM)) S NUM=NUM+1
23 ..S $P(^FSCD("COUNT",0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1,^(NUM,0)=DATE_U_1
24 ..S DA=NUM,DIK="^FSCD(""COUNT""," D IX1^DIK
25 ..L -^FSCD("COUNT")
26 .L +^FSCD("COUNT",NUM):30 I '$T S OK=0 Q
27 .S COUNT=$P(^FSCD("COUNT",NUM,0),U,2)+1,$P(^(0),U,2)=COUNT
28 .L -^FSCD("COUNT",NUM)
29 I 'OK Q
30 S COUNT=$TR($J(COUNT,4)," ",0)
31 Q
Note: See TracBrowser for help on using the repository browser.