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

ORWDBA2.m

Go to the documentation of this file.
  1. ORWDBA2 ; SLC/GDU - Billing Awareness - Phase I [11/26/04 15:43]
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**195**;Dec 17, 1997
  1. ;
  1. ;Clinician's Personal Diagnoses List
  1. ;The personal diagnoses list is stored in the NEW PERSON file # 200.
  1. ;In file # 200 it is stored in the multi-valued field PERSONAL DIAGNOSIS
  1. ;LIST, field # 351, sub-file 200.0351. This is unique to the individual
  1. ;clinician. It is designed to aid the clinician with the CIDC process
  1. ;by providing a list of diagnoses codes most frequently used by that
  1. ;clinician.
  1. ;
  1. ;External References:
  1. ; NOW^%DTC DBIA 10000
  1. ; FILE^DIE DBIA 2053
  1. ; UPDATE^DIE DBIA 2053
  1. ; DT^DILF DBIA 2054
  1. ; FDA^FILF DBIA 2054
  1. ; $$GET1^DIQ DBIA 2056
  1. ; GETS^DIQ DBIA 2056
  1. ; $$STATCHK^ICDAPIU DBIA 3991
  1. ; $$ICDDX^ICDCODE DBIA 3990
  1. ; $$NOW^XLFDT DBIA 10103
  1. ;
  1. ADDPDL(Y,ORCIEN,ORDXA) ;Add to Personal Diagnosis List
  1. ;Add a new personal diagnosis list or new ICD9 code to an existing
  1. ;personal diagnosis list for a clinician. It will filter out duplicate
  1. ;entries before updating an existing PDL.
  1. ;Input Variables:
  1. ; ORCIEN Clinician Internal Entry Number
  1. ; ORDXA Array of dx codes to be added to personal dx list
  1. ; format: ORDXA(#)=ICD9_Code^Lexicon_Expression_IEN
  1. ;Output Variable:
  1. ; Y Return value, 1 successful, 0 unsuccessful
  1. ;Local Variables:
  1. ; DXI Diagnosis Array Index
  1. ; DXIEN Diagnosis Code Internal Entry Number
  1. ; EM Error Message
  1. ; FDXR Found Diagnoses Records Array
  1. ; FDXRI Found Diagnoses Records Array Index
  1. ; IEN Internal Entry Number
  1. ; PDL Personal Diagnoses List Array
  1. ; PDLI Personal Diagnoses List Array Index
  1. N DXI,DXIEN,EM,FDXR,FDXRI,IEN,PDL,PDLI
  1. ;Gets clinician's Personal Diagnosis List and removes duplicates from
  1. ;dx input array. Quits if all are duplicates.
  1. D GETS^DIQ(200,ORCIEN,"351*,","","PDL","EM")
  1. I $D(PDL) D
  1. . S DXI="" F S DXI=$O(ORDXA(DXI)) Q:DXI="" D
  1. .. S PDLI="" F S PDLI=$O(PDL(200.0351,PDLI)) Q:PDLI="" D
  1. ... I PDL(200.0351,PDLI,.01)=$P($G(ORDXA(DXI)),U) K ORDXA(DXI)
  1. I $D(ORDXA)=0 S Y=0 Q
  1. ;Process dx input array
  1. S DXI="" F S DXI=$O(ORDXA(DXI)) Q:DXI=""!($D(EM)) D
  1. . K FDXR,EM
  1. . ;Get the IEN for the current diagnosis code
  1. . D FIND^DIC(80,"","","CM",$P(ORDXA(DXI),U),"*","","","","FDXR","EM")
  1. . I $P(FDXR("DILIST",0),U)=0 Q
  1. . I $P(FDXR("DILIST",0),U)=1 S DXIEN=FDXR("DILIST",2,1)
  1. . I $P(FDXR("DILIST",0),U)>1 D
  1. .. F FDXRI=1:1:FDXR("DILIST",0) D
  1. ... I FDXR("DILIST",1,FDXRI)=$P($G(ORDXA(DXI)),U) S DXIEN=FDXR("DILIST",2,FDXRI)
  1. . ;Add IDC9 code to personal diagnoses list
  1. . K IEN
  1. . S IEN="1,"_ORCIEN_",",IEN="+"_IEN
  1. . D FDA^DILF(200.0351,IEN,.01,"",DXIEN,"FDA","EM")
  1. . D UPDATE^DIE("","FDA","IEN","EM")
  1. . ;Add Lexicon Expression list
  1. . I $P(ORDXA(DXI),U,2)'="" D
  1. .. S IEN=IEN(1)_","_ORCIEN_","
  1. .. D FDA^DILF(200.0351,IEN,1,"",$P(ORDXA(DXI),U,2),"FDA","EM")
  1. .. D FILE^DIE("","FDA","EM")
  1. I $D(EM) S Y=0 Q
  1. S Y=1
  1. Q
  1. ;
  1. DELPDL(Y,ORCIEN,ORDXA) ;Delete from Personal Diagnosis List
  1. ;Delete a selected diagnosis code or group of diagnoses codes from a
  1. ;Clinician's Personal DX List.
  1. ;Input Variables:
  1. ; ORCIEN Clinician Internal ID number
  1. ; ORDXA Array of dx codes to be deleted from personal dx list
  1. ;Output Variable:
  1. ; Y Return value, 1 successful, 0 unsuccessful
  1. ;Local Variables:
  1. ; DXI Diagnosis code array index
  1. ; EM Error Message
  1. ; FDA FileMan Data Array
  1. ; IEN Interanl Entry Number
  1. ; RF Record Found
  1. N DXI,EM,FDA,IEN,RF
  1. D GETS^DIQ(200,ORCIEN,"351*,","","RF","EM")
  1. I $D(RF)=0 S Y=0 Q
  1. S IEN="" F S IEN=$O(RF(200.0351,IEN)) Q:IEN="" D
  1. .S DXI="" F S DXI=$O(ORDXA(DXI)) Q:DXI="" D
  1. .. I RF(200.0351,IEN,.01)=ORDXA(DXI) D
  1. ... D FDA^DILF(200.0351,IEN,.01,"","@","FDA","EM")
  1. ... D FILE^DIE("","FDA","EM")
  1. S Y=1
  1. Q
  1. ;
  1. GETPDL(Y,ORCIEN) ;Get Personal Diagnosis List
  1. ;This gets the clinician's personal diagnosis list. Using the personal
  1. ;diagnosis list, builds and returns an array variable with the ICD9
  1. ;codes and descriptions stored in the ICD DIAGNOSIS file, # 80.
  1. ;Flagging any inactive ICD9 code with a "#".
  1. ;Input Variable:
  1. ; ORCIEN Clinician Internal ID number
  1. ;Output Variable:
  1. ; Y Array of ICD9 codes and descriptions
  1. ; Y(#)=ICD9_code^DX_description^DX_Inactive
  1. ; If inactive # in third piece
  1. ; If active null in third piece
  1. ;Local Variables:
  1. ; DXC Diagnosis Code (for sorting)
  1. ; DXD Diagnosis Description
  1. ; DXDT Diagnosis Date
  1. ; DXI Diagnosis Inactive Flag
  1. ; EM Error Message
  1. ; ICD9 ICD9 code (for GUI)
  1. ; IEN Internal Entry Number
  1. ; RF Record Found
  1. N DXC,DXD,DXDT,DXI,EM,ICD9,IEN,RF
  1. S DXDT=$$NOW^XLFDT
  1. D GETS^DIQ(200,ORCIEN,"351*,","EI","RF","EM")
  1. I $D(RF) D
  1. . S (DXC,DXD,DXI,ICD9,IEN)=""
  1. . F S IEN=$O(RF(200.0351,IEN)) Q:IEN="" D
  1. .. S ICD9=RF(200.0351,IEN,.01,"E")
  1. .. S DXC=$$SETDXC(ICD9)
  1. .. I $G(RF(200.0351,IEN,1,"I"))="" S DXD=$$SETDXD($P($$ICDDX^ICDCODE(ICD9,DXDT),U,4))
  1. .. I $G(RF(200.0351,IEN,1,"I"))=1 S DXD=$$SETDXD($P($$ICDDX^ICDCODE(ICD9,DXDT),U,4))
  1. .. I $G(RF(200.0351,IEN,1,"I"))>1 S DXD=RF(200.0351,IEN,1,"E")
  1. .. S DXI=$$SETDXI($$STATCHK^ICDAPIU(ICD9,DXDT))
  1. .. S Y(DXC)=ICD9_U_DXD_U_DXI
  1. E S Y=0
  1. Q
  1. ;
  1. GETDUDC(Y,ORCIEN,ORPTIEN) ;Get Day's Unique Diagnoses Codes
  1. ;Gets all the unique ICD9 codes for the orders placed today by the
  1. ;clinician for this patient. Using the ICD9 codes it builds an array
  1. ;variable with the ICD9 code, its description from the ICD DIAGNOSIS
  1. ;file, #80. Flagging any inactive ICD9 codes with a "#".
  1. ;Input Variables:
  1. ; ORCIEN Clinician's internal ID number
  1. ; ORPTIEN Patient's internal ID number
  1. ;Output Variable:
  1. ; Y Array of ICD9 codes and descriptions
  1. ; Y(#)=ICD9_code^DX_Description^DX_Inactive
  1. ; If inactive # in third piece
  1. ; If active null in third piece
  1. ;Local Variables:
  1. ; CKDATE Check Date (stops loop)
  1. ; DXC Diagnosis Code (for sorting)
  1. ; DXD Diagnosis Description
  1. ; DXI Diagnosis Inactive Flag
  1. ; DXIEN Diagnosis Internal Entry Number
  1. ; ICD9 ICD9 code (for GUI display)
  1. ; IEN Internal Entry Number
  1. ; OBJORD Object of Order
  1. ; ORDATE Order Date
  1. ; ORDG Order Group (ACT index variable)
  1. ; OREM Order Error Message
  1. ; ORIEN Order Internal Entry Number
  1. ; ORRF Order Record Found
  1. ; RCODI Reverse Cronological Order Date Index
  1. ; SUBFILE Subfile Number
  1. N CKDATE,DXC,DXD,DXEM,DXI,DXIEN,DXRF,ICD9,IEN,OBJORD,ORDATE,ORDG,OREM
  1. N ORIEN,ORRF,RCODI,SUBFILE
  1. S OBJORD=ORPTIEN_";DPT("
  1. S (DXIEN,ORDATE,ORDG,ORIEN,RCODI)="",CKDATE=$$F24HA
  1. F S RCODI=$O(^OR(100,"ACT",OBJORD,RCODI)) S ORDATE=9999999-RCODI Q:ORDATE<CKDATE!(RCODI="") D
  1. . F S ORDG=$O(^OR(100,"ACT",OBJORD,RCODI,ORDG)) Q:ORDG="" D
  1. .. S ORIEN=$QS($Q(^OR(100,"ACT",OBJORD,RCODI,ORDG)),6)
  1. .. K ORRF,OREM
  1. .. D GETS^DIQ(100,ORIEN,"1;5.1*","I","ORRF","OREM")
  1. .. S IEN=$QS($Q(ORRF(100)),2)
  1. .. Q:ORRF(100,IEN,1,"I")'=ORCIEN
  1. .. Q:$D(ORRF(100.051))=0
  1. .. S (DXC,DXD,DXI,DXIEN,ICD9,IEN)=""
  1. .. F S IEN=$O(ORRF(100.051,IEN)) Q:IEN="" D
  1. ... Q:ORRF(100.051,IEN,.01,"I")=""
  1. ... S DXIEN=ORRF(100.051,IEN,.01,"I")
  1. ... S ICD9=$$GET1^DIQ(80,DXIEN,.01,"")
  1. ... S DXC=$$SETDXC(ICD9)
  1. ... S DXD=$$SETDXD($P($$ICDDX^ICDCODE(ICD9,ORDATE),U,4))
  1. ... S DXI=$$SETDXI($$STATCHK^ICDAPIU(ICD9,ORDATE))
  1. ... S Y(DXC)=ICD9_U_DXD_U_DXI
  1. Q
  1. ;
  1. SETDXC(X) ;Set diagnosis code variable for sorting
  1. S X=$S($E(X)?1A:X,1:+X) Q X
  1. ;
  1. SETDXD(X) ;Set upper case diagnosis discription to mixed case
  1. N X1,X2
  1. F X1=2:1:$L(X) D
  1. . I $E(X,X1)?1U,$E(X,X1-1)?1A D
  1. .. S X2=$E(X,X1)
  1. .. S X2=$C($A(X2)+32)
  1. .. S $E(X,X1)=X2
  1. Q X
  1. ;
  1. SETDXI(X) ;Set the diagnosis inactive indicator
  1. S X=$S($P(X,U)=0:"#",1:"") Q X
  1. ;
  1. CI(CNT) ;Counter Incrementer
  1. ; CNT - Counter
  1. S CNT=CNT+1 Q CNT
  1. ;
  1. F24HA() ;Returns date and time from exactly 24 hours ago
  1. N %,%H,%I,X
  1. D NOW^%DTC
  1. Q %-1
  1. ;
  1. ERRMSG(MT) ;Display Error Message
  1. ; to be determined
  1. Q