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

ACRFDOCN.m

Go to the documentation of this file.
ACRFDOCN ;IHS/OIRM/DSD/THL,AEF - SET DOCUMENT NUMBER; [ 11/30/2006   9:44 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**22**;NOV 05, 2001
 ;;ROUTINE USED TO CREATE DOCUMENT NUMBER
DOC ;EP;TO ASSIGN DOCUMENT NUMBERS
 I $D(ACRAMEND),$D(^ACRDOC(ACRAMEND,0)) D DOCAMEND Q
 S ACRREF=$P(^AUTTDOCR(ACRREFDA,0),U)
 I ACRREF=130!(ACRREF=600) D  Q
 .S ACRREF=130
 .D TO
PONUM1 I "^103^210^"[(U_ACRREF_U) D
 .N ACRFY
 .S ACRFY=$P(^ACRLOCB($P(ACRDOC0,U,6),"DT"),U)
 .S ACRFYX=$S(+$E(DT,4,5)<10:$E(DT,1,3),1:$E(DT,1,3)+1) S ACRFYX=ACRFYX+1700
 .S ACRFYX=$S(ACRFYX>ACRFY:ACRFYX,1:ACRFY)
 .I '$D(^ACRPO(ACRPODA,1,0)) S ^ACRPO(ACRPODA,1,0)="^9002199.41"
 .I '$D(^ACRPO(ACRPODA,1,"B",ACRFYX)) D
 ..S (X,DINUM)=ACRFYX
 ..S DA(1)=ACRPODA
 ..S DIC="^ACRPO("_DA(1)_",1,"
 ..S DIC(0)="L"
 ..D FILE^ACRFDIC
 .L +^ACRPO(ACRPODA):2
 .I $T=1 S ACRTXDOC=$P(^ACRPO(ACRPODA,1,ACRFYX,0),U,2),ACRTXDOC=ACRTXDOC+1,$P(^(0),U,2)=ACRTXDOC L -^ACRPO(ACRPODA):0
 .E  G PONUM1
 .F ACRJI=1:1:(4-$L(ACRTXDOC)) S ACRTXDOC="0"_ACRTXDOC
 .S ACRTXDOC=ACRTXDOC_"00"
 S ACRTXPFX=$P(^ACRTXTYP(ACRTXDA,"DT"),U,2)
 S ACRDPTDA=$P(^ACRLOCB(ACRFDNO,0),U,5)
 S ACRLCOD=$P(^ACRLOCB(ACRFDNO,"DT"),U,11)
 S ACRDEPT=$P(^AUTTPRG(ACRDPTDA,0),U,2)
 S ACRPDA=$P(^ACRCAN(ACRCANDA,"DFLT1"),U,15)
 S ACRAREA=$S('ACRPDA:"",$D(^ACRPO(ACRPDA,0)):$P(^(0),U,10),1:"")
 I 'ACRPDA D  Q
 .W *7,*7
 .W !!,"The Purchasing Office for the CAN NO. default data has not been defined."
 .W !,"Notify the ARMS systems manager immediately."
 .D PAUSE^ACRFWARN
 .S ACRQUIT=""
 I 'ACRAREA D  Q
 .W *7,*7
 .W !!,"The Area Office of your Purchasing Office has not been identified."
 .W !,"Notify the ARMS systems manager immediately."
 .S ACRQUIT=""
 .D PAUSE^ACRFWARN
 I 'ACRLCOD D  Q
 .W *7,*7
 .W !!,"The location code of your Purchasing Office has not been identified."
 .W !,"Notify the ARMS systems manager immediately."
 .D PAUSE^ACRFWARN
 .S ACRQUIT=""
 S ACRLCOD=$P(^AUTTLCOD(ACRLCOD,0),U)
 S ACRAREA=$P(^AUTTAREA(ACRAREA,0),U,3)
 G:"^103^210^"[(U_ACRREF_U) DOC3
DOC1 ;EP;
 S ACRFY=$P(^ACRLOCB(ACRFDNO,"DT"),U)
 S ACRFYX=$S(+$E(DT,4,5)<10:$E(DT,1,3),1:$E(DT,1,3)+1) S ACRFYX=ACRFYX+1700
 S ACRFYX=$S(ACRFYX>ACRFY:ACRFYX,1:ACRFY)
 I '$D(^ACRDEPT(ACRDPTDA,0)) D
 .S (X,DINUM)=ACRDPTDA
 .S DIC="^ACRDEPT(",DIC(0)="L"
 .D FILE^ACRFDIC
 I '$D(^ACRDEPT(ACRDPTDA,1,0)) S ^ACRDEPT(ACRDPTDA,1,0)="^9002188.11"
 I '$D(^ACRDEPT(ACRDPTDA,1,ACRFYX,0)) D
 .S DA(1)=ACRDPTDA
 .S (DINUM,X)=ACRFYX
 .S (ACRDIC,DIC)="^ACRDEPT("_DA(1)_",1,"
 .S DIC(0)="L"
 .D FILE^ACRFDIC
 I '$D(^ACRDEPT(ACRDPTDA,1,ACRFYX,1,0)) S ^ACRDEPT(ACRDPTDA,1,ACRFYX,1,0)="^9002188.112P"
 I '$D(^ACRDEPT(ACRDPTDA,1,ACRFYX,1,ACRREFDA)) D
 .S DA(2)=ACRDPTDA
 .S DA(1)=ACRFYX
 .S (DINUM,X)=ACRREFDA
 .S (ACRDIC,DIC)="^ACRDEPT("_DA(2)_",1,"_DA(1)_",1,"
 .S DIC(0)="L"
 .D FILE^ACRFDIC
DOC11 L +^ACRDEPT(ACRDPTDA,1,ACRFYX,1,ACRREFDA,0):2
 I $T=1 D  I 1
 .S ACRTXDOC=$P(^ACRDEPT(ACRDPTDA,1,ACRFYX,1,ACRREFDA,0),U,2)
 .S ACRTXDOC=ACRTXDOC+1
 .S $P(^ACRDEPT(ACRDPTDA,1,ACRFYX,1,ACRREFDA,0),U,2)=ACRTXDOC
 .L -^ACRDEPT(ACRDPTDA,1,ACRFYX,1,ACRREFDA,0):0
 E  G DOC11
 F ACRJI=1:1:(4-$L(ACRTXDOC)) S ACRTXDOC="0"_ACRTXDOC
 K ACRJI
DOC3 S ACRFY=$P(^ACRLOCB(ACRZDA,"DT"),U)
 S ACRFYX=$S(+$E(DT,4,5)<10:$E(DT,1,3),1:$E(DT,1,3)+1) S ACRFYX=ACRFYX+1700
 S ACRFYX=$S(ACRFYX>ACRFY:ACRFYX,1:ACRFY)
 S ACRDOC=$S(ACRREF=116!(ACRREF=101):ACRLCOD_"-"_ACRDEPT_"-"_$E(ACRFYX,4)_"-"_ACRTXDOC,ACRREF=103!(ACRREF=210):$E(ACRFYX,4)_ACRAREA_ACRLCOD_ACRTXDOC,1:$E(ACRFYX,4)_ACRTXPFX_ACRDEPT_ACRTXDOC)
 ;I "^103^210^"'[(U_ACRREF_U),$D(^ACRDOC("B",ACRDOC)) G DOC11             ;ACR*2.1*22.07 IM22855
 ;I "^103^210^"[(U_ACRREF_U),$D(^ACRDOC("B",ACRDOC))!$D(^ACRDOC("C",ACRDOC)) G DOC11    ;ACR*2.1*22.07 IM22855
 I $D(^ACRDOC("B",ACRDOC))!($D(^ACRDOC("C",ACRDOC)))!($D(^ACRDOC("O",ACRDOC))) G DOC11  ;ACR*2.1*22.07 IM22855
 K ACRFYX
 Q
TO ;EP;
 N ACRFY
 S ACRFY=$P(^ACRLOCB(ACRFDNO,"DT"),U)
 S ACRLC=$P(^ACRLOCB(ACRFDNO,"DT"),U,11)
 S ACRFYX=$S(+$E(DT,4,5)<10:$E(DT,1,3),1:$E(DT,1,3)+1) S ACRFYX=ACRFYX+1700
 S ACRFYX=$S(ACRFYX>ACRFY:ACRFYX,1:ACRFY)
 I '$D(^ACRPO(1,20,0)) S ^ACRPO(1,20,0)="^9002199.4201"
 I '$D(^ACRPO(1,20,"B",ACRFY)) D
 .S DA(1)=1
 .S (X,DINUM)=ACRFY
 .S DIC="^ACRPO(1,20,"
 .S DIC(0)="L"
 .S DIC("DR")=".02///0"
 .D FILE^ACRFDIC
TO1 L +^ACRPO(1):2
 I $T=1 D  I 1
 .S ACRNUM=$P(^ACRPO(1,20,ACRFY,0),U,2)
 .S ACRNUM=ACRNUM+1
 .S $P(^ACRPO(1,20,ACRFY,0),U,2)=ACRNUM
 .S ACRAPT=$P(^ACRPO(1,0),U,4)
 .S ACRAREA=$P(^ACRPO(1,0),U,10)
 .L -^ACRPO(1):0
 E  G TO1
 F ACRJI=1:1:(4-$L(ACRNUM)) S ACRNUM="0"_ACRNUM
 S (ACRDOC,ACRNUM)=$E(ACRFYX,4)_$E($P(^AUTTLCOD(ACRLC,0),U),1,3)_"TO"_ACRNUM
 I $D(^ACRDOC("B",ACRNUM)) G TO1
 K ACRFYX
 Q
DOCAMEND L +^ACRDOC(ACRAMEND,0):2
 G:'$T DOCAMEND
 S X=$P(^ACRDOC(ACRAMEND,0),U,9)
 S X=X+1
 S $P(^ACRDOC(ACRAMEND,0),U,9)=X
 L -^ACRDOC(ACRAMEND,0):0
 F Y=1:1:3-$L(X) S X="0"_X
 N ACRREFDA,ACRREF
 S ACRDOC=$P(^ACRDOC(ACRAMEND,0),U)_X
 S ACRANUM=X
 S ACRDOC2=$P(^ACRDOC(ACRAMEND,0),U,2)
 S ACRREFDA=$P(^ACRDOC(ACRAMEND,0),U,13)
 S ACRREF=$P(^AUTTDOCR(ACRREFDA,0),U)
 Q