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

IBECUSMU.m

Go to the documentation of this file.
  1. IBECUSMU ;ALB/CPM - PHARMACY BILLING OPTION UTILITIES ; 12-DEC-96
  1. ;;2.0;INTEGRATED BILLING;**52,347**;21-MAR-94;Build 24
  1. ;
  1. ;
  1. FINDC(IBIN,IBW,IBOUT) ; Find transactions which can be cancelled.
  1. ; Input: IBIN -- Array of transactions, passed by reference
  1. ; IBW -- 1 => Write reject statements
  1. ; 2 => No writes
  1. ; Output: IBOUT -- Array of transactions which can be cancelled
  1. ;
  1. N IBKEY,IBCHTRN,IBCHTRN5,IBCHTRN6
  1. S IBKEY="" F S IBKEY=$O(IBIN(IBKEY)) Q:IBKEY="" D
  1. .S IBCHTRN=IBIN(IBKEY)
  1. .S IBCHTRN5=$G(^IBA(351.5,IBCHTRN,5)),IBCHTRN6=$G(^(6))
  1. .;
  1. .; - can cancel if original transmission was billed
  1. .; (no billing rejects) without trying to cancel
  1. .; (no cancel auth) or if the cancel was rejected
  1. .I IBCHTRN5="",IBCHTRN6=""!($P(IBCHTRN6,"^",3)'="") S IBOUT(IBKEY)=IBCHTRN Q
  1. .;
  1. .; - write error messages
  1. .Q:'$G(IBW)
  1. .;
  1. .; - billing transaction was rejected
  1. .I IBCHTRN5]"" W !," The claim for ",$S($P(IBKEY,";",2):"refill #"_$P(IBKEY,";",2),1:"the original fill")," for this prescription was rejected." Q
  1. .;
  1. .; - transaction was cancelled
  1. .W !?1,$S($P(IBKEY,";",2):"Refill #"_$P(IBKEY,";",2),1:"The original fill")," for this prescription has already been reversed."
  1. ;
  1. Q
  1. ;
  1. ;
  1. FINDB(IBRX,IBW,IBOUT) ; Find prescriptions which can be billed.
  1. ; Input: IBRX -- Pointer to the prescription in file #52
  1. ; IBW -- 1 => Write reject statements
  1. ; 2 => No writes
  1. ; Output: IBOUT -- Array of transactions which can be billed
  1. ;
  1. N IBARR,IBREF,IBKEY,IBCHTRN,IBCHTRN5,IBCHTRN6,IBREF1,LIST
  1. S LIST="FINDBLIST"
  1. ;
  1. ; - build potential array from prescription (#52) file
  1. S IBARR(IBRX_";0")=$O(^IBA(351.5,"B",IBRX_";0",0))
  1. S IBREF=0
  1. D RX^PSO52API($$FILE^IBRXUTL(IBRX,2),LIST,IBRX,,"R^^",,)
  1. S IBREF=0 F S IBREF=$O(^TMP($J,LIST,$$FILE^IBRXUTL(IBRX,2),IBRX,"RF",IBREF)) Q:IBREF'>0 D
  1. .Q:'IBREF
  1. .S IBARR(IBRX_";"_IBREF)=$O(^IBA(351.5,"B",IBRX_";"_IBREF,0))
  1. ;
  1. K ^TMP($J,LIST)
  1. S IBKEY="" F S IBKEY=$O(IBARR(IBKEY)) Q:IBKEY="" D
  1. .S IBCHTRN=IBARR(IBKEY)
  1. .I 'IBCHTRN S IBOUT(IBKEY)=IBCHTRN Q
  1. .;
  1. .S IBCHTRN5=$G(^IBA(351.5,IBCHTRN,5)),IBCHTRN6=$G(^(6))
  1. .;
  1. .; - can bill if original transmission was rejected,
  1. .; or if that transmission was cancelled (re-submit)
  1. .I IBCHTRN5]""!(IBCHTRN5=""&($P(IBCHTRN6,"^")'="")) S IBOUT(IBKEY)=IBCHTRN Q
  1. .;
  1. .; - write messages
  1. .Q:'$G(IBW)
  1. .;
  1. .; - already billed (previous cancellation was rejected)
  1. .I $P(IBCHTRN6,"^",3)'="" W !!," The previous cancellation for ",$S($P(IBKEY,";",2):"refill #"_$P(IBKEY,";",2),1:"the original fill")," was rejected." Q
  1. .;
  1. .; - never tried to cancel
  1. .W !!?1,$S($P(IBKEY,";",2):"Refill #"_$P(IBKEY,";",2),1:"The original fill")," for this prescription has already been billed."
  1. ;
  1. Q
  1. ;
  1. ;
  1. SEL(IBARR) ; Select a fill for a prescription.
  1. ; Input: IBARR -- Array of prescriptions passed by reference.
  1. ; Output: IBNUM -- One of the fill numbers, or -1 (none selected)
  1. ;
  1. N DIR,DIRUT,DIROUT,DTOUT,DUOUT,IBSTR,IBKEY,IBRX,IBREF,IBFILL,IBNUM
  1. ;
  1. ; - build string for DIR(0)
  1. S (IBSTR,IBKEY)="",IBNUM=-1
  1. F S IBKEY=$O(IBARR(IBKEY)) Q:IBKEY="" D
  1. .S IBRX=+IBKEY,IBREF=+$P(IBKEY,";",2)
  1. .S IBFILL=$S(IBREF:+$$SUBFILE^IBRXUTL(IBRX,IBREF,52,.01),1:+$$FILE^IBRXUTL(IBRX,22))
  1. .S IBSTR=IBSTR_IBREF_":"_$S(IBREF:"Refill #"_IBREF,1:"Original Fill")_" (filled "_$$DAT1^IBOUTL(IBFILL)_");"
  1. ;
  1. I IBSTR="" G SELQ
  1. ;
  1. S DIR("A")="Select one of the fills by number",DIR(0)="S^"_IBSTR
  1. D ^DIR I $D(DUOUT)!$D(DIROUT)!$D(DTOUT) G SELQ
  1. ;
  1. S IBNUM=Y
  1. ;
  1. SELQ Q IBNUM