MDRPCOW ; HOIFO/DP/NCA - Billing Widget ;10/3/05 12:17
;;1.0;CLINICAL PROCEDURES;**6,29**;Apr 01, 2004;Build 22
; Reference IA# 2240 [Supported] ENCRYP^XUSRB1 call
; 2241 [Supported] DECRYP^XUSRB1 call
; 5679 [Supported] IMPDATE^LEXU call
; 10017 [Supported] ^DD("DD") reference
; 10040 [Supported] Hospital Location File Access
; 10045 [Supported] XUSHSHP call
; 10060 [Supported] FILE 200 references
;
RPC(RESULTS,OPTION,P1,P2,P3,P4,P5,P6,P7) ; [Procedure] Main RPC call
; RPC: [MD TMDWIDGET]
;
D CLEAN^DILF
S RESULTS=$NA(^TMP("MDKUTL",$J)) K @RESULTS
I $T(@OPTION)="" D Q
.S @RESULTS@(0)="-1^Error in RPC: MD TMDWIDGET at "_OPTION_U_$T(+0)
D @OPTION S:'$D(@RESULTS) @RESULTS@(0)="-1^No return"
D CLEAN^DILF
Q
;
SUBMIT ; Submit a final report to close out an entry in 702
;
; P1=702 IEN
; P2=Encoded E-Sig
; P3=Array containing the text for the note
;
I '$D(^MDD(702,+P1,0)) S @RESULTS@(0)="-1^No such study" Q
I $P(^MDD(702,+P1,0),U,9)=2 S @RESULTS@(0)="-1^Study is in Error status, cannot use study until the error is fixed." Q
I "016"[$P(^MDD(702,+P1,0),U,9) S @RESULTS@(0)="-1^Cannot submit - not a Dialysis study." Q
I $D(P3)<1 S @RESULTS@(0)="-1^No note text" Q
I P2="" D PCE Q
K ^TMP("MDTXT",$J)
S X="",Y=1
F S X=$O(P3(X)) Q:X="" S ^TMP("MDTXT",$J,Y)=P3(X),Y=Y+1
; a "1^Note Filed" if everything is ok otherwise an error msg
I P2'="" S P2=$$DECRYP^XUSRB1(P2),P2=$$ENCRYP^XUSRB1(P2)
;S @RESULTS@(0)=$$SUBMIT^MDRPCOT2(+P1,P2,$NA(^TMP("MDTXT",$J)),.P7)
S @RESULTS@(0)=$$SUBMIT^MDRPCOT2(+P1,P2,$NA(^TMP("MDTXT",$J)))
I +@RESULTS@(0)>0 S @RESULTS@(0)="1^Approval Message"
N XX S XX="",XX=$$UPDCONS^MDRPCOT1(+$P($G(^MDD(702,+P1,0)),U,5),+$P($G(^MDD(702,+P1,0)),U,6))
;
K ^TMP("MDTXT",$J) Q
Q
;
ESIG ; [Procedure] Verify users electronic signature
I $G(P1)="" D Q
.S @RESULTS@(0)="-1^Must supply electronic signature code"
S X=$$DECRYP^XUSRB1(P1)
D HASH^XUSHSHP
I X'=$$GET1^DIQ(200,DUZ_",",20.4,"I") S @RESULTS@(0)="-1^E-Sig Invalid^"
E S @RESULTS@(0)="1^E-Sig Verifed^"_X
Q
;
GETBILL ; Get Billing Data
Q
N MDFLD
;D BLDFLD^MDXMLFM(.MDFLD,702,".001;;STUDY_ID^.01;;PATIENT_ID")
;D BLDFLD^MDXMLFM(.MDFLD,702,".14;;ICD_01^.15;;ICD_02^.16;;ICD_03^.17;;ICD_04^.18;;CPT_01")
;D BLDFLD^MDXMLFM(.MDFLD,702,".19;;SC_CONDITION^.2;;MST^.21;;AO_EXPOSURE^.22;;IR_EXPOSURE^.23;;EV_CONTAMINENTS^.24;;HEAD_NECK_CANCER^.25;;COMBAT_VETERAN")
;D BLDFLD^MDXMLFM(.MDFLD,702,".26;;PRIMARY_PROVIDER_ID")
;D BLDFLD^MDXMLFM(.MDFLD,702,".26:.01;;PRIMARY_PROVIDER_NAME")
;D BLDFLD^MDXMLFM(.MDFLD,702,".27;;ATTENDING_PROVIDER_ID")
;D BLDFLD^MDXMLFM(.MDFLD,702,".27:.01;;ATTENDING_PROVIDER_NAME")
;D LOADONE^MDXMLFM(P1,702,.MDFLD)
Q
;
SETBILL ; Set Billing Data
N MDFDA,MDERR
;F X=0:1:13 S P2(X)=$G(P2(X)) D
;.D VAL^DIE(702,+P1_",",.14+(X*.01),"F",P2(X),.MDERR,"MDFDA")
;.Q:MDERR'="^" ; Validated
;.S Y="Bad value: "_$$GET1^DID(702,.14+(X*.01),,"LABEL")_" '"_P2(X)_"'"
;.S @RESULTS@($O(@RESULTS@(""),-1)+1)=Y
;I $D(@RESULTS) S @RESULTS@(0)="-1^Errors filing data" Q
;D FILE^DIE("","MDFDA")
S @RESULTS@(0)="1^Ok"
Q
;
PCE ; Set PCE Data
;
; P1=702 IEN
; P2=Encoded E-Sig
; P3=Array containing the text for the note
; P7=Array of Billing information
;
N CTR,DFN,MDCON,MDFDA,MDGST,MDL,MDLOC,MDNOTE,MDPDT,MDPROC,MDRESU,MDTITL,MDTSTR,MDVST,MDVSTR,MDWP S CTR=0,MDGST=+P1,MDRESU=""
I '$D(^MDD(702,+P1,0)) S @RESULTS@(0)="-1^No such study" Q
;
; Get data to set PCE data
S (MDTSTR,MDRESU)=$$GETDATA^MDRPCOT2(MDGST)
; File Error message
I +MDRESU<0 S @RESULTS@(0)=MDRESU Q
I $G(MDTSTR)="" S @RESULTS@(0)="-1^No Data in study to set PCE data." Q
F MDL="DFN","MDTITL","MDLOC","MDNOTE","MDCON","MDPROC","MDVSTR","MDNVST" D
.S CTR=CTR+1,@MDL=$P(MDTSTR,"^",CTR)
S (MDVST,MDRESU)=""
I 'MDLOC S @RESULTS@(0)="-1^No Hospital Location." Q
; Create new visit, if no vstring
S MDPDT=$$PDT^MDRPCOT1(MDGST)
S:'MDPDT MDPDT=$P(MDVSTR,";",2) ; If No D/T Performed grab visit D/T
; File PCE Error message
I MDNVST S MDRESU=$$EN1^MDPCE2(.P7,MDGST,$P(MDVSTR,";",2),MDPROC,$P(MDVSTR,";",3),"P",MDLOC) I +MDRESU S MDVST=+MDRESU
I 'MDNVST S MDVST=$P($G(^MDD(702,+MDGST,1)),U) S MDRESU=$$EN1^MDPCE2(.P7,MDGST,$P(MDVSTR,";",2),MDPROC,$P(MDVSTR,";",3),"P",MDLOC) I +MDRESU S MDVST=+MDRESU
I +MDRESU<0 S @RESULTS@(0)=MDRESU Q
;
S @RESULTS@(0)="Approval Message"
Q
GETLOC ; Get the existing hospital location
N MDCL,MDPR,MDVV
S MDPR=$P($G(^MDD(702,+P1,0)),U,4)
S MDVV=$P($G(^MDD(702,+P1,0)),U,7)
;S MDCL=$$GET1^DIQ(702.01,+MDPR_",",.05,"I")
S MDCL=$P(MDVV,";",3)
I 'MDCL S MDCL=$$GET1^DIQ(702.01,+MDPR_",",.05,"I")
I 'MDCL S @RESULTS@(0)="-1^No Hospital Location." Q
S Y=$P(MDVV,";",2) I Y'="" X ^DD("DD")
S @RESULTS@(0)=MDCL_U_$$GET1^DIQ(44,MDCL_",",.01,"I")_U_Y
Q
SETLOC ; Set a new clinic location from GUI if non is found.
N MDVV
S MDVV=$P($G(^MDD(702,+P1,0)),U,7)
I P2="" S @RESULTS@(0)="-1^No Location Selected."
I $L(MDVV,";")=1 S MDVV=";"_MDVV
S $P(MDVV,";",3)=P2
S $P(^MDD(702,P1,0),U,7)=MDVV
S @RESULTS@(0)="1^Okay Location Updated."
Q
CHECK ; return TRUE if PCE data filled
N MDIL,MDOKAY,MDCK,MDECTR
S (MDECTR,MDIL)=0,MDCK="",MDOKAY("POV")="",MDOKAY("CPT")="",MDOKAY("PRV")=""
F S MDIL=$O(@P2@(MDIL)) Q:MDIL="" S MDCK=$G(@P2@(MDIL)) D
. I $P(MDCK,U,1)="POV" S:$G(MDOKAY("POV"))="" MDOKAY("POV")=1
. I $P(MDCK,U,1)="CPT" S:$G(MDOKAY("CPT"))="" MDOKAY("CPT")=1
. I $P(MDCK,U,1)="PRV" S:$G(MDOKAY("PRV"))="" MDOKAY("PRV")=1
F MDIL="POV","PRV","CPT" S MDECTR=MDECTR+$G(MDOKAY(MDIL))
I MDECTR<3 S @RESULTS@(0)="-1^Missing PCE data--Review Data Again." Q
S @RESULTS@(0)=1
Q
NAME ; Get the person name
S @RESULTS@(0)="1^"_$$GET1^DIQ(200,+P2_",",.01,"E")
Q
STAT ; Get the okay status of the CP study
N MDST,MDGN S MDGN=""
S MDST=$$GET1^DIQ(702,+P1,.09,"E") S MDGN=MDST
I $$GET1^DIQ(702,+P1,.09,"I")=2 S MDGN=MDGN_"^"_$$GET1^DIQ(702,+P1,.08,"E")
S @RESULTS@(0)=MDGN
Q
STATUS ; [Procedure] Update transaction status
N MDFDA
S MDFDA(702,+P1_",",.09)=P2
D FILE^DIE("","MDFDA")
S @RESULTS@(0)="1^Done"
Q
;
MDICDDT ; ICD 10 IMPLEMENTATION DATE FOR CP
; Call to retrieve ICD-10 Implementation Date
S @RESULTS@(0)=$$IMPDATE^LEXU("10D")
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDRPCOW 6366 printed Nov 22, 2024@16:54:25 Page 2
MDRPCOW ; HOIFO/DP/NCA - Billing Widget ;10/3/05 12:17
+1 ;;1.0;CLINICAL PROCEDURES;**6,29**;Apr 01, 2004;Build 22
+2 ; Reference IA# 2240 [Supported] ENCRYP^XUSRB1 call
+3 ; 2241 [Supported] DECRYP^XUSRB1 call
+4 ; 5679 [Supported] IMPDATE^LEXU call
+5 ; 10017 [Supported] ^DD("DD") reference
+6 ; 10040 [Supported] Hospital Location File Access
+7 ; 10045 [Supported] XUSHSHP call
+8 ; 10060 [Supported] FILE 200 references
+9 ;
RPC(RESULTS,OPTION,P1,P2,P3,P4,P5,P6,P7) ; [Procedure] Main RPC call
+1 ; RPC: [MD TMDWIDGET]
+2 ;
+3 DO CLEAN^DILF
+4 SET RESULTS=$NAME(^TMP("MDKUTL",$JOB))
KILL @RESULTS
+5 IF $TEXT(@OPTION)=""
Begin DoDot:1
+6 SET @RESULTS@(0)="-1^Error in RPC: MD TMDWIDGET at "_OPTION_U_$TEXT(+0)
End DoDot:1
QUIT
+7 DO @OPTION
if '$DATA(@RESULTS)
SET @RESULTS@(0)="-1^No return"
+8 DO CLEAN^DILF
+9 QUIT
+10 ;
SUBMIT ; Submit a final report to close out an entry in 702
+1 ;
+2 ; P1=702 IEN
+3 ; P2=Encoded E-Sig
+4 ; P3=Array containing the text for the note
+5 ;
+6 IF '$DATA(^MDD(702,+P1,0))
SET @RESULTS@(0)="-1^No such study"
QUIT
+7 IF $PIECE(^MDD(702,+P1,0),U,9)=2
SET @RESULTS@(0)="-1^Study is in Error status, cannot use study until the error is fixed."
QUIT
+8 IF "016"[$PIECE(^MDD(702,+P1,0),U,9)
SET @RESULTS@(0)="-1^Cannot submit - not a Dialysis study."
QUIT
+9 IF $DATA(P3)<1
SET @RESULTS@(0)="-1^No note text"
QUIT
+10 IF P2=""
DO PCE
QUIT
+11 KILL ^TMP("MDTXT",$JOB)
+12 SET X=""
SET Y=1
+13 FOR
SET X=$ORDER(P3(X))
if X=""
QUIT
SET ^TMP("MDTXT",$JOB,Y)=P3(X)
SET Y=Y+1
+14 ; a "1^Note Filed" if everything is ok otherwise an error msg
+15 IF P2'=""
SET P2=$$DECRYP^XUSRB1(P2)
SET P2=$$ENCRYP^XUSRB1(P2)
+16 ;S @RESULTS@(0)=$$SUBMIT^MDRPCOT2(+P1,P2,$NA(^TMP("MDTXT",$J)),.P7)
+17 SET @RESULTS@(0)=$$SUBMIT^MDRPCOT2(+P1,P2,$NAME(^TMP("MDTXT",$JOB)))
+18 IF +@RESULTS@(0)>0
SET @RESULTS@(0)="1^Approval Message"
+19 NEW XX
SET XX=""
SET XX=$$UPDCONS^MDRPCOT1(+$PIECE($GET(^MDD(702,+P1,0)),U,5),+$PIECE($GET(^MDD(702,+P1,0)),U,6))
+20 ;
+21 KILL ^TMP("MDTXT",$JOB)
QUIT
+22 QUIT
+23 ;
ESIG ; [Procedure] Verify users electronic signature
+1 IF $GET(P1)=""
Begin DoDot:1
+2 SET @RESULTS@(0)="-1^Must supply electronic signature code"
End DoDot:1
QUIT
+3 SET X=$$DECRYP^XUSRB1(P1)
+4 DO HASH^XUSHSHP
+5 IF X'=$$GET1^DIQ(200,DUZ_",",20.4,"I")
SET @RESULTS@(0)="-1^E-Sig Invalid^"
+6 IF '$TEST
SET @RESULTS@(0)="1^E-Sig Verifed^"_X
+7 QUIT
+8 ;
GETBILL ; Get Billing Data
+1 QUIT
+2 NEW MDFLD
+3 ;D BLDFLD^MDXMLFM(.MDFLD,702,".001;;STUDY_ID^.01;;PATIENT_ID")
+4 ;D BLDFLD^MDXMLFM(.MDFLD,702,".14;;ICD_01^.15;;ICD_02^.16;;ICD_03^.17;;ICD_04^.18;;CPT_01")
+5 ;D BLDFLD^MDXMLFM(.MDFLD,702,".19;;SC_CONDITION^.2;;MST^.21;;AO_EXPOSURE^.22;;IR_EXPOSURE^.23;;EV_CONTAMINENTS^.24;;HEAD_NECK_CANCER^.25;;COMBAT_VETERAN")
+6 ;D BLDFLD^MDXMLFM(.MDFLD,702,".26;;PRIMARY_PROVIDER_ID")
+7 ;D BLDFLD^MDXMLFM(.MDFLD,702,".26:.01;;PRIMARY_PROVIDER_NAME")
+8 ;D BLDFLD^MDXMLFM(.MDFLD,702,".27;;ATTENDING_PROVIDER_ID")
+9 ;D BLDFLD^MDXMLFM(.MDFLD,702,".27:.01;;ATTENDING_PROVIDER_NAME")
+10 ;D LOADONE^MDXMLFM(P1,702,.MDFLD)
+11 QUIT
+12 ;
SETBILL ; Set Billing Data
+1 NEW MDFDA,MDERR
+2 ;F X=0:1:13 S P2(X)=$G(P2(X)) D
+3 ;.D VAL^DIE(702,+P1_",",.14+(X*.01),"F",P2(X),.MDERR,"MDFDA")
+4 ;.Q:MDERR'="^" ; Validated
+5 ;.S Y="Bad value: "_$$GET1^DID(702,.14+(X*.01),,"LABEL")_" '"_P2(X)_"'"
+6 ;.S @RESULTS@($O(@RESULTS@(""),-1)+1)=Y
+7 ;I $D(@RESULTS) S @RESULTS@(0)="-1^Errors filing data" Q
+8 ;D FILE^DIE("","MDFDA")
+9 SET @RESULTS@(0)="1^Ok"
+10 QUIT
+11 ;
PCE ; Set PCE Data
+1 ;
+2 ; P1=702 IEN
+3 ; P2=Encoded E-Sig
+4 ; P3=Array containing the text for the note
+5 ; P7=Array of Billing information
+6 ;
+7 NEW CTR,DFN,MDCON,MDFDA,MDGST,MDL,MDLOC,MDNOTE,MDPDT,MDPROC,MDRESU,MDTITL,MDTSTR,MDVST,MDVSTR,MDWP
SET CTR=0
SET MDGST=+P1
SET MDRESU=""
+8 IF '$DATA(^MDD(702,+P1,0))
SET @RESULTS@(0)="-1^No such study"
QUIT
+9 ;
+10 ; Get data to set PCE data
+11 SET (MDTSTR,MDRESU)=$$GETDATA^MDRPCOT2(MDGST)
+12 ; File Error message
+13 IF +MDRESU<0
SET @RESULTS@(0)=MDRESU
QUIT
+14 IF $GET(MDTSTR)=""
SET @RESULTS@(0)="-1^No Data in study to set PCE data."
QUIT
+15 FOR MDL="DFN","MDTITL","MDLOC","MDNOTE","MDCON","MDPROC","MDVSTR","MDNVST"
Begin DoDot:1
+16 SET CTR=CTR+1
SET @MDL=$PIECE(MDTSTR,"^",CTR)
End DoDot:1
+17 SET (MDVST,MDRESU)=""
+18 IF 'MDLOC
SET @RESULTS@(0)="-1^No Hospital Location."
QUIT
+19 ; Create new visit, if no vstring
+20 SET MDPDT=$$PDT^MDRPCOT1(MDGST)
+21 ; If No D/T Performed grab visit D/T
if 'MDPDT
SET MDPDT=$PIECE(MDVSTR,";",2)
+22 ; File PCE Error message
+23 IF MDNVST
SET MDRESU=$$EN1^MDPCE2(.P7,MDGST,$PIECE(MDVSTR,";",2),MDPROC,$PIECE(MDVSTR,";",3),"P",MDLOC)
IF +MDRESU
SET MDVST=+MDRESU
+24 IF 'MDNVST
SET MDVST=$PIECE($GET(^MDD(702,+MDGST,1)),U)
SET MDRESU=$$EN1^MDPCE2(.P7,MDGST,$PIECE(MDVSTR,";",2),MDPROC,$PIECE(MDVSTR,";",3),"P",MDLOC)
IF +MDRESU
SET MDVST=+MDRESU
+25 IF +MDRESU<0
SET @RESULTS@(0)=MDRESU
QUIT
+26 ;
+27 SET @RESULTS@(0)="Approval Message"
+28 QUIT
GETLOC ; Get the existing hospital location
+1 NEW MDCL,MDPR,MDVV
+2 SET MDPR=$PIECE($GET(^MDD(702,+P1,0)),U,4)
+3 SET MDVV=$PIECE($GET(^MDD(702,+P1,0)),U,7)
+4 ;S MDCL=$$GET1^DIQ(702.01,+MDPR_",",.05,"I")
+5 SET MDCL=$PIECE(MDVV,";",3)
+6 IF 'MDCL
SET MDCL=$$GET1^DIQ(702.01,+MDPR_",",.05,"I")
+7 IF 'MDCL
SET @RESULTS@(0)="-1^No Hospital Location."
QUIT
+8 SET Y=$PIECE(MDVV,";",2)
IF Y'=""
XECUTE ^DD("DD")
+9 SET @RESULTS@(0)=MDCL_U_$$GET1^DIQ(44,MDCL_",",.01,"I")_U_Y
+10 QUIT
SETLOC ; Set a new clinic location from GUI if non is found.
+1 NEW MDVV
+2 SET MDVV=$PIECE($GET(^MDD(702,+P1,0)),U,7)
+3 IF P2=""
SET @RESULTS@(0)="-1^No Location Selected."
+4 IF $LENGTH(MDVV,";")=1
SET MDVV=";"_MDVV
+5 SET $PIECE(MDVV,";",3)=P2
+6 SET $PIECE(^MDD(702,P1,0),U,7)=MDVV
+7 SET @RESULTS@(0)="1^Okay Location Updated."
+8 QUIT
CHECK ; return TRUE if PCE data filled
+1 NEW MDIL,MDOKAY,MDCK,MDECTR
+2 SET (MDECTR,MDIL)=0
SET MDCK=""
SET MDOKAY("POV")=""
SET MDOKAY("CPT")=""
SET MDOKAY("PRV")=""
+3 FOR
SET MDIL=$ORDER(@P2@(MDIL))
if MDIL=""
QUIT
SET MDCK=$GET(@P2@(MDIL))
Begin DoDot:1
+4 IF $PIECE(MDCK,U,1)="POV"
if $GET(MDOKAY("POV"))=""
SET MDOKAY("POV")=1
+5 IF $PIECE(MDCK,U,1)="CPT"
if $GET(MDOKAY("CPT"))=""
SET MDOKAY("CPT")=1
+6 IF $PIECE(MDCK,U,1)="PRV"
if $GET(MDOKAY("PRV"))=""
SET MDOKAY("PRV")=1
End DoDot:1
+7 FOR MDIL="POV","PRV","CPT"
SET MDECTR=MDECTR+$GET(MDOKAY(MDIL))
+8 IF MDECTR<3
SET @RESULTS@(0)="-1^Missing PCE data--Review Data Again."
QUIT
+9 SET @RESULTS@(0)=1
+10 QUIT
NAME ; Get the person name
+1 SET @RESULTS@(0)="1^"_$$GET1^DIQ(200,+P2_",",.01,"E")
+2 QUIT
STAT ; Get the okay status of the CP study
+1 NEW MDST,MDGN
SET MDGN=""
+2 SET MDST=$$GET1^DIQ(702,+P1,.09,"E")
SET MDGN=MDST
+3 IF $$GET1^DIQ(702,+P1,.09,"I")=2
SET MDGN=MDGN_"^"_$$GET1^DIQ(702,+P1,.08,"E")
+4 SET @RESULTS@(0)=MDGN
+5 QUIT
STATUS ; [Procedure] Update transaction status
+1 NEW MDFDA
+2 SET MDFDA(702,+P1_",",.09)=P2
+3 DO FILE^DIE("","MDFDA")
+4 SET @RESULTS@(0)="1^Done"
+5 QUIT
+6 ;
MDICDDT ; ICD 10 IMPLEMENTATION DATE FOR CP
+1 ; Call to retrieve ICD-10 Implementation Date
+2 SET @RESULTS@(0)=$$IMPDATE^LEXU("10D")
+3 QUIT