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

ABSPOSQS.m

Go to the documentation of this file.
  1. ABSPOSQS ; IHS/FCS/DRS - special queuing considerations ; [ 08/28/2002 2:25 PM ]
  1. ;;1.0;PHARMACY POINT OF SALE;**1,2,3,37,40**;JUN 21, 2001;Build 38
  1. ;
  1. ; IHS/DSD/lwj 4/18/02 on behalf of Patrick Cox
  1. ; IHS/OKCAO/POC 10/2/01 In Oklahoma there is a general 3 punch
  1. ; a month limitation. However, there are no limitation for kids
  1. ; under the age of 18, or for patients in a nursing home. This
  1. ; change will simply address the limitation on the kids under 18.
  1. ; The maximum number of prescriptions will simply be set to 999
  1. ; to reflect no limitation.
  1. ;
  1. ; IHS/SD/lwj 6/17/02 on behalf of Patrick Cox
  1. ; IHS/OKCAO/POC 5/22/02 In the subroutine CAIDPAID, the routine
  1. ; attempts to count how many Medicaid paid repsonses have been
  1. ; received for a given month. The script count could be incorrectly
  1. ; inflatted if a script was flled/reflled in a prev month, but was
  1. ; sbmtd/resbmtd in the current month. Original logic was only
  1. ; looking at the month of the claim - not the DOS. Logic
  1. ; changed to use the scripts fill dt/refill dt instead of clm dt.
  1. ; (effected back billing, or resubmittal of previous month scripts
  1. ; when current month limitation had been reached)
  1. ;
  1. ; IHS/SD/lwj 8/28/02 on behalf of Patrick Cox (OKCAO/POC)
  1. ; Cache systems do not allow the reverse dollar order on arrays.
  1. ; Patrick simply reversed the sign in the PRICEORD array, which
  1. ; allowed the values to appear in descending order - this eliminated
  1. ; the need for the reverse $O on the PRICEORD array.
  1. ;
  1. Q
  1. STAT19() ;EP - is called at the bottom of ABSPOSQ1
  1. ; if there are any claims of status 19 - waiting for special
  1. ; Oklahoma Medicaid rule to run its course
  1. N ROU S ROU=$T(+0)
  1. L +^TMP("ABSPOSQS"):0 Q:'$T 0 ; only one of these running
  1. N COUNT30 S COUNT30=0 ; count how many 19s got pushed to status 30
  1. D RULE19
  1. L -^TMP("ABSPOSQS")
  1. ; If there are still any claims with status = 19,
  1. ; then you need to schedule ABSPOSQ1 to run again in a little while.
  1. I $D(^ABSPT("AD",19)) D
  1. . N WAIT S WAIT=$P(^ABSP(9002313.99,1,"SPECIAL"),U,2)
  1. . S:'WAIT WAIT=60
  1. . S WAIT="."_$TR($J(WAIT\3600,2)_$J(WAIT#3600\60,2)_$J(WAIT#60,2)," ","0")
  1. . D TASKAT^ABSPOSIZ($$TADDNOW^ABSPOSUD(WAIT))
  1. Q COUNT30
  1. RULE19 ;
  1. N INCYCLE,NLIMIT,SINCEDAT,PAT,IEN59,STAT,LASTUPD,I,X,Y
  1. ;
  1. ; Gather all the claims with status 19 into ^TMP("ABSPOSQS",$J,PAT,19,IEN59)
  1. ; Medicaid claims only - already taken care of, in that only
  1. ; Medicaid claims can ever be in status 19
  1. ; For any status, just set ^TMP("ABSPOSQS",$J,PAT,status)=latest last-update
  1. ; to make it easy to detect if a given patient has any non-19's.
  1. ;
  1. K ^TMP("ABSPOSQS")
  1. S STAT="",IEN59=0
  1. F S STAT=$O(^ABSPT("AD",STAT)) Q:STAT="" Q:STAT=99 D
  1. . S IEN59=0
  1. . F S IEN59=$O(^ABSPT("AD",STAT,IEN59)) Q:'IEN59 D
  1. . . ; $G() in next line guards against corrupt index
  1. . . S PAT=$P($G(^ABSPT(IEN59,0)),U,6) Q:'PAT
  1. . . S LASTUPD=$P(^ABSPT(IEN59,0),U,8)
  1. . . S X=$G(^TMP("ABSPOSQS",$J,PAT,STAT))
  1. . . I LASTUPD>X S ^TMP("ABSPOSQS",$J,PAT,STAT)=LASTUPD
  1. . . I STAT=19 S ^TMP("ABSPOSQS",$J,PAT,STAT,IEN59)=""
  1. ;
  1. ; Loop for each such patient:
  1. S PAT="" F S PAT=$O(^TMP("ABSPOSQS",$J,PAT)) Q:'PAT D
  1. . I '$D(^TMP("ABSPOSQS",$J,PAT,19)) Q ; no 19's for this patient; nothing to do
  1. . D PAT19
  1. Q
  1. PAT19 ; Then look at each patient's situation:
  1. ;
  1. ; If the patient has any claims with status 20-98 (i.e., actively
  1. ; going through POS right now) then leave their 19s as 19 for now.
  1. ; What we do with these depends on how the others turn out.
  1. ;
  1. ; Also, if the patient has any with status <19, wait for those to
  1. ; catch up - because apparently, data entry is still going on
  1. ; and we want to wait, so we just pick off the three highest-priced.
  1. ;
  1. I $O(^TMP("ABSPOSQS",$J,PAT,""))'=19 Q ; there are some w/status < 19
  1. I $O(^TMP("ABSPOSQS",$J,PAT,19))'="" Q ; there are some w/status > 19
  1. ;
  1. ; IHS/DSD/lwj 04/18/02 on behalf of IHS/OKCAO/POC 10/2/2001
  1. ; begin changes
  1. ;
  1. ;N LIMIT,MAX S MAX=3 S LIMIT=MAX-$$CAIDPAID ;IHS/OKCAO/POC rmkd out
  1. N ABSPINS,ABSPERR,LIMIT,MAX,DFN ;IHS/OKCAO/POC new def
  1. ;
  1. ; In the ABSP setup file, there is a special node:
  1. ; ^ABSP(9002313.99,1,"SPECIAL")=OK MEDICAID INS NAME^OK MEDICAID
  1. ; CYCLE^OK MEDICAID LIMIT
  1. ; This portion of the code is retrieving the INS name, and the limits
  1. ; If the insurer is Oklahoma, we will adjust the limits for kids
  1. ;
  1. S ABSPINS=$$GET1^DIQ(9002313.99,"1,",1960.01,"","","ABSPERR")
  1. S MAX=+$P($G(^ABSP(9002313.99,1,"SPECIAL")),U,3) ;IHS/OKCAO/POC def
  1. S:'MAX MAX=3 ;IHS/OKCAO/POC use def when pos
  1. ;
  1. ;If this is for Oklahoma and patient is under 18 extend limits
  1. ; (insurance name is either Oklahoma Medicaid or Oklahoma)
  1. I ($G(ABSPINS)["OKLAHOMA")&($$AGE^AUPNPAT(PAT)<18) S MAX=999
  1. ;
  1. S LIMIT=MAX-$$CAIDPAID
  1. ;
  1. ; IHS/DSD/lwj 04/18/02 for IHS/OKCAO/POC 10/2/01 end changes
  1. ;
  1. ;
  1. ; LIMIT = how many more paid responses we're allowed for this month
  1. ;
  1. ; If LIMIT=0, we've used up our limit of Medicaid prescriptions
  1. ; for the month. Each of these will have to bump to the next
  1. ; insurer. (For now, just reject them
  1. ;
  1. I LIMIT=0 D Q
  1. . S IEN59=0 F S IEN59=$O(^TMP("ABSPOSQS",$J,PAT,19,IEN59)) Q:'IEN59 D
  1. . . D SETSLOT^ABSPOSL(IEN59)
  1. . . N MSG S MSG="Medicaid monthly limit of "_MAX_" reached."
  1. . . D LOG^ABSPOSL(MSG)
  1. . . I $$BUMPINS^ABSPOSQA(IEN59) D ; bump to next insurer
  1. . . . ; Succeeded, there is more insurance ;
  1. . . . ; And $$BUMPINS reset status to 0
  1. . . . D LOG^ABSPOSL(" We will try the next insurer.")
  1. . . E D
  1. . . . ; Failed - no more insurance - $$BUMPINS set status to 99
  1. . . . N ABSBRXI S ABSBRXI=IEN59 ; unfortunate variable naming
  1. . . . D SETRESU^ABSPOSU(19,MSG)
  1. . . D RELSLOT^ABSPOSL
  1. ;
  1. ; We can still submit some Medicaid prescriptions, but let's
  1. ; make sure we have all the ones that we're going to get at
  1. ; this visit - make sure that the most recent activity on
  1. ; any of the status 19 claims is at least 2 minutes old.
  1. ; Otherwise, there may be some more coming, and we would rather
  1. ; wait and make sure we get the more expensive ones.
  1. I $$TDIFNOW^ABSPOSUD(^TMP("ABSPOSQS",$J,PAT,19))<$P(^ABSP(9002313.99,1,"SPECIAL"),U,2) Q
  1. ;
  1. ; If LIMIT>0, then take this many of the patient's status 19 claims
  1. ; and change them to status 30. Any other 19s stay as 19s,
  1. ; as we need to wait and see how the others turn out. If they're
  1. ; rejected, we could still submit a few of the other 19s.
  1. ;
  1. N PRICEORD ; set PRICEORD(price,ien59)="" for each of this pat's 19s
  1. N PRICE,N
  1. S IEN59=0
  1. F S IEN59=$O(^TMP("ABSPOSQS",$J,PAT,19,IEN59)) Q:'IEN59 D
  1. . N PRICE S PRICE=$P(^ABSPT(IEN59,5),U,5)
  1. . ;IHS/SD/lwj 8/28/02 on behalf of IHS/OKCAO/POS nxt line remarked
  1. . ; out, following line added
  1. . ; S PRICEORD(PRICE,IEN59)="" ;IHS/OKCAO/POS 8/28/02
  1. . S PRICEORD(0-PRICE,IEN59)="" ;IHS/OKCAO/POC 8/28/02 reverse order
  1. S PRICE="",N=0
  1. F D Q:PRICE="" Q:N=LIMIT
  1. . ;IHS/SD/lwj 8/28/02 on behalf of IHS/OKCAO/POC nxt line remarked
  1. . ;out, following line added (reverse $O does not work on arrays
  1. . ;Cache)
  1. . ;S PRICE=$O(PRICEORD(PRICE),-1) Q:PRICE="" ; from highest to lowest
  1. . S PRICE=$O(PRICEORD(PRICE)) Q:PRICE="" ; from highest to lowest
  1. . S IEN59=0
  1. . F S IEN59=$O(PRICEORD(PRICE,IEN59)) Q:IEN59="" Q:N=LIMIT D
  1. . . N ABSBRXI S ABSBRXI=IEN59 D SETSTAT^ABSPOSU(30)
  1. . . S N=N+1 ; how many submitted for this patient
  1. . . S COUNT30=COUNT30+1 ; how many submitted in total by this routine
  1. Q
  1. CAIDPAID() ; count how many Medicaid paid responses for this patient
  1. ; this month, up to 3 maximum
  1. ; given PAT = patient IEN; MAX=3
  1. ;
  1. ; IHS/OKCAO/POS 5/22/02 (IHS/SD/lwj 6/17/02) changed to look
  1. ; at month script was filled/refilled for considering script in cnt
  1. ;
  1. N INS S INS=$P(^ABSP(9002313.99,1,"SPECIAL"),U) ; insurer we seek
  1. N FOUND S FOUND=0 ; count how many are found
  1. N SINCE S SINCE=DT,$E(SINCE,6,7)="00" ; yyymm00
  1. N IEN59,STOP S IEN59=0,STOP=0
  1. F S IEN59=$O(^ABSPT("AC",PAT,IEN59)) D Q:STOP
  1. . I 'IEN59 S STOP=1 Q
  1. . S X=^ABSPT(IEN59,0)
  1. . ; IHS/OKCAO/POC 05/22/02 (IHS/SD/lwj 6/17/02) begin changes
  1. . ;I $P(X,U,8)<SINCE Q ; previous month
  1. . N DATE
  1. . D
  1. . . N RXIEN,REFIEN
  1. . . S RXIEN=$P($G(^ABSPT(IEN59,1)),U,11),REFIEN=$P($G(^ABSPT(IEN59,1)),U,1)
  1. . . S DATE=$S(+REFIEN=0:$P($G(^PSRX(RXIEN,2)),U,2),1:$P($G(^PSRX(RXIEN,1,+REFIEN,0)),U,1))
  1. . I +DATE Q:DATE<SINCE
  1. . ; IHS/OKCAO/POS 05/22/02 (IHS/SD/lwj 6/17/02) end changes
  1. . I 99'=$P(X,U,2) Q ; not completed yet
  1. . I INS'=$P(^ABSPT(IEN59,1),U,6) Q ; not this insurer
  1. . ;IHS/OIT/RAN 021710 patch 37 Do not count if claim has been reversed -BEGIN
  1. . ;N Y S Y=$$RXPAID^ABSPOSNC(IEN59) Q:$P(Y,U,3)="Accepted reversal" ;IHS/OIT/CNI/SCR patch 40 OKC - replaced with next three lines
  1. . N ABSPINFO
  1. . S ABSPINFO=$$RXPAID^ABSPOSNC(IEN59)
  1. . Q:$P(ABSPINFO,U,1)=0 ;there are a lot of reasons not to count this
  1. . ;IHS/OIT/RAN 021710 patch 37 Do not count if claim has been reversed -END
  1. . I $$PAID^ABSPOSQ4(IEN59) D
  1. . . S FOUND=FOUND+1
  1. . . I FOUND=MAX S STOP=1
  1. Q FOUND