PXPXRMI1 ; SLC/PKR - Build indexes for the V files. ;28-Apr-2015 14:32;DU
;;1.0;PCE PATIENT CARE ENCOUNTER;**119,1003**;Aug 12, 1996;Build 3
;DBIA 4113 supports PXRMSXRM entry points.
;DBIA 4114 supports setting and killing ^PXRMINDX
;===============================================================
VCPT ;Build the indexes for V CPT.
N CPT,DAS,DATE,DFN,DIFF,DONE,END,ENTRIES,ETEXT,GLOBAL,IND,NE,NERROR,PP
N START,TEMP,TENP,TEXT,VISIT
;Don't leave any old stuff around.
K ^PXRMINDX(9000010.18)
S GLOBAL=$$GET1^DID(9000010.18,"","","GLOBAL NAME")
S ENTRIES=$P(^AUPNVCPT(0),U,4)
S TENP=ENTRIES/10
S TENP=+$P(TENP,".",1)
I TENP<1 S TENP=1
D BMES^XPDUTL("Building indexes for V CPT")
S TEXT="There are "_ENTRIES_" entries to process."
D MES^XPDUTL(TEXT)
S START=$H
S (DAS,DONE,IND,NE,NERROR)=0
F S DAS=$O(^AUPNVCPT(DAS)) Q:DONE D
. I +DAS=0 S DONE=1 Q
. I +DAS'=DAS D Q
.. S DONE=1
.. S ETEXT="Bad ien: "_DAS_", cannot continue."
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S IND=IND+1
. I IND#TENP=0 D
.. S TEXT="Processing entry "_IND
.. D MES^XPDUTL(TEXT)
. I IND#10000=0 W "."
. ;IHS/MSC/MGH Put a $G around it p1003
. S TEMP=$G(^AUPNVCPT(DAS,0))
. S CPT=$P(TEMP,U,1)
. I CPT="" D Q
.. S ETEXT=DAS_" missing CPT"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I '$D(^ICPT(CPT)) D Q
.. S ETEXT=DAS_" invalid CPT"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S DFN=$P(TEMP,U,2)
. I DFN="" D Q
.. S ETEXT=DAS_" missing DFN"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S VISIT=$P(TEMP,U,3)
. I VISIT="" D Q
.. S ETEXT=DAS_" missing visit"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I '$D(^AUPNVSIT(VISIT)) D Q
.. S ETEXT=DAS_" invalid visit"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. ;IHS/MGH/MGH Wrap it to prevent error
. S DATE=$P($G(^AUPNVSIT(VISIT,0)),U,1)
. I DATE="" D Q
.. S ETEXT=DAS_" missing visit date"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S PP=$P(TEMP,U,7)
. I PP="" S PP="U"
. S NE=NE+1
. S ^PXRMINDX(9000010.18,"IPP",CPT,PP,DFN,DATE,DAS)=""
. S ^PXRMINDX(9000010.18,"PPI",DFN,PP,CPT,DATE,DAS)=""
S END=$H
S TEXT=NE_" V CPT results indexed."
D MES^XPDUTL(TEXT)
D DETIME^PXRMSXRM(START,END)
;If there were errors send a message.
I NERROR>0 D ERRMSG^PXRMSXRM(NERROR,GLOBAL)
;Send a MailMan message with the results.
D COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
S ^PXRMINDX(9000010.18,"GLOBAL NAME")=GLOBAL
S ^PXRMINDX(9000010.18,"BUILT BY")=DUZ
S ^PXRMINDX(9000010.18,"DATE BUILT")=$$NOW^XLFDT
Q
;
;===============================================================
VHF ;Build the indexes for V HEALTH FACTORS.
N CAT,DAS,DATE,DFN,DIFF,DONE,END,ENTRIES,ETEXT,GLOBAL,HF,IND,NE,NERROR
N START,TEMP,TENP,TEXT,VISIT
;Don't leave any old stuff around.
K ^PXRMINDX(9000010.23)
S GLOBAL=$$GET1^DID(9000010.23,"","","GLOBAL NAME")
S ENTRIES=$P(^AUPNVHF(0),U,4)
S TENP=ENTRIES/10
S TENP=+$P(TENP,".",1)
I TENP<1 S TENP=1
D BMES^XPDUTL("Building indexes for V HEALTH FACTORS")
S TEXT="There are "_ENTRIES_" entries to process."
D MES^XPDUTL(TEXT)
S START=$H
S (DAS,DONE,IND,NE,NERROR)=0
F S DAS=$O(^AUPNVHF(DAS)) Q:DONE D
. I +DAS=0 S DONE=1 Q
. I +DAS'=DAS D Q
.. S DONE=1
.. S ETEXT="Bad ien: "_DAS_", cannot continue."
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S IND=IND+1
. I IND#TENP=0 D
.. S TEXT="Processing entry "_IND
.. D MES^XPDUTL(TEXT)
. I IND#10000=0 W "."
. ;IHS/MSC/MGH Put a $G around it p1003
. S TEMP=$G(^AUPNVHF(DAS,0))
. S HF=$P(TEMP,U,1)
. I HF="" D Q
.. S ETEXT=DAS_" missing HF"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I '$D(^AUTTHF(HF)) D Q
.. S ETEXT=DAS_" invalid HF"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S DFN=$P(TEMP,U,2)
. I DFN="" D Q
.. S ETEXT=DAS_" missing DFN"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S CAT=$P(^AUTTHF(HF,0),U,3)
. I CAT="" D Q
.. S ETEXT=DAS_" HF "_HF_" missing category"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I HF=CAT D Q
.. S ETEXT=DAS_" HF "_HF_" is a category"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S VISIT=$P(TEMP,U,3)
. I VISIT="" D Q
.. S ETEXT=DAS_" missing visit"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I '$D(^AUPNVSIT(VISIT)) D Q
.. S ETEXT=DAS_" invalid visit"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. ;IHS/MGH/MGH Wrap it to prevent error
. S DATE=$P($G(^AUPNVSIT(VISIT,0)),U,1)
. I DATE="" D Q
.. S ETEXT=DAS_" missing visit date"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S NE=NE+1
. S ^PXRMINDX(9000010.23,"IP",HF,DFN,DATE,DAS)=""
. S ^PXRMINDX(9000010.23,"PI",DFN,HF,DATE,DAS)=""
S END=$H
S TEXT=NE_" V HEALTH FACTOR results indexed."
D MES^XPDUTL(TEXT)
D DETIME^PXRMSXRM(START,END)
;If there were errors send a message.
I NERROR>0 D ERRMSG^PXRMSXRM(NERROR,GLOBAL)
;Send a MailMan message with the results.
D COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
S ^PXRMINDX(9000010.23,"GLOBAL NAME")=GLOBAL
S ^PXRMINDX(9000010.23,"BUILT BY")=DUZ
S ^PXRMINDX(9000010.23,"DATE BUILT")=$$NOW^XLFDT
Q
;
;===============================================================
VIMM ;Build the indexes for V IMMUNIZATION.
N DAS,DATE,DFN,DIFF,DONE,END,ENTRIES,ETEXT,GLOBAL,IMM,IND,NE,NERROR
N START,TEMP,TENP,TEXT,VISIT
;Don't leave any old stuff around.
K ^PXRMINDX(9000010.11)
S GLOBAL=$$GET1^DID(9000010.11,"","","GLOBAL NAME")
S ENTRIES=$P(^AUPNVIMM(0),U,4)
S TENP=ENTRIES/10
S TENP=+$P(TENP,".",1)
I TENP<1 S TENP=1
D BMES^XPDUTL("Building indexes for V IMMUNIZATION")
S TEXT="There are "_ENTRIES_" entries to process."
D MES^XPDUTL(TEXT)
S START=$H
S (DAS,DONE,IND,NE,NERROR)=0
F S DAS=$O(^AUPNVIMM(DAS)) Q:DONE D
. I +DAS=0 S DONE=1 Q
. I +DAS'=DAS D Q
.. S DONE=1
.. S ETEXT="Bad ien: "_DAS_", cannot continue."
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S IND=IND+1
. I IND#TENP=0 D
.. S TEXT="Processing entry "_IND
.. D MES^XPDUTL(TEXT)
. I IND#10000=0 W "."
. ;IHS/MSC/MGH Put a $G around it p1003
. S TEMP=$G(^AUPNVIMM(DAS,0))
. S IMM=$P(TEMP,U,1)
. I IMM="" D Q
.. S ETEXT=DAS_" missing immunization"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I '$D(^AUTTIMM(IMM)) D Q
.. S ETEXT=DAS_" invalid immunization"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S DFN=$P(TEMP,U,2)
. I DFN="" D Q
.. S ETEXT=DAS_" missing DFN"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S VISIT=$P(TEMP,U,3)
. I VISIT="" D Q
.. S ETEXT=DAS_" missing visit"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. I '$D(^AUPNVSIT(VISIT)) D Q
.. S ETEXT=DAS_" invalid visit"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. ;IHS/MGH/MGH Wrap it to prevent error
. S DATE=$P($G(^AUPNVSIT(VISIT,0)),U,1)
. I DATE="" D Q
.. S ETEXT=DAS_" missing visit date"
.. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
. S NE=NE+1
. S ^PXRMINDX(9000010.11,"IP",IMM,DFN,DATE,DAS)=""
. S ^PXRMINDX(9000010.11,"PI",DFN,IMM,DATE,DAS)=""
S END=$H
S TEXT=NE_" V IMMUNIZATION results indexed."
D MES^XPDUTL(TEXT)
D DETIME^PXRMSXRM(START,END)
;If there were errors send a message.
I NERROR>0 D ERRMSG^PXRMSXRM(NERROR,GLOBAL)
;Send a MailMan message with the results.
D COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
S ^PXRMINDX(9000010.11,"GLOBAL NAME")=GLOBAL
S ^PXRMINDX(9000010.11,"BUILT BY")=DUZ
S ^PXRMINDX(9000010.11,"DATE BUILT")=$$NOW^XLFDT
Q
;
PXPXRMI1 ; SLC/PKR - Build indexes for the V files. ;28-Apr-2015 14:32;DU
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**119,1003**;Aug 12, 1996;Build 3
+2 ;DBIA 4113 supports PXRMSXRM entry points.
+3 ;DBIA 4114 supports setting and killing ^PXRMINDX
+4 ;===============================================================
VCPT ;Build the indexes for V CPT.
+1 NEW CPT,DAS,DATE,DFN,DIFF,DONE,END,ENTRIES,ETEXT,GLOBAL,IND,NE,NERROR,PP
+2 NEW START,TEMP,TENP,TEXT,VISIT
+3 ;Don't leave any old stuff around.
+4 KILL ^PXRMINDX(9000010.18)
+5 SET GLOBAL=$$GET1^DID(9000010.18,"","","GLOBAL NAME")
+6 SET ENTRIES=$PIECE(^AUPNVCPT(0),U,4)
+7 SET TENP=ENTRIES/10
+8 SET TENP=+$PIECE(TENP,".",1)
+9 IF TENP<1
SET TENP=1
+10 DO BMES^XPDUTL("Building indexes for V CPT")
+11 SET TEXT="There are "_ENTRIES_" entries to process."
+12 DO MES^XPDUTL(TEXT)
+13 SET START=$HOROLOG
+14 SET (DAS,DONE,IND,NE,NERROR)=0
+15 FOR
SET DAS=$ORDER(^AUPNVCPT(DAS))
IF DONE
QUIT
Begin DoDot:1
+16 IF +DAS=0
SET DONE=1
QUIT
+17 IF +DAS'=DAS
Begin DoDot:2
+18 SET DONE=1
+19 SET ETEXT="Bad ien: "_DAS_", cannot continue."
+20 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+21 SET IND=IND+1
+22 IF IND#TENP=0
Begin DoDot:2
+23 SET TEXT="Processing entry "_IND
+24 DO MES^XPDUTL(TEXT)
End DoDot:2
+25 IF IND#10000=0
WRITE "."
+26 ;IHS/MSC/MGH Put a $G around it p1003
+27 SET TEMP=$GET(^AUPNVCPT(DAS,0))
+28 SET CPT=$PIECE(TEMP,U,1)
+29 IF CPT=""
Begin DoDot:2
+30 SET ETEXT=DAS_" missing CPT"
+31 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+32 IF '$DATA(^ICPT(CPT))
Begin DoDot:2
+33 SET ETEXT=DAS_" invalid CPT"
+34 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+35 SET DFN=$PIECE(TEMP,U,2)
+36 IF DFN=""
Begin DoDot:2
+37 SET ETEXT=DAS_" missing DFN"
+38 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+39 SET VISIT=$PIECE(TEMP,U,3)
+40 IF VISIT=""
Begin DoDot:2
+41 SET ETEXT=DAS_" missing visit"
+42 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+43 IF '$DATA(^AUPNVSIT(VISIT))
Begin DoDot:2
+44 SET ETEXT=DAS_" invalid visit"
+45 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+46 ;IHS/MGH/MGH Wrap it to prevent error
+47 SET DATE=$PIECE($GET(^AUPNVSIT(VISIT,0)),U,1)
+48 IF DATE=""
Begin DoDot:2
+49 SET ETEXT=DAS_" missing visit date"
+50 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+51 SET PP=$PIECE(TEMP,U,7)
+52 IF PP=""
SET PP="U"
+53 SET NE=NE+1
+54 SET ^PXRMINDX(9000010.18,"IPP",CPT,PP,DFN,DATE,DAS)=""
+55 SET ^PXRMINDX(9000010.18,"PPI",DFN,PP,CPT,DATE,DAS)=""
End DoDot:1
+56 SET END=$HOROLOG
+57 SET TEXT=NE_" V CPT results indexed."
+58 DO MES^XPDUTL(TEXT)
+59 DO DETIME^PXRMSXRM(START,END)
+60 ;If there were errors send a message.
+61 IF NERROR>0
DO ERRMSG^PXRMSXRM(NERROR,GLOBAL)
+62 ;Send a MailMan message with the results.
+63 DO COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
+64 SET ^PXRMINDX(9000010.18,"GLOBAL NAME")=GLOBAL
+65 SET ^PXRMINDX(9000010.18,"BUILT BY")=DUZ
+66 SET ^PXRMINDX(9000010.18,"DATE BUILT")=$$NOW^XLFDT
+67 QUIT
+68 ;
+69 ;===============================================================
VHF ;Build the indexes for V HEALTH FACTORS.
+1 NEW CAT,DAS,DATE,DFN,DIFF,DONE,END,ENTRIES,ETEXT,GLOBAL,HF,IND,NE,NERROR
+2 NEW START,TEMP,TENP,TEXT,VISIT
+3 ;Don't leave any old stuff around.
+4 KILL ^PXRMINDX(9000010.23)
+5 SET GLOBAL=$$GET1^DID(9000010.23,"","","GLOBAL NAME")
+6 SET ENTRIES=$PIECE(^AUPNVHF(0),U,4)
+7 SET TENP=ENTRIES/10
+8 SET TENP=+$PIECE(TENP,".",1)
+9 IF TENP<1
SET TENP=1
+10 DO BMES^XPDUTL("Building indexes for V HEALTH FACTORS")
+11 SET TEXT="There are "_ENTRIES_" entries to process."
+12 DO MES^XPDUTL(TEXT)
+13 SET START=$HOROLOG
+14 SET (DAS,DONE,IND,NE,NERROR)=0
+15 FOR
SET DAS=$ORDER(^AUPNVHF(DAS))
IF DONE
QUIT
Begin DoDot:1
+16 IF +DAS=0
SET DONE=1
QUIT
+17 IF +DAS'=DAS
Begin DoDot:2
+18 SET DONE=1
+19 SET ETEXT="Bad ien: "_DAS_", cannot continue."
+20 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+21 SET IND=IND+1
+22 IF IND#TENP=0
Begin DoDot:2
+23 SET TEXT="Processing entry "_IND
+24 DO MES^XPDUTL(TEXT)
End DoDot:2
+25 IF IND#10000=0
WRITE "."
+26 ;IHS/MSC/MGH Put a $G around it p1003
+27 SET TEMP=$GET(^AUPNVHF(DAS,0))
+28 SET HF=$PIECE(TEMP,U,1)
+29 IF HF=""
Begin DoDot:2
+30 SET ETEXT=DAS_" missing HF"
+31 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+32 IF '$DATA(^AUTTHF(HF))
Begin DoDot:2
+33 SET ETEXT=DAS_" invalid HF"
+34 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+35 SET DFN=$PIECE(TEMP,U,2)
+36 IF DFN=""
Begin DoDot:2
+37 SET ETEXT=DAS_" missing DFN"
+38 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+39 SET CAT=$PIECE(^AUTTHF(HF,0),U,3)
+40 IF CAT=""
Begin DoDot:2
+41 SET ETEXT=DAS_" HF "_HF_" missing category"
+42 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+43 IF HF=CAT
Begin DoDot:2
+44 SET ETEXT=DAS_" HF "_HF_" is a category"
+45 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+46 SET VISIT=$PIECE(TEMP,U,3)
+47 IF VISIT=""
Begin DoDot:2
+48 SET ETEXT=DAS_" missing visit"
+49 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+50 IF '$DATA(^AUPNVSIT(VISIT))
Begin DoDot:2
+51 SET ETEXT=DAS_" invalid visit"
+52 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+53 ;IHS/MGH/MGH Wrap it to prevent error
+54 SET DATE=$PIECE($GET(^AUPNVSIT(VISIT,0)),U,1)
+55 IF DATE=""
Begin DoDot:2
+56 SET ETEXT=DAS_" missing visit date"
+57 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+58 SET NE=NE+1
+59 SET ^PXRMINDX(9000010.23,"IP",HF,DFN,DATE,DAS)=""
+60 SET ^PXRMINDX(9000010.23,"PI",DFN,HF,DATE,DAS)=""
End DoDot:1
+61 SET END=$HOROLOG
+62 SET TEXT=NE_" V HEALTH FACTOR results indexed."
+63 DO MES^XPDUTL(TEXT)
+64 DO DETIME^PXRMSXRM(START,END)
+65 ;If there were errors send a message.
+66 IF NERROR>0
DO ERRMSG^PXRMSXRM(NERROR,GLOBAL)
+67 ;Send a MailMan message with the results.
+68 DO COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
+69 SET ^PXRMINDX(9000010.23,"GLOBAL NAME")=GLOBAL
+70 SET ^PXRMINDX(9000010.23,"BUILT BY")=DUZ
+71 SET ^PXRMINDX(9000010.23,"DATE BUILT")=$$NOW^XLFDT
+72 QUIT
+73 ;
+74 ;===============================================================
VIMM ;Build the indexes for V IMMUNIZATION.
+1 NEW DAS,DATE,DFN,DIFF,DONE,END,ENTRIES,ETEXT,GLOBAL,IMM,IND,NE,NERROR
+2 NEW START,TEMP,TENP,TEXT,VISIT
+3 ;Don't leave any old stuff around.
+4 KILL ^PXRMINDX(9000010.11)
+5 SET GLOBAL=$$GET1^DID(9000010.11,"","","GLOBAL NAME")
+6 SET ENTRIES=$PIECE(^AUPNVIMM(0),U,4)
+7 SET TENP=ENTRIES/10
+8 SET TENP=+$PIECE(TENP,".",1)
+9 IF TENP<1
SET TENP=1
+10 DO BMES^XPDUTL("Building indexes for V IMMUNIZATION")
+11 SET TEXT="There are "_ENTRIES_" entries to process."
+12 DO MES^XPDUTL(TEXT)
+13 SET START=$HOROLOG
+14 SET (DAS,DONE,IND,NE,NERROR)=0
+15 FOR
SET DAS=$ORDER(^AUPNVIMM(DAS))
IF DONE
QUIT
Begin DoDot:1
+16 IF +DAS=0
SET DONE=1
QUIT
+17 IF +DAS'=DAS
Begin DoDot:2
+18 SET DONE=1
+19 SET ETEXT="Bad ien: "_DAS_", cannot continue."
+20 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+21 SET IND=IND+1
+22 IF IND#TENP=0
Begin DoDot:2
+23 SET TEXT="Processing entry "_IND
+24 DO MES^XPDUTL(TEXT)
End DoDot:2
+25 IF IND#10000=0
WRITE "."
+26 ;IHS/MSC/MGH Put a $G around it p1003
+27 SET TEMP=$GET(^AUPNVIMM(DAS,0))
+28 SET IMM=$PIECE(TEMP,U,1)
+29 IF IMM=""
Begin DoDot:2
+30 SET ETEXT=DAS_" missing immunization"
+31 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+32 IF '$DATA(^AUTTIMM(IMM))
Begin DoDot:2
+33 SET ETEXT=DAS_" invalid immunization"
+34 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+35 SET DFN=$PIECE(TEMP,U,2)
+36 IF DFN=""
Begin DoDot:2
+37 SET ETEXT=DAS_" missing DFN"
+38 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+39 SET VISIT=$PIECE(TEMP,U,3)
+40 IF VISIT=""
Begin DoDot:2
+41 SET ETEXT=DAS_" missing visit"
+42 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+43 IF '$DATA(^AUPNVSIT(VISIT))
Begin DoDot:2
+44 SET ETEXT=DAS_" invalid visit"
+45 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+46 ;IHS/MGH/MGH Wrap it to prevent error
+47 SET DATE=$PIECE($GET(^AUPNVSIT(VISIT,0)),U,1)
+48 IF DATE=""
Begin DoDot:2
+49 SET ETEXT=DAS_" missing visit date"
+50 DO ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
End DoDot:2
QUIT
+51 SET NE=NE+1
+52 SET ^PXRMINDX(9000010.11,"IP",IMM,DFN,DATE,DAS)=""
+53 SET ^PXRMINDX(9000010.11,"PI",DFN,IMM,DATE,DAS)=""
End DoDot:1
+54 SET END=$HOROLOG
+55 SET TEXT=NE_" V IMMUNIZATION results indexed."
+56 DO MES^XPDUTL(TEXT)
+57 DO DETIME^PXRMSXRM(START,END)
+58 ;If there were errors send a message.
+59 IF NERROR>0
DO ERRMSG^PXRMSXRM(NERROR,GLOBAL)
+60 ;Send a MailMan message with the results.
+61 DO COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
+62 SET ^PXRMINDX(9000010.11,"GLOBAL NAME")=GLOBAL
+63 SET ^PXRMINDX(9000010.11,"BUILT BY")=DUZ
+64 SET ^PXRMINDX(9000010.11,"DATE BUILT")=$$NOW^XLFDT
+65 QUIT
+66 ;