PXPNARR ;SLC/PKR - Utilities for Provider Narrative fields in V CPT and V POV ;01/28/2021
;;1.0;PCE PATIENT CARE ENCOUNTER;**211**;Aug 12, 1996;Build 454
Q
;
;===============
ONEVCPT(VISITIEN,VCPTIEN,ENTRY) ;Repair a single V CPT entry.
N CPT,EVENTDT,NARR,NODE,PNARR,PNARRP,SUBJECT
S EVENTDT=$P($G(^AUPNVCPT(VCPTIEN,12)),U,1)
I EVENTDT="" S EVENTDT=$P(^AUPNVSIT(VISITIEN,0),U,1)
S CPT=$P(^AUPNVCPT(VCPTIEN,0),U,1)
S NARR=$P($$CPT^ICPTCOD(CPT,EVENTDT),U,3)
;Get the Provider Narrative pointer.
S PNARR=$$PROVNARR^PXAPI(NARR,9000010.18)
S PNARRP=+$P(PNARR,U,1)
I PNARRP'>0 Q
S $P(^AUPNVCPT(IEN,0),U,4)=PNARRP
S $P(ENTRY(0),U,4)=PNARRP
S NODE="PXXMZ"
S SUBJECT="V CPT Provider Narrative Repair"
K ^TMP(NODE,$J)
S ^TMP(NODE,$J,1,0)="Provider Narrative set to CPT short description for V CPT IEN="_VCPTIEN_"."
S ^TMP(NODE,$J,2,0)="No further action is needed."
D SEND^PXMSG(NODE,SUBJECT)
K ^TMP(NODE,$J)
Q
;
;===============
ONEVPOV(VISITIEN,VPOVIEN,ENTRY) ;Repair a single V POV entry.
N DIAG,EVENTDT,NARR,NODE,PNARR,PNARRP,SUBJECT
S EVENTDT=$P($G(^AUPNVPOV(VPOVIEN,12)),U,1)
I EVENTDT="" S EVENTDT=$P(^AUPNVSIT(VISITIEN,0),U,1)
S DIAG=$P(^AUPNVPOV(VPOVIEN,0),U,1)
S NARR=$$LD^ICDEX(80,DIAG,EVENTDT,.NARR,245)
;Get the Provider Narrative pointer.
S PNARR=$$PROVNARR^PXAPI(NARR,9000010.07)
S PNARRP=+$P(PNARR,U,1)
I PNARRP'>0 Q
S $P(^AUPNVPOV(IEN,0),U,4)=PNARRP
S $P(ENTRY(0),U,4)=PNARRP
S NODE="PXXMZ"
S SUBJECT="V POV Provider Narrative Repair"
K ^TMP(NODE,$J)
S ^TMP(NODE,$J,1,0)="Provider Narrative set to ICD long description for V POV IEN="_VPOVIEN_"."
S ^TMP(NODE,$J,2,0)="No further action is needed."
D SEND^PXMSG(NODE,SUBJECT)
K ^TMP(NODE,$J)
Q
;
;===============
TASKBOTH ;Task the V CPT and V POV Provider Narrative check/repair.
D TASKVCPT^PXPNARR
D MES^XPDUTL("")
D TASKVPOV^PXPNARR
Q
;
;===============
TASKVCPT ;Task the V CPT Provider Narraative Check/Repair.
S ZTDESC="V CPT Provider Narrative and Narrative Category Check/Repair"
S ZTDTH=$H
S ZTIO=""
S ZTREQ="@"
S ZTRTN="VCPT^PXPNARR"
D MES^XPDUTL(ZTDESC)
D ^%ZTLOAD
D MES^XPDUTL("Task Number "_ZTSK_" started.")
Q
;
;===============
TASKVPOV ;Task the V POV Provider Narrative Check/Repair.
S ZTDESC="V POV Provider Narrative and Narrative Category Check/Repair"
S ZTDTH=$H
S ZTIO=""
S ZTREQ="@"
S ZTRTN="VPOV^PXPNARR"
D MES^XPDUTL(ZTDESC)
D ^%ZTLOAD
D MES^XPDUTL("Task Number "_ZTSK_" started.")
Q
;
;===============
VCPT ;V CPT Provider Narrative and Provider Narrative Category check/repair.
N CPT,EVENTDT,IEN,IND,NARR,NL,NODE,NPNARR,NPNARRC,NVT,PNARR,PNARRC
N PNARRP,SUBJECT,TEMP,TEXT,VALID,VISITIEN,VTEXT
S NL=4
S (IEN,NPNARR,NPNARRC,NVT)=0
F S IEN=+$O(^AUPNVCPT(IEN)) Q:IEN=0 D
.;Check for a corrupted entry.
. I '$D(^AUPNVCPT(IEN,0)) Q
.;Is the Provider Narrative pointer valid?
. S PNARR=+$P(^AUPNVCPT(IEN,0),U,4)
. S VALID=$S(PNARR'>0:0,1:$D(^AUTNPOV(PNARR)))
. I 'VALID D
..;When the pointer is missing or invalid use the default, which is
..;the CPT short description.
.. S TEMP=^AUPNVCPT(IEN,0)
.. S VISITIEN=+$P(TEMP,U,3)
..;If the Visit is not valid quit.
..;Save info about bad Visit.
.. I VISITIEN'>0 D Q
... S NVT=NVT+1,VTEXT(NVT)="V CPT IEN="_IEN_", visit pointer is missing."
.. I (VISITIEN>0),'$D(^AUPNVSIT(VISITIEN)) D Q
... S NVT=NVT+1,VTEXT(NVT)="V CPT IEN="_IEN_", visit pointer points to a non-existent Visit."
.. S EVENTDT=$P($G(^AUPNVCPT(IEN,12)),U,1)
.. I (EVENTDT=""),(VISITIEN'>0) S EVENTDT=DT
.. I EVENTDT="" S EVENTDT=$P(^AUPNVSIT(VISITIEN,0),U,1)
.. S CPT=$P(TEMP,U,1)
.. S NARR=$P($$CPT^ICPTCOD(CPT,EVENTDT),U,3)
..;Get the Provider Narrative pointer.
.. S PNARR=$$PROVNARR^PXAPI(NARR,9000010.18)
.. S PNARRP=+$P(PNARR,U,1)
.. S $P(^AUPNVCPT(IEN,0),U,4)=PNARRP
.. I PNARRP>0 D
... S NPNARR=NPNARR+1
... S NL=NL+1,TEXT(NL)="Provider Narrative set to CPT short description for IEN="_IEN_"."
.. E S NL=NL+1,TEXT(NL)="Provider Narrative pointer is: "_PNARRP_" for IEN="_IEN_"."
.;
.;Is the Provider Narrative Category pointer valid?
. S PNARRC=$P($G(^AUPNVCPT(IEN,802)),U,1)
. S VALID=$S(PNARRC="":1,1:$D(^AUTNPOV(PNARRC)))
.;Provider Narrative Category is not a required field, when the pointer
.;is not valid delete it.
. I 'VALID D
.. S $P(^AUPNVCPT(IEN,802),U,1)=""
.. S NPNARRC=NPNARRC+1
.. S NL=NL+1,TEXT(NL)="Provider Narrative Category set to NULL for IEN="_IEN_"."
S TEXT(1)="V CPT Provider Narrative and Provider Narrative Category check/repair results:"
I NPNARR=0 S TEXT(2)="No problems were found for Provider Narrative."
E S TEXT(2)=NPNARR_" Provider Narratives were set to the default."
I NPNARRC=0 S TEXT(3)="No problems were found for Provider Narrative Category."
E S TEXT(3)=NPNARRC_" Provider Narrative Categories were set to NULL."
S TEXT(4)=$S((NPNARR+NPNARRC)>0:"The following changes were made:",1:"")
;Setup ^TMP for sending a MailMan message.
S NODE="PXXMZ"
S SUBJECT="V CPT Provider Narrative and Narrative Category Check/Repair"
K ^TMP(NODE,$J)
S (IND,NL)=0
F S IND=+$O(TEXT(IND)) Q:IND=0 S NL=NL+1,^TMP(NODE,$J,NL,0)=TEXT(IND)
I NVT>0 D
. S NL=NL+1,^TMP(NODE,$J,NL,0)=""
. S NL=NL+1,^TMP(NODE,$J,NL,0)="Additional issues that were found:"
. S IND=0
. F S IND=+$O(VTEXT(IND)) Q:IND=0 S NL=NL+1,^TMP(NODE,$J,NL,0)=VTEXT(IND)
D SEND^PXMSG(NODE,SUBJECT)
Q
;
;===============
VPNARR(PNARR) ;Check for a valid provider narrative.
;The provder narrative is free text, but do not allow control characters.
N CHAR,CTRLFOUND,DONE,IND,LEN
S LEN=$L(PNARR)
S (CTRLFOUND,DONE,IND)=0
F Q:DONE D
. S IND=IND+1
. S CHAR=$E(PNARR,IND)
. I CHAR?1C S (CTRLFOUND,DONE)=1 Q
. I IND=LEN S DONE=1
Q $S(CTRLFOUND=1:0,1:1)
;
;===============
VPOV ;V POV Provider Narrative and Provider Narrative Category check/repair.
N DIAG,EVENTDT,IEN,IND,NARR,NL,NODE,NPNARR,NPNARRC,NVT,PNARR,PNARRC
N PNARRP,SUBJECT,TEMP,TEXT,VALID,VISITIEN,VTEXT
S NL=4
S (IEN,NPNARR,NPNARRC,NVT)=0
F S IEN=+$O(^AUPNVPOV(IEN)) Q:IEN=0 D
.;Check for a corrupted entry.
. I '$D(^AUPNVPOV(IEN,0)) Q
.;Is the Provider Narrative pointer valid?
. S PNARR=+$P(^AUPNVPOV(IEN,0),U,4)
. S VALID=$S(PNARR'>0:0,1:$D(^AUTNPOV(PNARR)))
. I 'VALID D
..;When the pointer is missing or invalid use the default, which is
..;the ICD description.
.. S TEMP=^AUPNVPOV(IEN,0)
.. S VISITIEN=+$P(TEMP,U,3)
..;If the Visit is not valid quit.
..;Save info about bad Visit.
.. I VISITIEN'>0 D Q
... S NVT=NVT+1,VTEXT(NVT)="V POV IEN="_IEN_", visit pointer is missing."
.. I (VISITIEN>0),'$D(^AUPNVSIT(VISITIEN)) D Q
... S NVT=NVT+1,VTEXT(NVT)="V POV IEN="_IEN_", visit pointer points to a non-existent Visit."
.. S EVENTDT=$P($G(^AUPNVPOV(IEN,12)),U,1)
.. I (EVENTDT=""),(VISITIEN'>0) S EVENTDT=DT
.. I EVENTDT="" S EVENTDT=$P(^AUPNVSIT(VISITIEN,0),U,1)
.. S DIAG=$P(TEMP,U,1)
.. S NARR=$$LD^ICDEX(80,DIAG,EVENTDT,.NARR,245)
..;Get the Provider Narrative pointer.
.. S PNARR=$$PROVNARR^PXAPI(NARR,9000010.07)
.. S PNARRP=+$P(PNARR,U,1)
.. S $P(^AUPNVPOV(IEN,0),U,4)=PNARRP
.. I PNARRP>0 D
... S NPNARR=NPNARR+1
... S NL=NL+1,TEXT(NL)="Provider Narrative set to ICD long description for IEN="_IEN_"."
.. E S NL=NL+1,TEXT(NL)="Provider Narrative pointer is: "_PNARRP_" for IEN="_IEN_"."
.;
.;Is the Provider Narrative Category pointer valid?
. S PNARRC=$P($G(^AUPNVPOV(IEN,802)),U,1)
. S VALID=$S(PNARRC="":1,1:$D(^AUTNPOV(PNARRC)))
.;Provider Narrative Category is not a required field, when the pointer
.;is not valid delete it.
. I 'VALID D
.. S $P(^AUPNVPOV(IEN,802),U,1)=""
.. S NPNARRC=NPNARRC+1
.. S NL=NL+1,TEXT(NL)="Provider Narrative Category set to NULL for IEN="_IEN_"."
S TEXT(1)="V POV Provider Narrative and Provider Narrative Category check/repair results:"
I NPNARR=0 S TEXT(2)="No problems were found for Provider Narrative."
E S TEXT(2)=NPNARR_" Provider Narratives were set to the default."
I NPNARRC=0 S TEXT(3)="No problems were found for Provider Narrative Category."
E S TEXT(3)=NPNARRC_" Provider Narrative Categories were set to NULL."
S TEXT(4)=$S((NPNARR+NPNARRC)>0:"The following changes were made:",1:"")
;Setup ^TMP for sending a MailMan message.
S NODE="PXXMZ"
S SUBJECT="V POV Provider Narrative and Narrative Category Check/Repair"
K ^TMP(NODE,$J)
S (IND,NL)=0
F S IND=+$O(TEXT(IND)) Q:IND=0 S NL=NL+1,^TMP(NODE,$J,NL,0)=TEXT(IND)
I NVT>0 D
. S NL=NL+1,^TMP(NODE,$J,NL,0)=""
. S NL=NL+1,^TMP(NODE,$J,NL,0)="Additional issues that were found:"
. S IND=0
. F S IND=+$O(VTEXT(IND)) Q:IND=0 S NL=NL+1,^TMP(NODE,$J,NL,0)=VTEXT(IND)
D SEND^PXMSG(NODE,SUBJECT)
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXPNARR 8797 printed Nov 22, 2024@17:39:50 Page 2
PXPNARR ;SLC/PKR - Utilities for Provider Narrative fields in V CPT and V POV ;01/28/2021
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**211**;Aug 12, 1996;Build 454
+2 QUIT
+3 ;
+4 ;===============
ONEVCPT(VISITIEN,VCPTIEN,ENTRY) ;Repair a single V CPT entry.
+1 NEW CPT,EVENTDT,NARR,NODE,PNARR,PNARRP,SUBJECT
+2 SET EVENTDT=$PIECE($GET(^AUPNVCPT(VCPTIEN,12)),U,1)
+3 IF EVENTDT=""
SET EVENTDT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+4 SET CPT=$PIECE(^AUPNVCPT(VCPTIEN,0),U,1)
+5 SET NARR=$PIECE($$CPT^ICPTCOD(CPT,EVENTDT),U,3)
+6 ;Get the Provider Narrative pointer.
+7 SET PNARR=$$PROVNARR^PXAPI(NARR,9000010.18)
+8 SET PNARRP=+$PIECE(PNARR,U,1)
+9 IF PNARRP'>0
QUIT
+10 SET $PIECE(^AUPNVCPT(IEN,0),U,4)=PNARRP
+11 SET $PIECE(ENTRY(0),U,4)=PNARRP
+12 SET NODE="PXXMZ"
+13 SET SUBJECT="V CPT Provider Narrative Repair"
+14 KILL ^TMP(NODE,$JOB)
+15 SET ^TMP(NODE,$JOB,1,0)="Provider Narrative set to CPT short description for V CPT IEN="_VCPTIEN_"."
+16 SET ^TMP(NODE,$JOB,2,0)="No further action is needed."
+17 DO SEND^PXMSG(NODE,SUBJECT)
+18 KILL ^TMP(NODE,$JOB)
+19 QUIT
+20 ;
+21 ;===============
ONEVPOV(VISITIEN,VPOVIEN,ENTRY) ;Repair a single V POV entry.
+1 NEW DIAG,EVENTDT,NARR,NODE,PNARR,PNARRP,SUBJECT
+2 SET EVENTDT=$PIECE($GET(^AUPNVPOV(VPOVIEN,12)),U,1)
+3 IF EVENTDT=""
SET EVENTDT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+4 SET DIAG=$PIECE(^AUPNVPOV(VPOVIEN,0),U,1)
+5 SET NARR=$$LD^ICDEX(80,DIAG,EVENTDT,.NARR,245)
+6 ;Get the Provider Narrative pointer.
+7 SET PNARR=$$PROVNARR^PXAPI(NARR,9000010.07)
+8 SET PNARRP=+$PIECE(PNARR,U,1)
+9 IF PNARRP'>0
QUIT
+10 SET $PIECE(^AUPNVPOV(IEN,0),U,4)=PNARRP
+11 SET $PIECE(ENTRY(0),U,4)=PNARRP
+12 SET NODE="PXXMZ"
+13 SET SUBJECT="V POV Provider Narrative Repair"
+14 KILL ^TMP(NODE,$JOB)
+15 SET ^TMP(NODE,$JOB,1,0)="Provider Narrative set to ICD long description for V POV IEN="_VPOVIEN_"."
+16 SET ^TMP(NODE,$JOB,2,0)="No further action is needed."
+17 DO SEND^PXMSG(NODE,SUBJECT)
+18 KILL ^TMP(NODE,$JOB)
+19 QUIT
+20 ;
+21 ;===============
TASKBOTH ;Task the V CPT and V POV Provider Narrative check/repair.
+1 DO TASKVCPT^PXPNARR
+2 DO MES^XPDUTL("")
+3 DO TASKVPOV^PXPNARR
+4 QUIT
+5 ;
+6 ;===============
TASKVCPT ;Task the V CPT Provider Narraative Check/Repair.
+1 SET ZTDESC="V CPT Provider Narrative and Narrative Category Check/Repair"
+2 SET ZTDTH=$HOROLOG
+3 SET ZTIO=""
+4 SET ZTREQ="@"
+5 SET ZTRTN="VCPT^PXPNARR"
+6 DO MES^XPDUTL(ZTDESC)
+7 DO ^%ZTLOAD
+8 DO MES^XPDUTL("Task Number "_ZTSK_" started.")
+9 QUIT
+10 ;
+11 ;===============
TASKVPOV ;Task the V POV Provider Narrative Check/Repair.
+1 SET ZTDESC="V POV Provider Narrative and Narrative Category Check/Repair"
+2 SET ZTDTH=$HOROLOG
+3 SET ZTIO=""
+4 SET ZTREQ="@"
+5 SET ZTRTN="VPOV^PXPNARR"
+6 DO MES^XPDUTL(ZTDESC)
+7 DO ^%ZTLOAD
+8 DO MES^XPDUTL("Task Number "_ZTSK_" started.")
+9 QUIT
+10 ;
+11 ;===============
VCPT ;V CPT Provider Narrative and Provider Narrative Category check/repair.
+1 NEW CPT,EVENTDT,IEN,IND,NARR,NL,NODE,NPNARR,NPNARRC,NVT,PNARR,PNARRC
+2 NEW PNARRP,SUBJECT,TEMP,TEXT,VALID,VISITIEN,VTEXT
+3 SET NL=4
+4 SET (IEN,NPNARR,NPNARRC,NVT)=0
+5 FOR
SET IEN=+$ORDER(^AUPNVCPT(IEN))
if IEN=0
QUIT
Begin DoDot:1
+6 ;Check for a corrupted entry.
+7 IF '$DATA(^AUPNVCPT(IEN,0))
QUIT
+8 ;Is the Provider Narrative pointer valid?
+9 SET PNARR=+$PIECE(^AUPNVCPT(IEN,0),U,4)
+10 SET VALID=$SELECT(PNARR'>0:0,1:$DATA(^AUTNPOV(PNARR)))
+11 IF 'VALID
Begin DoDot:2
+12 ;When the pointer is missing or invalid use the default, which is
+13 ;the CPT short description.
+14 SET TEMP=^AUPNVCPT(IEN,0)
+15 SET VISITIEN=+$PIECE(TEMP,U,3)
+16 ;If the Visit is not valid quit.
+17 ;Save info about bad Visit.
+18 IF VISITIEN'>0
Begin DoDot:3
+19 SET NVT=NVT+1
SET VTEXT(NVT)="V CPT IEN="_IEN_", visit pointer is missing."
End DoDot:3
QUIT
+20 IF (VISITIEN>0)
IF '$DATA(^AUPNVSIT(VISITIEN))
Begin DoDot:3
+21 SET NVT=NVT+1
SET VTEXT(NVT)="V CPT IEN="_IEN_", visit pointer points to a non-existent Visit."
End DoDot:3
QUIT
+22 SET EVENTDT=$PIECE($GET(^AUPNVCPT(IEN,12)),U,1)
+23 IF (EVENTDT="")
IF (VISITIEN'>0)
SET EVENTDT=DT
+24 IF EVENTDT=""
SET EVENTDT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+25 SET CPT=$PIECE(TEMP,U,1)
+26 SET NARR=$PIECE($$CPT^ICPTCOD(CPT,EVENTDT),U,3)
+27 ;Get the Provider Narrative pointer.
+28 SET PNARR=$$PROVNARR^PXAPI(NARR,9000010.18)
+29 SET PNARRP=+$PIECE(PNARR,U,1)
+30 SET $PIECE(^AUPNVCPT(IEN,0),U,4)=PNARRP
+31 IF PNARRP>0
Begin DoDot:3
+32 SET NPNARR=NPNARR+1
+33 SET NL=NL+1
SET TEXT(NL)="Provider Narrative set to CPT short description for IEN="_IEN_"."
End DoDot:3
+34 IF '$TEST
SET NL=NL+1
SET TEXT(NL)="Provider Narrative pointer is: "_PNARRP_" for IEN="_IEN_"."
End DoDot:2
+35 ;
+36 ;Is the Provider Narrative Category pointer valid?
+37 SET PNARRC=$PIECE($GET(^AUPNVCPT(IEN,802)),U,1)
+38 SET VALID=$SELECT(PNARRC="":1,1:$DATA(^AUTNPOV(PNARRC)))
+39 ;Provider Narrative Category is not a required field, when the pointer
+40 ;is not valid delete it.
+41 IF 'VALID
Begin DoDot:2
+42 SET $PIECE(^AUPNVCPT(IEN,802),U,1)=""
+43 SET NPNARRC=NPNARRC+1
+44 SET NL=NL+1
SET TEXT(NL)="Provider Narrative Category set to NULL for IEN="_IEN_"."
End DoDot:2
End DoDot:1
+45 SET TEXT(1)="V CPT Provider Narrative and Provider Narrative Category check/repair results:"
+46 IF NPNARR=0
SET TEXT(2)="No problems were found for Provider Narrative."
+47 IF '$TEST
SET TEXT(2)=NPNARR_" Provider Narratives were set to the default."
+48 IF NPNARRC=0
SET TEXT(3)="No problems were found for Provider Narrative Category."
+49 IF '$TEST
SET TEXT(3)=NPNARRC_" Provider Narrative Categories were set to NULL."
+50 SET TEXT(4)=$SELECT((NPNARR+NPNARRC)>0:"The following changes were made:",1:"")
+51 ;Setup ^TMP for sending a MailMan message.
+52 SET NODE="PXXMZ"
+53 SET SUBJECT="V CPT Provider Narrative and Narrative Category Check/Repair"
+54 KILL ^TMP(NODE,$JOB)
+55 SET (IND,NL)=0
+56 FOR
SET IND=+$ORDER(TEXT(IND))
if IND=0
QUIT
SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)=TEXT(IND)
+57 IF NVT>0
Begin DoDot:1
+58 SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)=""
+59 SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)="Additional issues that were found:"
+60 SET IND=0
+61 FOR
SET IND=+$ORDER(VTEXT(IND))
if IND=0
QUIT
SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)=VTEXT(IND)
End DoDot:1
+62 DO SEND^PXMSG(NODE,SUBJECT)
+63 QUIT
+64 ;
+65 ;===============
VPNARR(PNARR) ;Check for a valid provider narrative.
+1 ;The provder narrative is free text, but do not allow control characters.
+2 NEW CHAR,CTRLFOUND,DONE,IND,LEN
+3 SET LEN=$LENGTH(PNARR)
+4 SET (CTRLFOUND,DONE,IND)=0
+5 FOR
if DONE
QUIT
Begin DoDot:1
+6 SET IND=IND+1
+7 SET CHAR=$EXTRACT(PNARR,IND)
+8 IF CHAR?1C
SET (CTRLFOUND,DONE)=1
QUIT
+9 IF IND=LEN
SET DONE=1
End DoDot:1
+10 QUIT $SELECT(CTRLFOUND=1:0,1:1)
+11 ;
+12 ;===============
VPOV ;V POV Provider Narrative and Provider Narrative Category check/repair.
+1 NEW DIAG,EVENTDT,IEN,IND,NARR,NL,NODE,NPNARR,NPNARRC,NVT,PNARR,PNARRC
+2 NEW PNARRP,SUBJECT,TEMP,TEXT,VALID,VISITIEN,VTEXT
+3 SET NL=4
+4 SET (IEN,NPNARR,NPNARRC,NVT)=0
+5 FOR
SET IEN=+$ORDER(^AUPNVPOV(IEN))
if IEN=0
QUIT
Begin DoDot:1
+6 ;Check for a corrupted entry.
+7 IF '$DATA(^AUPNVPOV(IEN,0))
QUIT
+8 ;Is the Provider Narrative pointer valid?
+9 SET PNARR=+$PIECE(^AUPNVPOV(IEN,0),U,4)
+10 SET VALID=$SELECT(PNARR'>0:0,1:$DATA(^AUTNPOV(PNARR)))
+11 IF 'VALID
Begin DoDot:2
+12 ;When the pointer is missing or invalid use the default, which is
+13 ;the ICD description.
+14 SET TEMP=^AUPNVPOV(IEN,0)
+15 SET VISITIEN=+$PIECE(TEMP,U,3)
+16 ;If the Visit is not valid quit.
+17 ;Save info about bad Visit.
+18 IF VISITIEN'>0
Begin DoDot:3
+19 SET NVT=NVT+1
SET VTEXT(NVT)="V POV IEN="_IEN_", visit pointer is missing."
End DoDot:3
QUIT
+20 IF (VISITIEN>0)
IF '$DATA(^AUPNVSIT(VISITIEN))
Begin DoDot:3
+21 SET NVT=NVT+1
SET VTEXT(NVT)="V POV IEN="_IEN_", visit pointer points to a non-existent Visit."
End DoDot:3
QUIT
+22 SET EVENTDT=$PIECE($GET(^AUPNVPOV(IEN,12)),U,1)
+23 IF (EVENTDT="")
IF (VISITIEN'>0)
SET EVENTDT=DT
+24 IF EVENTDT=""
SET EVENTDT=$PIECE(^AUPNVSIT(VISITIEN,0),U,1)
+25 SET DIAG=$PIECE(TEMP,U,1)
+26 SET NARR=$$LD^ICDEX(80,DIAG,EVENTDT,.NARR,245)
+27 ;Get the Provider Narrative pointer.
+28 SET PNARR=$$PROVNARR^PXAPI(NARR,9000010.07)
+29 SET PNARRP=+$PIECE(PNARR,U,1)
+30 SET $PIECE(^AUPNVPOV(IEN,0),U,4)=PNARRP
+31 IF PNARRP>0
Begin DoDot:3
+32 SET NPNARR=NPNARR+1
+33 SET NL=NL+1
SET TEXT(NL)="Provider Narrative set to ICD long description for IEN="_IEN_"."
End DoDot:3
+34 IF '$TEST
SET NL=NL+1
SET TEXT(NL)="Provider Narrative pointer is: "_PNARRP_" for IEN="_IEN_"."
End DoDot:2
+35 ;
+36 ;Is the Provider Narrative Category pointer valid?
+37 SET PNARRC=$PIECE($GET(^AUPNVPOV(IEN,802)),U,1)
+38 SET VALID=$SELECT(PNARRC="":1,1:$DATA(^AUTNPOV(PNARRC)))
+39 ;Provider Narrative Category is not a required field, when the pointer
+40 ;is not valid delete it.
+41 IF 'VALID
Begin DoDot:2
+42 SET $PIECE(^AUPNVPOV(IEN,802),U,1)=""
+43 SET NPNARRC=NPNARRC+1
+44 SET NL=NL+1
SET TEXT(NL)="Provider Narrative Category set to NULL for IEN="_IEN_"."
End DoDot:2
End DoDot:1
+45 SET TEXT(1)="V POV Provider Narrative and Provider Narrative Category check/repair results:"
+46 IF NPNARR=0
SET TEXT(2)="No problems were found for Provider Narrative."
+47 IF '$TEST
SET TEXT(2)=NPNARR_" Provider Narratives were set to the default."
+48 IF NPNARRC=0
SET TEXT(3)="No problems were found for Provider Narrative Category."
+49 IF '$TEST
SET TEXT(3)=NPNARRC_" Provider Narrative Categories were set to NULL."
+50 SET TEXT(4)=$SELECT((NPNARR+NPNARRC)>0:"The following changes were made:",1:"")
+51 ;Setup ^TMP for sending a MailMan message.
+52 SET NODE="PXXMZ"
+53 SET SUBJECT="V POV Provider Narrative and Narrative Category Check/Repair"
+54 KILL ^TMP(NODE,$JOB)
+55 SET (IND,NL)=0
+56 FOR
SET IND=+$ORDER(TEXT(IND))
if IND=0
QUIT
SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)=TEXT(IND)
+57 IF NVT>0
Begin DoDot:1
+58 SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)=""
+59 SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)="Additional issues that were found:"
+60 SET IND=0
+61 FOR
SET IND=+$ORDER(VTEXT(IND))
if IND=0
QUIT
SET NL=NL+1
SET ^TMP(NODE,$JOB,NL,0)=VTEXT(IND)
End DoDot:1
+62 DO SEND^PXMSG(NODE,SUBJECT)
+63 QUIT
+64 ;