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

IBTRH5C.m

Go to the documentation of this file.
  1. IBTRH5C ;ALB/FA - HCSR Create 278 Request ;12-AUG-2014
  1. ;;2.0;INTEGRATED BILLING;**517**;21-MAR-94;Build 240
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;;
  1. ; Contains Entry points and functions used in creating a 278 request from a
  1. ; selected entry in the HCSR Response worklist
  1. ;
  1. ; -------------------------- Entry Points --------------------------------
  1. ; AMBTI - Called from within the input template to see if any of the
  1. ; Ambulance Transport Information fields have a value
  1. ; Fields: 18.01, 18.02, 18.03, 18.04, 18.05, 18.06, 18.09, 18.1
  1. ; ATTPHY - Returns the Attending Physician of the entry
  1. ; CERTCD - Dictionary Screen function for Certification Type Code (2.02)
  1. ; CONTPH - Input Validation method for fields 20, 21, 22
  1. ; CRTENTRY - Creates a new worklist entry from a specified worklist entry.
  1. ; Copies all the request data from the specified entry into the
  1. ; new entry
  1. ; OXYET - Called from within the input template to determine if one of
  1. ; Oxygen Equipment Type fields = 'D' or 'E'. Fields 8.01, 8.02
  1. ; 8.03
  1. ; REQCAT - Dictionary Screen function for Request Category Field 2.01
  1. ; and field 356.2216/.15
  1. ; SLDXDUP - Dictionary Screen function for Service Line Diagnosis fields
  1. ; Checks to insure the diagnosis is NOT a duplicate entry AND
  1. ; points to a valid diagnosis multiple.
  1. ; Fields: 2216,2.01, 2216,2.02, 2216,2.03, 2216,2.04
  1. ; TOOTHSP - Called from within the Input Template to check if subsequent
  1. ; Tooth Surfaces have values
  1. ;-----------------------------------------------------------------------------
  1. ;
  1. CONTPH(FIELD) ;EP
  1. ; Input validation method for Requester Contact Numbers 1,2 and 3 (fields 20,
  1. ; 21 and 22)
  1. ; Input: FIELD - Requester Contact Number field being validated
  1. ; DA - IEN of the 356.22 entry being edited
  1. ; X - Internal Value of the user response
  1. ; Output: None
  1. ; Returns: 1 - Answer is valid, 0 - Otherwise
  1. N RETURN,TYPE,XX
  1. S XX=$S(FIELD=20:19.01,FIELD=21:19.02,FIELD=22:19.03,1:0)
  1. Q:XX=0 0 ; Invalid FIELD
  1. S RETURN=1 ; Assume valid
  1. S TYPE=$$GET1^DIQ(356.22,DA_",",XX,"I") ; Requester Contact Qualifier
  1. S TYPE=$$GET1^DIQ(365.021,TYPE_",",.01) ; Requester Contact Qualifier Code
  1. ;
  1. I (TYPE="ED")!(TYPE="EM")!(TYPE="UR")!(TYPE="EX") D Q RETURN
  1. . S RETURN=$S($L(X)'>250:1,1:0)
  1. S XX=$TR(X,"-","") ; Remove dashes
  1. I XX'?10N S RETURN=0
  1. Q RETURN
  1. ;
  1. CRTENTRY(IBTRIEN,RIEN,IEN312,REQBY,DELCCDE,DELAY,NOOUTPUT,TTYPE) ;EP
  1. ; Creates a new entry in 356.22 by copying fields from an existing entry. Used
  1. ; to create a request from a Response by copying the request entry pointed to
  1. ; from the response entry
  1. ; Input: IBTRIEN - IEN of the entry to be copied
  1. ; RIEN - IEN of the response entry
  1. ; IEN312 - IEN of the insurance multiple to set into field .03
  1. ; Optional, if not passed, this field is copied from the
  1. ; existing entry
  1. ; REQBY - DUZ of the Requested By user to set into field .11
  1. ; Optional, if not passed, this field is copied from the
  1. ; existing entry
  1. ; DELCCDE - 1 to clear the value for Certification Type (field 2.02)
  1. ; Optional, if not passed, defaults to 0
  1. ; DELAY - 'D' or a future date to set a next review date and status
  1. ; to '08'
  1. ; Optional, if not passed, defaults to ""
  1. ; NOOUTPUT - suppress error message output, if not passed, defaults to 0 (false)
  1. ; TTYPE - UM02 value for 278x215 if cancel
  1. ;
  1. ; Output: New entry created in 356.22
  1. ; Returns: 0 - Copy was NOT successful and error messages were displayed
  1. ; Otherwise, IEN of the new entry in 356.22 is returned
  1. N ERROR,FLDS,IENARRY,IENS,NEWENTRY,NIENS,NIENS16,OLDENTRY,STOPFLG,XX,Z,Z1,XX1
  1. S:'$D(NOOUTPUT) NOOUTPUT=0
  1. S:'$D(IEN312) IEN312=""
  1. S:'$D(REQBY) REQBY=""
  1. S:'$D(DELCCDE) DELCCDE=0
  1. S:'$D(DELAY) DELAY=""
  1. S IENS=IBTRIEN_","
  1. S FLDS=".02;.03:.07;.11;.16;2.01:2.25;3*;4.01:4.14;5.01:5.18;6.01:6.18"
  1. S FLDS=FLDS_";7.01:7.13;8.01:8.08;9.01:9.08;10.01:10.13;11*;12;14*;15*;18.01:18.1;19.01:19.03;20:22"
  1. D GETS^DIQ(356.22,IENS,FLDS,"NI","OLDENTRY","ERROR")
  1. I $D(ERROR) D COPYERR(0,.ERROR) Q 0 ; Unsuccessful read of initial entry
  1. ;
  1. ; Copy internal data from the specified entry to a new array
  1. M NEWENTRY(356.22,"+1,")=OLDENTRY(356.22,IENS)
  1. D COPYINT(.NEWENTRY)
  1. ;
  1. ; Set the Event Date to 'NOW'
  1. S NEWENTRY(356.22,"+1,",.01)=$$NOW^XLFDT()
  1. S:IEN312'="" NEWENTRY(356.22,"+1,",.03)=IEN312 ; Set Insurance Multiple IEN
  1. S NEWENTRY(356.22,"+1,",.08)=$S(DELAY'="":"08",1:0) ; Initialize status to 0
  1. S:REQBY'="" NEWENTRY(356.22,"+1,",.11)=REQBY
  1. I DELCCDE D
  1. . S NEWENTRY(356.22,"+1,",2.02)="" ; Clear Certification Type field
  1. . S NEWENTRY(356.22,"+1,",.18)=1 ; Flag creation from Response
  1. I $G(TTYPE)="C" S NEWENTRY(356.22,"+1,",2.02)=3
  1. S:DELAY'="" NEWENTRY(356.22,"+1,",.17)=DELAY ; Delayed until DELAY
  1. S XX=$$GET1^DIQ(356.22,RIEN_",",103.02) ; Auth. or Ref. number from response
  1. S XX1=$$GET1^DIQ(356.22,RIEN_",",103.01) ; CERT ACT CODE
  1. I $F(",A1,A2,A6,",","_XX1_",") S NEWENTRY(356.22,"+1,",17.01)=XX
  1. I $F(",A3,A4,C,CT,NA,",","_XX1_",") D
  1. . I XX="" S XX=$$GET1^DIQ(356.22,RIEN_",",17.02)
  1. . S NEWENTRY(356.22,"+1,",17.02)=XX
  1. K IENARRY
  1. D UPDATE^DIE(,"NEWENTRY","IENARRY","ERROR") ; File the initial data
  1. I $D(ERROR) D COPYERR(1,.ERROR) Q 0 ; Unsuccessful copy of initial data
  1. ; update field .27 of response message
  1. I DELCCDE D I $D(ERROR) D COPYERR(1,.ERROR) Q 0
  1. . N UPDRSP
  1. . S UPDRSP(356.22,RIEN_",",.27)=1
  1. . D FILE^DIE("I","UPDRSP","ERROR")
  1. . Q
  1. ;
  1. ; Next copy multiples IENs of the new entry in 356.22 (top level)
  1. S NIENS=IENARRY(1)_","
  1. ;
  1. ; File Diagnosis multiples (356.223)
  1. I '$$MLTCPY(356.223,NIENS) Q 0
  1. ;
  1. ; File Attachment multiples (356.2211)
  1. I '$$MLTCPY(356.2211,NIENS) Q 0
  1. ;
  1. ; File Patient Event Transport multiples (356.2214)
  1. I '$$MLTCPY(356.2214,NIENS) Q 0
  1. ;
  1. ; File Other UMO multiples (356.2215)
  1. I '$$MLTCPY(356.2215,NIENS) Q 0
  1. ;
  1. ; File Provider multiples (356.2213)
  1. ; NOTE: not all fields are being copied, each entry needs to be handled separately
  1. S Z=0,STOPFLG=0
  1. F D Q:'Z!STOPFLG
  1. . S Z=$O(^IBT(356.22,IBTRIEN,13,Z))
  1. . Q:'Z
  1. . S IENS=Z_","_IBTRIEN_","
  1. . K NEWENTRY,OLDENTRY
  1. . D GETS^DIQ(356.2213,IENS,".01:.03","NI","OLDENTRY","ERROR")
  1. . I $D(ERROR) D COPYERR(0,.ERROR) S STOPFLG=1 Q
  1. . M NEWENTRY(356.2213,"+1,"_NIENS)=OLDENTRY(356.2213,IENS)
  1. . D COPYINT(.NEWENTRY)
  1. . D UPDATE^DIE(,"NEWENTRY",,"ERROR")
  1. . I $D(ERROR) D COPYERR(1,.ERROR) S STOPFLG=1
  1. Q:STOPFLG 0
  1. ;
  1. ; File Service Line multiples (356.2216)
  1. ; NOTE: not all fields are being copied, each entry needs to be handled separately
  1. S Z=0,STOPFLG=0
  1. F D Q:'Z!STOPFLG
  1. . S Z=$O(^IBT(356.22,IBTRIEN,16,Z))
  1. . Q:'Z
  1. . S IENS=Z_","_IBTRIEN_","
  1. . K OLDENTRY
  1. . S FLDS=".01:.14;1.01:1.12;2.01:2.09;3.01:3.07;4*;5.01:5.08;6*;7"
  1. . D GETS^DIQ(356.2216,IENS,FLDS,"NI","OLDENTRY","ERROR")
  1. . I $D(ERROR) D COPYERR(0,.ERROR) S STOPFLG=1 Q
  1. . K NEWENTRY
  1. . M NEWENTRY(356.2216,"+1,"_NIENS)=OLDENTRY(356.2216,IENS)
  1. . D COPYINT(.NEWENTRY)
  1. . K IENARRY
  1. . D UPDATE^DIE(,"NEWENTRY","IENARRY","ERROR")
  1. . I $D(ERROR) D COPYERR(1,.ERROR) S STOPFLG=1
  1. . S NIENS16=IENARRY(1)_","_NIENS ; IENs of the new Service Line in 356.2216
  1. . ;
  1. . ; File Service Line Tooth Information multiples (356.22164)
  1. . I '$$MLTCPY(356.22164,NIENS16) S STOPFLG=1 Q
  1. . ;
  1. . ; File Service Line Attachment multiple (356.22166)
  1. . I '$$MLTCPY(356.22166,NIENS16) S STOPFLG=1 Q
  1. . ;
  1. . ; File Service Line Provider Data multiples (356.22168)
  1. . ; NOTE - not all fields are being copied, each entry needs to be handled separately
  1. . S Z1=0
  1. . F D Q:'Z1!STOPFLG
  1. . . S Z1=$O(^IBT(356.22,IBTRIEN,16,Z,8,Z1))
  1. . . Q:'Z1
  1. . . S IENS=Z1_","_Z_","_IBTRIEN_","
  1. . . K NEWENTRY,OLDENTRY
  1. . . D GETS^DIQ(356.22168,IENS,".01:.03","NI","OLDENTRY","ERROR")
  1. . . I $D(ERROR) D COPYERR(0,.ERROR) S STOPFLG=1 Q
  1. . . M NEWENTRY(356.22168,"+1,"_NIENS16)=OLDENTRY(356.22168,IENS)
  1. . . D COPYINT(.NEWENTRY)
  1. . . D UPDATE^DIE(,"NEWENTRY",,"ERROR")
  1. . . I $D(ERROR) D COPYERR(1,.ERROR) S STOPFLG=1
  1. I STOPFLG Q 0
  1. Q $P(NIENS,",",1)
  1. ;
  1. COPYERR(TYPE,ERROR) ; Displays any errors encountered while copying a request
  1. ; Input: TYPE - 0 - Error while reading data
  1. ; - 1 - Error while filing data
  1. ; ERROR - Array used for FM error reporting
  1. ; Output: Error(s) are displayed
  1. I '$G(NOOUTPUT) Q ;IF NOT TO DISPLAY OUTPUT, for background job
  1. N STR,Z,Z1
  1. Q:'$D(ERROR)
  1. W !,"Unable to copy - the following error was encountered while "
  1. W $S(TYPE:"filing",1:"retrieving")," the data:"
  1. S Z=0
  1. F D Q:'Z
  1. . S Z=$O(ERROR("DIERR",Z))
  1. . Q:'Z
  1. . S STR=$G(ERROR("DIERR",Z))
  1. . W:STR'="" !,"Error code: "_STR
  1. . S STR=$G(ERROR("DIERR",Z,"PARAM","FILE"))
  1. . W:STR'="" !,"File number: "_STR
  1. . S STR=$G(ERROR("DIERR",Z,"PARAM","FIELD"))
  1. . W:STR'="" !,"Field number: "_STR
  1. . W !,"Error text:"
  1. . S Z1=0
  1. . F D Q:'Z1
  1. . . S Z1=$O(ERROR("DIERR",1,"TEXT",Z1))
  1. . . Q:'Z1
  1. . . W !,ERROR("DIERR",1,"TEXT",Z1)
  1. Q
  1. ;
  1. MLTCPY(SFNUM,NEWIENS) ; Copies the specified multiple
  1. ; Input: SFNUM - Sub-file number of the multiple to copy
  1. ; NIENS - IENs of the new entry (copied to)
  1. ; OLDENTRY - FDA array to get data from (defined in the calling tag)
  1. ; Returns: 1 on successful copy, 0 on failure
  1. ;
  1. N ERROR,NEWENTRY,RES,STOPFLG,Z
  1. S RES=1,STOPFLG=0
  1. S Z=0
  1. F D Q:'Z!STOPFLG
  1. . S Z=$O(OLDENTRY(SFNUM,Z))
  1. . Q:'Z
  1. . K NEWENTRY
  1. . M NEWENTRY(SFNUM,"+1,"_NEWIENS)=OLDENTRY(SFNUM,Z)
  1. . D COPYINT(.NEWENTRY)
  1. . D UPDATE^DIE(,"NEWENTRY",,"ERROR")
  1. . I $D(ERROR) D COPYERR(1) S STOPFLG=1,RES=0
  1. Q RES
  1. ;
  1. COPYINT(NEW) ; Copies an array of internal values to a new array
  1. ; Input: NEW - Current Array of internal values
  1. ; Retrieved using D GETS^DIQ(356.22,IENS,FLDS,"NI","OLD","ERROR")
  1. ; e.g. NEW(356.223,"+1,19,",.02,"I")=7209320
  1. ; Output: NEW - Updated array of internal values, stripping off the "I" subscript
  1. ; e.g. NEW(356.223,"+1,19,",.02)=7209320
  1. N ARRAY,NEW2,YY
  1. S ARRAY="NEW("""")"
  1. F D Q:ARRAY=""
  1. . S ARRAY=$Q(@ARRAY)
  1. . Q:ARRAY=""
  1. . I ARRAY[",""I"")" D Q
  1. . . S YY=$P(ARRAY,",""I"")",1)_")"
  1. . . S YY="NEW2("_$P(YY,"(",2)
  1. . . S @YY=@ARRAY
  1. . S YY="NEW2("_$P(ARRAY,"(",2)
  1. . S @YY=@ARRAY
  1. K NEW
  1. M NEW=NEW2
  1. Q
  1. ;
  1. OXYET(IBTRIEN) ;EP
  1. ; Called from within the input template
  1. ; Checks to see if any of the currently filed Oxygen Equipment
  1. ; Types have a value of 'D' or 'E'
  1. ; Input: IBTRIEN - IEN of the Patient Event
  1. ; Returns: 1 - at least one of the Oxygen Equipment Types is 'D' or 'E'
  1. ; 0 Otherwise
  1. N NDE
  1. S NDE=$G(^IBT(356.22,IBTRIEN,8))
  1. I ($P(NDE,"^",1)=4)!($P(NDE,"^",1)=5) Q 1
  1. I ($P(NDE,"^",2)=4)!($P(NDE,"^",2)=5) Q 1
  1. I ($P(NDE,"^",3)=4)!($P(NDE,"^",3)=5) Q 1
  1. Q 0
  1. ;
  1. ATTPHY(IBTRIEN) ;EP
  1. ; Returns the Attending Physician for the admission of the
  1. ; specified Inpatient event
  1. ; Input: IBTRIEN - IEN of the Inpatient Event
  1. ; Returns: IEN in file 200 of the Attending Physician or ""
  1. N ADATE,DA,DFN,DT,EVENT,FOUND,IADATE
  1. S EVENT=$G(^IBT(356.22,IBTRIEN,0))
  1. S DFN=$P(EVENT,"^",2) ; DFN of the patient
  1. S ADATE=$P($P(EVENT,"^",7),"-",1) ; Internal Admit date
  1. S IADATE=9999999.9999999-ADATE
  1. S DA=$O(^DGPM("ATID1",DFN,IADATE,"")) ; DBIA419
  1. Q:DA="" "" ; No Patient Movement admission record
  1. Q $$GET1^DIQ(405,DA_",",.19,"I")
  1. ;
  1. REQCAT(FIELD) ;EP
  1. ; Dictionary Screen for Request Category (2.01)
  1. ; Checks the Request Category (2.01 OR 356.2216/.15) to make sure the answer
  1. ; is valid for the event type
  1. ; Input: FIELD - Only passed when called from 356.2216/.15
  1. ; DA - IEN of the 356.22 entry being edited
  1. ; Y - Internal Value of the user response
  1. ; Output: None
  1. ; Returns: 1 - Answer is valid, 0 - Otherwise
  1. N RETURN,STAT
  1. I $D(FIELD) D Q RETURN
  1. . S RETURN=1
  1. . I Y'=2,Y'=4 S RETURN=0
  1. ;
  1. S STAT=$P($G(^IBT(356.22,DA,0)),"^",4)
  1. I STAT="I",Y'=1 Q 0
  1. I STAT="O",Y=1 Q 0
  1. Q 1
  1. ;
  1. CERTCD() ;EP
  1. ; Dictionary screen for field Certification Type Code 2.02
  1. ; Checks the code to make sure the answer is valid for the event type
  1. ; Input: DA - IEN of the 356.22 entry being edited
  1. ; Y - Internal Value of the user response
  1. ; Output: None
  1. ; Returns: 1 - Answer is valid, 0 - Otherwise
  1. N FREP
  1. I '$F(",3,5,",","_Y_",") Q 0
  1. S FREP=$P($G(^IBT(356.22,DA,0)),"^",18)
  1. I FREP=1,Y=5 Q 0
  1. Q 1
  1. ;
  1. AMBTI(IBTRIEN) ;EP
  1. ; Called from Input Template IB CREATE 278 REQUEST to check if any of the
  1. ; Ambulance Transport Information fields has a value. Used to potentially
  1. ; skip to potentially skip the Patient Event Transport Information questions
  1. ; Input: IBTRIEN - IEN of the 356.22 entry being edited
  1. ; Returns: 1 - At least one field has a value, 0 otherwise
  1. N NDE
  1. S NDE=$G(^IBT(356.22,IBTRIEN,18))
  1. I $P(NDE,"^",1)'="" Q 1
  1. I $P(NDE,"^",2)'="" Q 1
  1. I $P(NDE,"^",3)'="" Q 1
  1. I $P(NDE,"^",4)'="" Q 1
  1. I $P(NDE,"^",5)'="" Q 1
  1. I $P(NDE,"^",6)'="" Q 1
  1. I $P(NDE,"^",9)'="" Q 1
  1. I $P(NDE,"^",10)'="" Q 1
  1. Q 0
  1. ;
  1. SLDXDUP(FIELD) ;EP
  1. ; Dictionary Screen Function
  1. ; Checks to see if the specified Service Line Diagnosis is a duplicate entry
  1. ; AND points to valid Diagnosis multiple.
  1. ; Fields: 2216,2.01, 2216,2.02, 2216,2.03, 2216,2.04
  1. ; Input: FIELD - Field number of the field being checked
  1. ; DA(1) - IEN of the 356.22 entry being edited
  1. ; DA - IEN of the service line multiple
  1. ; Y - Internal Value of the user response
  1. ; Output: None
  1. ; Returns: 1 - Answer is valid, 0 - Otherwise
  1. N NDE,RETURN
  1. S RETURN=1 ; Assume Valid Input
  1. Q:Y="" 1 ; No value entered
  1. ;
  1. ; Not a valid service line multiple
  1. I '$D(^IBT(356.22,DA(1),3,Y,0)) Q 0
  1. ;
  1. ; Check for duplicates
  1. S NDE=$G(^IBT(356.22,DA(1),16,DA,2))
  1. I FIELD="2.01" D Q RETURN
  1. . I $P(NDE,"^",2)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",3)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",4)=Y S RETURN=0 Q
  1. I FIELD="2.02" D Q RETURN
  1. . I $P(NDE,"^",1)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",3)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",4)=Y S RETURN=0 Q
  1. I FIELD="2.03" D Q RETURN
  1. . I $P(NDE,"^",1)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",2)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",4)=Y S RETURN=0 Q
  1. I FIELD="2.04" D Q RETURN
  1. . I $P(NDE,"^",1)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",2)=Y S RETURN=0 Q
  1. . I $P(NDE,"^",3)=Y S RETURN=0 Q
  1. Q 1
  1. ;
  1. TOOTHSP(FIELD) ;EP
  1. ; Called from Input Template IB CREATE 278 REQUEST for Service Line Tooth
  1. ; Surface fields. Checks to see if subsequent Tooth Surfaces have values.
  1. ; Input: FIELD - Field # of the field being checked
  1. ; DA - IEN of the Tooth multiple being edited
  1. ; DA(1) - IEN of the Service Line Multiple being edited
  1. ; DA(2) - IEN of the 356.22 entry being edited
  1. ; Returns: 1 - Subsequent entries have values, 0 otherwise
  1. N NDE,RETURN
  1. S NDE=$G(^IBT(356.22,DA(2),16,DA(1),4,DA,0))
  1. I FIELD=.02 D Q RETURN
  1. . I $P(NDE,"^",2)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",3)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",4)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",5)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",6)'="" S RETURN=1 Q
  1. . S RETURN=0
  1. I FIELD=.03 D Q RETURN
  1. . I $P(NDE,"^",4)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",5)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",6)'="" S RETURN=1 Q
  1. . S RETURN=0
  1. I FIELD=.04 D Q RETURN
  1. . I $P(NDE,"^",5)'="" S RETURN=1 Q
  1. . I $P(NDE,"^",6)'="" S RETURN=1 Q
  1. . S RETURN=0
  1. I FIELD=.05,$P(NDE,"^",6)'="" Q 1
  1. Q 0
  1. ;