VistA-WorldVistAEHR/r/ASISTS-OOPS/OOPSCSN.m

20 lines
556 B
Mathematica

OOPSCSN ;HINES CIOFO/WAA-Finding case number for stub record ;3/5/98
;;2.0;ASISTS;;Jun 03, 2002
;;
FYEAR(DATE) ; FIND CURRENT FISCAL YEAR FOR A GIVEN DATE
; DATE IS THE DATE THAT THE DATE WAS PASSED IN.
N FYEAR,FYDATE
S FYEAR=1700+$E(DATE,1,3)
S FYDATE=$E(DATE,1,3)_"1001" ;FISICAL DATE IF CURRENT YEAR
I DATE'<FYDATE S FYEAR=FYEAR+1
Q FYEAR
;
NEWR(FYEAR) ;
N NUM,SEQ
S NUM="",NUM=$O(^OOPS(2260,"B",NUM),-1)
I $E(NUM,1,4)'=FYEAR S NUM=FYEAR_"-00000"
S SEQ=+$E(NUM,6,10)
S SEQ=SEQ+1 F I=1:1:5-$L(SEQ) S SEQ=0_SEQ
S NUM=$E(NUM,1,5)_SEQ
Q NUM