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

PXPXRMI2.m

Go to the documentation of this file.
PXPXRMI2 ; SLC/PKR,SCK - Build indexes for the V files (continued). ;03/16/2020
 ;;1.0;PCE PATIENT CARE ENCOUNTER;**119,194,199,211,217**;Aug 12, 1996;Build 134
 ;DBIA 4113 supports PXRMSXRM entry points.
 ;DBIA 4114 supports setting and killing ^PXRMINDX
 ; Reference to ICDEX supported by ICR #5747.
 ;
 ;===============================================================
VPED ;Build the indexes for V PATIENT ED.
 N DAS,DATE,DFN,DONE,EDU,END,ENTRIES,ETEXT,GLOBAL,IND,NE,NERROR
 N START,TEMP,TENP,TEXT,VISIT
 ;Don't leave any old stuff around.
 K ^PXRMINDX(9000010.16)
 S GLOBAL=$$GET1^DID(9000010.16,"","","GLOBAL NAME")
 S ENTRIES=+$P(^AUPNVPED(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 PATIENT ED")
 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(^AUPNVPED(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 "."
 . S TEMP=^AUPNVPED(DAS,0)
 . S EDU=$P(TEMP,U,1)
 . I EDU="" D  Q
 .. S ETEXT=DAS_" missing education topic"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . I '$D(^AUTTEDT(EDU)) D  Q
 .. S ETEXT=DAS_" invalid education topic"
 .. 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)
 . S DATE=$P($G(^AUPNVPED(DAS,12)),U,1)
 . I DATE="" S DATE=$P(^AUPNVSIT(VISIT,0),U,1)
 . I DATE="" D  Q
 .. S ETEXT=DAS_" missing date"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . S NE=NE+1
 . S ^PXRMINDX(9000010.16,"IP",EDU,DFN,DATE,DAS)=""
 . S ^PXRMINDX(9000010.16,"PI",DFN,EDU,DATE,DAS)=""
 S END=$H
 S TEXT=NE_" V PATIENT ED 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.16,"GLOBAL NAME")=GLOBAL
 S ^PXRMINDX(9000010.16,"BUILT BY")=DUZ
 S ^PXRMINDX(9000010.16,"DATE BUILT")=$$NOW^XLFDT
 Q
 ;
 ;===============================================================
VPOV ;Build the indexes for V POV.
 N CODE,DAS,DATE,DFN,DONE,END,ENTRIES,ETEXT,GLOBAL,IND,NE
 N NERROR,POV,PS,PXCSYS,START,TEMP,TENP,TEXT,VISIT
 ;Don't leave any old stuff around.
 K ^PXRMINDX(9000010.07)
 S GLOBAL=$$GET1^DID(9000010.07,"","","GLOBAL NAME")
 S ENTRIES=+$P(^AUPNVPOV(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 POV")
 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(^AUPNVPOV(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 "."
 . S TEMP=^AUPNVPOV(DAS,0)
 . S POV=$P(TEMP,U,1)
 . I POV="" D  Q
 .. S ETEXT=DAS_" missing POV (ICD)"
 .. 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)
 . S PS=$P(TEMP,U,12)
 . I PS="" S PS="U"
 . S DATE=$P($G(^AUPNVPOV(DAS,12)),U,1)
 . I DATE="" S DATE=$P(^AUPNVSIT(VISIT,0),U,1)
 . I DATE="" D  Q
 .. S ETEXT=DAS_" missing date"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . I $P($$ICDDATA^ICDXCODE("DIAG",POV,DATE,"I"),U,1)<0 D  Q
 .. S ETEXT=DAS_" invalid ICD"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . S NE=NE+1
 . S PXCSYS=$P($$SINFO^ICDEX($$CSI^ICDEX(80,POV)),U,3)
 . I PXCSYS="ICD" D  ; ICD-9 version
 .. S ^PXRMINDX(9000010.07,"IPP",POV,PS,DFN,DATE,DAS)=""
 .. S ^PXRMINDX(9000010.07,"PPI",DFN,PS,POV,DATE,DAS)=""
 . E  D  ; ICD-10 and higher version
 .. S CODE=$$CODEC^ICDEX(80,POV)
 .. S ^PXRMINDX(9000010.07,PXCSYS,"IPP",CODE,PS,DFN,DATE,DAS)=""
 .. S ^PXRMINDX(9000010.07,PXCSYS,"PPI",DFN,PS,CODE,DATE,DAS)=""
 S END=$H
 S TEXT=NE_" V POV 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.07,"GLOBAL NAME")=GLOBAL
 S ^PXRMINDX(9000010.07,"BUILT BY")=DUZ
 S ^PXRMINDX(9000010.07,"DATE BUILT")=$$NOW^XLFDT
 Q
 ;
 ;===============================================================
VSC ;Build the indexes for V Standard Codes.
 N CODE,CODESYS,DAS,DATE,DFN,DONE,END,ENTRIES,ETEXT,GLOBAL,IND,NE
 N NERROR,START,TEMP,TENP,TEXT,VISIT
 ;Don't leave any old stuff around.
 K ^PXRMINDX(9000010.71)
 S GLOBAL=$$GET1^DID(9000010.71,"","","GLOBAL NAME")
 S ENTRIES=+$P(^AUPNVSC(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 Standard Codes.")
 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(^AUPNVSC(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 "."
 . S TEMP=^AUPNVSC(DAS,0)
 . S CODE=$P(TEMP,U,1)
 . I CODE="" D  Q
 .. S ETEXT=DAS_" missing CODE"
 .. 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)
 . S CODESYS=$P(TEMP,U,5)
 . I CODESYS="" D  Q
 .. S ETEXT=DAS_" missing coding system"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . I '$$VCODESYS^PXLEX(CODESYS,0) D  Q
 .. S ETEXT=DAS_" "_CODESYS_" is not a valid coding system"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . I '$$VCODE^PXLEX(CODESYS,CODE) D  Q
 .. S ETEXT=DAS_" The coding system "_CODESYS_" code "_CODE_" pair is not valid"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . S DATE=$P($G(^AUPNVSC(DAS,12)),U,1)
 . I DATE="" S DATE=$P(^AUPNVSIT(VISIT,0),U,1)
 . I DATE="" D  Q
 .. S ETEXT=DAS_" missing date"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . S NE=NE+1
 . S ^PXRMINDX(9000010.71,"IP",CODESYS,CODE,DFN,DATE,DAS)=""
 . S ^PXRMINDX(9000010.71,"PI",DFN,CODESYS,CODE,DATE,DAS)=""
 S END=$H
 S TEXT=NE_" V Standard Codes 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.71,"GLOBAL NAME")=GLOBAL
 S ^PXRMINDX(9000010.71,"BUILT BY")=DUZ
 S ^PXRMINDX(9000010.71,"DATE BUILT")=$$NOW^XLFDT
 Q
 ;
 ;===============================================================
VSK ;Build the indexes for V SKIN TEST.
 N DAS,DATE,DFN,DONE,END,ENTRIES,GLOBAL,IND,NE,NERROR
 N SK,START,TEMP,TENP,TEXT,VISIT
 ;Don't leave any old stuff around.
 K ^PXRMINDX(9000010.12)
 S GLOBAL=$$GET1^DID(9000010.12,"","","GLOBAL NAME")
 S ENTRIES=+$P(^AUPNVSK(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 SKIN TEST")
 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(^AUPNVSK(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)
 . ; Don't index a placement skin test that is linked to a reading skin test
 . I $D(^AUPNVSK("APT",DAS)) Q
 . S IND=IND+1
 . I IND#TENP=0 D
 .. S TEXT="Processing entry "_IND
 .. D MES^XPDUTL(TEXT)
 . I IND#10000=0 W "."
 . S TEMP=^AUPNVSK(DAS,0)
 . S SK=$P(TEMP,U,1)
 . I SK="" D  Q
 .. S ETEXT=DAS_" missing skin test"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . I '$D(^AUTTSK(SK)) D  Q
 .. S ETEXT=DAS_" invalid skin test"
 .. 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)
 . S DATE=$P(TEMP,U,6) ; Date Read
 . I DATE="" S DATE=$P($G(^AUPNVSK(DAS,12)),U,1)
 . I DATE="" S DATE=$P(^AUPNVSIT(VISIT,0),U,1)
 . I DATE="" D  Q
 .. S ETEXT=DAS_" missing date"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . S NE=NE+1
 . S ^PXRMINDX(9000010.12,"IP",SK,DFN,DATE,DAS)=""
 . S ^PXRMINDX(9000010.12,"PI",DFN,SK,DATE,DAS)=""
 S END=$H
 S TEXT=NE_" V SKIN TEST 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.12,"GLOBAL NAME")=GLOBAL
 S ^PXRMINDX(9000010.12,"BUILT BY")=DUZ
 S ^PXRMINDX(9000010.12,"DATE BUILT")=$$NOW^XLFDT
 Q
 ;
 ;===============================================================
VXAM ;Build the indexes for V EXAM.
 N DAS,DATE,DFN,DONE,END,ENTRIES,ETEXT,EXAM,GLOBAL,IND,NE,NERROR
 N START,TEMP,TENP,TEXT,VISIT
 ;Don't leave any old stuff around.
 K ^PXRMINDX(9000010.13)
 S GLOBAL=$$GET1^DID(9000010.13,"","","GLOBAL NAME")
 S ENTRIES=+$P(^AUPNVXAM(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 EXAM")
 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(^AUPNVXAM(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 "."
 . S TEMP=^AUPNVXAM(DAS,0)
 . S EXAM=$P(TEMP,U,1)
 . I EXAM="" D  Q
 .. S ETEXT=DAS_" missing exam"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . I '$D(^AUTTEXAM(EXAM)) D  Q
 .. S ETEXT=DAS_" invalid exam"
 .. 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)
 . S DATE=$P($G(^AUPNVXAM(DAS,12)),U,1)
 . I DATE="" S DATE=$P(^AUPNVSIT(VISIT,0),U,1)
 . I DATE="" D  Q
 .. S ETEXT=DAS_" missing date"
 .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
 . S NE=NE+1
 . S ^PXRMINDX(9000010.13,"IP",EXAM,DFN,DATE,DAS)=""
 . S ^PXRMINDX(9000010.13,"PI",DFN,EXAM,DATE,DAS)=""
 S END=$H
 S TEXT=NE_" V EXAM 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.13,"GLOBAL NAME")=GLOBAL
 S ^PXRMINDX(9000010.13,"BUILT BY")=DUZ
 S ^PXRMINDX(9000010.13,"DATE BUILT")=$$NOW^XLFDT
 Q
 ;