SCRPTPHS ;ALB/DJS - Team Position History Extract for PCMMR Data Validation; 04/10/14
;;5.3;Scheduling;**620**;AUG 13, 1993;Build 11
;
ENTER ; Entry point
;
; Extract file will be a delimited text file (.TXT) that will provide information for PCMM data validation
; Delimiter is a pipe ("|") character
;
; FILE OUTPUT:
;
; STANUM - Station #
; TPHIEN - IEN of Team Position History file
; TPIEN - IEN of Team Position
; TPOS - Name of Team Position
; EFFDT - Effective Date
; STATUS - Status
; STATRSN - Status Reason
;
N SCMCPATH,SCMCHFS,SCMCERR,SCMCMODE,MSG,IOF,SITE
N SCDATA,SCIENS,STANUM,TPHIEN,TPIEN,TPOS,EFFDT,STATUS,STATRSN
S SITE=$$SITE^VASITE,STANUM=$P(SITE,"^",3)
S SCMCPATH=$$DEFDIR^%ZISH(),SCMCHFS=STANUM_"_PCMMTEAMPOSITIONHISTORY.TXT",SCMCERR=0 U 0 W !!,SCMCPATH
D HFSOPEN("SCMCRP",SCMCPATH,SCMCHFS,"W") I SCMCERR G END
U IO
D COLHDR,SETREC G END
;
SETREC ;$O through Team Position History file and find all team positions
S TPHIEN=0
F S TPHIEN=$O(^SCTM(404.59,TPHIEN)) Q:TPHIEN=""!(TPHIEN'?.N) D
.K SCDATA
.S SCIENS=+$G(TPHIEN)_","
.D GETS^DIQ(404.59,SCIENS,".01;.02;.03;.04","IE","SCDATA","")
.S TPIEN=$G(SCDATA(404.59,SCIENS,.01,"I"))
.S TPOS=$G(SCDATA(404.59,SCIENS,.01,"E"))
.S EFFDT=$G(SCDATA(404.59,SCIENS,.02,"E"))
.S STATUS=$G(SCDATA(404.59,SCIENS,.03,"E"))
.S STATRSN=$G(SCDATA(404.59,SCIENS,.04,"E"))
.W STANUM_"|"_TPHIEN_"|"_TPIEN_"|"_TPOS_"|"_EFFDT_"|"_STATUS_"|"_STATRSN,!
Q
;
COLHDR ;Create column header for Team Position History extract file
W "Station #|Team Position History IEN|Team Position IEN|Team Name|Effective Date|Status|Status Reason",!
Q
;
END D HFSCLOSE("SCMCRP",SCMCHFS)
N I
I '+SCMCERR D Q ;Create pipe delimited output if no errors
.S MSG=$NA(^TMP("SCMC",$J))
;Replace "##FFFF##" with Form Feeds - code needed for LINUX environments
S I=0 F S I=$O(^TMP("SCMC",$J,1,I)) Q:'I D
.S:^TMP("SCMC",$J,1,I)["##FFFF##" ^TMP("SCMC",$J,1,I)=$P(^TMP("SCMC",$J,1,I),"##FFFF##")_$C(13,12)_$P(^TMP("SCMC",$J,1,I),"##FFFF##",2)
.S ^TMP("SCMC",$J,1,I)=^TMP("SCMC",$J,1,I)_$C(13)
.S:^TMP("SCMC",$J,1,I)["$END" ^TMP("SCMC",$J,1,I)=""
S MSG=$NA(^TMP("SCMC",$J))
Q
;
HFSOPEN(HANDLE,SCMCPATH,SCMCHFS,SCMCMODE) ; Open File
N POP
D OPEN^%ZISH(HANDLE,SCMCPATH,SCMCHFS,$G(SCMCMODE,"W")) D:POP Q:POP
.S SCMCERR=1,^TMP("SCMC",$J,1)="0^Unable to open file "
S IOF="$$IOF^SCRPTPHS" ;resets screen position and adds page break flag - added to deal with Linux environments.
Q
;
HFSCLOSE(HANDLE,SCMHFS) ;Close HFS and unload data
D CLOSE^%ZISH(HANDLE)
Q
;
IOF() ;used to reset position and insert page break flag when @IOF is executed.
S $X=0,$Y=0
Q "##FFFF##"_$C(13,10)
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCRPTPHS 2734 printed Dec 13, 2024@02:43:05 Page 2
SCRPTPHS ;ALB/DJS - Team Position History Extract for PCMMR Data Validation; 04/10/14
+1 ;;5.3;Scheduling;**620**;AUG 13, 1993;Build 11
+2 ;
ENTER ; Entry point
+1 ;
+2 ; Extract file will be a delimited text file (.TXT) that will provide information for PCMM data validation
+3 ; Delimiter is a pipe ("|") character
+4 ;
+5 ; FILE OUTPUT:
+6 ;
+7 ; STANUM - Station #
+8 ; TPHIEN - IEN of Team Position History file
+9 ; TPIEN - IEN of Team Position
+10 ; TPOS - Name of Team Position
+11 ; EFFDT - Effective Date
+12 ; STATUS - Status
+13 ; STATRSN - Status Reason
+14 ;
+15 NEW SCMCPATH,SCMCHFS,SCMCERR,SCMCMODE,MSG,IOF,SITE
+16 NEW SCDATA,SCIENS,STANUM,TPHIEN,TPIEN,TPOS,EFFDT,STATUS,STATRSN
+17 SET SITE=$$SITE^VASITE
SET STANUM=$PIECE(SITE,"^",3)
+18 SET SCMCPATH=$$DEFDIR^%ZISH()
SET SCMCHFS=STANUM_"_PCMMTEAMPOSITIONHISTORY.TXT"
SET SCMCERR=0
USE 0
WRITE !!,SCMCPATH
+19 DO HFSOPEN("SCMCRP",SCMCPATH,SCMCHFS,"W")
IF SCMCERR
GOTO END
+20 USE IO
+21 DO COLHDR
DO SETREC
GOTO END
+22 ;
SETREC ;$O through Team Position History file and find all team positions
+1 SET TPHIEN=0
+2 FOR
SET TPHIEN=$ORDER(^SCTM(404.59,TPHIEN))
if TPHIEN=""!(TPHIEN'?.N)
QUIT
Begin DoDot:1
+3 KILL SCDATA
+4 SET SCIENS=+$GET(TPHIEN)_","
+5 DO GETS^DIQ(404.59,SCIENS,".01;.02;.03;.04","IE","SCDATA","")
+6 SET TPIEN=$GET(SCDATA(404.59,SCIENS,.01,"I"))
+7 SET TPOS=$GET(SCDATA(404.59,SCIENS,.01,"E"))
+8 SET EFFDT=$GET(SCDATA(404.59,SCIENS,.02,"E"))
+9 SET STATUS=$GET(SCDATA(404.59,SCIENS,.03,"E"))
+10 SET STATRSN=$GET(SCDATA(404.59,SCIENS,.04,"E"))
+11 WRITE STANUM_"|"_TPHIEN_"|"_TPIEN_"|"_TPOS_"|"_EFFDT_"|"_STATUS_"|"_STATRSN,!
End DoDot:1
+12 QUIT
+13 ;
COLHDR ;Create column header for Team Position History extract file
+1 WRITE "Station #|Team Position History IEN|Team Position IEN|Team Name|Effective Date|Status|Status Reason",!
+2 QUIT
+3 ;
END DO HFSCLOSE("SCMCRP",SCMCHFS)
+1 NEW I
+2 ;Create pipe delimited output if no errors
IF '+SCMCERR
Begin DoDot:1
+3 SET MSG=$NAME(^TMP("SCMC",$JOB))
End DoDot:1
QUIT
+4 ;Replace "##FFFF##" with Form Feeds - code needed for LINUX environments
+5 SET I=0
FOR
SET I=$ORDER(^TMP("SCMC",$JOB,1,I))
if 'I
QUIT
Begin DoDot:1
+6 if ^TMP("SCMC",$JOB,1,I)["##FFFF##"
SET ^TMP("SCMC",$JOB,1,I)=$PIECE(^TMP("SCMC",$JOB,1,I),"##FFFF##")_$CHAR(13,12)_$PIECE(^TMP("SCMC",$JOB,1,I),"##FFFF##",2)
+7 SET ^TMP("SCMC",$JOB,1,I)=^TMP("SCMC",$JOB,1,I)_$CHAR(13)
+8 if ^TMP("SCMC",$JOB,1,I)["$END"
SET ^TMP("SCMC",$JOB,1,I)=""
End DoDot:1
+9 SET MSG=$NAME(^TMP("SCMC",$JOB))
+10 QUIT
+11 ;
HFSOPEN(HANDLE,SCMCPATH,SCMCHFS,SCMCMODE) ; Open File
+1 NEW POP
+2 DO OPEN^%ZISH(HANDLE,SCMCPATH,SCMCHFS,$GET(SCMCMODE,"W"))
if POP
Begin DoDot:1
+3 SET SCMCERR=1
SET ^TMP("SCMC",$JOB,1)="0^Unable to open file "
End DoDot:1
if POP
QUIT
+4 ;resets screen position and adds page break flag - added to deal with Linux environments.
SET IOF="$$IOF^SCRPTPHS"
+5 QUIT
+6 ;
HFSCLOSE(HANDLE,SCMHFS) ;Close HFS and unload data
+1 DO CLOSE^%ZISH(HANDLE)
+2 QUIT
+3 ;
IOF() ;used to reset position and insert page break flag when @IOF is executed.
+1 SET $X=0
SET $Y=0
+2 QUIT "##FFFF##"_$CHAR(13,10)
+3 ;