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

PSOHLNE4.m

Go to the documentation of this file.
  1. PSOHLNE4 ;BIR/LE - Process Edit Information from CPRS - CONTINUED FROM PSOHLNE3 ;02/27/04
  1. ;;7.0;OUTPATIENT PHARMACY;**201,225**;DEC 1997;Build 29
  1. ;
  1. ;This API is used to update the prescription file when ICD-9 diagnosis
  1. ; and SC/EI's are updated as a result of an e-sig in CPRS.
  1. Q
  1. COPAY ;For IB, cancel copay charges if SC<50% and SC/EI changed and released; For PFS, send charge update msgs for SC 0-100%
  1. ; must have PSODA,PSO,PSODAYS,PSOFLAG,PSOREF,PSOIB,PSOPAR7,PSOOLD,PSONW before call to PSOCPA
  1. N PSODA,PSO,PSODAYS,PSOFLAG,PSOREF,PSOIB,PSZ,PSOPAR7,PSOCSEQ,PSZ1,PSZ2,RELDAT,PSOOLD,PSONW,PSOSITE,PREA,PSOFLD,PSOPFS
  1. S PSODA=RXN,PSO=3,PSODAYS=$$GET1^DIQ(52,PSODA_",","8")
  1. S PSOOLD="Copay"
  1. S PSONW="No Copay"
  1. S PSOSITE=$P(^PSRX(PSODA,2),"^",9)
  1. S PSOPAR7=$G(^PS(59,PSOSITE,"IB"))
  1. S PSOFLAG=1 ;1 used here to eliminate display/print of messages.
  1. CSORT ; get orig fill copay info if released.
  1. S RELDAT=$$GET1^DIQ(52,PSODA_",","31","I")
  1. I RELDAT'="" S PSOCSEQ("A",0)=$G(^PSRX(PSODA,"IB"))
  1. ;I RELDAT="" S PREA="R" D:'$G(PSOSI)&(PSOSCP<50)&($P($G(^PS(53,+$G(PTSTATUS),0)),"^",7)'=1) ACTLOG^PSOCPA G SET ;set act log when unreleased, but SC/EI changed copay
  1. I RELDAT="" S PREA="R" D:+$G(PSOCPAY)>0&(PSOIBQC[1&(PSOPIBQ'[1)) ACTLOG^PSOCPA G SET ;set act log when unreleased, but SC/EI changed copay
  1. ; get copay info for all released refills; if any
  1. F PSZ=0:0 S PSZ=$O(^PSRX(PSODA,1,PSZ)) Q:PSZ'>0 D
  1. . S RELDAT="",RELDAT=$$GET1^DIQ(52.1,PSZ_","_PSODA_",","17","I")
  1. . Q:RELDAT=""
  1. . S PSOCSEQ("A",PSZ)=$G(^PSRX(PSODA,1,PSZ,"IB"))
  1. ; Sort potential refills to be cancelled first starting with last fill
  1. ; then orig fill then the rest of the entries.
  1. S (PSZ1,PSZ2,PSZ)="" F S PSZ=$O(PSOCSEQ("A",PSZ),-1) Q:PSZ="" D
  1. . I PSZ>0&($P(PSOCSEQ("A",PSZ),"^",2)'="") S PSZ1=PSZ1+1,PSOCSEQ("B",PSZ1,PSZ)="" Q
  1. . I PSZ>0&($P(PSOCSEQ("A",PSZ),"^",2)="") S PSZ2=PSZ2+1000,PSOCSEQ("B",PSZ2,PSZ)="" Q
  1. . I PSZ=0&($P(PSOCSEQ("A",PSZ),"^",4)'="") S PSZ1=PSZ1+1,PSOCSEQ("B",PSZ1,PSZ)="" Q
  1. . I PSZ=0&($P(PSOCSEQ("A",PSZ),"^",4)="") S PSZ2=PSZ2+1000,PSOCSEQ("B",PSZ2,PSZ)="" Q
  1. ;
  1. ;S (PSZ,PSZ1)="",PSOFLD=0,PREA="R" D:'$G(PSOSI)&(PSOSCP<50)&($P($G(^PS(53,+$G(PTSTATUS),0)),"^",7)'=1) ACTLOG^PSOCPA F S PSZ1=$O(PSOCSEQ("B",PSZ1)) Q:PSZ1="" D
  1. S (PSZ,PSZ1)="",PSOFLD=0,PREA="R" D:+$G(PSOCPAY)>0&(PSOIBQC[1&(PSOPIBQ'[1)) ACTLOG^PSOCPA F S PSZ1=$O(PSOCSEQ("B",PSZ1)) Q:PSZ1="" D
  1. . F S PSZ=$O(PSOCSEQ("B",PSZ1,PSZ)) Q:PSZ="" D
  1. .. S (PSOREF,PSOIB)="",PSOFLD=PSOFLD+1 S PREA="C" ;$S(PSOFLD=1:"R",1:"C")
  1. .. ;I PSOFLD>1
  1. .. S (PSOOLD,PSONW)=""
  1. .. S PSOREF=PSZ
  1. .. ;
  1. .. S PSOPFS="",PSOPFS=$P($S('PSOREF:$G(^PSRX(PSODA,"PFS")),1:$G(^PSRX(PSODA,1,PSOREF,"PFS"))),"^",1,2)
  1. .. I +$G(PSOPFS)>0&('$P($G(PSOPFS),"^",2)) K PSOPFS Q ;don't send unreleased charge msg
  1. .. I +$G(PSOPFS)<1 K PSOPFS ;invalid PFSS ACCT REF/ SEND TO IB
  1. .. I +$G(PSOPFS)>0 S PSOPFS="1^"_PSOPFS
  1. .. ;
  1. .. N TYPE S PSOIB=PSOCSEQ("A",PSOREF),TYPE=PSOREF
  1. .. I +$G(PSOPFS) D CHRG^PSOPFSU1(PSODA,PSOREF,"CG",PSOPFS) D:+$G(PSOCPAY)>0&(PSOIBQC[1&(PSOPIBQ'[1)) ACTLOG^PSOCPA Q ;PFSS charge update only
  1. .. I PSOSCP<50 D RXED^PSOCPA ;IB - if SC<50 and not billed via PFSS
  1. SET S:$D(^PSRX(RXN,"IB"))&(PSOSCP<50)&('$G(PSOSI)) $P(^PSRX(RXN,"IB"),"^",1)=""
  1. K PSOSCP
  1. Q
  1. ;
  1. OBR ;Flag/Unflag orders
  1. I PSOTYPE'="OBR"!($G(PSOSEG)="") Q
  1. N PSOFLAG,PSORDER,PSOPEN,DR,PSOREA,PSOBY,PSONOW
  1. S PSORDER=+$P($P(PSOSEG,"|",2),"^") ; Pointer to ORDER file (#100)
  1. S PSOPEN=+$O(^PS(52.41,"B",PSORDER,0)) ; Pointer to PENDING OUTPATIENT ORDERS file (#52.41)
  1. S PSOFLAG=$P(PSOSEG,"|",4) ; "FL" for Flag and "UF" for Unflag action
  1. S PSOREA=$P(PSOSEG,"|",13) ; Reason for Flag/Unflag (Freetext up to 80chars)
  1. S PSOBY=$P(PSOSEG,"|",16) ; Flagged/Unflagged By - Pointer to NEW PERSON file (#200)
  1. S PSONOW=$E($$NOW^XLFDT(),1,12) ; CURRENT DATE/TIME wihtout seconds
  1. ;
  1. I 'PSOPEN!'$P($G(^PS(52.41,PSOPEN,0)),"^") D EN^ORERR("Invalid Pending Order/Flag Msg",.MSG) Q
  1. ;
  1. I PSOFLAG="FL" D
  1. . S $P(^PS(52.41,PSOPEN,"FLG"),"^",1,3)=PSONOW_"^"_PSOBY_"^"_$E(PSOREA,1,80)
  1. . S $P(^PS(52.41,PSOPEN,"FLG"),"^",4,6)="^^"
  1. . S $P(^PS(52.41,PSOPEN,0),"^",23)=1
  1. E D
  1. . S $P(^PS(52.41,PSOPEN,"FLG"),"^",4,6)=PSONOW_"^"_PSOBY_"^"_$E(PSOREA,1,80)
  1. . S $P(^PS(52.41,PSOPEN,0),"^",23)=""
  1. ;
  1. Q