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

SCAPMC19.m

Go to the documentation of this file.
  1. SCAPMC19 ;ALB/REW - Team API's ; 12 Jan 99 9:10 AM
  1. ;;5.3;Scheduling;**41,174**;AUG 13, 1993
  1. ;;1.0
  1. ACPRTP(SC200,SCTP,SCFIELDA,SCEFF,SCERR) ; assign practitioner to position
  1. ; input:
  1. ; SC200 = New Person File (#200) Pointer
  1. ; SCTP = Pointer To Team Position File (#404.57)
  1. ; SCFIELDA= array of extra field entries - scfielda('fld#')=value
  1. ; -Note: Only used if BRAND NEW POSITION - team fields (404.57)
  1. ; SCEFF = date to activate/inactivate [default=DT]
  1. ; SCERR = array NAME to store error messages.
  1. ; [ex. ^TMP("ORXX",$J)]
  1. ;
  1. ; Output:
  1. ; SCERR() = Array of DIALOG file messages(errors) .
  1. ; Foramt:
  1. ; Subscript: Sequential # from 1 to n
  1. ; Piece Description
  1. ; 1 IEN of DIALOG file
  1. ;
  1. ; 1 2 3 4 5
  1. ; Returned: status^histien^actdt^inactdt^sctm
  1. ;
  1. ;
  1. N SCTPDTS,SCXX,SCOK,SCHIST,SCACTP,SCSTATUS
  1. N SCPTAIEN,SCESEQ,SCPARM,SCIEN
  1. G:'$$OKDATA() QT
  1. S SCSTATUS=$G(@SCFIELDA@(.04))
  1. S SCTPDTS("BEGIN")=SCEFF
  1. S SCTPDTS("END")=3990101
  1. ;for inactive check for any activity in future
  1. ;for active check for continuous activity in future
  1. S SCTPDTS("INCL")='SCSTATUS
  1. S SCOK=0
  1. IF "^1^0^"'[(U_SCSTATUS_U) D G QT
  1. .S SCOK=-1
  1. .S SCPARM("POSITION")=$G(SCTP,"Undefined")
  1. .S SCPARM("PRACTITIONER")=$G(SC200,"Undefined")
  1. .S SCPARM("MESSAGE")="Required Field: #.04 = "_SCSTATUS
  1. .D ERR^SCAPMCU1(.SCESEQ,4045200,.SCPARM,"",.SCERR)
  1. ;is position already active or will be in future?
  1. S SCHIST=$P($$ACTHIST^SCAPMCU2(404.52,SCTP,"SCTPDTS",.SCERR,"SCXX"),U,1,4)
  1. ;inactivation must be after activation date
  1. IF ('SCSTATUS)&($P(SCHIST,U,3)'<SCEFF) D G QT
  1. . S SCPARM("PRACTITIONER")=$G(SC200,"Undefined")
  1. . S SCPARM("POSITION")=$G(SCTP,"Undefined")
  1. . S SCPARM("MESSAGE")="Inactivation Date must not be equal to Inactivation Date"
  1. . D ERR^SCAPMCU1(.SCESEQ,4045200,.SCPARM,"",.SCERR)
  1. ;must inactivate same practitioner who was last activated
  1. S SCOLD200=$P($G(^SCTM(404.52,+$P(SCHIST,U,2),0)),U,3)
  1. IF ('SCSTATUS)&(SCOLD200&(SCOLD200'=SC200)) D G QT
  1. . S SCOK=-1
  1. . S SCPARM("PRACTITIONER")=$G(SC200,"Undefined")
  1. . S SCPARM("MESSAGE")="Inactivation must be for same practitioner who was last activated"
  1. . D ERR^SCAPMCU1(.SCESEQ,4045200,.SCPARM,"",.SCERR)
  1. IF (+SCHIST+SCSTATUS)=1!('$D(^SCTM(404.52,"B",SCTP))) D ;procede if not at state now
  1. .S SC($J,404.52,"+1,",.01)=SCTP
  1. .S SC($J,404.52,"+1,",.02)=SCEFF
  1. .S SC($J,404.52,"+1,",.03)=SC200
  1. .IF $D(SCFIELDA) D
  1. ..S SCFLD=0
  1. ..F S SCFLD=$O(@SCFIELDA@(SCFLD)) Q:'SCFLD D
  1. ...S SC($J,404.52,"+1,",SCFLD)=@SCFIELDA@(SCFLD)
  1. .D UPDATE^DIE("","SC($J)","SCIEN",.SCERR)
  1. .IF '$G(@SCERR@(0))<1 D
  1. .S:SCSTATUS SCHIST=SCSTATUS_U_SCIEN(1)_U_SCEFF_U
  1. .S:'SCSTATUS SCHIST=SCSTATUS_U_SCIEN(1)_U_$P(SCHIST,U,3)_U_SCEFF
  1. .S SCOK=1
  1. QT Q SCOK_U_$G(SCHIST)
  1. ;
  1. OKDATA() ;
  1. ;setup/check variables for acTP call
  1. N SCOK,SCFLD
  1. S SCOK=1
  1. D INIT^SCAPMCU1(.SCOK)
  1. S:'$G(SCEFF) SCEFF=DT
  1. IF '$D(^VA(200,+$G(SC200),0)) D
  1. . S SCPARM("PRACTITIONER")=$G(SC200,"Undefined")
  1. . D ERR^SCAPMCU1(.SCESEQ,4045201,.SCPARM,"",.SCERR)
  1. IF '$D(^SCTM(404.57,+$G(SCTP),0)) D
  1. . S SCPARM("POSITION")=$G(SCTP,"Undefined")
  1. . D ERR^SCAPMCU1(.SCESEQ,4045701,.SCPARM,"",.SCERR)
  1. F SCFLD=.04,.05 IF '($D(@SCFIELDA@(SCFLD))#2) D
  1. . S SCPARM("PRACTITIONER")=$G(SC200,"Undefined")
  1. . S SCPARM("MESSAGE")="Undefined history fields"
  1. . D ERR^SCAPMCU1(.SCESEQ,4045200,.SCPARM,"",.SCERR)
  1. Q SCOK