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

ORPXRM.m

Go to the documentation of this file.
  1. ORPXRM ; SLC/PKR - Clinical Reminder index routines for file 100. ;8/13/06 14:19
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**157,260**;Dec 17, 1997;Build 26
  1. ;DBIA 4113 supports PXRMSXRM entry points.
  1. ;DBIA 4114 supports setting and killing ^PXRMINDX
  1. ;=========================================================
  1. INDEX ;Build the index for the ORDER file.
  1. N D0,D0P,D1,DAS,DFN,END,ENTRIES,ETEXT,FERROR,GLOBAL,IND,NE,NDUP,NERROR
  1. N OI,PROC,START,STRTDATE,STOP,TEMP,TENP,TEXT
  1. ;Don't leave any old stuff around.
  1. K ^PXRMINDX(100)
  1. S GLOBAL=$$GET1^DID(100,"","","GLOBAL NAME")
  1. S ENTRIES=$P(^OR(100,0),U,4)
  1. S TENP=ENTRIES/10
  1. S TENP=+$P(TENP,".",1)
  1. I TENP<1 S TENP=1
  1. D BMES^XPDUTL("Building index for ORDER file")
  1. S TEXT="There are "_ENTRIES_" entries to process."
  1. D MES^XPDUTL(TEXT)
  1. S START=$H
  1. S (D0,D0P,FERROR,IND,NDUP,NE,NERROR)=0
  1. F S D0=$O(^OR(100,D0)) Q:(+D0=0)!(FERROR) D
  1. . I D0'>D0P D Q
  1. .. S FERROR=1
  1. .. S ETEXT=D0_" subscript is a bad, cannot continue!"
  1. .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
  1. . S D0P=D0
  1. . S IND=IND+1
  1. . I IND#TENP=0 D
  1. .. S TEXT="Processing entry "_IND
  1. .. D MES^XPDUTL(TEXT)
  1. . I IND#10000=0 W "."
  1. . S TEMP=$G(^OR(100,D0,0))
  1. . I TEMP="" D Q
  1. .. S ETEXT=D0_" bad entry no 0 node"
  1. .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
  1. . S DFN=$P(TEMP,U,2)
  1. . I DFN="" D Q
  1. .. S ETEXT=D0_" no DFN"
  1. .. D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
  1. . I DFN'["DPT(" Q
  1. . S DFN=$P(DFN,";",1)
  1. . S STRTDATE=$P(TEMP,U,8)
  1. .;If there is no start date get the release date for the new order.
  1. . I STRTDATE="" S STRTDATE=$$RDATE(D0)
  1. . I STRTDATE="" Q
  1. . S STOP=$P(TEMP,U,9)
  1. . S STOP=$S(STOP="":"U"_D0,1:STOP)
  1. . S D1=0
  1. . F S D1=+$O(^OR(100,D0,.1,D1)) Q:D1=0 D
  1. .. S OI=^OR(100,D0,.1,D1,0)
  1. .. S DAS=D0_";.1;"_D1_";0"
  1. .. I OI="" D Q
  1. ... S ETEXT=DAS_" no orderable item"
  1. ... D ADDERROR^PXRMSXRM(GLOBAL,ETEXT,.NERROR)
  1. .. I $D(^PXRMINDX(100,"IP",OI,DFN,STRTDATE,STOP,DAS)) S NDUP=NDUP+1
  1. .. S ^PXRMINDX(100,"IP",OI,DFN,STRTDATE,STOP,DAS)=""
  1. .. S ^PXRMINDX(100,"PI",DFN,OI,STRTDATE,STOP,DAS)=""
  1. .. S NE=NE+1
  1. S END=$H
  1. S TEXT=NE_" ORDER results indexed."
  1. W !,"There were "_NDUP_" duplicates."
  1. D MES^XPDUTL(TEXT)
  1. D DETIME^PXRMSXRM(START,END)
  1. ;If there were errors send a message.
  1. I NERROR>0 D ERRMSG^PXRMSXRM(NERROR,GLOBAL)
  1. ;Send a MailMan message with the results.
  1. D COMMSG^PXRMSXRM(GLOBAL,START,END,NE,NERROR)
  1. S ^PXRMINDX(100,"GLOBAL NAME")=GLOBAL
  1. S ^PXRMINDX(100,"BUILT BY")=DUZ
  1. S ^PXRMINDX(100,"DATE BUILT")=$$NOW^XLFDT
  1. Q
  1. ;
  1. ;=========================================================
  1. GETDATA(ORIFN,DATA) ;Return data, for a specified order file entry.
  1. N ORUPCHUK
  1. D EN^ORX8(ORIFN)
  1. S ORUPCHUK("ORORDER")=$$OI^ORX8(ORIFN)
  1. S ORUPCHUK("ORREL")=$$RDATE(ORIFN)
  1. M DATA=ORUPCHUK
  1. Q
  1. ;
  1. ;=========================================================
  1. KOR(X,DA) ;Kill index for Order file.
  1. N DAS,DFN,STOP
  1. I X(1)'["DPT" Q
  1. I 'X(2)!'X(3) Q
  1. S DFN=$P(X(1),";",1)
  1. S DAS=DA(1)_";.1;"_DA_";0"
  1. S STOP=$S(X(4)="":"U"_DA(1),1:X(4))
  1. K ^PXRMINDX(100,"IP",X(2),DFN,X(3),STOP,DAS)
  1. K ^PXRMINDX(100,"PI",DFN,X(2),X(3),STOP,DAS)
  1. Q
  1. ;=========================================================
  1. RDATE(ORIFN) ;Return the release date for the new order action.
  1. N RDIEN
  1. S RDIEN=$O(^OR(100,ORIFN,8,"C","NW",""))
  1. I RDIEN="" Q ""
  1. Q $P(^OR(100,ORIFN,8,RDIEN,0),U,16)
  1. ;
  1. ;=========================================================
  1. SOR(X,DA) ;Set index for Order file.
  1. ;X(1)=OBJECT OF ORDER, X(2)=ORDERABLE ITEM, X(3)=START DATE
  1. ;or release date, X(4)=STOP DATE
  1. N DAS,DFN,STOP
  1. I X(1)'["DPT" Q
  1. I 'X(2)!'X(3) Q
  1. S DFN=$P(X(1),";",1)
  1. S DAS=DA(1)_";.1;"_DA_";0"
  1. S STOP=$S(X(4)="":"U"_DA(1),1:+X(4))
  1. S ^PXRMINDX(100,"IP",X(2),DFN,+X(3),STOP,DAS)=""
  1. S ^PXRMINDX(100,"PI",DFN,X(2),+X(3),STOP,DAS)=""
  1. Q
  1. ;