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

SDACS1.m

Go to the documentation of this file.
SDACS1 ; IHS/ADC/PDW/ENM - EXTERNAL PACKAGE CALL TO ADD STOP CODES &/OR PROCEDURES 12:30 ;  [ 03/25/1999  11:48 AM ]
 ;;5.3;IHS SCHEDULING;**1015**;MAR 25, 1999;Build 21
 ;;MAS VERSION 5.0;
 ;Continued from SDACS0
 G:SDCTYPE="C" CPT S SDA=SDC K SDC S SDC=SDA
 F SDA=1:1 S SDB=+$P(SDC,"^",SDA) Q:'SDB  S SDC(SDB)="",SDD=$O(^DIC(40.7,"C",SDB,0)) I $S('SDD:1,SDB=900:1,'$D(^DIC(40.7,+SDD,0)):1,1:$P(^(0),"^",3)&(SDATE'<$P(^(0),"^",3))) D INV K SDC(SDB) D ERR:"SB"[SDMSG
DUPCHK I $D(SDC)=11,$D(^SDV("ADT",DFN,$P(SDATE,"."))) S SDFDT=^($P(SDATE,".")) I $D(^SDV(SDFDT,0)) F SDB=0:0 S SDB=$O(^SDV(SDFDT,"CS",SDB)) Q:SDB'>0  S SDA=+^(SDB,0),SDA=$P(^DIC(40.7,+SDA,0),"^",2) I $D(SDC(SDA)) K SDC(SDA)
 ;
 G:$D(SDC)'=11 CPT I '$D(^SDV("ADT",DFN,$P(SDATE,"."))) D ADD
 F SDA=0:0 S SDA=$O(SDC(SDA)) Q:SDA'>0!(SDSCCT'<15)  S DIE="^SDV(",DA=SDFDT,DR="10///"_SDA,DR(2,409.51)="2////^S X=DUZ;5////^S X=SDAPTYP;11////^S X=1" D ^DIE S SDERR=0,SDCTR=SDCTR+1,SDSCCT=SDSCCT+1
CPT G Q:SDCTYPE="S" S SDCPTCT=0
 S DIC=40.7,DIC(0)="QMZ",X=900 D ^DIC I Y'>0 G CLEAN
 S SD900=+Y,IJ=""
 F SDJ=0:0 S SDJ=$O(SDCPT(SDJ)) Q:SDJ=""!(SDCPTCT>6)!(SDSCCT'<15)  S SDECPT=0 D CHECK S SDERR=SDERR_"^"_SDECPT I 'SDECPT D ADD:'$D(^SDV("ADT",DFN,$P(SDATE,"."))),FILE I +SDY>0 S SDCTR=SDCTR+1,SDCPTCT=SDCPTCT+1,SDSCCT=SDSCCT+1
Q I SDCPTCT>6!(SDSCCT'<15) D EXCESS
 ;I SDCTR W:'$D(SDMSG) !,"*** ",SDCTR," Stop code(s) recorded in Scheduling module ***",! G CLEAN
 S SDERR=$S(SDERR[0:0,1:1)
CLEAN K SD900,SDA,SDAPTYP,SDA1,SDB,SDCPT,SDCPTCT,SDCTR,SDD,SDECPT,SDEMSG,SDF,SDFDT,SDFLAG,SDJ,SDP,SDSCCT,SDVNODE,SDY,DA,DIC,DIE,DR,IJ,IX,J,VAEL,VAERR,X,Y K:SDMSG=0 SDMSG Q
INV S SDEMSG="Invalid, duplicate or inactive stop code "_SDB_" - Not " Q
CHECK S SDECPT=$S($P(SDCPT(SDJ),U)'=900:1,$P(SDCPT(SDJ),U,2)']"":1,'$D(^SC(+$P(SDCPT(SDJ),U,2),0)):1,$P(^(0),U,3)'="C":1,1:0) I SDECPT K SDCPT(SDJ) S SDEMSG="Invalid data contained in CPT string - not " D ERR:"CB"[SDMSG Q
 S $P(SDCPT(SDJ),"^",8)=""
 I $P(SDCPT(SDJ),"^",3,7)?."^" S SDECPT=1 K SDCPT(SDJ) S SDEMSG="No CPT codes in SDCPT array - not " D ERR:"CB"[SDMSG Q
 I $D(^SDV("ADT",DFN,$P(SDATE,"."))) S DA(1)=+^SDV("ADT",DFN,$P(SDATE,".")),IX=0 F IJ=0:1 S IX=$O(^SDV("AP",DA(1),IX)) Q:IX'>0!(IJ=6)
 I IJ S SDCPTCT=IJ I SDCPTCT>6 S SDECPT=1 Q
 S SDCPT=$P(SDCPT(SDJ),"^",1,2)
 F J=3:1:7 S Y=$P(SDCPT(SDJ),"^",J) I Y D CHK1 S:'SDECPT SDCPT=SDCPT_"^"_Y S SDECPT=0
 S SDCPT(SDJ)=SDCPT,SDCPT="" I $P(SDCPT(SDJ),"^",3)']"" S SDECPT=1
 Q  ;Return to CPT+3
CHK1 I $S('$D(^SD(409.72,+$O(^(+$O(^SD(409.72,"AIVDT",Y,(9999998-SDATE))),0)),0)):1,'$P(^(0),"^",5):1,1:0) S SDECPT=1,SDEMSG="Invalid or Inactive CPT code "_Y_" -not " D ERR:"CB"[SDMSG
 Q
ERR W !,*7,SDEMSG,"recorded in Scheduling module" Q
EXCESS S SDEMSG=$S(SDSCCT'<15:"Fifteen ",1:"Six '900' ")_"Stop Codes for this date on record - no more can be " D ERR:SDMSG'=0 Q
ADD S SDFDT=$S($P(SDATE,".",2)]"":SDATE,1:SDATE+.08)
LOCK L ^SDV(SDFDT):1 I '$T!$D(^SDV(SDFDT)) L  S SDFDT=SDFDT+.00001 G LOCK
 K DD,DO S DIC="^SDV(",DIC(0)="L",(DINUM,X)=SDFDT,DIC("DR")="2////"_DFN_";3////"_SDIV D FILE^DICN K DINUM,DIC,DO S DA(1)=+^SDV("ADT",DFN,$P(SDATE,"."))
 Q
FILE ;
 K DR,DO,DD S X=SD900,DIC(0)="LM",(DIC,DIE)="^SDV("_DA(1)_",""CS"","
 I '$D(^SDV(DA(1),"CS",0)) S ^SDV(DA(1),"CS",0)="^"_$P(^DD(409.5,10,0),"^",2)_"^^"
 D FILE^DICN S SDY=Y Q:+Y'>0
 ;DR="2////^S X=DUZ;3////^S X=$P(SDCPT(SDJ),U,2);5////^S X=SDAPTYP;21////^S X=$P(SDCPT(SDJ),U,3)"_$S($P(SDCPT(SDJ),U,4)]"":";22////^S X=$P(SDCPT(SDJ),U,4)",1:"")
 ;S DR=DR_$S($P(SDCPT(SDJ),U,5)]"":";23////^S X=$P(SDCPT(SDJ),U,5)",1:"")_$S($P(SDCPT(SDJ),U,6)]"":";24////^S X=$P(SDCPT(SDJ),U,6)",1:"")_$S($P(SDCPT(SDJ),U,7)]"":";25////^S X=$P(SDCPT(SDJ),U,7)",1:""),SDVNODE=DIE_DA_")"
 S (DA,SDA1)=DA(1),DR="[SDXACSE]",DIE="^SDV(",SDVNODE=DIE_DA_")"
 L SDVNODE:2 I $T D ^DIE L  K DR,DQ,DE,DIC,X S DA(1)=SDA1,DA=+SDY Q
 W !,*7,"Another user is editing this entry.",!
 Q