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

ORWDBA7.m

Go to the documentation of this file.
  1. ORWDBA7 ;;SLC/GSS Billing Awareness (CIDC-Clinical Indicators Data Capture)
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**195,215,243**;Dec 17, 1997;Build 242
  1. ;
  1. BDOEDIT ; Backdoor entered orders edit in CPRS - entry point
  1. ; Data Flow> Ancillary creates a back door order which is incomplete
  1. ; and thus edited in CPRS GUI. The ancillary needs to know
  1. ; what Dx and TF's are edited thus this tag calls three
  1. ; ancillary APIs, passing the Dx and TF data to them.
  1. ;
  1. ; Variable Description
  1. ; ANCILARY Acronym of ancillary/package relative to order
  1. ; DXN Diagnosis sequence number in ^OR file
  1. ; MSG Error message
  1. ; ORDX Array of diagnoses (1-n) with value from ICD file (#80)
  1. ; ORIFN Order internal reference number (defined in ORCSEND)
  1. ; ORITEM Package reference or ^OR(100,ORIFN,4)
  1. ; ORSCEI String of Treatment Factors in table SD008 order/format
  1. ; PTIEN Patient IEN
  1. ; TAGROU Tag^Routine of ancillary routine to store edited data
  1. ; TFO Treatment Factors in ^OR (GBL) order
  1. ;
  1. ; If CIDC master switch set, then no back door orders to store
  1. I $$BASTAT^ORWDBA1=0 Q ;CIDC (nee BA) not used
  1. ; If ORIFN not defined (God only knows why) then log error and quit
  1. I '$D(ORIFN) S MSG="ORIFN not defined" D VAR,EN^ORERR(MSG,"",.VAR) Q
  1. ;
  1. N ANCILARY,DXN,MSG,ORDX,ORITEM,ORSCEI,PTIEN,RT,SUCCESS,TAGROU,TFO,VAR
  1. ;
  1. S DXN=0,(RT,SUCCESS)="",PTIEN=+$P($G(^OR(100,ORIFN,0)),U,2)
  1. ; Package (ancillary) reference data
  1. S ORITEM=$G(^OR(100,ORIFN,4))
  1. ; Create an array (ORDX) of diagnoses
  1. F S DXN=$O(^OR(100,ORIFN,5.1,DXN)) Q:'DXN D
  1. . S ORDX(DXN)=$G(^OR(100,ORIFN,5.1,DXN,0))
  1. ; Treatment Factors - converted and reformatted
  1. S ORSCEI=$$TFGBLTBL($G(^OR(100,ORIFN,5.2)))
  1. ; Get the acronym of the package generating this order
  1. S ANCILARY=$P($G(^DIC(9.4,$P($G(^OR(100,ORIFN,0)),U,14),0)),U,2)
  1. ; Send data to the appropriate ancillary API based on package
  1. D OUTPUT
  1. ; If ancillary routine or tag w/in the routine doesn't exist check
  1. I 'RT D
  1. . S MSG="NON-EXISTANT ROUTINE/TAG FOR "_ANCILARY
  1. . D VAR,EN^ORERR(MSG,"",.VAR)
  1. ; If we don't get back a thumbs-up from the ancillary re: the order data
  1. I 'SUCCESS,RT D
  1. . S MSG="ANCILLARY API RETURNED ERROR FOR CPRS EDITED BACK DOOR DATA"
  1. . D VAR,EN^ORERR(MSG,"",.VAR)
  1. Q
  1. ;
  1. OUTPUT ; Call ancillary's API to store data after checking for it's existence
  1. ;
  1. ; Laboratory
  1. I ANCILARY?1"LR".U D Q
  1. . S RT=$$CKROUTAG("UPDOR^LRBEBA4") Q:'RT
  1. . S SUCCESS=$$UPDOR^LRBEBA4(PTIEN,ORITEM,ORIFN,.ORDX,ORSCEI) ;IA 4775
  1. ;
  1. ; Pharmacy
  1. I ANCILARY?1"PS".U D Q
  1. . S RT=$$CKROUTAG("EN^PSOHLNE3") Q:'RT
  1. . S SUCCESS=$$EN^PSOHLNE3(PTIEN,ORITEM,ORIFN,.ORDX,ORSCEI) ;IA 4666
  1. ;
  1. ; Radiolgy
  1. I ANCILARY?1"RA".U D Q
  1. . S RT=$$CKROUTAG("CPRSUPD^RABWORD1") Q:'RT
  1. . S SUCCESS=$$CPRSUPD^RABWORD1(PTIEN,ORITEM,ORIFN,.ORDX,ORSCEI) ;IA 4771
  1. Q
  1. ;
  1. CKROUTAG(TAGROU) ;Check if valid tag and routine
  1. ; Temporary check until all the ancillaries have their API's built
  1. Q $L($T(@TAGROU))
  1. ;
  1. TFGBLTBL(GBL) ;Convert Tx Factors from Global to TBL (HL7) order & format
  1. ; Note: this does not set Tx Factors in ZCL segment format but rather
  1. ; AO^IR^SC^EC^MST^HNC^CV^SHD ('^' delimited string) format
  1. ;
  1. ; Input: GBL in 1^1^0^0^^^0^ (global) format
  1. ; Output: TBL in 0^0^1^^1^^0^ (TBL) format (also reordered)
  1. ;
  1. N J,NTF,TBL,TF,TFGBL,TFGUI,TFTBL
  1. S TBL="",NTF=8 ;NCI=# of TxF
  1. ; Get Treatment Factor sequence order strings
  1. D TFSTGS^ORWDBA1
  1. ; Convert from GBL to TBL format and sequence
  1. F J=1:1:NTF S TF=$P(GBL,U,J) D
  1. . ;OK..just in case there is a '?' we'll return a null for a '?'
  1. . S TF($P(TFGBL,U,J))=$S(TF=1:1,TF=0:0,TF="?":"",1:"")
  1. F J=1:1:NTF S TBL=TBL_U_TF($P(TFTBL,U,J))
  1. ; Remove the first '^' and pass TBL formatted TF's
  1. Q $E(TBL,2,99)
  1. ;
  1. VAR ;Create VAR array for tracking error in ^ORYX("ORERR",err#)
  1. S VAR("DFN")=PTIEN
  1. S VAR("ORITEM")=ORITEM
  1. S VAR("ORIFN")=ORIFN
  1. M VAR("ORDX")=ORDX
  1. S VAR("ORSCEI")=ORSCEI
  1. Q
  1. ;
  1. ISWITCH(Y,DFN) ;Return 0 if don't ask (no ins) or 1 to ask CIDC quest (yes ins)
  1. S Y=$$CIDC^IBBAPI(DFN)
  1. Q
  1. ;
  1. GETIEN9(Y,ICD9) ;Return IEN for an ICD9 code (RPC: ORWDBA7 GETIEN9)
  1. S Y=$P($$CODEN^ICDCODE(ICD9,80),"~")
  1. Q
  1. ;
  1. CONDTLD ;Consult Detailed Display Compile for CIDC/BA (called by GMRCSLM2)
  1. ; Input: ORIFN and GMRCCT defined in GMRCSLM2
  1. ; Output: CIDCARY = array of CIDC display lines for GMRCSLM2 display
  1. N BGNRCCT,DXIEN,DXOF,DXV,EYE,ICD9,ICDR,LINE,OCT,ORFMDAT,TF
  1. S BGNRCCT=GMRCCT,OCT=0
  1. ; Get the date of the order for CSV/CTD usage
  1. S ORFMDAT=$$ORFMDAT^ORWDBA3(ORIFN)
  1. ; $O through diagnoses for an order
  1. F S OCT=$O(^OR(100,ORIFN,5.1,OCT)) Q:OCT'?1N.N D
  1. . S DXOF=" "
  1. . ; DXIEN=Dx IEN
  1. . S DXIEN=+^OR(100,ORIFN,5.1,OCT,0)
  1. . ; Get Dx record for date ORFMDAT
  1. . S ICDR=$$ICDDX^ICDCODE(DXIEN,ORFMDAT)
  1. . ; Get Dx verbiage and ICD code
  1. . S DXV=$P(ICDR,U,4),ICD9=$P(ICDR,U,2)
  1. . I OCT=1 D
  1. .. S CIDCARY(GMRCCT,0)=" ",GMRCCT=GMRCCT+1 ;blank line
  1. .. S CIDCARY(GMRCCT,0)="Clinical Indicators",GMRCCT=GMRCCT+1
  1. .. S DXOF="Diagnosis of: "
  1. . S LINE=DXOF_ICD9_" - "_DXV
  1. . S CIDCARY(GMRCCT,0)=LINE,GMRCCT=GMRCCT+1
  1. I OCT'="" D ;if there are diagnoses then show Treatment Factors
  1. . S LINE="For conditions related to: "
  1. . F EYE=1:1:8 S TF=$P(^OR(100,ORIFN,5.2),U,EYE) I TF D
  1. .. S CIDCARY(GMRCCT,0)=LINE_$$SC^ORQ21(EYE)
  1. .. S X=$$REPEAT^XLFSTR(" ",30),GMRCCT=GMRCCT+1
  1. Q