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

FSCES.m

Go to the documentation of this file.
FSCES ;SLC/STAFF-NOIS Edit Status ;9/6/98  20:38
 ;;1.1;NOIS;;Sep 06, 1998
 ;
STATUS(CALL,OLD,NEW,REOPEN) ; from FSCEB, FSCED, FSCEL, FSCELID, FSCELSNS, FSCLMPE1, FSCLMPES, FSCRPCEC, FSCRPCEF, FSCRPCF, FSCRPCNC
 Q:'$G(CALL)  Q:'$L($G(NEW))
 S OLD=$G(OLD),REOPEN=+$G(REOPEN)
 N DEV,SUP
 D STATNEW(NEW,.SUP,.DEV)
 D CALL(CALL,OLD,NEW,REOPEN)
 Q
 ;
CALL(CALL,OLD,NEW,REOPEN) ;
 N DA,DEV,DIE,DR,HISTORY,SUP,TIME
 S TIME=$$NOW^XLFDT
 D STATNEW(NEW,.SUP,.DEV)
 S DA=CALL,DIE="^FSCD(""CALL"","
 S DR="4///`"_SUP
 D RTDCHECK(CALL,.DR,SUP)
 S:DEV DEV="`"_DEV S:DEV="" DEV="@"
 S DR=DR_";4.1///"_DEV_";4.5///"_NEW_";121///"_TIME_";123///"_TIME_";124///`"_DUZ
 I OLD S DR=DR_";4.6///`"_OLD
 S HISTORY=$$HISTORY(OLD,NEW,TIME,DUZ)
 L +^FSCD("CALL",CALL):30 I '$T Q  ; *** needs ok
 I REOPEN D
 .S DR=DR_";2.6///"_TIME_";81///@;82///@;8///@;9///@;122///@"
 .D TRANSFER(CALL) ;
 D ^DIE
 D STUFF(CALL,HISTORY)
 L -^FSCD("CALL",CALL)
 D PICKUP(CALL)
 D STATHIST(CALL,DUZ,TIME,NEW,OLD)
 D MRE^FSCMR(DUZ,CALL)
 Q
 ;
PICKUP(CALL) ; from FSCED, FSCELS, FSCLMPE1, FSCRPCEC, FSCRPCEF, FSCRPCNC
 I $P(^FSCD("CALL",CALL,120),U,22) Q
 I $P(^FSCD("CALL",CALL,120),U)<2970901 Q  ;** pickup times only collected after 9/1/97
 I $P(^FSCD("CALL",CALL,0),U,9) D PICKSET(CALL) Q
 I $P(^FSCD("CALL",CALL,0),U,2)=2 D PICKSET(CALL) Q
 Q
 ;
PICKSET(CALL) ;
 N DA,DIE,DR,NOW,PTIME,RTIME
 S DA=CALL,DIE="^FSCD(""CALL"","
 S RTIME=$P(^FSCD("CALL",CALL,120),U)
 S NOW=$$NOW^XLFDT
 S PTIME=$$FMDIFF^XLFDT(NOW,RTIME,2)/60\1
 S DR="125///NOW;126///"_PTIME
 L +^FSCD("CALL",CALL):30 I '$T Q  ; *** needs ok
 D ^DIE
 L -^FSCD("CALL",CALL)
 Q
 ;
RTDCHECK(CALL,DR,SUP) ;
 I $P(^FSCD("CALL",CALL,0),U,17) D
 .I SUP'=3 S DR=DR_";4.8///"_DT
 E  D
 .I SUP=3 D
 ..I $$DEVEXIST(CALL) S DR=DR_";4.9///"_DT
 ..S DR=DR_";4.7///"_DT_";4.8///@"
 Q
 ;
DEVEXIST(CALL) ; $$(call) -> 1 if ever referred else 0
 N RESULT,SUB
 S RESULT=0
 S SUB=0 F  S SUB=$O(^FSCD("STATUS HIST","B",CALL,SUB)) Q:SUB<1  D  Q:RESULT
 .I $P(^FSCD("STATUS HIST",SUB,0),U,4)=3 S RESULT=1
 Q RESULT
 ;
HISTORY(OLD,NEW,TIME,USER) ; $$(old status,new status,time,person) -> formatted text
 I OLD Q "  Changed from "_$$VALUE^FSCGET(OLD,7100,4.5)_" to "_$$VALUE^FSCGET(NEW,7100,4.5)_" on "_$$FMTE^XLFDT(TIME)_" by "_$$VALUE^FSCGET(USER,7100,124)_"."
 Q "  "_$$VALUE^FSCGET(NEW,7100,4.5)_" on "_$$FMTE^XLFDT(TIME)_" by "_$$VALUE^FSCGET(USER,7100,124)_"."
 ;
STUFF(CALL,HISTORY) ;
 N LINE
 S LINE=1+$O(^FSCD("CALL",CALL,110,"A"),-1)
 S ^FSCD("CALL",CALL,110,LINE,0)=HISTORY
 S ^FSCD("CALL",CALL,110,0)="^^"_LINE_U_LINE_U_DT_"^^"
 Q
 ;
STATHIST(CALL,USER,DATE,STATUS,PREV) ;
 S PREV=$G(PREV)
 N DA,DATA,DIK,NUM
 S DATA=CALL_U_USER_U_DATE_U_STATUS_U_PREV
 S NUM=1+$P(^FSCD("STATUS HIST",0),U,3)
 L +^FSCD("STATUS HIST",0):30 I '$T Q  ; *** needs ok
 F  Q:'$D(^FSCD("STATUS HIST",NUM,0))  S NUM=NUM+1
 S ^FSCD("STATUS HIST",NUM,0)=DATA
 S $P(^FSCD("STATUS HIST",0),U,3)=NUM,$P(^(0),U,4)=$P(^(0),U,4)+1
 L -^FSCD("STATUS HIST",0)
 S DIK="^FSCD(""STATUS HIST"",",DA=NUM D IX1^DIK
 Q
 ;
TRANSFER(CALL) ;
 N CNT,DATE,LINE,NUM,PERSON
 S DATE=$P(^FSCD("CALL",CALL,0),U,4),PERSON=$P(^(0),U,11)
 I 'DATE,'PERSON Q
 S NUM=$P(^FSCD("CALL",CALL,120),U,7)+1,$P(^(120),U,7)=NUM
 S LINE="("_NUM_") Call closed by "_$$VALUE^FSCGET(PERSON,7100,81)_" on "_$$VALUE^FSCGET(DATE,7100,82)_"."
 I '$D(^FSCD("CALL",CALL,50,0)) S ^FSCD("CALL",CALL,50,0)="^^0^0^"_DT_U
 S CNT=1+$O(^FSCD("CALL",CALL,50,"A"),-1)
 S $P(^FSCD("CALL",CALL,120),U,6)=CNT
 S ^FSCD("CALL",CALL,50,CNT,0)=LINE
 S LINE=0 F  S LINE=$O(^FSCD("CALL",CALL,80,LINE)) Q:LINE<1  S CNT=CNT+1,^FSCD("CALL",CALL,50,CNT,0)=^(LINE,0)
 S CNT=CNT+1,^FSCD("CALL",CALL,50,CNT,0)=" "
 S $P(^FSCD("CALL",CALL,50,0),U,3,4)=CNT_U_CNT
 K ^FSCD("CALL",CALL,80)
 Q
 ;
STATNEW(NEW,SUP,DEV) ; returns sup and dev status from new status
 S SUP=$G(SUP),DEV=$G(DEV)
 I 'NEW Q
 I NEW=1 S SUP=1,DEV="" Q
 I NEW=2 S SUP=2 I DEV S DEV=2 Q
 I NEW=3 S SUP=3,DEV=1 Q
 I NEW=4 S SUP=4,DEV="" Q
 I NEW=5 S SUP=3,DEV=5 Q
 I NEW=6 S SUP=3,DEV=6 Q
 I NEW=7 S SUP=3,DEV=7 Q
 I NEW=8 S SUP=3,DEV=8 Q
 I NEW=9 S SUP=3,DEV=9 Q
 I NEW=10 S SUP=10,DEV="" Q
 I NEW=99 S SUP=99 I DEV S DEV=99 Q
 Q