SCMCCV6 ;BP/CMF - PCMM HL7 Baseline Xmit to AAC ; March 26, 2000
 ;;5.3;Scheduling;**212**;AUG 13, 1993
 ;
 ;Traverse PATIENT TEAM POSITION ASSIGNMENT file (#404.43)
 ;and create events in file (#404.48) for all entries that meet
 ;the following criteria:
 ;    1. Field PC ROLE=1 ;..Primary Care
 ;           -- and one of the following --
 ;    2a. assignment is active as of SD*5.3*212 run date (now!)
 ;    2b. assignment was active as of SD*5.3*177 install date
 ;    2c. assignment was active between 2a and 2b 
 ;
 ;
 W !,"This is not an interactive entry point."
 W !,"This routine should only be executed by IRM staff"
 W !,"              -- ONCE --"
 W !,"using Taskman to Queue option 'PCMM BASELINE SEEDING'"
 W !,"to run during a non-busy period."
 Q
 ;
EN(SCTST,SCDFN) ;
 ; entry point for option 'SCMC PCMM BASELINE SEEDING'
 ;  this option should not be on any users menu
 ;  this option should be queued to run once
 ;  it should not be run more than once without consulting NVS
 ;
 ; input
 ;  SCTST - 1 = test [default = 0]
 ;  SCDFN - Patient IEN used to seed for restarts only [default = 0]
 ;
 S SCTST=+$G(SCTST,0)
 S SCDFN=+$G(SCDFN,0)
 N SCP177  ; patch 177 install date
 N SCP212  ; patch 212 run date
 N SC1,SC2 ; message holders
 N SCARRAY ; message text array
 N SCSTIM  ; process start time
 S SCSTIM=$$HTE^XLFDT($H)
 S SC1="PCMM PC Baseline Seed Process Aborted:"
 ;
 I $$VPATCH^SCUTBK3("SD*5.3*177")=0 D  Q
 . S SC2="  PCMM Patch 'SD*5.3*177' has not been loaded!"
 . D MSG(SC1,SC2)
 . Q
 ;
 I $$VPROGMR^SCUTBK3()=0 D  Q
 . S SC2="  User must have 'XUPROG' key!"
 . D MSG(SC1,SC2)
 . Q
 ;
 S SCP212=$$CHECK()
 I SCP212'="" D  Q
 . I +SCP212 D  Q
 . . S SC2="  PCMM Baseline seeded on "_$$FMTE^XLFDT(SCP212)_"."
 . . D MSG(SC1,SC2)
 . . Q
 . I SCP212=-1 D  Q
 . . S SC2="  Missing PCMM Parameter file entry."
 . . D MSG(SC1,SC2)
 . . Q
 . I SCP212=-2 D  Q
 . . S SC2="  FM Error retrieving data from PCMM Parameter file."
 . . D MSG(SC1,SC2)
 . . Q
 . S SC2="  Undefined Error."
 . D MSG(SC1,SC2)
 . Q
 ;
 S SCP177=$$PDAT^SCMCGU("SD*5.3*177")
 I +SCP177=0 D  Q
 . S SC2="  Unable to obtain SD*5.3*177 Installation Date."
 . D MSG(SC1,SC2)
 . Q
 ;
 I $$BASELINE(SCP177,DT,SCDFN,SCTST)'=1 D  Q
 . S SC2="  PCMM PC Baseline failed"_$$FMTE^XLFDT($$NOW^XLFDT)_"."
 . D MSG(SC1,SC2)
 . Q
 ;
 Q
 ;
BASELINE(SCP177,SCP212,SCPDFN,SCPTST) ;
 ; input
 ;  SCP177 = Patch 177 date (required)
 ;  SCP212 = Patch 212 date (optional, default = today)
 ;  SCPDFN = Patient ien    (optional, default = 0)
 ;  SCPTST = 1 := test [default = 0]
 ;      
 ; output
 ;  1 = success
 ;  0 = failure
 ;
 N SCFLAG,SC1,SC2
 S SC1="PCMM PC Baseline Process Failure:"
 S SC177=$G(SCP177,"")
 I SC177="" D  Q 0
 . S SC2="  Invalid SD*5.3*177 Date Parameter"
 . D MSG(SC1,SC2)
 . Q
 S SC212=$G(SCP212,DT)
 I SC212="" D  Q 0
 . S SC2="  Invalid SD*5.3*212 Date (DT) Parameter"
 . D MSG(SC1,SC2)
 . Q
 S SCDFN=$G(SCPDFN,0)
 I SCDFN="" D  Q 0
 . S SC2="  Invalid DFN Parameter"
 . D MSG(SC1,SC2)
 . Q
 I '$D(^SCPT(404.43,"APCPOS")) D  Q 0
 . S SC2="  Missing ""APCPOS"" x-ref in file 404.43!"
 . D MSG(SC1,SC2)
 . Q
 ;
 S SCTST=+$G(SCPTST,0)
 S SCFLAG=$$EVENT(SC177,SC212,SCDFN,SCTST)
 ;
 I SCTST=1 D MSG("","",+SCFLAG) Q 1
 N SCFDA,SCERR,SC1,SC2
 S SC1="PCMM PC Baseline Seeding"
 S SC2=+$P(SCFLAG,U,2)
 S SCFLAG=+$P(SCFLAG,U)
 S SC1=SC1_$S(+SC2:" stopped by TM stop request:",1:" completed:")
 S SCFDA(1,404.44,"1,",17)=SC212
 D FILE^DIE("","SCFDA(1)","SCERR")
 I $D(SCERR) D 
 . S SC2="  Caution: Baseline Date NOT updated in PCMM Parameter file"
 . D MSG(SC1,SC2)
 . Q
 S SC2="  "_SCFLAG_" assignments placed in HL7 transmission queue."
 D MSG(SC1,SC2)
 Q 1
 ;
CHECK() ;
 ; Description:  Determine whether or not the Baseline has run.
 ;
 ; Input: None
 ;
 ; Output:
 ;   Function Value: Return date Baseline was run
 ;
 N SCX
 I '$D(^SCTM(404.44,1)) Q -1
 K ^TMP($J,"SCMCCV6")
 S SCX=$$GET1^DIQ(404.44,"1,",17,"I","","^TMP($J,""SCMCCV6"")")
 I $D(^TMP($J,"SCMCCV6")) S SCX=-2
 K ^TMP($J,"SCMCCV6")
 Q SCX
 ;
 ;
EVENT(SC177,SC212,SCDFN,SCTST) ;
 ; Description: Create an Event in file (#404.48)
 ;
 ; Input:
 ;   SC177 - date patch SD*5.3*177 was installed. [required]
 ;   SC212 - date process runs [default = DT]
 ;   SCDFN - patient ien (ptr file 2) [default = 0]
 ;   SCTST - 1 = test [default = 0]
 ;
 ; Output: 
 ;   p1 = number of entries created
 ;   p2 = stopped by Taskman
 ;
 N SCCNT   ; counter
 N SCPAI   ; position assignment IEN (ptr file 404.43)
 N SCTP    ; team position IEN (ptr file 404.57)
 N SCADT   ; position assignment start date
 N SCDDT   ; position assignment end date
 N SCNOW   ; time process starts
 N SCVAR   ; variable pointer string for HL7
 N SC1     ; shorthand for ' "APCPOS",SCDFN,1 ' node
 N SCZ     ; Taskman flag to stop process
 ;
 ; check for ZSTOP
 S SCZ=$$S^%ZTLOAD
 I +SCZ Q 0_U_1
 S SCTST=+$G(SCTST,0)
 K ^XTMP("SCMCCV6")
 S ^XTMP("SCMCCV6",0)=DT_U_$$FMADD^XLFDT(""_DT_"",7)_U_"SCMC PCMM BASELINE SEEDING"
 S SCNOW=$$NOW^XLFDT
 S SCCNT=0
 S SCDFN=+SCDFN
 F  S SCDFN=$O(^SCPT(404.43,"APCPOS",SCDFN)) Q:(SCDFN="")!(SCZ)  D
 . S SCZ=$$S^%ZTLOAD
 . Q:+SCZ
 . ;
 . S ^XTMP("SCMCCV6","LASTDFN")=SCDFN
 . S SC1="^SCPT(404.43,""APCPOS"",SCDFN,1)"
 . ;
 . ; quit if no PC assignments
 . Q:'$D(@SC1)
 . S SCADT=0
 . F  S SCADT=$O(@SC1@(SCADT)) Q:SCADT=""  D
 . . S SCTP=0
 . . F  S SCTP=$O(@SC1@(SCADT,SCTP)) Q:'SCTP  D
 . . . ;
 . . . ; quit if team position does not exist
 . . . Q:'$D(^SCTM(404.57,SCTP,0))
 . . . S SCPAI=0
 . . . F  S SCPAI=$O(@SC1@(SCADT,SCTP,SCPAI)) Q:'SCPAI  D
 . . . . S SCDDT=$P($G(^SCPT(404.43,SCPAI,0)),U,4)
 . . . . ;
 . . . . ; quit if not active within date range
 . . . . Q:$$DTCHK^SCAPU1(SC177,SC212,0,SCADT,SCDDT)<1
 . . . . S SCVAR=SCPAI_";SCPT(404.43,"
 . . . . ;
 . . . . ; add to HL7 event file
 . . . . Q:$$CHECK^SCMCHLB1(SCVAR)'=1
 . . . . ;
 . . . . ; queue for transmit or report
 . . . . I SCTST=0 D ADD^SCMCHLE("NOW",SCVAR,SCDFN,SCTP)
 . . . . I SCTST=1 S SCARRAY(SCCNT+3)=SCVAR_" ^ "_$$GET1^DIQ(2,SCDFN_",",.01)_" ^ "_$$GET1^DIQ(404.57,SCTP_",",.01)_" ^ "_$$FMTE^XLFDT(SCADT)_" ^ "_$$FMTE^XLFDT(SCDDT)
 . . . . ;
 . . . . ; increment counter
 . . . . S SCCNT=SCCNT+1
 . . . . Q
 . . . Q
 . . Q
 . Q
 ;
 Q SCCNT_U_SCZ
 ;
MSG(SC1,SC2,SCTST) ;
 N XMY,XMDUZ,XMSUB,XMTEXT
 S SCTST=+$G(SCTST,0)
 S XMDUZ="PCMM Module"
 S (XMY(DUZ),XMY(XMDUZ))=""
 I SCTST=0 D
 . S XMSUB="PCMM PC Baseline Seeding Job"
 . K SCARRAY
 . S SCARRAY(1)=""
 . S SCARRAY(2)=SC1
 . S SCARRAY(3)=SC2
 . S SCARRAY(4)=""
 . S SCARRAY(5)="TaskMan Job Number:       "_$G(ZTSK)
 . S SCARRAY(6)="Baseline Start Date/Time: "_$G(SCSTIM)
 . S SCARRAY(7)="Baseline End Date/Time:   "_$$HTE^XLFDT($H)
 . S SCARRAY(8)="HL7 Transmit Limit:       "_$$GET1^DIQ(404.44,"1,",15)
 . S SCARRAY(9)=""
 . Q
 E  D
 . S XMSUB="PCMM PC Baseline Trial Entries ("_$G(ZTSK)_")"
 . S SCARRAY(1)=""
 . S SCARRAY(2)=SCTST_" entries would have been placed in HL7 queue:"
 . S SCARRAY(3)="==================================================="
 S XMTEXT="SCARRAY("
 D ^XMD
 Q
 ;
RESTART(SCTST) ; alb/rpm
 ; This undocumented entry point allows a user to clear the Baseline
 ; date stored in file #404.44 field #17.  Then the last patient IEN
 ; that was processed from the last run is retrieved from ^XTMP("SCMCCV6"
 ; and decremented to seed the restart point.  If ^XTMP does not exist
 ; the IEN is set to 0.
 ;
 ; Input:
 ;       SCTST - 1 = test [default = 0]
 ;
 S SCTST=+$G(SCTST,0)
 ;
 NEW SC1,SC2,SCDFA,SCDFN,SCERR
 S SC1="PCMM PC Baseline Seeding"
 S SCDFN=0
 ; Retrieve the last IEN processed
 I +$G(^XTMP("SCMCCV6","LASTDFN"))>0 D
 . S SCDFN=+$G(^XTMP("SCMCCV6","LASTDFN"))-1
 ; Delete the Baseline date from last run
 S SCFDA(1,404.44,"1,",17)="@"
 D FILE^DIE("","SCFDA(1)","SCERR")
 I $D(SCERR) D  Q
 . S SC2="  Warning: Baseline Date NOT cleared in PCMM Parameter file"
 . D MSG(SC1,SC2)
 . Q
 ; Call interactive entry point
 D EN(SCTST,SCDFN)
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCMCCV6   8153     printed  Sep 23, 2025@20:16:25                                                                                                                                                                                                     Page 2
SCMCCV6   ;BP/CMF - PCMM HL7 Baseline Xmit to AAC ; March 26, 2000
 +1       ;;5.3;Scheduling;**212**;AUG 13, 1993
 +2       ;
 +3       ;Traverse PATIENT TEAM POSITION ASSIGNMENT file (#404.43)
 +4       ;and create events in file (#404.48) for all entries that meet
 +5       ;the following criteria:
 +6       ;    1. Field PC ROLE=1 ;..Primary Care
 +7       ;           -- and one of the following --
 +8       ;    2a. assignment is active as of SD*5.3*212 run date (now!)
 +9       ;    2b. assignment was active as of SD*5.3*177 install date
 +10      ;    2c. assignment was active between 2a and 2b 
 +11      ;
 +12      ;
 +13       WRITE !,"This is not an interactive entry point."
 +14       WRITE !,"This routine should only be executed by IRM staff"
 +15       WRITE !,"              -- ONCE --"
 +16       WRITE !,"using Taskman to Queue option 'PCMM BASELINE SEEDING'"
 +17       WRITE !,"to run during a non-busy period."
 +18       QUIT 
 +19      ;
EN(SCTST,SCDFN) ;
 +1       ; entry point for option 'SCMC PCMM BASELINE SEEDING'
 +2       ;  this option should not be on any users menu
 +3       ;  this option should be queued to run once
 +4       ;  it should not be run more than once without consulting NVS
 +5       ;
 +6       ; input
 +7       ;  SCTST - 1 = test [default = 0]
 +8       ;  SCDFN - Patient IEN used to seed for restarts only [default = 0]
 +9       ;
 +10       SET SCTST=+$GET(SCTST,0)
 +11       SET SCDFN=+$GET(SCDFN,0)
 +12      ; patch 177 install date
           NEW SCP177
 +13      ; patch 212 run date
           NEW SCP212
 +14      ; message holders
           NEW SC1,SC2
 +15      ; message text array
           NEW SCARRAY
 +16      ; process start time
           NEW SCSTIM
 +17       SET SCSTIM=$$HTE^XLFDT($HOROLOG)
 +18       SET SC1="PCMM PC Baseline Seed Process Aborted:"
 +19      ;
 +20       IF $$VPATCH^SCUTBK3("SD*5.3*177")=0
               Begin DoDot:1
 +21               SET SC2="  PCMM Patch 'SD*5.3*177' has not been loaded!"
 +22               DO MSG(SC1,SC2)
 +23               QUIT 
               End DoDot:1
               QUIT 
 +24      ;
 +25       IF $$VPROGMR^SCUTBK3()=0
               Begin DoDot:1
 +26               SET SC2="  User must have 'XUPROG' key!"
 +27               DO MSG(SC1,SC2)
 +28               QUIT 
               End DoDot:1
               QUIT 
 +29      ;
 +30       SET SCP212=$$CHECK()
 +31       IF SCP212'=""
               Begin DoDot:1
 +32               IF +SCP212
                       Begin DoDot:2
 +33                       SET SC2="  PCMM Baseline seeded on "_$$FMTE^XLFDT(SCP212)_"."
 +34                       DO MSG(SC1,SC2)
 +35                       QUIT 
                       End DoDot:2
                       QUIT 
 +36               IF SCP212=-1
                       Begin DoDot:2
 +37                       SET SC2="  Missing PCMM Parameter file entry."
 +38                       DO MSG(SC1,SC2)
 +39                       QUIT 
                       End DoDot:2
                       QUIT 
 +40               IF SCP212=-2
                       Begin DoDot:2
 +41                       SET SC2="  FM Error retrieving data from PCMM Parameter file."
 +42                       DO MSG(SC1,SC2)
 +43                       QUIT 
                       End DoDot:2
                       QUIT 
 +44               SET SC2="  Undefined Error."
 +45               DO MSG(SC1,SC2)
 +46               QUIT 
               End DoDot:1
               QUIT 
 +47      ;
 +48       SET SCP177=$$PDAT^SCMCGU("SD*5.3*177")
 +49       IF +SCP177=0
               Begin DoDot:1
 +50               SET SC2="  Unable to obtain SD*5.3*177 Installation Date."
 +51               DO MSG(SC1,SC2)
 +52               QUIT 
               End DoDot:1
               QUIT 
 +53      ;
 +54       IF $$BASELINE(SCP177,DT,SCDFN,SCTST)'=1
               Begin DoDot:1
 +55               SET SC2="  PCMM PC Baseline failed"_$$FMTE^XLFDT($$NOW^XLFDT)_"."
 +56               DO MSG(SC1,SC2)
 +57               QUIT 
               End DoDot:1
               QUIT 
 +58      ;
 +59       QUIT 
 +60      ;
BASELINE(SCP177,SCP212,SCPDFN,SCPTST) ;
 +1       ; input
 +2       ;  SCP177 = Patch 177 date (required)
 +3       ;  SCP212 = Patch 212 date (optional, default = today)
 +4       ;  SCPDFN = Patient ien    (optional, default = 0)
 +5       ;  SCPTST = 1 := test [default = 0]
 +6       ;      
 +7       ; output
 +8       ;  1 = success
 +9       ;  0 = failure
 +10      ;
 +11       NEW SCFLAG,SC1,SC2
 +12       SET SC1="PCMM PC Baseline Process Failure:"
 +13       SET SC177=$GET(SCP177,"")
 +14       IF SC177=""
               Begin DoDot:1
 +15               SET SC2="  Invalid SD*5.3*177 Date Parameter"
 +16               DO MSG(SC1,SC2)
 +17               QUIT 
               End DoDot:1
               QUIT 0
 +18       SET SC212=$GET(SCP212,DT)
 +19       IF SC212=""
               Begin DoDot:1
 +20               SET SC2="  Invalid SD*5.3*212 Date (DT) Parameter"
 +21               DO MSG(SC1,SC2)
 +22               QUIT 
               End DoDot:1
               QUIT 0
 +23       SET SCDFN=$GET(SCPDFN,0)
 +24       IF SCDFN=""
               Begin DoDot:1
 +25               SET SC2="  Invalid DFN Parameter"
 +26               DO MSG(SC1,SC2)
 +27               QUIT 
               End DoDot:1
               QUIT 0
 +28       IF '$DATA(^SCPT(404.43,"APCPOS"))
               Begin DoDot:1
 +29               SET SC2="  Missing ""APCPOS"" x-ref in file 404.43!"
 +30               DO MSG(SC1,SC2)
 +31               QUIT 
               End DoDot:1
               QUIT 0
 +32      ;
 +33       SET SCTST=+$GET(SCPTST,0)
 +34       SET SCFLAG=$$EVENT(SC177,SC212,SCDFN,SCTST)
 +35      ;
 +36       IF SCTST=1
               DO MSG("","",+SCFLAG)
               QUIT 1
 +37       NEW SCFDA,SCERR,SC1,SC2
 +38       SET SC1="PCMM PC Baseline Seeding"
 +39       SET SC2=+$PIECE(SCFLAG,U,2)
 +40       SET SCFLAG=+$PIECE(SCFLAG,U)
 +41       SET SC1=SC1_$SELECT(+SC2:" stopped by TM stop request:",1:" completed:")
 +42       SET SCFDA(1,404.44,"1,",17)=SC212
 +43       DO FILE^DIE("","SCFDA(1)","SCERR")
 +44       IF $DATA(SCERR)
               Begin DoDot:1
 +45               SET SC2="  Caution: Baseline Date NOT updated in PCMM Parameter file"
 +46               DO MSG(SC1,SC2)
 +47               QUIT 
               End DoDot:1
 +48       SET SC2="  "_SCFLAG_" assignments placed in HL7 transmission queue."
 +49       DO MSG(SC1,SC2)
 +50       QUIT 1
 +51      ;
CHECK()   ;
 +1       ; Description:  Determine whether or not the Baseline has run.
 +2       ;
 +3       ; Input: None
 +4       ;
 +5       ; Output:
 +6       ;   Function Value: Return date Baseline was run
 +7       ;
 +8        NEW SCX
 +9        IF '$DATA(^SCTM(404.44,1))
               QUIT -1
 +10       KILL ^TMP($JOB,"SCMCCV6")
 +11       SET SCX=$$GET1^DIQ(404.44,"1,",17,"I","","^TMP($J,""SCMCCV6"")")
 +12       IF $DATA(^TMP($JOB,"SCMCCV6"))
               SET SCX=-2
 +13       KILL ^TMP($JOB,"SCMCCV6")
 +14       QUIT SCX
 +15      ;
 +16      ;
EVENT(SC177,SC212,SCDFN,SCTST) ;
 +1       ; Description: Create an Event in file (#404.48)
 +2       ;
 +3       ; Input:
 +4       ;   SC177 - date patch SD*5.3*177 was installed. [required]
 +5       ;   SC212 - date process runs [default = DT]
 +6       ;   SCDFN - patient ien (ptr file 2) [default = 0]
 +7       ;   SCTST - 1 = test [default = 0]
 +8       ;
 +9       ; Output: 
 +10      ;   p1 = number of entries created
 +11      ;   p2 = stopped by Taskman
 +12      ;
 +13      ; counter
           NEW SCCNT
 +14      ; position assignment IEN (ptr file 404.43)
           NEW SCPAI
 +15      ; team position IEN (ptr file 404.57)
           NEW SCTP
 +16      ; position assignment start date
           NEW SCADT
 +17      ; position assignment end date
           NEW SCDDT
 +18      ; time process starts
           NEW SCNOW
 +19      ; variable pointer string for HL7
           NEW SCVAR
 +20      ; shorthand for ' "APCPOS",SCDFN,1 ' node
           NEW SC1
 +21      ; Taskman flag to stop process
           NEW SCZ
 +22      ;
 +23      ; check for ZSTOP
 +24       SET SCZ=$$S^%ZTLOAD
 +25       IF +SCZ
               QUIT 0_U_1
 +26       SET SCTST=+$GET(SCTST,0)
 +27       KILL ^XTMP("SCMCCV6")
 +28       SET ^XTMP("SCMCCV6",0)=DT_U_$$FMADD^XLFDT(""_DT_"",7)_U_"SCMC PCMM BASELINE SEEDING"
 +29       SET SCNOW=$$NOW^XLFDT
 +30       SET SCCNT=0
 +31       SET SCDFN=+SCDFN
 +32       FOR 
               SET SCDFN=$ORDER(^SCPT(404.43,"APCPOS",SCDFN))
               if (SCDFN="")!(SCZ)
                   QUIT 
               Begin DoDot:1
 +33               SET SCZ=$$S^%ZTLOAD
 +34               if +SCZ
                       QUIT 
 +35      ;
 +36               SET ^XTMP("SCMCCV6","LASTDFN")=SCDFN
 +37               SET SC1="^SCPT(404.43,""APCPOS"",SCDFN,1)"
 +38      ;
 +39      ; quit if no PC assignments
 +40               if '$DATA(@SC1)
                       QUIT 
 +41               SET SCADT=0
 +42               FOR 
                       SET SCADT=$ORDER(@SC1@(SCADT))
                       if SCADT=""
                           QUIT 
                       Begin DoDot:2
 +43                       SET SCTP=0
 +44                       FOR 
                               SET SCTP=$ORDER(@SC1@(SCADT,SCTP))
                               if 'SCTP
                                   QUIT 
                               Begin DoDot:3
 +45      ;
 +46      ; quit if team position does not exist
 +47                               if '$DATA(^SCTM(404.57,SCTP,0))
                                       QUIT 
 +48                               SET SCPAI=0
 +49                               FOR 
                                       SET SCPAI=$ORDER(@SC1@(SCADT,SCTP,SCPAI))
                                       if 'SCPAI
                                           QUIT 
                                       Begin DoDot:4
 +50                                       SET SCDDT=$PIECE($GET(^SCPT(404.43,SCPAI,0)),U,4)
 +51      ;
 +52      ; quit if not active within date range
 +53                                       if $$DTCHK^SCAPU1(SC177,SC212,0,SCADT,SCDDT)<1
                                               QUIT 
 +54                                       SET SCVAR=SCPAI_";SCPT(404.43,"
 +55      ;
 +56      ; add to HL7 event file
 +57                                       if $$CHECK^SCMCHLB1(SCVAR)'=1
                                               QUIT 
 +58      ;
 +59      ; queue for transmit or report
 +60                                       IF SCTST=0
                                               DO ADD^SCMCHLE("NOW",SCVAR,SCDFN,SCTP)
 +61                                       IF SCTST=1
                                               SET SCARRAY(SCCNT+3)=SCVAR_" ^ "_$$GET1^DIQ(2,SCDFN_",",.01)_" ^ "_$$GET1^DIQ(404.57,SCTP_",",.01)_" ^ "_$$FMTE^XLFDT(SCADT)_" ^ "_$$FMTE^XLFDT(SCDDT)
 +62      ;
 +63      ; increment counter
 +64                                       SET SCCNT=SCCNT+1
 +65                                       QUIT 
                                       End DoDot:4
 +66                               QUIT 
                               End DoDot:3
 +67                       QUIT 
                       End DoDot:2
 +68               QUIT 
               End DoDot:1
 +69      ;
 +70       QUIT SCCNT_U_SCZ
 +71      ;
MSG(SC1,SC2,SCTST) ;
 +1        NEW XMY,XMDUZ,XMSUB,XMTEXT
 +2        SET SCTST=+$GET(SCTST,0)
 +3        SET XMDUZ="PCMM Module"
 +4        SET (XMY(DUZ),XMY(XMDUZ))=""
 +5        IF SCTST=0
               Begin DoDot:1
 +6                SET XMSUB="PCMM PC Baseline Seeding Job"
 +7                KILL SCARRAY
 +8                SET SCARRAY(1)=""
 +9                SET SCARRAY(2)=SC1
 +10               SET SCARRAY(3)=SC2
 +11               SET SCARRAY(4)=""
 +12               SET SCARRAY(5)="TaskMan Job Number:       "_$GET(ZTSK)
 +13               SET SCARRAY(6)="Baseline Start Date/Time: "_$GET(SCSTIM)
 +14               SET SCARRAY(7)="Baseline End Date/Time:   "_$$HTE^XLFDT($HOROLOG)
 +15               SET SCARRAY(8)="HL7 Transmit Limit:       "_$$GET1^DIQ(404.44,"1,",15)
 +16               SET SCARRAY(9)=""
 +17               QUIT 
               End DoDot:1
 +18      IF '$TEST
               Begin DoDot:1
 +19               SET XMSUB="PCMM PC Baseline Trial Entries ("_$GET(ZTSK)_")"
 +20               SET SCARRAY(1)=""
 +21               SET SCARRAY(2)=SCTST_" entries would have been placed in HL7 queue:"
 +22               SET SCARRAY(3)="==================================================="
               End DoDot:1
 +23       SET XMTEXT="SCARRAY("
 +24       DO ^XMD
 +25       QUIT 
 +26      ;
RESTART(SCTST) ; alb/rpm
 +1       ; This undocumented entry point allows a user to clear the Baseline
 +2       ; date stored in file #404.44 field #17.  Then the last patient IEN
 +3       ; that was processed from the last run is retrieved from ^XTMP("SCMCCV6"
 +4       ; and decremented to seed the restart point.  If ^XTMP does not exist
 +5       ; the IEN is set to 0.
 +6       ;
 +7       ; Input:
 +8       ;       SCTST - 1 = test [default = 0]
 +9       ;
 +10       SET SCTST=+$GET(SCTST,0)
 +11      ;
 +12       NEW SC1,SC2,SCDFA,SCDFN,SCERR
 +13       SET SC1="PCMM PC Baseline Seeding"
 +14       SET SCDFN=0
 +15      ; Retrieve the last IEN processed
 +16       IF +$GET(^XTMP("SCMCCV6","LASTDFN"))>0
               Begin DoDot:1
 +17               SET SCDFN=+$GET(^XTMP("SCMCCV6","LASTDFN"))-1
               End DoDot:1
 +18      ; Delete the Baseline date from last run
 +19       SET SCFDA(1,404.44,"1,",17)="@"
 +20       DO FILE^DIE("","SCFDA(1)","SCERR")
 +21       IF $DATA(SCERR)
               Begin DoDot:1
 +22               SET SC2="  Warning: Baseline Date NOT cleared in PCMM Parameter file"
 +23               DO MSG(SC1,SC2)
 +24               QUIT 
               End DoDot:1
               QUIT 
 +25      ; Call interactive entry point
 +26       DO EN(SCTST,SCDFN)
 +27       QUIT