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

TIUEDIT.m

Go to the documentation of this file.
  1. TIUEDIT ; SLC/JER - Enter/Edit a Document ;01-Aug-2011 11:29;MGH
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**1,7,22,52,100,109,112,1009**;Jun 20, 1997;Build 22
  1. ; Moved LOADDFLT, BOIL, CANXEC, REPLACE, INSMULT to TIUEDI4
  1. ; Moved DIE, TEXTEDIT from TIUEDIT to TIUEDI4
  1. ; Separated out modules SETTL, GETVST, ASKOK
  1. ; Moved SETTL, GETVST, ASKOK from TIUEDIT to TIUEDI4
  1. ; Changed call to GETREC^TIUEDI1 to call GETRECNW^TIUEDI3
  1. ;IHS/ITSC/LJF 02/26/2003 create v note entry & clean up TIUTITLE variable
  1. ;IHS/ITSC/LJF 08/22/2003 quit patient loop if called by IPD option (BTIURPT)
  1. ;IHS/ITSC/LJF 12/11/2003 review previous notes works for all notes
  1. MAIN(TIUCLASS,SUCCESS,DFN,TIUTITLE,EVNTFLAG,NOSAVE,TIUNDA,TIUSNGL,TIUCHNG) ; Create new document(s)
  1. ; May branch off to edit existing docmt instead of creating new one.
  1. ; Call with: [TIUCLASS] --> pointer to file (8925) corresponding to
  1. ; the class (e.g., Progress Notes=3)
  1. ; from which to select a title
  1. ; [by ref] [SUCCESS] --> Boolean flag returned as IFN when a
  1. ; record is created, or 0 when record
  1. ; creation fails
  1. ; [DFN] --> IEN in patient file (#2)
  1. ; [TIUTITLE] --> Pointer or NAME or PTR^NAME of the
  1. ; TITLE from file 8925.1 to be used as
  1. ; the default.
  1. ; [EVNTFLAG] --> Boolean flag for visit prompt (0 to
  1. ; prompt, 1 to force event type visit)
  1. ; [NOSAVE] --> Boolean flag to suppress saving the data
  1. ; (e.g., when testing new Boilerplates
  1. ; using DDEF action TRY, etc.).
  1. ; [by ref] [TIUNDA] --> array of form: TIUNDA(IFN)="".
  1. ; Used in SHOW NOTES ACROSS PATIENTS.
  1. ; See TIURC, which sets TIUONCE.
  1. ; Also used in TIUEDIM, for mult pts.
  1. ; [TIUSNGL] --> Boolean flag to create only ONE note
  1. ; regardless of multiple pt preference.
  1. ; [by ref] [TIUCHNG] --> If received, passes back TIUCHNG array,
  1. ; which collects info across records about
  1. ; actions taken. Used in feedback
  1. ; msgs to user.
  1. ; Other variables:
  1. ; sets [TIUTYP] --> array with form similar to that of XQORNOD:
  1. ; TIUTYP = title IFN
  1. ; TIUTYP(1) = 1^title IFN^title name,
  1. ; where 1 for us is just a positive #
  1. ; sets [TIUBY] --> used in some input templates to BYpass fields.
  1. ; Called by:
  1. ; Outpt Pharmacy, Consults, ...
  1. N TIUASK,TIUOUT,TIUREL,TIUCHK,TIUDA,TIUEDIT,TIUY,TIUTYP,TIUDPRM
  1. N TIUDFLT,TIUPREF,TIULMETH,TIUVMETH,DIRUT,DUOUT,DTOUT,TIUPRM0
  1. N TIUPRM1,TIUPRM3,TIUENTRY,TIUEXIT,TIUBY,TIUPNAME,TIUST
  1. S EVNTFLAG=+$G(EVNTFLAG,0)
  1. ; --Get user's division parameters, preferences: --
  1. I '$D(TIUPRM0) D SETPARM^TIULE
  1. S TIUPREF=$$PERSPRF^TIULE(DUZ)
  1. ; -- multiple pts; not in OERR, not TRYing DDEF, not single docmt: --
  1. I $P(TIUPREF,U,6)="M",(+$G(ORVP)'>0),(+$G(NOSAVE)'>0),'+$G(TIUSNGL) D MAIN^TIUEDIM(TIUCLASS,.TIUOUT,.TIUNDA,.TIUCHNG) Q
  1. ; -- Loop: Create docmt --
  1. ;F D Q:+$G(ORVP)!+$G(TIUOUT)!+$G(NOSAVE)!+$G(TIUSNGL)
  1. F D Q:+$G(ORVP)!+$G(TIUOUT)!+$G(NOSAVE)!+$G(TIUSNGL)!$G(BTIURPT) ;IHS/ITSC/LJF 08/22/2003
  1. . N TIU,TIUCMMTX,TIUBY,TIUEDIT,TIUNEW,TIUTYP,VADM,VAIN,CANEDIT
  1. . ; -- User specifies basic info for new docmt --
  1. . ; -- Get patient --
  1. . I +$G(ORVP) S DFN=+$G(ORVP)
  1. . I +$G(DFN)'>0 D I +DFN'>0 S TIUOUT=1 Q
  1. . . S DFN=+$$PATIENT^TIULA
  1. . ; -- [For progress notes, show available notes]: --
  1. . S TIUCLASS=$G(TIUCLASS,38)
  1. . ;
  1. . ;IHS/ITSC/LJF 12/11/2003
  1. . ;I TIUCLASS=3,$S(+$$ISA^USRLM(DUZ,"TRANSCRIPTIONIST"):0,1:1),(+$G(NOSAVE)'>0) D EXSTNOTE^TIUEDI2(DFN) D:$G(VALMAR)="^TMP(""OR"",$J,""CURRENT"")" FULL^VALM1
  1. . I $S(+$$ISA^USRLM(DUZ,"TRANSCRIPTIONIST"):0,1:1),(+$G(NOSAVE)'>0) D EXSTNOTE^TIUEDI2(DFN) D:$G(VALMAR)="^TMP(""OR"",$J,""CURRENT"")" FULL^VALM1
  1. . ;
  1. . I +$G(DIROUT)!+$G(DUOUT)!+$G(DTOUT) S TIUOUT=1 Q
  1. . ; -- Set title array TIUTYP (use TIUTITLE or ask user) --
  1. . D SETTL^TIUEDI4(.TIUTYP,TIUCLASS,$G(TIUTITLE)) I +$G(TIUTYP)'>0 S TIUOUT=1 Q
  1. . ; --- Re-direct SURGICAL REPORTS ---
  1. . I +$$ISA^TIULX(TIUTYP,+$$CLASS^TIUSROI("SURGICAL REPORTS")) D ENTEROP^TIUSROI(DFN,TIUTYP) Q
  1. . ; -- Get doc parameters for title, X entry action --
  1. . D DOCPRM^TIULC1(TIUTYP,.TIUDPRM)
  1. . S TIUENTRY=$$GETENTRY^TIUEDI2(+TIUTYP)
  1. . I $L(TIUENTRY) X TIUENTRY
  1. . Q:+$G(TIUOUT) ; If ENTRY ACTION sets TIUOUT=1 Abort entry
  1. . ; -- Set visit array TIU --
  1. . D GETVST^TIUEDI4(DFN,TIUTYP,.TIU,EVNTFLAG)
  1. . I '$D(TIU("VSTR")) K DFN,TIUTYP Q
  1. . ; -- Ask OK --
  1. . D ASKOK^TIUEDI4(TIUTYP,.TIU,.TIUBY,.TIUASK) I '$D(TIU("VSTR")) K DFN,TIUTYP Q
  1. . ; -- If user OK'd basic info, go on to get text, etc.: --
  1. . I $D(TIU),+$G(TIUASK) D
  1. . . ; -- Get record DA --
  1. . . ; DA is either: new stub record, ready for edit, or
  1. . . ; existing record, for edit, or
  1. . . ; existing record, for addendum
  1. . . N DA
  1. . . S DA=$$GETRECNW^TIUEDI3(DFN,.TIU,TIUTYP(1),.TIUNEW,.TIUDPRM,1,DUZ,.CANEDIT)
  1. . . I +DA'>0 W !,"Unable to enter/edit." Q
  1. . . ; -- [Addend DA and Quit] --
  1. . . ; If record not new & user can't edit it, let user
  1. . . ; write addendum and quit:
  1. . . I 'TIUNEW,'CANEDIT D Q
  1. . . . D ADDENDUM^TIUADD(DA,"",.TIUCHNG,1)
  1. . . N TIUQUIT,TIUADD,TIUTDA
  1. . . ; -- Edit new or existing DA --
  1. . . D DIE^TIUEDI4(DA,.TIUQUIT)
  1. . . Q:+$G(TIUQUIT)=2 ; DA doesn't exist (e.g. uparrowed w/ bad record)
  1. . . ;If (CP) and (Timeout or Not Select Consult) and (Consult Associated), Quit before EMPTYDOC check
  1. . . I +$$ISA^TIULX(TIUTYP,+$$CLASS^TIUCP),+$G(TIUQUIT)=1,+$P($G(^TIU(8925,+DA,14)),U,5)>0 Q
  1. . . I $$EMPTYDOC^TIULF(DA) D DELETE(DA,0) S:$G(VALMAR)="^TMP(""TIUVIEW"",$J)" VALMBCK="Q" S:'+$G(TIUNEW) TIUCHNG("DELETE")=1 H:'+$G(TIUNEW) 2 Q
  1. . . Q:+$G(TIUQUIT)
  1. . . S:+DA SUCCESS=+DA
  1. . . I +$G(TIUONCE) S TIUNDA(+$G(DA))="" ; See TIURC, Across Patients
  1. . . ; -- Misc after-edit-stuff for DA --
  1. . . ; -- Mark to ask workload at signature;
  1. . . ; (STOP for Stop codes for stand-alone visits): --
  1. . . I +$G(TIU("STOP")),(+$P($G(TIUDPRM(0)),U,14)'=1) D DEFER^TIUVSIT(DA,TIU("STOP")) I 1 ;piece 14 = suppress DX/CPT on entry
  1. . . E D QUE^TIUPXAP1 ; Post workload now in background
  1. . . ;
  1. . . D VNOTE^BTIUPCC(DA,+TIU("VISIT"),DFN,"ADD") ;IHS/ITSC/LJF 02/26/2003
  1. . . ;
  1. . . S TIUCMMTX=$$COMMIT^TIULC1(+$P(TIUTYP(1),U,2))
  1. . . I TIUCMMTX]"" X TIUCMMTX
  1. . . D RELEASE^TIUT(DA)
  1. . . D VERIFY^TIUT(DA)
  1. . . ; -- Get signature for DA
  1. . . D EDSIG^TIURS(DA)
  1. . . ; - execute EXIT ACTION -
  1. . . S TIUEXIT=$$GETEXIT^TIUEDI2(+$P(TIUTYP(1),U,2))
  1. . . I $L(TIUEXIT) S TIUTDA=DA X TIUEXIT S DA=TIUTDA
  1. . . ; -- [Prompt to add ID stub] --
  1. . . ; I +$P($G(TIUDPRM(0)),U,20) D ADDSTUB^TIUGEDIT(DA)
  1. . . ; -- [Prompt to print DA] --
  1. . . I +$P($G(TIUDPRM(0)),U,8) D PRINT^TIUEPRNT(DA)
  1. . K DFN ; Free patient
  1. . K TIUTITLE ;IHS/ITSC/LJF 02/26/2003 clean up variable for next note
  1. . S TIUPNAME=$$PNAME^TIULC1(TIUCLASS)
  1. . I $$UP^XLFSTR($E(TIUPNAME,$L(TIUPNAME)))="S" S TIUPNAME=$E(TIUPNAME,1,$L(TIUPNAME)-1)
  1. . ; -- [loop again] --
  1. . I '+$G(NOSAVE),'+$G(ORVP),'+$G(TIUSNGL) W !!,"You may enter another ",TIUPNAME,". Press RETURN to exit.",!
  1. Q
  1. ;
  1. DELETE(TIUDA,PROMPT,MSG,HUSH) ; Delete record
  1. N DIDEL,DIE,DR,TIUD0,TIUVSIT,TIUVKILL,TIUDELX,TIUTYPE
  1. S TIUD0=$G(^TIU(8925,+TIUDA,0)),TIUVSIT=$P(TIUD0,U,3),TIUTYPE=+TIUD0
  1. I +$G(PROMPT),'+$$READ^TIUU("YO",MSG,"NO") W !,"Nothing Deleted." Q
  1. K ^TIU(8925,"ASAVE",DUZ,TIUDA)
  1. D DELIRT^TIUDIRT(TIUDA)
  1. ; If a DELETE Action exists for the document definition, execute it
  1. S TIUDELX=$$DELETE^TIULC1(TIUTYPE)
  1. I TIUDELX]"" X TIUDELX
  1. S DA=TIUDA,(DIDEL,DIE)=8925,DR=".01///@"
  1. D ^DIE W:'+$G(HUSH) !,"<NOTHING ENTERED. "
  1. I '+$G(HUSH) W:+TIUD0 $$PNAME^TIULC1(+TIUD0)," DELETED>"
  1. D DELCOMP^TIUEDI1(TIUDA),DELAUDIT^TIUEDI1(TIUDA)
  1. K ^TIU(8925,"ASAVE",DUZ,TIUDA) ; Remove Save Flag
  1. D ALERTDEL^TIUALRT(TIUDA),ADDENDEL^TIUALRT(TIUDA)
  1. ; I +TIUVSIT S TIUVKILL=$$DELVFILE^PXAPI("ALL",TIUVSIT,"","TEXT INTEGRATION UTILITIES")
  1. Q
  1. ;