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

TIUGEDIT.m

Go to the documentation of this file.
  1. TIUGEDIT ; SLC/MAM - Add New ID Entry; 8/28/01
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**100,123**;Jun 20, 1997
  1. DIE(DA,TIUQUIT) ; Invoke ^DIE
  1. N Y,DIE,DR
  1. S ^TIU(8925,"ASAVE",DUZ,DA)=""
  1. S DR=$$GETTMPL^TIUEDI1(+$P(^TIU(8925,+DA,0),U))
  1. I DR']"" W !?5,$C(7),"No Edit template defined for ",$$PNAME^TIULC1(+$P(^TIU(8925,+DA,0),U)),! S TIUQUIT=2 Q
  1. S DIE=8925 D ^DIE
  1. S DR=".05///undictated",DIE=8925 D ^DIE
  1. D UPDTIRT^TIUDIRT(.TIU,DA),SEND^TIUALRT(DA)
  1. L -^TIU(8925,+DA)
  1. Q
  1. ;
  1. ADDSTUB(DADDA) ; Prompt user for new stub ID entries for parent DADDA
  1. N TIUAUTH,TIUTYP,TIUDAD,DFN,TIUDPRM,DA,TIURTYP,TIUPRMT
  1. N X,Y,DIC
  1. S DFN=$P(^TIU(8925,DADDA,0),U,2)
  1. W !!," If you wish you may add stub interdisciplinary entries for this note:",!
  1. F D Q:$G(TIUAUTH)'>0 Q:$G(TIUTYP)'>0
  1. . K TIUTYP,TIUAUTH
  1. . S DIC=200,DIC(0)="AEMQ",DIC("A")="Select stub AUTHOR: "
  1. . S DIC("S")="I '+$$ISTERM^USRLM(+Y)"
  1. . D ^DIC
  1. . ;I Y'>0 S TIUOUT=1 Q
  1. . Q:Y'>0
  1. . S TIUAUTH=+Y
  1. . ; -- Get data array TIUDAD on parent note DADDA: --
  1. . I '$D(TIUDAD) D GETTIU^TIULD(.TIUDAD,DADDA)
  1. . D DOCSPICK^TIULA2(.TIUTYP,3,"1A","LAST","Select stub TITLE: ","+$$CANPICK^TIULP(+Y),+$$CANENTR^TIULP(+Y),$$CANLINK^TIULP(+Y)")
  1. . ;I +$G(TIUTYP)'>0 S TIUOUT=1 Q
  1. . Q:+$G(TIUTYP)'>0
  1. . S TIUTYP=+$P($G(TIUTYP(1)),U,2) ; IFN. (DOCSPICK returns TIUTYP as 1.)
  1. . ; -- Use visit of parent: --
  1. . M TIU=TIUDAD
  1. . ;-- Get parameters for selected title: --
  1. . D DOCPRM^TIULC1(TIUTYP,.TIUDPRM)
  1. . ; -- Get DA: --
  1. . S DA=$$CREATREC^TIUEDI3(DFN,.TIU,TIUTYP(1))
  1. . N TIUQUIT,TIUTDA
  1. . D DIE(DA,.TIUQUIT)
  1. . D LINK^TIUGR2(DA,DADDA)
  1. . W !," Stub entry added",!!
  1. Q
  1. ;
  1. ADDDAD(DADDA,ADDED) ; Create new ID entry and link it to note DADDA
  1. ; Assumes DADDA can receive ID entries.
  1. ; Requires DADDA = parent note
  1. ; Requires DADLINE = parent note line number
  1. ; Returns ADDED > 0 if new note added (may not be linked), otherwise = 0
  1. N TITLE,TIUD0,TITLEDA,ADDING,STATUS,KIDDA
  1. S ADDED=0
  1. S TIUD0=$G(^TIU(8925,+DADDA,0))
  1. S TITLEDA=+TIUD0,STATUS=$P(TIUD0,U,5),TITLE=$$PNAME^TIULC1(TITLEDA)
  1. I STATUS<6 Q
  1. S ADDING=$$READ^TIUU("Y","Are you adding a new interdisciplinary entry to this note","YES")
  1. I 'ADDING D Q
  1. . W !!,"This note appears to be an interdisciplinary parent. Please select"
  1. . W !,"the note you want to attach to this note FIRST, or check with IRM"
  1. . W !,"or your clinical coordinator."
  1. . I $$READ^TIUU("EA","Press RETURN to continue...")
  1. D CLEAR^VALM1 W !!,"Adding a new interdisciplinary entry to",!,TITLE
  1. D FULL^VALM1
  1. D ADDDAD1(DADDA,.KIDDA)
  1. I $G(KIDDA) S ADDED=1 D:$D(^TMP("TIUR",$J)) UPIDDATA^TIURL1(DADDA),UPIDDATA^TIURL1(KIDDA)
  1. Q
  1. ;
  1. ADDDAD1(DADDA,DA) ; Enter one new ID Document and link it to DADDA
  1. ; Call with:
  1. ; [DADDA] --> IFN of note new note will be added to,
  1. ; i.e. parent note. Required.
  1. ; [DA] --> IFN of new note or 0 if not created. Passed back.
  1. N LINKTL,TIUVSUPP,TIULMETH,TIU,TIUVMETH,TIUOUT,TIUASK,TIUDAD
  1. N TIUNEW,TIU,TIUTYP,DFN,EDIT,TIUCMMTX,TIUDPRM,TIUEXIT,CONTINUE
  1. N TIUQUIT
  1. S DA=0
  1. ; -- Get data array TIUDAD on parent note DADDA: --
  1. D GETTIU^TIULD(.TIUDAD,DADDA)
  1. S DFN=$P(^TIU(8925,DADDA,0),U,2)
  1. ; -- Get new title from user.
  1. ; Set info into array TIUTYP where
  1. ; TIUTYP = title DA
  1. ; TIUTYP(1) = 1^title DA^Name...
  1. TITLE ; -- Get title. Limit titles to those user can link, at least
  1. ;for SOME status. Check again later after we know the status.
  1. W !!,"Please select a title for your entry:"
  1. D DOCSPICK^TIULA2(.TIUTYP,3,"1A","LAST","","+$$CANPICK^TIULP(+Y),+$$CANENTR^TIULP(+Y),$$CANLINK^TIULP(+Y)")
  1. I +$G(TIUTYP)'>0 S TIUOUT=1 Q
  1. S TIUTYP=+$P($G(TIUTYP(1)),U,2) ; IFN. (DOCSPICK returns TIUTYP as 1.)
  1. VISIT ; -- Get visit (use same visit as first entry unless visit
  1. ;must be an historical event and parent visit is not hist): --
  1. S TIUVSUPP=+$$SUPPVSIT^TIULC1(TIUTYP)
  1. I TIUVSUPP,$P(TIUDAD("VSTR"),";",3)'="E" D EVENT^TIUSRVP1(.TIU,DFN) I 1
  1. E M TIU=TIUDAD
  1. VALID ; -- Validate, i.e. ask user if OK: --
  1. S TIUVMETH=$$GETVMETH^TIUEDI1(TIUTYP)
  1. I '$L(TIUVMETH) D S TIUOUT=1 Q
  1. . W !,$C(7),"No Validation Method defined for "
  1. . W $$PNAME^TIULC1(TIUTYP),".",!,"Please contact IRM..."
  1. ; -- Ask user if proposed docmt looks OK.
  1. ; May change array TIU, gets user answer in TIUASK: --
  1. K TIU("REFDT") ; for new ID child, want default = NOW. See TIULD
  1. X TIUVMETH
  1. I '$D(TIU("VSTR")) D Q
  1. . W !,$C(7),"Patient & Visit required." H 2
  1. ; -- Go on if user answers says OK: --
  1. Q:'TIUASK
  1. ;-- Get parameters for selected title: --
  1. D DOCPRM^TIULC1(TIUTYP,.TIUDPRM)
  1. ; -- Get DA: new docmt for user to continue entering, or
  1. ; existing docmt for user to edit, or existing docmt for
  1. ; user to link w/o editing since they may not edit it: --
  1. S DA=$$GETRECG^TIUGEDI1(DFN,.TIU,.TIUTYP,.TIUDPRM,.TIUNEW,.EDIT,DADDA)
  1. I 'DA S VALMSG="** No entry added **" Q
  1. ; -- If user is attaching an existing docmt they may not edit,
  1. ; try to attach, and quit: --
  1. I 'TIUNEW,'EDIT D TRYLINK(DA,DADDA,.TIUDAD) H 2 Q
  1. ; -- Edit new or existing DA: --
  1. N TIUQUIT,TIUTDA
  1. D DIE^TIUEDI4(DA,.TIUQUIT)
  1. Q:'$G(^TIU(8925,DA,0)) ; uparrow w/ bad docmt, already deleted
  1. I $$EMPTYDOC^TIULF(DA) D DELETE^TIUEDIT(DA,0) S:$G(VALMAR)="^TMP(""TIUVIEW"",$J)" VALMBCK="Q" S:'TIUNEW TIUCHNG("DELETE")=1 H:'TIUNEW 2 Q
  1. I +$G(TIUQUIT),'EDIT W !,"Document not attached" H 2 Q
  1. ; -- Misc after-edit-stuff for DA --
  1. I +$G(TIU("STOP")),(+$P($G(TIUDPRM(0)),U,14)'=1) D DEFER^TIUVSIT(DA,TIU("STOP")) I 1 ; Stop code: For stand alones, mark to get work load at signature
  1. E D QUE^TIUPXAP1 ; Post workload now in background
  1. S TIUCMMTX=$$COMMIT^TIULC1(TIUTYP)
  1. I TIUCMMTX]"" X TIUCMMTX
  1. D RELEASE^TIUT(DA)
  1. D VERIFY^TIUT(DA)
  1. ; -- If get this far without quitting, attach entry,
  1. ; new or existing, so auto-print prints whole note:
  1. D LINK^TIUGR2(DA,DADDA) S VALMSG="** Entry attached **"
  1. ; -- Get signature
  1. D EDSIG^TIURS(DA) ;does auto-print
  1. ; -- execute EXIT ACTION --
  1. S TIUEXIT=$$GETEXIT^TIUEDI2(TIUTYP)
  1. I $L(TIUEXIT) S TIUTDA=DA X TIUEXIT S DA=TIUTDA
  1. ;I '$G(^TIU(8925,DA,21)) D TRYLINK(DA,DADDA,.TIUDAD)
  1. ; -- [Prompt to print DA] --
  1. I +$P($G(TIUDPRM(0)),U,8) D PRINT^TIUEPRNT(DA)
  1. Q
  1. ;
  1. ;its status, to see if user can attach it to an ID note; if so,
  1. ;attach DA to DADDA.
  1. ; Already know that DADDA can receive ID entries.
  1. ;4/11/01 not currently used
  1. N CANLINK
  1. S CANLINK=$$CANDO^TIULP(DA,"ATTACH TO ID NOTE")
  1. I 'CANLINK D Q
  1. . W !!,$P(CANLINK,U,2),!," Entry saved as a stand-alone note. Please attach it later if you are",!," authorized to do so."
  1. . I $$READ^TIUU("EA","Press RETURN to continue...")
  1. . I $D(DUOUT)!$D(DTOUT)!$D(DIROUT) S TIUQUIT=1
  1. . S VALMSG="** Entry saved as a stand-alone note **"
  1. D LINK^TIUGR2(DA,DADDA)
  1. W !!,"Entry added to ",$P(TIUDAD("DOCTYP"),U,2)
  1. S VALMSG="** Entry attached **"
  1. Q
  1. ;