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

ORWDBA3.m

Go to the documentation of this file.
  1. ORWDBA3 ; SLC/GSS Billing Awareness (CIDC) [8/20/03 9:19am] ;05/23/12 10:36
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**190,195,243,361**;Dec 17, 1997;Build 39
  1. ;
  1. ORFMDAT(ORDFN) ; Return date in FM format regarding order for CSV/CTD/HIPAA
  1. ; Pass in Order IEN
  1. Q ($P($G(^OR(100,ORDFN,8,1,0)),"^",16)\1)
  1. ;
  1. DISPLAY ; Display of BA data from original copied order (ORIT = ORIEN)
  1. ; Displayed in window with all order info and user can accept/edit
  1. ; Note: TxF = Treatment Factor
  1. ; BA data (Dx,TxF's) not editable but in signature window, not in above
  1. ; ORIT defined in ORWDXM1, DISPLAY called from ORWDXM2
  1. ;
  1. ; Input:
  1. ; ORIT, ILST, and LST() from ORWDXM* routines
  1. ; Output:
  1. ; ILST and LST() appropriately incremented/populated for order display
  1. ; Variables:
  1. ; CUN = TxF's in C, U, or N format
  1. ; I = counter
  1. ; ILST = line counter, initially from ORWDXM* routines
  1. ; LST() = array of lines to output, initially from ORWDXM* routines
  1. ; NTF = # of Treatment Factors
  1. ; ORITARY = ORIT array of 1 needed to access GETTFCI^ORWDBA4
  1. ; SPCS = # of characters to space to left of ':'
  1. ; TF1 = first TxF output? (0/1)
  1. ; TFGBL = TxF's in Global stored order
  1. ; TFGUI = TxF's in GUI returned order
  1. ; TFV = TxF verbiage
  1. ;
  1. N CUN,I,NTF,ORITARY,SPCS,TF1,TFGBL,TFGUI,TFV,Y
  1. S NTF=8,SPCS=28,ORITARY(1)=+ORIT
  1. ; Get Y(+ORIT) string in ORIEN^CUUUCCN^Dx1^Desc1^Dx2^Desc2^... format
  1. D GETTFCI^ORWDBA4(.Y,.ORITARY)
  1. S CUN=$P($G(Y(1)),U,2) ;CUN = Treatment Factors in CUN syntax
  1. ; First output Diagnosis information - if any
  1. F I=3:2:9 I $P($G(Y(1)),U,I)'="" D
  1. . S ILST=ILST+1,LST(ILST)=$S(I=3:"Diagnoses",1:"")
  1. . S LST(ILST)=LST(ILST)_":"_$P(Y(1),U,I)_" - "_$P(Y(1),U,I+1)
  1. . D FRMTLST
  1. ; Get GUI and GBL Treatment Factor sequence strings
  1. D TFSTGS^ORWDBA1
  1. ; Assumes SC will always be first in sequence! - not likely to change
  1. S ILST=ILST+1
  1. S LST(ILST)="Service Connected:"_$S($E(CUN)="C":"YES",1:"NO")
  1. D FRMTLST
  1. S ILST=ILST+1,LST(ILST)="Treatment Factors:"
  1. ; If no TxF's (no 'C'hecked) {SC output above} then output '<none>'
  1. I '$F($E(CUN,2,NTF),"C") S LST(ILST)=LST(ILST)_"<none>" D FRMTLST Q
  1. S TF1=0 ;No TxF yet output
  1. ; Verbiage for TxF's
  1. S TFV("MST")="MILITARY SEXUAL TRAUMA",TFV("AO")="AGENT ORANGE"
  1. S TFV("IR")="IONIZING RADIATION",TFV("EC")="ENVIRONMENTAL CONTAMINANTS"
  1. S TFV("HNC")="HEAD AND NECK CANCER",TFV("CV")="COMBAT VETERAN"
  1. S TFV("SHD")="SHIPBOARD HAZARD"
  1. ; Output Checked TxF's
  1. F I=2:1:NTF I $E(CUN,I)="C" D
  1. . I 'TF1 S LST(ILST)=LST(ILST)_TFV($P(TFGUI,U,I)),TF1=1 D FRMTLST Q
  1. . S ILST=ILST+1,LST(ILST)=":"_TFV($P(TFGUI,U,I)) D FRMTLST
  1. Q
  1. ;
  1. FRMTLST ; Format the variable LST(ILST) for DISPLAY tag
  1. S LST(ILST)=$J($P(LST(ILST),":"),SPCS)_": "_$P(LST(ILST),":",2)
  1. Q
  1. ;
  1. HINTS(Y) ; Return HINTS for ORBA Treatment Factors - used by Delphi
  1. ; The hints returned in the Y array will be used in the CPRS GUI and
  1. ; displayed on fly-over of the cursor over the TxF text in the window
  1. ;
  1. ; Input
  1. ; <none>
  1. ; Output
  1. ; Y array of the hints for TxF's> Y(#)=TxFA ^ TxF line # ^ hint text
  1. ; where TxFA is Treatment Factor acronym, e.g., CV=Combat Veteran
  1. ; Variables
  1. ; CT = line number count, used in Y(#) where #=CT
  1. ; I = incrementor index #
  1. ; ORTFIEN = the IEN for the TxF in the Help Frame (^DIC(9.2)) file
  1. ; TF = TxF acronym
  1. ; TFLN = TxF text line number, e.g., ^DIC(9.2,ORTFIEN,1,TFLN,0)
  1. ; TFS = string of TxF acronyms
  1. ; TFV = TxF description/text
  1. ;
  1. N CT,I,ORTFIEN,TF,TFLN,TFS,TFV
  1. ;
  1. S TFS="SC^MST^AO^IR^EC^HNC^CV^SHD",CT=0
  1. ; Get next TxF from TFS
  1. F I=1:1 S TF=$P(TFS,U,I) Q:TF="" D
  1. . S ORTFIEN=$O(^DIC(9.2,"B","ORBA-"_TF,"")),TFV="",TFLN=0
  1. . ; Get next line of hint text
  1. . F S TFLN=$O(^DIC(9.2,ORTFIEN,1,TFLN)) Q:'TFLN D
  1. .. S CT=CT+1,Y(CT)=TF_U_TFLN_U_^DIC(9.2,ORTFIEN,1,TFLN,0)
  1. Q
  1. ;
  1. DG1(ORDFN,COUNTER,CTVALUE) ; Create DG1 segment(s) & make call for ZCL seg.
  1. ;
  1. ; Input
  1. ; ORDFN Internal Order ID#
  1. ; COUNTER Variable used as counter from calling routine
  1. ; CTVALUE Value of COUNTER when DG1 called
  1. ; Output
  1. ; DG1 & ZCL HL7 segments
  1. ;
  1. I $$BASTAT^ORWDBA1=0 Q ;BA not used
  1. N DG13,DXIEN,DXR,DXV,FROMFILE,ICD9,OCT,OREC,ORFMDAT
  1. ; zero order count variable
  1. S OCT=0
  1. ; Get the date of order (for CSV/CTD usage)
  1. S ORFMDAT=$$ORFMDAT(ORDFN)
  1. ; Get the diagnoses for an order
  1. F S OCT=$O(^OR(100,ORDFN,5.1,OCT)) Q:OCT'?1N.N D
  1. . S OREC=^OR(100,ORDFN,5.1,OCT,0)
  1. . S DXIEN=$P(OREC,U) ; DXIEN=pointer to diagnosis (ICD9) file #80
  1. . ; the DXIEN pointer should point to a valid diagnosis (after all is
  1. . ; was previously entered .. but just in case ...)
  1. . S (DXV,ICD9)=""
  1. . I DXIEN'="" D
  1. .. S DXR=$$ICDDATA^ICDXCODE("DIAGNOSIS",DXIEN,ORFMDAT) Q:+DXR=-1
  1. .. ; Get diagnosis verbiage and ICD code
  1. .. S DXV=$P(DXR,U,4),ICD9=$P(DXR,U,2)
  1. . S FROMFILE=80
  1. . S DG13=DXIEN_U_DXV_U_FROMFILE_U_ICD9_U_DXV_U_"ICD9"
  1. . S CTVALUE=CTVALUE+1
  1. . S ORMSG(CTVALUE)="DG1"_"|"_OCT_"||"_DG13_"|||||||||||||"
  1. . D ZCL
  1. S @COUNTER=CTVALUE
  1. Q
  1. ;
  1. ZCL ;create all the ZCL segments (currently 8 TxF's) for order number OCT
  1. ;
  1. N I,J,TABLE,TF,TFGBL,TFGUI,TFTBL,TFIN,TFS,VALUE
  1. D TFSTGS^ORWDBA1 ;set string sequence of treatment factors
  1. ; TFS is TxF data in ^OR(100,ORIEN,5.2) order
  1. S TFS=$G(^OR(100,ORDFN,5.2)),TABLE=""
  1. ; conversion order from ^OR stored data and Table SD008 for HL7 msg
  1. ; convert so that the ZCL segments will be in Table SD008 order (1-8)
  1. F I=1:1:8 S TF=$P(TFTBL,U,I) F J=1:1:8 I $P(TFGBL,U,J)=TF S TABLE=TABLE_J Q
  1. F TFIN=1:1:8 D
  1. . ; ORMSG counter incremented
  1. . S CTVALUE=CTVALUE+1
  1. . ; TF VALUE=0 for no or 1 for yes (only if not req. is it null)
  1. . S VALUE=$P(TFS,U,$E(TABLE,TFIN))
  1. . I VALUE="?" S VALUE=0 ;temp fix if sending '?' to ancillary???
  1. . ; for Table SD008: OCT=Set ID, SCIN=O/P Classif. Type, VALUE=Value
  1. . S ORMSG(CTVALUE)="ZCL|"_OCT_"|"_TFIN_"|"_VALUE
  1. Q
  1. ;
  1. BDOSTR ;Store backdoor order DG1 and ZCL messages from HL7
  1. ;Processes one order per entry into BDOSTR, e.g., ROUT(1)
  1. ;Depends upon ORM* routines to set-up a number of variables including
  1. ; ORMSG array and ORIFN.
  1. ;ORM* routines calling BDOSTR: ORMGMRC, ORMLR, ORMPS, & ORMRA
  1. ;
  1. ; Input: HL7 messages and related data
  1. ; Output: ROUT array in Delphi GUI format, i.e.
  1. ; OrderIEN;11CNNNCNN^exDx1^exDx2^exDx3^exDx4
  1. ;
  1. ; Variables Used
  1. ; DG1 = sequential numbered array with a value of DXIEN
  1. ; I,J = counters
  1. ; GUITF = GUI order treatment factors (TxF)
  1. ; NDX = number of diagnoses being passed
  1. ; NTF = number of TxF
  1. ; OBX = @ORMSG Dx array element # (max of 4 diagnoses stored)
  1. ; REC = set to sequential HL7 messages, contains HL7 message data
  1. ; ROUT = record sent for storage processing to RCVORCI
  1. ; TF = individual TxF values
  1. ; TFGBL = TxF acronyms in ^ delimited string in ^OR sequence
  1. ; TFGUI = TxF acronyms in ^ delimited string in from GUI sequence
  1. ; TFTBL = TxF acronyms in ^ delimited string in Table SD008 sequence
  1. ; VAL = individual TxF values
  1. ; ZCL = TxF in Table SD008 format and sequence
  1. ;
  1. ; See if CIDC master switch set, if not then no DG1/ZCL seg, to store
  1. I $$BASTAT^ORWDBA1=0 Q ;CIDC (nee BA) not used
  1. ;
  1. N CPNODE,CT,DG1,I,J,GUITF,NDX,NTF,OBX,REC,ROUT,ORSDCARY,SDCARYA
  1. N TF,TFGBL,TFGUI,TFTBL,VAL,X,ZCL
  1. ;
  1. K ORSDCARY,SDCARYA
  1. D TFSTGS^ORWDBA1 ;set string sequence of treatment factors
  1. S (CT,NDX,OBX)=0,NTF=8,(CPNODE,GUITF,TF,Y,ZCL)="",X="T"
  1. ; Call API to acquire Treatment Factors in force
  1. D NOW^%DTC,CL^SDCO21(DFN,%,"",.ORSDCARY) ;DBIA 406
  1. ; Retrved array order: AO,IR,SC,EC,MST,HNC,CV,SHD, e.g., ORSDCARY(3) for SC
  1. ; Convert to character array, e.g., SDCARYA("SC")=""
  1. F I=1:1:NTF S:$D(ORSDCARY(I)) SDCARYA($P("AO^IR^SC^EC^MST^HNC^CV^SHD",U,I))=""
  1. ; Process only four DG1 segments and first set of ZCL segments
  1. F S OBX=$O(@ORMSG@(OBX)) Q:OBX'>0 S J=$E(@ORMSG@(OBX),1,3) I J="DG1"!(J="ZCL"&($P(@ORMSG@(OBX),"|",2)=1)) D
  1. . S REC=@ORMSG@(OBX)
  1. . ; Setting DG1(#)=DXIEN where # is Dx sequence # (1=primary)
  1. . I J="DG1"&(NDX<4) S DG1($P(REC,"|",2))=$P(REC,U,4),NDX=NDX+1 Q
  1. . ; Create ZCL string of TxFs, e.g., 1101011
  1. . I J="ZCL" D
  1. .. S:$P(REC,"|",4)="" $P(REC,"|",4)=" "
  1. .. S $E(ZCL,$P(REC,"|",3))=$P(REC,"|",4)
  1. ; convert order and format from Table SD008 to GUI
  1. F I=1:1:NTF S TF=$P(TFGUI,U,I) F J=1:1:NTF I $P(TFTBL,U,J)=TF D
  1. . ; If patient does not have that Tx Factor (TF) then ghost in GUI ("N")
  1. . I '$D(SDCARYA(TF)) S GUITF=GUITF_"N" Q
  1. . ; If patient has TF then format for GUI (C=ck'd, U=unck'd, ?=not ans)
  1. . S VAL=$E(ZCL,J),GUITF=GUITF_$S(VAL=1:"C",VAL=0:"U",1:"?")
  1. ; Create output string in a format that can be stored by RCVORCI^ORWDBA1
  1. S ROUT(1)=ORIFN_";11"_GUITF_U_$G(DG1(1))_U_$G(DG1(2))_U_$G(DG1(3))_U_$G(DG1(4))
  1. ; Store diagnoses and treatment factors
  1. D RCVORCI^ORWDBA1(Y,.ROUT)
  1. Q
  1. ;
  1. ERRMSG(VISIT) ; Error handling and message
  1. ; to be determined
  1. Q