PXQPPUTILR ;SLS/PKR - Utility for primary provider, report. ;08/14/2020
;;1.0;PCE PATIENT CARE ENCOUNTER;**211**;Aug 12, 1996;Build 454
;
;===============
REPORT ;Report what was done.
N FMTSTR,IENS,JND,NL,NOUT,NUM,OUTPUT,PROVIDER,PROVNAME
N REPEND,REPSTART,TEMP,TEXT
N VISIT,VISITID,VISITIEN,X
S REPSTART=^TMP("PXQPPR",$J,"REPSTART")
S REPEND=$$NOW^XLFDT
S TEXT(1)="Primary Provider repair utility started "_$$FMTE^XLFDT(REPSTART)_"."
S TEXT(2)="Finished "_$$FMTE^XLFDT(REPEND)_"."
S TEXT(3)="Elapsed time "_$$FMDIFF^XLFDT(REPEND,REPSTART,3)_"."
S TEXT(4)=""
S TEXT(5)="Encounter start date: "_$$FMTE^XLFDT(^TMP("PXQPPR",$J,"STARTDATE"))
S TEXT(6)="Encounter end date: "_$$FMTE^XLFDT(^TMP("PXQPPR",$J,"ENDDATE"))
S TEXT(7)=" "
S NL=7
;
;Lab encounters.
I $D(^TMP("PXQPPR",$J,"LAB")) D
. S NL=NL+1,TEXT(NL)=" "
. S NL=NL+1,TEXT(NL)="Lab Encounter Results:"
. I $D(^TMP("PXQPPR",$J,"LAB","SETP")) D
.. S FMTSTR="25L2^44L2^7L"
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)="List of Ordering Providers Made Primary"
.. S TEMP="Visit^Primary Provider^Result"
.. D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
.. S NL=NL+1,TEXT(NL)=OUTPUT(1)
.. S NUM=0,VISITIEN=""
.. F S VISITIEN=$O(^TMP("PXQPPR",$J,"LAB","SETP",VISITIEN)) Q:VISITIEN="" D
... S VISIT=$P(^AUPNVSIT(VISITIEN,0),U,1)
... S VISITID=$P(^AUPNVSIT(VISITIEN,150),U,1)
... S VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
... S PROVIDER=$O(^TMP("PXQPPR",$J,"LAB","SETP",VISITIEN,""))
... S PROVNAME=$P(^VA(200,PROVIDER,0),U,1)_" ("_PROVIDER_")"
... S RESULT=^TMP("PXQPPR",$J,"LAB","SETP",VISITIEN,PROVIDER)
... I RESULT="SUCCESS" S NUM=NUM+1
... S TEMP=VISIT_"^"_PROVNAME_"^"_RESULT
... D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
... F JND=1:1:NOUT S NL=NL+1,TEXT(NL)=OUTPUT(JND)
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)=NUM_" lab encounters had a primary provider automatically set."
. I $D(^TMP("PXQPPR",$J,"LAB","OPEN")) D
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)="Lab Encounters Opened For Editing"
.. S NUM=0,VISITIEN=""
.. F S VISITIEN=$O(^TMP("PXQPPR",$J,"LAB","OPEN",VISITIEN)) Q:VISITIEN="" D
... S VISIT=$P(^AUPNVSIT(VISITIEN,0),U,1)
... S VISITID=$P(^AUPNVSIT(VISITIEN,150),U,1)
... S VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
... S NL=NL+1,TEXT(NL)=VISIT
... S NUM=NUM+1
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)=NUM_" lab encounters were opened for editing."
S NL=NL+1,TEXT(NL)=" "
;
;Radiology encounters.
I $D(^TMP("PXQPPR",$J,"RAD")) D
. S NL=NL+1,TEXT(NL)=" "
. S NL=NL+1,TEXT(NL)="Radiology Encounter Results:"
. I $D(^TMP("PXQPPR",$J,"RAD","SETP")) D
.. S FMTSTR="25L2^44L2^7L"
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)="List of Encounter Providers Made Primary"
.. S TEMP="Visit^Primary Provider^Result"
.. D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
.. S NL=NL+1,TEXT(NL)=OUTPUT(1)
.. S NUM=0,VISITIEN=""
.. F S VISITIEN=$O(^TMP("PXQPPR",$J,"RAD","SETP",VISITIEN)) Q:VISITIEN="" D
... S VISIT=$P(^AUPNVSIT(VISITIEN,0),U,1)
... S VISITID=$P(^AUPNVSIT(VISITIEN,150),U,1)
... S VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
... S PROVIDER=$O(^TMP("PXQPPR",$J,"RAD","SETP",VISITIEN,""))
... S PROVNAME=$P(^VA(200,PROVIDER,0),U,1)_" ("_PROVIDER_")"
... S RESULT=^TMP("PXQPPR",$J,"RAD","SETP",VISITIEN,PROVIDER)
... I RESULT="SUCCESS" S NUM=NUM+1
... S TEMP=VISIT_"^"_PROVNAME_"^"_RESULT
... D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
... F JND=1:1:NOUT S NL=NL+1,TEXT(NL)=OUTPUT(JND)
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)=NUM_" radiology encounters had a primary provider automatically set."
.;
. I $D(^TMP("PXQPPR",$J,"RAD","NO EXAM")) D
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)="No Radiology Exams are linked to the following encounters."
.. S NUM=0,VISITIEN=""
.. F S VISITIEN=$O(^TMP("PXQPPR",$J,"RAD","NO EXAM",VISITIEN)) Q:VISITIEN="" D
... S VISIT=$P(^AUPNVSIT(VISITIEN,0),U,1)
... S VISITID=$P(^AUPNVSIT(VISITIEN,150),U,1)
... S VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
... S NUM=NUM+1
... S NL=NL+1,TEXT(NL)=VISIT
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)=NUM_" radiology encounters could not be linked to an exam."
.;
. I $D(^TMP("PXQPPR",$J,"RAD","VISIT")) D
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)="The following Radiology Exams were linked to an encounter."
.. S FMTSTR="30L2^35L"
.. S TEMP="Exam IENS^Visit"
.. D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
.. S NL=NL+1,TEXT(NL)=OUTPUT(1)
.. S NUM=0,VISITIEN=""
.. F S VISITIEN=$O(^TMP("PXQPPR",$J,"RAD","VISIT",VISITIEN)) Q:VISITIEN="" D
... S NUM=NUM+1
... S VISIT=$P(^AUPNVSIT(VISITIEN,0),U,1)
... S VISITID=$P(^AUPNVSIT(VISITIEN,150),U,1)
... S VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
... S IENS=^TMP("PXQPPR",$J,"RAD","VISIT",VISITIEN)
... S TEMP=IENS_"^"_VISIT
... D COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
... S NL=NL+1,TEXT(NL)=OUTPUT(1)
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)=NUM_" Exams were linked to a Visit."
.;
. I $D(^TMP("PXQPPR",$J,"RAD","PROXY")) D
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)="Encounters with RADIOLOGY,OUTSIDE SERVICE as Primary Provider Opened For Editing"
.. S NUM=0,VISITIEN=""
.. F S VISITIEN=$O(^TMP("PXQPPR",$J,"RAD","PROXY",VISITIEN)) Q:VISITIEN="" D
... S VISIT=$P(^AUPNVSIT(VISITIEN,0),U,1)
... S VISITID=$P(^AUPNVSIT(VISITIEN,150),U,1)
... S VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
... S NL=NL+1,TEXT(NL)=VISIT
... S NUM=NUM+1
.. S NL=NL+1,TEXT(NL)=" "
.. S NL=NL+1,TEXT(NL)=NUM_" radiology encounters were opened for editing."
S NL=NL+1,TEXT(NL)=" "
;
;Show the results.
S X="IORESET"
D ENDR^%ZISS
D BROWSE^DDBR("TEXT","NR","Primary Provider Repair Utility Report")
W IORESET
D KILL^%ZISS
K ^TMP("PXQPPR",$J)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXQPPUTILR 5892 printed Nov 22, 2024@17:40:12 Page 2
PXQPPUTILR ;SLS/PKR - Utility for primary provider, report. ;08/14/2020
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**211**;Aug 12, 1996;Build 454
+2 ;
+3 ;===============
REPORT ;Report what was done.
+1 NEW FMTSTR,IENS,JND,NL,NOUT,NUM,OUTPUT,PROVIDER,PROVNAME
+2 NEW REPEND,REPSTART,TEMP,TEXT
+3 NEW VISIT,VISITID,VISITIEN,X
+4 SET REPSTART=^TMP("PXQPPR",$JOB,"REPSTART")
+5 SET REPEND=$$NOW^XLFDT
+6 SET TEXT(1)="Primary Provider repair utility started "_$$FMTE^XLFDT(REPSTART)_"."
+7 SET TEXT(2)="Finished "_$$FMTE^XLFDT(REPEND)_"."
+8 SET TEXT(3)="Elapsed time "_$$FMDIFF^XLFDT(REPEND,REPSTART,3)_"."
+9 SET TEXT(4)=""
+10 SET TEXT(5)="Encounter start date: "_$$FMTE^XLFDT(^TMP("PXQPPR",$JOB,"STARTDATE"))
+11 SET TEXT(6)="Encounter end date: "_$$FMTE^XLFDT(^TMP("PXQPPR",$JOB,"ENDDATE"))
+12 SET TEXT(7)=" "
+13 SET NL=7
+14 ;
+15 ;Lab encounters.
+16 IF $DATA(^TMP("PXQPPR",$JOB,"LAB"))
Begin DoDot:1
+17 SET NL=NL+1
SET TEXT(NL)=" "
+18 SET NL=NL+1
SET TEXT(NL)="Lab Encounter Results:"
+19 IF $DATA(^TMP("PXQPPR",$JOB,"LAB","SETP"))
Begin DoDot:2
+20 SET FMTSTR="25L2^44L2^7L"
+21 SET NL=NL+1
SET TEXT(NL)=" "
+22 SET NL=NL+1
SET TEXT(NL)="List of Ordering Providers Made Primary"
+23 SET TEMP="Visit^Primary Provider^Result"
+24 DO COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
+25 SET NL=NL+1
SET TEXT(NL)=OUTPUT(1)
+26 SET NUM=0
SET VISITIEN=""
+27 FOR
SET VISITIEN=$ORDER(^TMP("PXQPPR",$JOB,"LAB","SETP",VISITIEN))
if VISITIEN=""
QUIT
Begin DoDot:3
+28 SET VISIT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+29 SET VISITID=$PIECE(^AUPNVSIT(VISITIEN,150),U,1)
+30 SET VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
+31 SET PROVIDER=$ORDER(^TMP("PXQPPR",$JOB,"LAB","SETP",VISITIEN,""))
+32 SET PROVNAME=$PIECE(^VA(200,PROVIDER,0),U,1)_" ("_PROVIDER_")"
+33 SET RESULT=^TMP("PXQPPR",$JOB,"LAB","SETP",VISITIEN,PROVIDER)
+34 IF RESULT="SUCCESS"
SET NUM=NUM+1
+35 SET TEMP=VISIT_"^"_PROVNAME_"^"_RESULT
+36 DO COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
+37 FOR JND=1:1:NOUT
SET NL=NL+1
SET TEXT(NL)=OUTPUT(JND)
End DoDot:3
+38 SET NL=NL+1
SET TEXT(NL)=" "
+39 SET NL=NL+1
SET TEXT(NL)=NUM_" lab encounters had a primary provider automatically set."
End DoDot:2
+40 IF $DATA(^TMP("PXQPPR",$JOB,"LAB","OPEN"))
Begin DoDot:2
+41 SET NL=NL+1
SET TEXT(NL)=" "
+42 SET NL=NL+1
SET TEXT(NL)="Lab Encounters Opened For Editing"
+43 SET NUM=0
SET VISITIEN=""
+44 FOR
SET VISITIEN=$ORDER(^TMP("PXQPPR",$JOB,"LAB","OPEN",VISITIEN))
if VISITIEN=""
QUIT
Begin DoDot:3
+45 SET VISIT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+46 SET VISITID=$PIECE(^AUPNVSIT(VISITIEN,150),U,1)
+47 SET VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
+48 SET NL=NL+1
SET TEXT(NL)=VISIT
+49 SET NUM=NUM+1
End DoDot:3
+50 SET NL=NL+1
SET TEXT(NL)=" "
+51 SET NL=NL+1
SET TEXT(NL)=NUM_" lab encounters were opened for editing."
End DoDot:2
End DoDot:1
+52 SET NL=NL+1
SET TEXT(NL)=" "
+53 ;
+54 ;Radiology encounters.
+55 IF $DATA(^TMP("PXQPPR",$JOB,"RAD"))
Begin DoDot:1
+56 SET NL=NL+1
SET TEXT(NL)=" "
+57 SET NL=NL+1
SET TEXT(NL)="Radiology Encounter Results:"
+58 IF $DATA(^TMP("PXQPPR",$JOB,"RAD","SETP"))
Begin DoDot:2
+59 SET FMTSTR="25L2^44L2^7L"
+60 SET NL=NL+1
SET TEXT(NL)=" "
+61 SET NL=NL+1
SET TEXT(NL)="List of Encounter Providers Made Primary"
+62 SET TEMP="Visit^Primary Provider^Result"
+63 DO COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
+64 SET NL=NL+1
SET TEXT(NL)=OUTPUT(1)
+65 SET NUM=0
SET VISITIEN=""
+66 FOR
SET VISITIEN=$ORDER(^TMP("PXQPPR",$JOB,"RAD","SETP",VISITIEN))
if VISITIEN=""
QUIT
Begin DoDot:3
+67 SET VISIT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+68 SET VISITID=$PIECE(^AUPNVSIT(VISITIEN,150),U,1)
+69 SET VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
+70 SET PROVIDER=$ORDER(^TMP("PXQPPR",$JOB,"RAD","SETP",VISITIEN,""))
+71 SET PROVNAME=$PIECE(^VA(200,PROVIDER,0),U,1)_" ("_PROVIDER_")"
+72 SET RESULT=^TMP("PXQPPR",$JOB,"RAD","SETP",VISITIEN,PROVIDER)
+73 IF RESULT="SUCCESS"
SET NUM=NUM+1
+74 SET TEMP=VISIT_"^"_PROVNAME_"^"_RESULT
+75 DO COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
+76 FOR JND=1:1:NOUT
SET NL=NL+1
SET TEXT(NL)=OUTPUT(JND)
End DoDot:3
+77 SET NL=NL+1
SET TEXT(NL)=" "
+78 SET NL=NL+1
SET TEXT(NL)=NUM_" radiology encounters had a primary provider automatically set."
End DoDot:2
+79 ;
+80 IF $DATA(^TMP("PXQPPR",$JOB,"RAD","NO EXAM"))
Begin DoDot:2
+81 SET NL=NL+1
SET TEXT(NL)=" "
+82 SET NL=NL+1
SET TEXT(NL)="No Radiology Exams are linked to the following encounters."
+83 SET NUM=0
SET VISITIEN=""
+84 FOR
SET VISITIEN=$ORDER(^TMP("PXQPPR",$JOB,"RAD","NO EXAM",VISITIEN))
if VISITIEN=""
QUIT
Begin DoDot:3
+85 SET VISIT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+86 SET VISITID=$PIECE(^AUPNVSIT(VISITIEN,150),U,1)
+87 SET VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
+88 SET NUM=NUM+1
+89 SET NL=NL+1
SET TEXT(NL)=VISIT
End DoDot:3
+90 SET NL=NL+1
SET TEXT(NL)=" "
+91 SET NL=NL+1
SET TEXT(NL)=NUM_" radiology encounters could not be linked to an exam."
End DoDot:2
+92 ;
+93 IF $DATA(^TMP("PXQPPR",$JOB,"RAD","VISIT"))
Begin DoDot:2
+94 SET NL=NL+1
SET TEXT(NL)=" "
+95 SET NL=NL+1
SET TEXT(NL)="The following Radiology Exams were linked to an encounter."
+96 SET FMTSTR="30L2^35L"
+97 SET TEMP="Exam IENS^Visit"
+98 DO COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
+99 SET NL=NL+1
SET TEXT(NL)=OUTPUT(1)
+100 SET NUM=0
SET VISITIEN=""
+101 FOR
SET VISITIEN=$ORDER(^TMP("PXQPPR",$JOB,"RAD","VISIT",VISITIEN))
if VISITIEN=""
QUIT
Begin DoDot:3
+102 SET NUM=NUM+1
+103 SET VISIT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+104 SET VISITID=$PIECE(^AUPNVSIT(VISITIEN,150),U,1)
+105 SET VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
+106 SET IENS=^TMP("PXQPPR",$JOB,"RAD","VISIT",VISITIEN)
+107 SET TEMP=IENS_"^"_VISIT
+108 DO COLFMT^PXRMTEXT(FMTSTR,TEMP," ",.NOUT,.OUTPUT)
+109 SET NL=NL+1
SET TEXT(NL)=OUTPUT(1)
End DoDot:3
+110 SET NL=NL+1
SET TEXT(NL)=" "
+111 SET NL=NL+1
SET TEXT(NL)=NUM_" Exams were linked to a Visit."
End DoDot:2
+112 ;
+113 IF $DATA(^TMP("PXQPPR",$JOB,"RAD","PROXY"))
Begin DoDot:2
+114 SET NL=NL+1
SET TEXT(NL)=" "
+115 SET NL=NL+1
SET TEXT(NL)="Encounters with RADIOLOGY,OUTSIDE SERVICE as Primary Provider Opened For Editing"
+116 SET NUM=0
SET VISITIEN=""
+117 FOR
SET VISITIEN=$ORDER(^TMP("PXQPPR",$JOB,"RAD","PROXY",VISITIEN))
if VISITIEN=""
QUIT
Begin DoDot:3
+118 SET VISIT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+119 SET VISITID=$PIECE(^AUPNVSIT(VISITIEN,150),U,1)
+120 SET VISIT=$$FMTE^XLFDT(VISIT)_" ("_VISITID_")"
+121 SET NL=NL+1
SET TEXT(NL)=VISIT
+122 SET NUM=NUM+1
End DoDot:3
+123 SET NL=NL+1
SET TEXT(NL)=" "
+124 SET NL=NL+1
SET TEXT(NL)=NUM_" radiology encounters were opened for editing."
End DoDot:2
End DoDot:1
+125 SET NL=NL+1
SET TEXT(NL)=" "
+126 ;
+127 ;Show the results.
+128 SET X="IORESET"
+129 DO ENDR^%ZISS
+130 DO BROWSE^DDBR("TEXT","NR","Primary Provider Repair Utility Report")
+131 WRITE IORESET
+132 DO KILL^%ZISS
+133 KILL ^TMP("PXQPPR",$JOB)
+134 QUIT
+135 ;