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

ISIJRPT.m

Go to the documentation of this file.
  1. ISIJRPT ; ISI/JHC - ISIRAD Report Entry functions ; 10/17/2022
  1. ;;1.1;ESL ISI IMAGING;**102,106,110**;Dec 21, 2022;Build 41
  1. ;; This routine is the property of ViTel Net, and should not be modified.
  1. ;; This software is a medical device and is subject to FDA regulation.
  1. ;; Modifications to this software may only be made under the terms of
  1. ;; 21CFR820 regulation. 21CFR Subpart A 820.1: "The failure to comply
  1. ;; with any applicable provision in this part renders a device
  1. ;; adulterated under section 501(h) of the act. Such a device,
  1. ;; as well as any person responsible for the failure to comply,
  1. ;; is subject to regulatory action."
  1. ; Reference to DAYCASE^MAGJUTL6 in ICR #7407
  1. ; Reference to File #2006.69 in ICR #7410
  1. ;
  1. Q
  1. ;
  1. ERR ;
  1. N ERR S ERR=$$EC^%ZOSV S @MAGGRY@(0)="0^4~"_ERR
  1. D @^%ZOSF("ERRTN")
  1. Q:$Q 1 Q
  1. ;
  1. ; rpc ISIJ REPORT ENTER -- initialize report enter window
  1. ;
  1. RPTOPEN(MAGGRY,PARAMS) ;
  1. ; PARAMS: TXID ^ CASEID [ | CASEID-2 | etc. ] -- (one or more Cases accepted for input)
  1. ; TXID: 0: View only; 1: EDIT report; 2: AMEND report
  1. ; CASEID: RADFN ^ RADTI ^ RACNI ^ RARPT ("normal" identifier for VistARad)
  1. ; Reply message:
  1. ; # Lines to follow (0-n) ^ Reply Code ~ Reply display text
  1. ; Reply Code- 0-Normal; 3-Abnormal; 4-Error
  1. ; Exams List:
  1. ; Text | Case ID | "Active" flag ^ DX Code flag ^ Required elements flag ^ Case # ^ CPT ^ Procedure
  1. ; Report data follows (for Amend pathway & Edit Draft pathways):
  1. ; *REPORT Start for REPORT
  1. ; (1:N lines of text follow)
  1. ; *REPORT_END End
  1. ; *IMPRESSION Start
  1. ; (1:N lines of text follow)
  1. ; *IMPRESSION_END end
  1. ; *DXCODE Start
  1. ; Code ^ Text (1:N lines of follow)
  1. ; *DXCODE_END end
  1. ;
  1. ;
  1. N $ETRAP,$ESTACK S $ETRAP="D ERR^ISIJRPT"
  1. N CASEID,DAYCASE,MAGLST,REPLY,TXID,PIPE
  1. N RADFN,RADTI,RACNI,RARPT,RASTCAT,RASTORD,REQFLAGS,REQFLG
  1. N ACTIVE,EDITFLAG,EXAMS,IEXAM,NEXAMS,PSETS,PSETCT
  1. N LINECT,ICT,OUT,RPTSTAT,STATCT,GETRPT,TXTYPE
  1. S LINECT=0,REPLY="",TXTYPE="",REQFLAGS=0
  1. S PIPE="|"
  1. S TXID=+PARAMS,RADFN=+$P(PARAMS,U,2),RADTI=$P(PARAMS,U,3),RACNI=+$P(PARAMS,U,4)
  1. S MAGLST="ISIJRPC" S MAGGRY=$NA(^TMP($J,MAGLST)) K @MAGGRY
  1. N DIQUIET S DIQUIET=1 D DT^DICRW
  1. I RADFN,RADTI,RACNI,$D(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)) ; ICR 65
  1. E S REPLY="0^4~Invalid Request; no Exam found for input data. ("_PARAMS_") errcode*1" G RPTOPENZ
  1. ;
  1. ; verify user type is valid for Editing a report
  1. I +TXID D
  1. . I +MAGJOB("USER",1)
  1. . E S REPLY="0^4~Only a radiologist may edit a report. ("_PARAMS_") errcode*1a" G RPTOPENZ
  1. ;
  1. ; init array of exams to be processed
  1. S EXAMS(1)="|"_$P($P(PARAMS,PIPE),U,2,5)
  1. F IEXAM=2:1 S CASEID=$P(PARAMS,PIPE,IEXAM) Q:CASEID="" D I REPLY]"" G RPTOPENZ
  1. . I +CASEID'=RADFN S REPLY="0^4~Invalid Request; multiple exams for different patients. ("_PARAMS_") errcode*2" Q
  1. . S EXAMS(IEXAM)="|"_CASEID
  1. S NEXAMS=IEXAM-1
  1. ;
  1. I NEXAMS>1 D I REPLY]"" G RPTOPENZ
  1. . I "^2^0^"[TXID S REPLY="0^4~Invalid Request; only one exam allowed for View or Amend. ("_PARAMS_") errcode*3" Q
  1. ;
  1. ; get all needed data for each exam
  1. F IEXAM=1:1:NEXAMS S CASEID=$P(EXAMS(IEXAM),PIPE,2) D
  1. . S $P(EXAMS(IEXAM),PIPE)=$$GETDATA^ISIJRPT2(.CASEID,0) ; caseid updated if rarpt not available w/ input caseid (Cat. "R" exams)
  1. . S $P(EXAMS(IEXAM),PIPE,2)=CASEID
  1. ;
  1. ; EXAMS(n) = Exam_DATA | dfn^dti^cni^rarpt | ACTIVE_flag ^ EDIT_flag
  1. ; Exam_DATA:
  1. ; PrtSetCase# ^ PROC ^ DAYCASE ^ RASTNAM ^ CPT ^ MODIF ^ RASTCAT ^ RPT STATUS ^ DXCODE-IMPRESSION_FLAGS
  1. ;
  1. ; get rid of input "duplicate" pset exams, if any
  1. I NEXAMS>1 D
  1. . F IEXAM=1:1:NEXAMS S X=$P(EXAMS(IEXAM),PIPE),T=+X D:T
  1. . . I $D(PSETS(T)) K EXAMS(IEXAM) S NEXAMS=NEXAMS-1 Q
  1. . . S PSETS(T)=IEXAM
  1. ;
  1. ; get display data for printset members of "final" exams list
  1. S IEXAM=0
  1. F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM I +EXAMS(IEXAM) D ; printset member
  1. . S PSETCT=0,EXAMS(IEXAM,PSETCT)=0
  1. . S T=EXAMS(IEXAM)
  1. . S DAYCASE=$P(T,U,3)
  1. . S T=$P(EXAMS(IEXAM),PIPE,2)
  1. . S RADFN=$P(T,U,1),RADTI=$P(T,U,2),RACNI=$P(T,U,3)
  1. . S PSETS=$$DAYCASE^MAGJUTL6(RADFN,RADTI,RACNI) ; list of pset members' acns
  1. . F I=1:1:$L(PSETS,U) S T=$P(PSETS,U,I) I T'=DAYCASE D ; n/a for starting case #
  1. . . S X=$$DAYCASE3^MAGJUTL6(T) ; get caseid for this pset member
  1. . . I +X S X=$$GETDATA^ISIJRPT2(X,1),PSETCT=PSETCT+1,EXAMS(IEXAM,PSETCT)=X,EXAMS(IEXAM,0)=PSETCT
  1. ;
  1. ; verify individual exams OK to proceed
  1. S IEXAM=0,GETRPT=0
  1. F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM D I REPLY]"" G RPTOPENZ
  1. . S X=$P(EXAMS(IEXAM),PIPE),CASEID=$P(EXAMS(IEXAM),PIPE,2)
  1. . S RASTCAT=$P(X,U,7),RPTSTAT=$P(X,U,8),REQFLG=$P(X,U,9),DAYCASE=$P(X,U,3)
  1. . ; 1st check if user has required locks
  1. . D I REPLY]"" Q
  1. . . N LOCKSTAT,LTYPE
  1. . . S LOCKSTAT="",LTYPE=$S(RASTCAT="E":"Exam",1:"Report")
  1. . . I +TXID S LOCKSTAT=$$LOCKCHK(CASEID,RASTCAT,DAYCASE)
  1. . . I +LOCKSTAT!(RASTCAT="C"&'TXID) ; ok: Locked, or View a Complete report
  1. . . E D Q ; got a problem
  1. . . . I LOCKSTAT="" S REPLY="0^3~"_LTYPE_" not locked; no report entry/edit allowed. errcode*4"
  1. . . . E S REPLY="0^3~"_LTYPE_" locked by "_LOCKSTAT_"; no report entry/edit allowed. errcode*4a"
  1. . . ; verify Tx type and Exam Status lines up; set active/editflag values
  1. . . S STATCT(RASTCAT)=$G(STATCT(RASTCAT))+1 ; count by status code
  1. . . I RASTCAT="W" S REPLY="0^4~Report entry not supported for Exam Status WAITING. ("_PARAMS_") errcode*7" Q
  1. . . I RASTCAT="E",(TXID=1) S ACTIVE=1,EDITFLAG=0,TXTYPE="New" Q
  1. . . I RASTCAT="R",(TXID=1) S ACTIVE=1,EDITFLAG=0,TXTYPE="New" Q
  1. . . I RASTCAT="I",(TXID=1) S ACTIVE=1,EDITFLAG=$S(RPTSTAT="":0,1:1),TXTYPE=$S(EDITFLAG:"Edit",1:"New") Q ; assume for "I": no rpt, or D/PD/R rpt
  1. . . I RASTCAT="C",'TXID S ACTIVE=-1,EDITFLAG=3,TXTYPE="View" Q ; view only
  1. . . I RASTCAT="C",(TXID=2) S ACTIVE=1,EDITFLAG=2,TXTYPE="Amend" Q ; amend report
  1. . . S REPLY="0^4~Request ("_$S(TXID=1:"Edit",TXID=2:"Amend",1:"View")_") not supported for this Exam Status code ("_RASTCAT_"); no report entry/edit allowed. ("_PARAMS_") errcode*5" Q
  1. . S $P(EXAMS(IEXAM),PIPE,3)=ACTIVE_U_EDITFLAG
  1. . I EDITFLAG,'GETRPT S GETRPT=CASEID ; report text to return
  1. . I REQFLAGS<11,+REQFLG S REQFLAGS=$S(REQFLG=11:11,REQFLAGS=REQFLG:REQFLG,1:REQFLAGS+REQFLG)
  1. ;
  1. ; verify: multiple exams OK, based on exam/report statuses
  1. I NEXAMS>1 D I REPLY]"" G RPTOPENZ ; if mult exams, statuses must align acceptably
  1. . S RASTCAT="" F I=0:1 S RASTCAT=$O(STATCT(RASTCAT)) Q:RASTCAT=""
  1. . I I>1 S REPLY="0^4~Multiple exams with different statuses not allowed. ("_PARAMS_") errcode*6" Q
  1. . I $D(STATCT("C")) S REPLY="0^4~Multiple exams with status COMPLETE not allowed. ("_PARAMS_") errcode*8" Q
  1. . I $D(STATCT("E")) Q ; good to go
  1. . I $D(STATCT("I")) D Q:REPLY]"" ; ok if Zero or 1 exam has a ~draft report
  1. . . S IEXAM=0 N CT
  1. . . F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM D I REPLY]"" Q ; allow if only 1 exam has a report (D/PD/R)
  1. . . . S RPTSTAT=$P($P(EXAMS(IEXAM),PIPE),U,8),T=$S(RPTSTAT="":0,1:1),CT(T)=$G(CT(T))+1
  1. . . . I $G(CT(1))>1 S REPLY="0^4~Multiple exams with unverified reports not allowed. ("_PARAMS_") errcode*9" Q
  1. ;
  1. ; assemble output lines
  1. S IEXAM=0
  1. F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM D
  1. . S LINECT=LINECT+1,OUT(LINECT)=$$ONELINE(EXAMS(IEXAM),REQFLAGS)
  1. . S PSETCT=+$G(EXAMS(IEXAM,0)) I PSETCT D ; printset members
  1. . . F ICT=1:1:PSETCT D
  1. . . . I ICT=1 S LINECT=LINECT+1,OUT(LINECT)=" Includes:"_PIPE_PIPE_0_U
  1. . . . S LINECT=LINECT+1,OUT(LINECT)=$$ONELINE(EXAMS(IEXAM,ICT))
  1. ;
  1. ; get report text, if applicable
  1. I GETRPT D I REPLY]"" G RPTOPENZ
  1. . N ZJ D RPTSTAT^ISIJDCU1(.ZJ,GETRPT,LINECT)
  1. . I $P($G(ZJ(0)),U)=-1 D Q:REPLY]""
  1. . . S LINECT=0,REPLY="0^4~Error occurred: "_ZJ(0)_" ("_PARAMS_") errcode*10"
  1. . I +ZJ(0) S LINECT=ZJ(0) K ZJ(0) M OUT=ZJ
  1. ;
  1. RPTOPENZ ;
  1. I REPLY="" M @MAGGRY=OUT S REPLY=LINECT_U_"0~Report entry results ("_TXTYPE_" report)"
  1. S @MAGGRY@(0)=REPLY
  1. Q
  1. ;
  1. ONELINE(EXAM,REQFLAGS) ; Format output lines--details at rpc entry point
  1. N X,LINE,T
  1. N ACTIVE,EDITFLAG
  1. S REQFLAGS=$G(REQFLAGS)
  1. S T=$P(EXAM,PIPE,3),ACTIVE=+$P(T,U),EDITFLAG=$P(T,U,2)
  1. S X=$P(EXAM,PIPE)
  1. S LINE=$S(+ACTIVE:"",1:" ") ; indent text for non-active exam
  1. I ACTIVE=-1 S ACTIVE=0 ; View-only not really active
  1. S LINE=LINE_$P(X,U,3)_" ("_$P(X,U,4)_") "_$P(X,U,2) ; Acn, status, proc
  1. S T=$P(X,U,6) I T]"" S LINE=LINE_" ("_$P(X,U,6)_")" ; modif
  1. S T=$S(ACTIVE:$P(EXAM,PIPE,2),1:"") ; caseid string
  1. S LINE=LINE_PIPE_T_PIPE ;
  1. S LINE=LINE_+ACTIVE_U ; active flag
  1. S LINE=LINE_REQFLAGS_U_EDITFLAG ; Dx Code/Impression required; "active" exam
  1. I ACTIVE S LINE=LINE_U_$P(X,U,3)_U_$P(X,U,5)_U_$P(X,U,2) ; Acn, CPT, Proc
  1. Q LINE
  1. ;
  1. ; rpc ISIJ LOCK REPORT -- lock protection for draft reports entry
  1. ;
  1. RPTLOCK(MAGGRY,PARAMS) ; Lock or UNlock exams
  1. ; Locks done here are solely for exams in status "I" or "C"
  1. ; PARAMS: TXID ^ CASEID [ | CASEID-2 | etc. ] -- (one or more Cases accepted for LOCK)
  1. ; TXID: 1: Lock (1 or more OK); 0: Unlock (UNLOCK only one at a time)
  1. ; 11: Lock (1 or more OK); 10: Unlock ( ditto )
  1. ; * 11 & 10 apply only to Status Code "R" exams
  1. ; CASEID: RADFN ^ RADTI ^ RACNI ^ RARPT ("normal" identifier for VistARad)
  1. ; Reply message:
  1. ; Reply Code ~ Reply display text
  1. ; Reply Code: 0-Normal; 3-Abnormal; 4-Error
  1. ; Note re TXID=11--this locks exams of vistarad category "R", which normally
  1. ; have no images when initiating the report, and therefore no RARPT entry yet
  1. ; the pre-processing detects this state, and calls ^raric to create it
  1. N $ETRAP,$ESTACK S $ETRAP="D ERR^ISIJRPT"
  1. N CASEID,DAYCASE,MAGLST,REPLY,TXID,PIPE
  1. N RADFN,RADTI,RACNI,RARPT,RASTCAT,RASTORD
  1. N NLOCKS,ACTIVE,EDITFLAG,EXAMS,IEXAM,NEXAMS,PSETS,PSETCT
  1. N LINECT,ICT,OUT,RPTSTAT,STATCT,GETRPT,LOCKED,CT
  1. N CREATRPT,RCODE,LOCKEDEX
  1. S PIPE="|"
  1. S REPLY="",NLOCKS=0
  1. S TXID=+PARAMS,RADFN=+$P(PARAMS,U,2),RADTI=$P(PARAMS,U,3),RACNI=+$P(PARAMS,U,4)
  1. S MAGLST="ISIJRPC" S MAGGRY=$NA(^TMP($J,MAGLST)) K @MAGGRY
  1. N DIQUIET S DIQUIET=1 D DT^DICRW
  1. I RADFN,RADTI,RACNI,$D(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)) ; ICR 65
  1. E S REPLY="4~Invalid Request; no Exam found for input data. ("_PARAMS_") errcode*19" G RPTLOCKZ
  1. I TXID=0!(TXID=1)!(TXID=10)!(TXID=11)
  1. E S REPLY="4~Invalid Request; unrecognized input txid. ("_PARAMS_") errcode*19b" G RPTLOCKZ
  1. S RCODE=0 I TXID=10!(TXID=11) S RCODE=1 ; flag for Status Type "R" management, in case Ex Status not reliable
  1. I TXID=0!(TXID=10) D I REPLY]"" G RPTLOCKZ
  1. . S X=$P(PARAMS,PIPE,2) I X=""
  1. . E S REPLY="4~Invalid Request; Unlock only one exam per request. ("_PARAMS_") errcode*20a" G RPTLOCKZ
  1. ;
  1. ; EXAMS array contents as described above, except pipe-piece 3 tracks Locks for: Report_Lev ^ Exam_lev
  1. ; init array of exams to be processed
  1. S EXAMS(1)="|"_$P($P(PARAMS,PIPE),U,2,5)
  1. F IEXAM=2:1 S CASEID=$P(PARAMS,PIPE,IEXAM) Q:CASEID="" D I REPLY]"" G RPTLOCKZ
  1. . I +CASEID'=RADFN S REPLY="4~Invalid Request; multiple exams for different patients. ("_PARAMS_") errcode*21" Q
  1. . S EXAMS(IEXAM)="|"_CASEID
  1. S NEXAMS=IEXAM-1
  1. ;
  1. ; get all needed data for each exam; RARPT will be created if applicable, returned in caseid value
  1. F IEXAM=1:1:NEXAMS S CASEID=$P(EXAMS(IEXAM),PIPE,2) D I REPLY]"" G RPTLOCKZ
  1. . S RARPT=+$P(CASEID,U,4),CREATRPT=0
  1. . I TXID=11,'RARPT S CREATRPT=1
  1. . S X=$$GETDATA^ISIJRPT2(.CASEID,0,CREATRPT) ; 1--flag to create rarpt when needed; note .CaseId is updated when rarpt is created
  1. . I $P(X,U)=-1 S REPLY="4~"_$P(X,U,2,99) Q ; error detected
  1. . S $P(EXAMS(IEXAM),PIPE)=X,$P(EXAMS(IEXAM),PIPE,2)=CASEID ; store updated caseid in array
  1. . I CREATRPT,(+$P(CASEID,U,4)) S T=$P(EXAMS(IEXAM),PIPE,3),$P(T,U,2)=1,$P(EXAMS(IEXAM),PIPE,3)=T ; exam lock was opened in getdata; save incase need to unlock if error
  1. ;
  1. ; process UNLOCKs here--only one exam per call allowed
  1. I TXID=0!(TXID=10) D G RPTLOCKZ
  1. . S CASEID=$P(EXAMS(1),PIPE,2),RARPT=$P(CASEID,U,4)
  1. . I RARPT
  1. . E S REPLY="4~Invalid Request; caseid string missing rarpt value. ("_PARAMS_") errcode*22a" Q
  1. . S X=$P(EXAMS(1),PIPE),DAYCASE=$P(X,U,3),RASTCAT=$P(X,U,7)
  1. . I "^I^C^"[RASTCAT D Q:REPLY]""
  1. . . I TXID=0
  1. . . E S REPLY="4~Invalid Request; Exam status must be 'Ready for Interp' for this unlock request. ("_PARAMS_") errcode*22c" Q
  1. . I RASTCAT="R" D Q:REPLY]""
  1. . . I TXID=10
  1. . . E S REPLY="4~Invalid Request; Exam status must be Interpreted or Complete for this unlock request. ("_PARAMS_") errcode*22d" Q
  1. . I $$LOCKCHK(CASEID,RASTCAT,DAYCASE) D Q
  1. . . D UNLOCKRP^ISIJRPT2(RARPT) ; unlock report level
  1. . . I +RCODE D UNLOCKEX^ISIJRPT2(CASEID) ; unlock exam level for "R" category exams
  1. . . S REPLY="0~Exam unlocked."_"-"_RASTCAT_"-"
  1. . E S REPLY="4~Invalid Request; exam/report was not locked by user. ("_PARAMS_"-"_RASTCAT_"-"_") errcode*22b"
  1. ;
  1. ; process lock request(s)
  1. ; get rid of input "duplicate" pset exams, if any
  1. I NEXAMS>1 D
  1. . F IEXAM=1:1:NEXAMS S X=$P(EXAMS(IEXAM),PIPE),T=+X D:T
  1. . . I $D(PSETS(T)) K EXAMS(IEXAM) S NEXAMS=NEXAMS-1 Q
  1. . . S PSETS(T)=IEXAM
  1. ;
  1. ; verify user type is valid for doing a lock
  1. I +MAGJOB("USER",1)
  1. E S REPLY="4~Only a radiologist may lock a report. ("_PARAMS_") errcode*21a" G RPTLOCKZ
  1. ;
  1. ; verify exam status is valid for doing a lock
  1. S IEXAM=0
  1. F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM D I REPLY]"" G RPTLOCKZ
  1. . S X=$P(EXAMS(IEXAM),PIPE),RASTCAT=$P(X,U,7),RPTSTAT=$P(X,U,8)
  1. . S T=$S(RPTSTAT="":0,1:1),CT(T)=$G(CT(T))+1
  1. . I $G(CT(1))>1 S REPLY="4~Cannot lock multiple exams having unverified reports. ("_PARAMS_") errcode*23f" Q
  1. . I RASTCAT]"",("^I^C^R^"[RASTCAT)
  1. . E S REPLY="4~Invalid Report Lock request--exam status must be Complete, Ready for Interp, or Interpreted. ("_PARAMS_") errcode*23" Q
  1. . I RASTCAT="R" D Q:REPLY]""
  1. . . I TXID'=11 S REPLY="4~Invalid Report Lock request--Invalid TxID code for 'Ready for Interp' exam. ("_PARAMS_") errcode*23d" Q
  1. . I TXID=11 D Q:REPLY]""
  1. . . I RASTCAT'="R" S REPLY="4~Invalid Report Lock request--TxID code valid only for 'Ready for Interp' exams. ("_PARAMS_") errcode*23e" Q
  1. . S STATCT(RASTCAT)=$G(STATCT(RASTCAT))+1
  1. I $G(STATCT("C"))>1!($G(STATCT("C"))&($G(STATCT("I"))!$G(STATCT("R")))) D G RPTLOCKZ
  1. . S REPLY="4~Invalid Report Lock request--Complete exam cannot be edited with another exam. ("_PARAMS_") errcode*23a" Q
  1. I $G(STATCT("R"))&$G(STATCT("I")) D G RPTLOCKZ
  1. . S REPLY="4~Invalid Report Lock request--Ready for Interp exam cannot be edited with another exam. ("_PARAMS_") errcode*23c" Q
  1. ;
  1. ; make sure not already locked by me
  1. S IEXAM=0
  1. F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM D I REPLY]"" G RPTLOCKZ
  1. . S CASEID=$P(EXAMS(IEXAM),PIPE,2)
  1. . S X=$P(EXAMS(IEXAM),PIPE),RASTCAT=$P(X,U,7),DAYCASE=$P(X,U,3)
  1. . S T=$$LOCKCHK(CASEID,RASTCAT,DAYCASE) ; for Category "R" exams, we assume this (report) lock happened only if the Exam lock also succeeded
  1. . I T S REPLY="4~Invalid Request; exam/report already locked by user. ("_PARAMS_"-"_RASTCAT_"-"_") errcode*23b"
  1. ;
  1. ; obtain locks for the active exams
  1. S IEXAM=0
  1. F S IEXAM=$O(EXAMS(IEXAM)) Q:'IEXAM D I REPLY]"" G RPTLOCKZ
  1. . S CASEID=$P(EXAMS(IEXAM),PIPE,2),RARPT=$P(CASEID,U,4)
  1. . I RCODE D Q:'LOCKEDEX
  1. . . S X=$P(EXAMS(IEXAM),PIPE),RASTCAT=$P(X,U,7)
  1. . . D LOCKEX(CASEID,RASTCAT,.LOCKEDEX) ; lock at exam level for Category "R" exams only
  1. . . I LOCKEDEX
  1. . . E S REPLY="3~Unable to lock exam for report entry/edit; try again later; code*24a." Q
  1. . D LOCKRPT(RARPT,.LOCKED) ; ALL exams require report level lock
  1. . I LOCKED S $P(EXAMS(IEXAM),PIPE,3)=1_U,NLOCKS=NLOCKS+1
  1. . E D Q
  1. . . I RCODE D UNLOCKEX^ISIJRPT2(CASEID) ; undo the exam lock
  1. . . S REPLY="3~Unable to lock report for entry/edit; try again later; code*24b." Q
  1. S REPLY="0~Report"_$S(NLOCKS>1:"s",1:"")_" locked for entry/edit."
  1. ;
  1. RPTLOCKZ ;
  1. I +REPLY>0 D ; clear up locks, if need be
  1. . D UNLOCKEM^ISIJRPT2(RCODE,NLOCKS)
  1. S @MAGGRY@(0)=REPLY
  1. Q
  1. ;
  1. LOCKRPT(RARPT,LOCKED) ; for input rarpt, return success/fail for lock attempt
  1. S LOCKED=0
  1. I 'RARPT
  1. E D
  1. . L +^RARPT(RARPT):2 ; this is sufficient to protect all printset members (both ISIRad and roll'n scroll)
  1. . I D
  1. . . S ^TMP("RAD LOCKS","ISI",$J,DUZ,"^RARPT(",RARPT)=$P($G(MAGJOB("USER",1)),U,3)
  1. . . S LOCKED=1 ; success
  1. . ;
  1. Q
  1. ;
  1. LOCKEX(CASEID,RASTCAT,LOCKED) ; for input caseid, return success/fail for lock attempt
  1. ; 1) Lock the Exam level--this will persist for the report entry session (protects Tech field update)
  1. ; Return: Lock successful 0/1
  1. N RADFN,RADTI,RACNI
  1. S LOCKED=0
  1. I RASTCAT="R"
  1. E S LOCKED=LOCKED_U_"Invalid exam status for 'R-category' exam lock operation. errcode*25a" Q
  1. S RADFN=$P(CASEID,U),RADTI=$P(CASEID,U,2),RACNI=$P(CASEID,U,3)
  1. L +^RADPT(RADFN,"DT",RADTI,"P",RACNI,0):2
  1. I S LOCKED=1
  1. E S LOCKED=0_U_"Unable to obtain exam lock; errcode*25c"
  1. Q
  1. ;
  1. LOCKCHK(CASEID,RASTCAT,DAYCASE) ; does current user have a lock?
  1. ; Return: 1=Locked by me; nil=not locked; INI[:R] or Text=Locked/Reserved by other
  1. N OK,RARPT
  1. S OK="",RARPT=$P(CASEID,U,4)
  1. I RASTCAT="E" D ; Should have been locked by "normal" exam lock
  1. . S X=$$CHKLOCK^MAGJLS2B(RARPT,DAYCASE)
  1. . S OK=($P(X,U,2)=1) ; Exam locked by Client
  1. . I 'OK S OK=$P(X,U) ; initials of other user, or nil
  1. E I RASTCAT]"",("^I^C^R^"[RASTCAT) D ; lock would be the "report entry" lock per this module
  1. . L +^RARPT(RARPT,"checklock"):0
  1. . I D L -^RARPT(RARPT,"checklock")
  1. . . I $D(^TMP("RAD LOCKS","ISI",$J,DUZ,"^RARPT(",RARPT)) S OK=1 ; locked by me
  1. . . E S OK="" Q ; not locked
  1. . E S OK="another user"
  1. Q OK
  1. ;
  1. READYINT(IMGTYP) ; "Ready for Interpretation" feature enabled? -- P106 enhancement
  1. ; --> If is enabled for input Type of Imaging, returns field # & data value to stuff into Exam Record
  1. ; current (perhaps only) user is RTT: called by ISIRAD03
  1. ;
  1. N FIELD,FILE,REPLY,VALUE,X
  1. S REPLY=""
  1. S X=$P(^MAG(2006.69,1,"ISI"),U,7,8)
  1. I +X=$G(IMGTYP) D ; does apply to this Imaging Type
  1. . S X=$P(X,U,2)
  1. . S VALUE=$P(X,";",1),FILE=$P(X,";",2)
  1. . S FIELD=$S(FILE="RA(78.6,":18,1:"") ; <*> thus far, we only use #78.6 Camera/Equip/Rm
  1. . I FIELD=""!(VALUE="") S REPLY="-1^Invalid 'Ready for Interpretation' setting in MAG VISTARAD SITE PARAMETERS file." Q
  1. . S REPLY=FIELD_U_VALUE
  1. Q:$Q REPLY Q
  1. ;
  1. END ;