Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ACRFNEW1

ACRFNEW1.m

Go to the documentation of this file.
ACRFNEW1 ;IHS/OIRM/DSD/THL,AEF - CREATE NEW DOCUMENT - UTILITY; [ 10/27/2004   4:15 PM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**14**;NOV 05, 2001
 ;;UTILITY ROUTINE TO CREATE NEW DOCUMENTS
 ;CALLNUM ;EP;CALCULATE CALL NUMBER ;OLD CODE ACR*2.1*14.03 IM13538
 ;N ACRTCALL
 ;L +^ACRDOC(ACRBPA,0):4
 ;S ACRCALL=$P(^ACRDOC(ACRBPA,0),U,20)
 ;D NUM
 ;I ACRCALL>ACRTCALL S ACRTCALL=ACRCALL
 ;I ACRTCALL<100 S ACRCALL=ACRTCALL+1
 ;E  I ACRTCALL>99,ACRCALL'?1U1N&(ACRCALL'?2U) S ACRCALL="A1"
 ;E  I $E(ACRCALL)?1U D C1
C ;S $P(^ACRDOC(ACRBPA,0),U,20)=ACRCALL
 ;L -^ACRDOC(ACRBPA,0):0
 ;Q
 ;C1 I ACRCALL="ZZ" S ACRCALL="A0" Q   ;OLD CODE ACR*2.1*14.03 IM13538
 ;N X1,X2
 ;S X1=$E(ACRCALL)
 ;S X2=$E(ACRCALL,2)
 ;I X2?1N,X2<9 S X2=X2+1
 ;E  I X2=9 S X2="A"
 ;E  I $A(X2)<90 S X2=$C($S($A(X2)>64:$A(X2),1:64)+1)
 ;E  S X2=0
 ;I X2=0 S X1=$C($A(X1)+1)
 ;S ACRCALL=X1_X2
 ;Q
 ;NUM      ;CALCULATE NUMBER OF CALLS TO DATE ;OLD CODE ACR*2.1*14.03 IM13538
 ;N I
 ;S (I,ACRTCALL)=0
 ;F  S I=$O(^ACRDOC("BPA",ACRBPA,I)) Q:'I  S ACRTCALL=ACRTCALL+1
 ;Q
CALLNUM(ACRBPA) ;EP; EXTRINSIC FUNCTION TO CALCULATE CALL NUMBER ACR*2.1*14.03 IM13538
 ;  Enter with FMS Document ien for BPA
 ;  Returns next extension for call number
 ;
 N ACRTCALL
 S ACRCALL=""
 L +^ACRDOC(ACRBPA,0):4 I '$T Q ACRCALL
 S ACRCALL=$P(^ACRDOC(ACRBPA,0),U,20)                ;LAST CALL NUMBER
 S ACRTCALL=$$NUM^ACRFNEW1(ACRBPA)                   ;NEXT CALL NUMBER
 S $P(^ACRDOC(ACRBPA,0),U,20)=$$C1(ACRTCALL,.ACRCALL)
 L -^ACRDOC(ACRBPA,0):0
 Q ACRCALL
 ;
C1(ACRTCALL,ACRCALL) ; LOCAL ENTRY; EXTRINSIC FUNCTION TO CALCULATE BPA EXTENSION; ACR*2.1*14.03 IM13538
 ;     --------ENTERS
 ;                    ACRTCALL=NEXT CALL NUMBER
 ;                    ACRCALL= LAST CALL NUMBER
 ;
 ;             RETURNS:
 ;                   ACRCALL = CALL NUMBER TO USE
 ;
 I ACRCALL>ACRTCALL S ACRTCALL=ACRCALL
 I ACRTCALL<98,$E(ACRCALL)'?1U S ACRCALL=ACRTCALL+1 Q ACRCALL ; NUMBER
 I ACRTCALL>98,$E(ACRCALL)'?1U S ACRCALL="A1" Q ACRCALL
 N X1,X2
 S X1=$E(ACRCALL)
 S X2=$E(ACRCALL,2)
 D
 .I X2?1N,X2<9 S X2=X2+1 Q
 .I X2=9 S X2="A" Q
 .I $A(X2)<90 S X2=$C($S($A(X2)>64:$A(X2),1:64)+1) Q
 .S X2=0 Q
 I X2=0 S X1=$C($A(X1)+1)
 S ACRCALL=X1_X2
 Q ACRCALL
 ;
NUM(ACRBPA) ;LOCAL ENTRY; EXTRINSIC FUNCTION TO CALCULATE NUMBER OF CALLS TO DATE; ACR*2.1*14.03 IM13538
 ; RETURNS NUMBER OF CALL DOCUMENTS IN BPA CROSS-REFERENCE
 N I
 S (I,ACRTCALL)=0
 F  S I=$O(^ACRDOC("BPA",ACRBPA,I)) Q:'I  S ACRTCALL=ACRTCALL+1
 Q ACRTCALL                             ; ACR*2.1*14.03 IM13538
 ;
LASTBPA(X)         ;EP
 ;----- EXTRINSIC FUNCTION - DETERMINES IF ALL BPA CALL NUMBERS HAVE
 ;      BEEN USED
 ;
 ;      INPUT:
 ;      X = DOCUMENT INTERNAL ENTRY NUMBER
 ;
 ;      RETURNS:
 ;      1 IF ALL NUMBERS HAVE BEEN USED
 ;      0 IF ALL NUMBERS HAVE NOT BEEN USED
 ;
 N Z
 S Z=$P(^ACRDOC(X,0),U,2)
 I Z']"" Q 1
 S Z=$E(Z,1,8)_"ZZ"
 I $D(^ACRDOC("C",Z)) Q 1
 Q 0
 ;
AMEND(Y) ;EP;                           ; ACR*2.1*14.02 IM13539
 ;      - DETERMINES IF DOCUMENT HAS ALREADY BEEN AMENDED
 ;      - AND DISALLOWS THE AMENDING OF AMENDMENTS
 ;
 ;      INPUT:
 ;      Y = DOCUMENT INTERNAL ENTRY NUMBER
 ;
 ;      RETURNS:
 ;      1 IF NOT AN AMENDED DOCUMENT 
 ;      0 IF ALREADY AN AMENDED DOCUMENT
 ;
 N ACRDOC,ACRDOC0,ACRAPV,ACRREF
 S ACRDOC0=^ACRDOC(+Y,0)
 I $P(ACRDOC0,U,15) Q 0                     ; Doc Amended field
 S ACRDOC=$P(ACRDOC0,U,1)
 I ACRDOC["-",$L($P(ACRDOC,"-",4))>4 Q 0    ; Amended request
 I $L($P(ACRDOC0,U,2))>10 Q 0               ; Amended PO
 S ACRAPV=$G(^ACROBL(+Y,"APV"))             ; Doc is approved
 I $P(ACRAPV,U)="A" Q 1
 Q 0