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

PSOPOS12.m

Go to the documentation of this file.
  1. PSOPOS12 ;VRN/MFR - Patient Merge Clean-up ;10/17/03
  1. ;;7.0;OUTPATIENT PHARMACY;**154**;DEC 1997
  1. ;
  1. ;External reference to ^OR(100 supported by DBIA 3582
  1. ;External reference to ^OR(100 supported by DBIA 3463
  1. ;External reference to ^PS(55 supported by DBIA 2228
  1. ;External reference to GET1^DIQ supported by DBIA 2056
  1. ;External reference to ^XMD supported by DBIA 10070
  1. ;
  1. FIX(OLDDFN,NEWDFN) ; Fix problems caused by Patient Merge
  1. N DIE,DA,DR,EXPDT,RXIEN,ORIEN,RXST,ORST,RXSTN,ORSTN,COMM
  1. ;
  1. S EXPDT=0 F S EXPDT=$O(^PS(55,NEWDFN,"P","A",EXPDT)) Q:'EXPDT D
  1. . S RXIEN=0 F S RXIEN=$O(^PS(55,NEWDFN,"P","A",EXPDT,RXIEN)) Q:'RXIEN D
  1. . . I '$D(^PSRX(RXIEN,0)) Q
  1. . . I $P($G(^PSRX(RXIEN,0)),"^",2)=NEWDFN Q
  1. . . S DIE=52,DA=RXIEN,DR="2///"_NEWDFN D ^DIE
  1. . . S ORIEN=$P($G(^PSRX(RXIEN,"OR1")),"^",2) Q:'ORIEN
  1. . . S RXST=+$G(^PSRX(RXIEN,"STA"))
  1. . . S RXSTN=$$GET1^DIQ(52,RXIEN,100),ORSTN=$$GET1^DIQ(100,ORIEN,5)
  1. . . I $E(RXSTN,1,10)=$E(ORSTN,1,10) Q
  1. . . I RXST'=11,RXST'=12,RXST'=14,RXST'=15 Q
  1. . . S STCNT=$G(STCNT)+1
  1. . . I RXST=11 D EXP
  1. . . D DSC
  1. ;
  1. K OLDDFN,NEWDFN
  1. Q
  1. ;
  1. EXP ; Sets CPRS order status to EXPIRED
  1. I $P(^PSRX(RXIEN,0),"^",19)=2 S $P(^PSRX(RXIEN,0),"^",19)=1
  1. S COMM="Prescription past expiration date"
  1. D EN^PSOHLSN1(RXIEN,"SC","ZE",COMM)
  1. I $D(^OR(100,ORIEN,3)) S $P(^OR(100,ORIEN,3),"^")=EXPDT
  1. Q
  1. ;
  1. DSC ; Sets CPRS order status to DISCONTINUED
  1. N ACTLOG,LSTACT,PHARM,ACTDT,RSN,ACT0,ACTCOM,SAVEDUZ,NACT
  1. ;
  1. S (ACTLOG,LSTACT,PHARM,ACTDT)=0
  1. F S ACTLOG=$O(^PSRX(RXIEN,"A",ACTLOG)) Q:'ACTLOG D
  1. . S RSN=$P($G(^PSRX(RXIEN,"A",ACTLOG,0)),"^",2)
  1. . I RSN="C"!(RSN="L") S LSTACT=ACTLOG
  1. I 'LSTACT S COMM="Discontinued by Pharmacy",NACT=""
  1. I LSTACT S ACT0=$G(^PSRX(RXIEN,"A",LSTACT,0)) D
  1. . S PHARM=$P(ACT0,"^",3),ACTCOM=$P(ACT0,"^",5)
  1. . S ACTDT=$P(ACT0,"^"),(NACT,COMM)=""
  1. . I ACTCOM["Renewed" D
  1. . . S COMM="Renewed by Pharmacy"
  1. . I ACTCOM["Auto Discontinued" D
  1. . . S PHARM="",NACT="A",COMM=$E($P(ACTCOM,".",2),2,99)
  1. . . S:COMM="" COMM=ACTCOM
  1. . I ACTCOM["Discontinued During" D
  1. . . S COMM="Discontinued by Pharmacy"
  1. S SAVEDUZ=$G(DUZ) S:$G(PHARM) DUZ=PHARM
  1. D EN^PSOHLSN1(RXIEN,"OD",$S(RXST=15:"RP",1:""),COMM,NACT)
  1. S DUZ=SAVEDUZ W "."
  1. I '$G(ACTDT) S ACTDT=DT_".2200"
  1. I $D(^OR(100,ORIEN,3)) S $P(^OR(100,ORIEN,3),"^")=$E(ACTDT,1,12)
  1. I $D(^OR(100,ORIEN,6)) S $P(^OR(100,ORIEN,6),"^",3)=$E(ACTDT,1,12)
  1. ;
  1. Q