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

TIUPXAP2.m

Go to the documentation of this file.
  1. TIUPXAP2 ; SLC/JER - More code for the workload capture ;12/4/02@07:54:52 [1/18/05 9:27am]
  1. ;;1.0;TEXT INTEGRATION UTILITIES;**20,67,82,107,126,124,149,179,190**;Jun 20, 1997;Build 1
  1. TEST ; Test the PXAPI Data Capture dialogs
  1. N CPT,DFN,ICD,ICDARR,CPTARR,SC,DTOUT,TIU,TIUOK
  1. S DFN=+$$PATIENT^TIULA
  1. S TIU("LOC")=$$SELLOC^TIUVSIT
  1. D GETICD^TIUPXAPI(TIU("LOC"),.ICDARR)
  1. D ICD^TIUPXAPI(.ICD,.ICDARR)
  1. D GETCPT^TIUPXAPC(TIU("LOC"),.CPTARR)
  1. CPTCALL D CPT^TIUPXAPC(.CPT,.CPTARR)
  1. I '$D(CPT),'$D(DTOUT) W !!,$C(7),"You MUST enter one or more Procedures." G CPTCALL
  1. D SCASK^TIUPXAPS(.SC,+DFN,.TIU)
  1. I $D(DTOUT)!(+$O(ICD(0))'>0)&(+$O(CPT(0))'>0)&(+$O(SC(0))'>0) D Q
  1. . W !,$C(7),"Insufficient information for Workload Credit."
  1. . W !,"Missing information will have to be captured by another method."
  1. S TIUOK=$$CONFIRM^TIUPXAPI(.ICD,.CPT,.SC)
  1. I '+TIUOK D G TEST
  1. . W !!,"Changes Discarded. Please Enter Corrected Workload Data..." H 3
  1. . K ICD,CPT,SC,ICDARR,CPTARR
  1. K CPTARR,ICDARR
  1. W "Done."
  1. Q
  1. CMBLST(EMCODES,CPTCODES) ; Combine E/M and other CPT codes
  1. N TIUI,TIUJ,TMPARRY S (TIUI,TIUJ)=0
  1. M TMPARRY=EMCODES S TIUI=EMCODES(0)
  1. F S TIUJ=$O(CPTCODES(TIUJ)) Q:+TIUJ'>0 D
  1. . S TIUI=+$G(TIUI)+1,TMPARRY(TIUI)=CPTCODES(TIUJ),TMPARRY(0)=TIUI
  1. . ;Merge CPT Modifiers
  1. . M TMPARRY(TIUI,"MODIFIER")=CPTCODES(TIUJ,"MODIFIER")
  1. K CPTCODES
  1. M CPTCODES=TMPARRY
  1. Q
  1. PICK(LOW,HIGH,PROMPT,TYPE) ; List selection
  1. N X,Y S PROMPT=$G(PROMPT,"Select Item"),TYPE=$G(TYPE,"LO")
  1. W !
  1. S Y=$$READ^TIUU(TYPE_U_LOW_":"_HIGH,PROMPT)
  1. Q Y
  1. EDTENC(TIUDA,CHNG) ; Edit the encounter for a given note
  1. N TIUD0,TIUD12,TIUDFN,TIUI,TIUVSIT,TIUHL,TIUEDT,TIUPAUSE,TIUERR,TIUWHAT
  1. N TIUCONT,DA
  1. Q:$D(XWBOS)
  1. Q:+$P($G(TIUDPRM(0)),U,14)
  1. D FULL^VALM1
  1. S TIUD0=$G(^TIU(8925,+TIUDA,0)),TIUD12=$G(^(12))
  1. S TIUHL=$P(TIUD12,U,11)
  1. I $P($G(^SC(+TIUHL,0)),U,3)'="C" Q
  1. ;
  1. ;If not ok to ask workload, quit
  1. I '$$WORKOK^TIUPXAP1(+TIUDA) Q
  1. ;
  1. S TIUDFN=$P(TIUD0,U,2),TIUEDT=$P(TIUD0,U,7),TIUVSIT=$P(TIUD0,U,3)
  1. N TIUMVSTF,TIUVSITS
  1. ;If no visit has been filed with the document
  1. I $G(TIUVSIT)'>0 D
  1. . ;Check for the visit
  1. . S TIUVSITS=$$GETENC^PXAPI(TIUDFN,TIUEDT,TIUHL)
  1. . I TIUVSITS>0 S TIUVSIT=+TIUVSITS
  1. . ;Set a flag if multiple visits
  1. . I $P(TIUVSITS,U,2)'="" S TIUMVSTF=1
  1. . ;If only one visit update the document
  1. . I $G(TIUVSIT)>0,'$G(TIUMVSTF) D
  1. . . S TIUERR=$$UPDVST(TIUDA,TIUVSIT)
  1. . . K ^TMP("PXKENC",$J)
  1. W !!
  1. ;Ask the user if they wish to enter workload if the parameter is defined
  1. ;and the multiple visit flag is not set
  1. I $D(TIUDPRM(0)),'$G(TIUMVSTF),$G(TIUVSIT)>0 D Q:'+TIUCONT
  1. . S TIUCONT=$$READ^TIUU("Y","Do you wish to enter workload data at this time","YES")
  1. I $G(VALMAR)="^TMP(""TIUR"",$J)" D
  1. . N TIU D GETTIU^TIULD(.TIU,TIUDA)
  1. . W !!,"For ",$G(TIU("PNM"))," ",$G(TIU("PID"))," Visit on "
  1. . W $P($G(TIU("EDT")),U,2),"...",!
  1. I $P($P(TIUD0,U,7),".")>DT D Q
  1. . W !!,$C(7),"ACRP will not accept data for future Encounters.",!
  1. . W !,"Workload questions won't be asked for this note.",!
  1. . S TIUPAUSE=$$READ^TIUU("EA","Press RETURN to continue...")
  1. I $G(VALMAR)'="^TMP(""TIUR"",$J)" W !!,"Editing Encounter Data...",!
  1. S TIUWHAT=$S($$CHKAPPT(TIUVSIT,TIUDFN,TIUEDT,TIUHL):"INTV",1:"ADDEDIT")
  1. S TIUERR=$$INTV^PXAPI(TIUWHAT,"TIU","TEXT INTEGRATION UTILITIES",.TIUVSIT,$S(+$G(TIUVSIT):"",1:TIUHL),TIUDFN,$S(+$G(TIUVSIT):"",1:TIUEDT))
  1. ;
  1. ;If an error is returned prompt to continue otherwise if a Visit
  1. ;IEN is returned and one is not already defined update the document
  1. I +TIUERR<0 D
  1. . W ! S TIUPAUSE=$$READ^TIUU("EA","Press RETURN to continue...")
  1. ELSE D
  1. . I $G(TIUVSIT)>0,'$P($G(^TIU(8925,+TIUDA,0)),U,3) S TIUERR=$$UPDVST(TIUDA,TIUVSIT)
  1. S CHNG=1
  1. Q
  1. ;
  1. CHKVST(TIUDA) ;Check the visit associated with the document for key workload
  1. ;data elements. Key data elements include provider, diagnosis,
  1. ;procedure and classifications.
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; Output -- 0=No Key Workload Data Elements Exist
  1. ; 1=Key Workload Data Elements Exist
  1. ; 2=Unable to Determine if Key Workload Data Elements Exist
  1. N I,TIUCHKF,TIUD0,TIUDFN,TIUEDT,TIUHL,TIUVSIT,TIUVSITS,X
  1. ;
  1. ;Set variables, if the 0th node of the document is not defined quit
  1. S TIUD0=$G(^TIU(8925,+TIUDA,0)) I TIUD0="" S TIUCHKF=2 G CHKVSTQ
  1. S TIUDFN=$P(TIUD0,U,2),TIUVSIT=$P(TIUD0,U,3),TIUEDT=$P(TIUD0,U,7)
  1. S TIUHL=$P($G(^TIU(8925,+TIUDA,12)),U,11)
  1. ;
  1. ;Get data associated with the visit
  1. I $G(TIUVSIT)>0 D
  1. . D ENCEVENT^PXKENC(TIUVSIT)
  1. ELSE D
  1. . S TIUVSITS=$$GETENC^PXAPI(TIUDFN,TIUEDT,TIUHL)
  1. . I TIUVSITS>0 S TIUVSIT=+TIUVSITS
  1. . I $P(TIUVSITS,U,2)'="" S TIUCHKF=2 ;multiple visits
  1. ;
  1. ;If a visit is not defined or multiple visits exist, quit
  1. I $G(TIUVSIT)'>0!($G(TIUCHKF)=2) G CHKVSTQ
  1. ;
  1. ;If a provider or diagnosis or procedure exists for the visit, set flag
  1. ;and quit
  1. I $D(^TMP("PXKENC",$J,TIUVSIT,"PRV"))!($D(^("CPT")))!($D(^("POV"))) S TIUCHKF=1 G CHKVSTQ
  1. ;
  1. ;If a classification exists for the visit, set flag and quit
  1. I $D(^TMP("PXKENC",$J,TIUVSIT,"VST",TIUVSIT,800)) S X=^(800) D
  1. . F I=1:1:6 I $P(X,U,I)'="" S TIUCHKF=1 Q
  1. ;
  1. CHKVSTQ K ^TMP("PXKENC",$J)
  1. Q +$G(TIUCHKF)
  1. ;
  1. UPDVST(TIUDA,TIUVSIT,ERROR) ;Update Visit in TIU Document file #8925
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; TIUVSIT Visit file (#9000010) IEN
  1. ; Output -- 1=Successful and 0=Failure
  1. ; ERROR Error Message (Optional)
  1. N DIERR,OKF,TIUFDA
  1. ;
  1. ;Quit if a visit is not defined
  1. G UPDVSTQ:$G(TIUVSIT)'>0
  1. ;
  1. ;Update document with visit
  1. S TIUFDA(8925,TIUDA_",",.03)=TIUVSIT
  1. L +^TIU(8925,TIUDA):1 I $T D
  1. . D FILE^DIE("","TIUFDA","") L -^TIU(8925,TIUDA)
  1. . S ERROR=$G(DIERR)
  1. . S OKF=$S(+$G(ERROR):0,1:1)
  1. ELSE D
  1. . S OKF=0
  1. UPDVSTQ Q +$G(OKF)
  1. ;
  1. CHKWKL(TIUDA,TIUDPRM) ;Check if workload data should be entered
  1. ; Input -- TIUDA TIU Document file (#8925) IEN
  1. ; TIUDPRM TIU Document Parameters file (#8925.95) Array
  1. ; Output -- 1=Enter Workload and 0=Do Not Enter Workload
  1. N STATUS,TIUAPPTF,TIUD0,TIUDFN,TIUEDT,TIUHL,TIUVSIT,TIUWKLF,TIURES,TIUINC,TIUARRAY,TIUCNT
  1. ;
  1. ;Set variables, if the 0th node of the document is not defined quit
  1. S TIUD0=$G(^TIU(8925,+TIUDA,0)) G CHKWKLQ:TIUD0=""
  1. S TIUDFN=$P(TIUD0,U,2),TIUVSIT=$P(TIUD0,U,3),TIUEDT=$P(TIUD0,U,7)
  1. S TIUHL=$P($G(^TIU(8925,+TIUDA,12)),U,11)
  1. ;
  1. ;Check if an appointment is associated with the visit
  1. S:$$CHKAPPT(TIUVSIT,TIUDFN,TIUEDT,TIUHL)>0 TIUAPPTF=1
  1. ;
  1. ;If an appointment is not associated with the visit, assume
  1. ;the visit is new, set flag to enter workload and quit
  1. I '$G(TIUAPPTF) S TIUWKLF=1 G CHKWKLQ
  1. ;
  1. ;Check the parameter 'Ask Dx/CPT on All Opt Visits'. If it is set to
  1. ;No, workload should not be entered for the appointment.
  1. I '$$BROKER^XWBLIB(),'$P($G(TIUDPRM(0)),U,16) G CHKWKLQ
  1. ;
  1. ;Get the status of the appointment
  1. S TIUARRAY(1)=TIUEDT_";"_TIUEDT
  1. S TIUARRAY(2)=TIUHL
  1. S TIUARRAY(4)=TIUDFN
  1. S TIUARRAY("SORT")="P"
  1. S TIUARRAY("FLDS")="22"
  1. S TIUARRAY("MAX")=1
  1. S TIUCNT=$$SDAPI^SDAMA301(.TIUARRAY)
  1. I TIUCNT=-1 K ^TMP($J,"SDAMA301") Q +$G(TIUWKLF)
  1. S STATUS=+$P($G(^TMP($J,"SDAMA301",TIUDFN,TIUEDT)),U,22)
  1. K ^TMP($J,"SDAMA301")
  1. ;Check the status of the appointment. If the appointment can be
  1. ;checked-out, workload can be entered.
  1. I $D(^SD(409.63,"ACO",1,STATUS)) S TIUWKLF=1
  1. ;
  1. CHKWKLQ Q +$G(TIUWKLF)
  1. ;
  1. CHKAPPT(TIUVSIT,TIUDFN,TIUEDT,TIUHL) ;Check if an appointment is associated with the Visit
  1. ; Input -- TIUVSIT Visit file (#9000010) IEN
  1. ; TIUDFN Patient file (#2) IEN
  1. ; TIUEDT Episode Begin Date/Time
  1. ; TIUHL Hospital Location file (#44) IEN
  1. ; Output -- 0=Appointment is not associated with the Visit
  1. ; 1=Appointment is associated with the Visit
  1. N TIUAPPTF
  1. I $G(TIUVSIT),'$$BROKER^XWBLIB() D
  1. . S:$$VST2APPT^PXAPI(TIUVSIT)>0 TIUAPPTF=1
  1. ELSE D
  1. . S:$$APPOINT^PXUTL1(TIUDFN,TIUEDT,TIUHL)>0 TIUAPPTF=1
  1. Q +$G(TIUAPPTF)