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

PXRMXTF.m

Go to the documentation of this file.
  1. PXRMXTF ; SLC/PJH - Reminder Reports Template Filing ;05/02/2002
  1. ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
  1. ;
  1. ; Called from PXRMXTA
  1. ;
  1. ;Select template name and file
  1. ;-----------------------------
  1. START N NEWIEN,NEWTEMP,OLDTEMP
  1. ;Save original name
  1. S OLDTEMP=$P(PXRMTMP,U,2)
  1. ;Reset PXRMTMP in case the template name field has been edited
  1. S $P(PXRMTMP,U,2)=$P($G(^PXRMPT(810.1,$P(PXRMTMP,U,1),0)),U)
  1. ;Redisplay changes made
  1. D REDISP
  1. ;Prompt template name
  1. D NAME
  1. ;Rollback ^DIE changes if edit is abandoned
  1. I $D(DTOUT)!$D(DUOUT) D ROLL Q
  1. ;
  1. I NEWTEMP=$P(PXRMTMP,U,2),NEWTEMP=OLDTEMP D MESS(1,NEWTEMP)
  1. I NEWTEMP=$P(PXRMTMP,U,2),NEWTEMP'=OLDTEMP D MESS(3,OLDTEMP,NEWTEMP)
  1. ;
  1. ;If a new template ID is selected then create a new template
  1. I NEWTEMP'=$P(PXRMTMP,U,2) D I $D(MSG) S DTOUT=1 Q
  1. .;Create template header
  1. .D HEADER
  1. .;Save edited template detail to new template name
  1. .D REFILE Q:$D(MSG)
  1. .;Save Message
  1. .D MESS(2,NEWTEMP)
  1. .;File original arrays to old template (rollback ^DIE changes)
  1. .D FILE^PXRMXTU(PXRMTMP,1,1)
  1. .;Set selected template ID
  1. .S PXRMTMP=NEWIEN
  1. ;
  1. ;Reload arrays
  1. D LOAD^PXRMXT I $D(MSG) S DTOUT=1 Q
  1. EXIT Q
  1. ;
  1. ;Rename edited template
  1. ;----------------------
  1. NAME N X,Y,TEXT,DIR
  1. K DIROUT,DIRUT,DTOUT,DUOUT
  1. S DIR(0)="FAU"_U_"3:30"_U_"K:'$$OK^PXRMXTF(X) X"
  1. S DIR("A")="STORE REPORT LOGIC IN TEMPLATE NAME: "
  1. S DIR("B")=$P(PXRMTMP,U,2)
  1. S DIR("?")="Enter template name. For detailed help type ??"
  1. S DIR("??")=U_"D HELP^PXRMXTF(1)"
  1. W !
  1. D ^DIR K DIR
  1. I $D(DIROUT) S DTOUT=1
  1. I $D(DTOUT)!($D(DUOUT)) Q
  1. S NEWTEMP=Y
  1. Q
  1. ;
  1. ;Check if the template name is in use
  1. ;------------------------------------
  1. OK(NAME) ;
  1. ;Original template name may be used
  1. I X=DIR("B") Q 1
  1. I $E(DIR("B"),1,$L(X))=X Q 0
  1. ;Else check if template name defined
  1. I '$D(^PXRMPT(810.1,"B",NAME)) Q 1
  1. Q 0
  1. ;
  1. ;Create Template header and get IEN
  1. ;----------------------------------
  1. ;Otherwise create a new entry
  1. S DATA=$G(^PXRMPT(810.1,0)),IEN=$P(DATA,U,3),NUM=$P(DATA,U,4)
  1. F S IEN=IEN+1 Q:'$D(^PXRMPT(IEN,0))
  1. S ^PXRMPT(810.1,IEN,0)=NEWTEMP
  1. S ^PXRMPT(810.1,"B",NEWTEMP,IEN)=""
  1. S $P(^PXRMPT(810.1,0),U,3)=IEN,$P(^PXRMPT(810.1,0),U,4)=NUM+1
  1. S NEWIEN=IEN_U_NEWTEMP
  1. Q
  1. ;
  1. ;Redisplay edited template details
  1. ;---------------------------------------------
  1. REDISP N PXRMLCSC,PXRMPRIM,PXRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
  1. N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
  1. N PXRMLIST,TITLE
  1. ;
  1. ;Load temporary arrays from edited template PXRMTMP
  1. D LOAD^PXRMXT I $D(MSG) Q
  1. ;Clear last run date
  1. S RUN=""
  1. ;Display
  1. D ^PXRMXTD
  1. ;
  1. Q
  1. ;
  1. ;Copy edited template details to new template
  1. ;---------------------------------------------
  1. REFILE N PXRMLCSC,PXRMPRIM,PXRMREP,PXRMSEL,PXRMTYP,PXRMFD,RUN,PXRMCS
  1. N PXRMREM,PXRMFAC,PXRMPRV,PXRMPAT,PXRMOTM,PXRMSCAT,PXRMLCHL,PXRMCS
  1. N PXRMLIST,TITLE
  1. ;
  1. ;Load temporary arrays from edited template PXRMTMP
  1. D LOAD^PXRMXT I $D(MSG) Q
  1. ;Clear last run date
  1. S RUN=""
  1. ;Save arrays to new ID
  1. D FILE^PXRMXTU(NEWIEN,1,0) Q:$D(MSG)
  1. Q
  1. ;
  1. ;Rollback changes (also called from PXRMXTA)
  1. ;----------------
  1. ROLL ;
  1. D FILE^PXRMXTU(PXRMTMP,1,1)
  1. I $D(MSG) S DTOUT=1 Q
  1. ;Changes not saved message
  1. D MESS(0,$P(PXRMTMP,U,2))
  1. Q
  1. ;
  1. ;Filing messages
  1. ;---------------
  1. MESS(MODE,INP,INP1) ;
  1. I MODE=0 W !,"Changes to template '"_INP_"' have not been saved" Q
  1. I MODE=1 W !,"Changes to template '"_INP_"' have been saved"
  1. I MODE=2 W !,"A new template '"_INP_"' has been created"
  1. I MODE=3 W !,"Template '"_INP_"' renamed as '"_INP1_"'"
  1. I MODE=4 W !,"Template '"_INP_"' not saved"
  1. Q
  1. ;
  1. ;General help text routine. Write out the text in the HTEXT array
  1. ;----------------------------------------------------------------
  1. HELP(CALL) ;
  1. N HTEXT
  1. N DIWF,DIWL,DIWR,IC
  1. S DIWF="C70",DIWL=0,DIWR=70
  1. ;
  1. I CALL=1 D
  1. .S HTEXT(1)="To save or rename the existing template use the default"
  1. .S HTEXT(2)="name. To create a new template and leave the original "
  1. .S HTEXT(3)="unchanged enter a different template name "
  1. .S HTEXT(4)="that is not in use."
  1. ;
  1. K ^UTILITY($J,"W")
  1. S IC=""
  1. F S IC=$O(HTEXT(IC)) Q:IC="" D
  1. . S X=HTEXT(IC)
  1. . D ^DIWP
  1. W !
  1. S IC=0
  1. F S IC=$O(^UTILITY($J,"W",0,IC)) Q:IC="" D
  1. . W !,^UTILITY($J,"W",0,IC,0)
  1. K ^UTILITY($J,"W")
  1. W !
  1. Q