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

PSOUTOR1.m

Go to the documentation of this file.
  1. PSOUTOR1 ;HPS/DSK - MEDICATION ORDER STATUS CHECK AGAINST ORDERS (#100) FILE ;NOV. 9,2018@16:00
  1. ;;7.0;OUTPATIENT PHARMACY;**546**;DEC 1997;Build 23
  1. ;
  1. Q
  1. ;
  1. ;Continuation of PSOUTOR
  1. ;
  1. ;;Reference to SENDMSG^XMXAPI supported by IA #2729
  1. ;
  1. MAIL() ;
  1. N PSOMES,PSOSUB,PSOMIN,PSOTEXT,PSOMZ,PSOX,Y,PSOMY
  1. ;
  1. ;kill ^TMP in case somehow it exists after previously running the option
  1. S PSOMES="PSOUTOR "_$J
  1. K ^TMP(PSOMES)
  1. S PSOSUB="Medication File Search Finished"
  1. S PSOMIN("FROM")="PSO ORDER STATUS MISMATCH SEARCH ROUTINE"
  1. S PSOMY(PSODUZ)=""
  1. S PSOTEXT="^TMP("""_PSOMES_""")"
  1. S ^TMP(PSOMES,1)=" "
  1. S ^TMP(PSOMES,2)="SUMMARY"
  1. S ^TMP(PSOMES,3)="======="
  1. S ^TMP(PSOMES,4)=" "
  1. S ^TMP(PSOMES,5)="Search of:"
  1. S ^TMP(PSOMES,6)=PSOAR(PSOTYP)
  1. I PSOTYP="ION" S ^TMP(PSOMES,6)=^TMP(PSOMES,6)_" - Inpatient, Outpatient, and Non-VA - "
  1. S ^TMP(PSOMES,6)=^TMP(PSOMES,6)_" Medication File(s)"
  1. S Y=PSOSTART X ^DD("DD") S ^TMP(PSOMES,7)="from "_Y_" to "
  1. S Y=PSOEDT-1 X ^DD("DD") S ^TMP(PSOMES,7)=^TMP(PSOMES,7)_Y
  1. S ^TMP(PSOMES,8)="The order"_$S(PSOA=1:" was ",1:"s were ")_$S(PSOCORR:"",1:"*** NOT *** ")_"corrected at user's request."
  1. S ^TMP(PSOMES,9)=" "
  1. S ^TMP(PSOMES,10)="Orders should be reviewed to confirm if it is appropriate for their statuses"
  1. S ^TMP(PSOMES,11)="to be matched. The report should then be rerun with the prompt ""Should the"
  1. S ^TMP(PSOMES,12)="status in the ORDERS (#100) file be corrected automatically? NO//"" answered"
  1. S ^TMP(PSOMES,13)="""YES"" to have the corrections made."
  1. S ^TMP(PSOMES,14)=" "
  1. S ^TMP(PSOMES,15)="Search performed was for orders with a status mismatch where the ORDERS (#100)"
  1. S ^TMP(PSOMES,16)="file status is active but the status is expired or discontinued in the"
  1. S ^TMP(PSOMES,17)="PHARMACY PATIENT (#55) or PRESCRIPTION (#52) file."
  1. S ^TMP(PSOMES,18)=" "
  1. S ^TMP(PSOMES,19)="The orders are listed in a separate section below."
  1. S ^TMP(PSOMES,20)="The list of affected order(s) is also stored in the global"
  1. S ^TMP(PSOMES,21)="^XTMP("""_PSOTMP_""" for 60 days."
  1. S ^TMP(PSOMES,22)=" "
  1. S ^TMP(PSOMES,23)="Associated documentation can be found in:"
  1. S ^TMP(PSOMES,24)="Chapter 27 of the Outpatient Pharmacy (PSO) Manager's User Manual."
  1. D DETAIL
  1. D SENDMSG^XMXAPI(PSODUZ,PSOSUB,PSOTEXT,.PSOMY,.PSOMIN,.PSOMZ,"")
  1. K ^TMP(PSOMES)
  1. Q PSOMZ
  1. ;
  1. DETAIL ;
  1. N PSODASH,PSOSTR,PSODATA,PSOSPACE,PSOY,PSOZ
  1. S PSODASH="-----------------------------------------------------------------"
  1. S PSOSPACE=" "
  1. S ^TMP(PSOMES,25)=" "
  1. S ^TMP(PSOMES,26)="Detail: ORDERS (#100) File Active / Medication File Not Active"
  1. S ^TMP(PSOMES,27)="=============================================================="
  1. S ^TMP(PSOMES,28)=" "
  1. S ^TMP(PSOMES,29)=$S('PSOA:"No",1:"** "_PSOA_" **")_" mismatches found."
  1. S PSOX=29
  1. Q:'PSOA
  1. ;kill "no issues found" subscript in case research is performed later on ^XMTP
  1. K ^XTMP(PSOTMP,"A",1)
  1. S PSOY=""
  1. F S PSOY=$O(^XTMP(PSOTMP,"A",PSOY)) Q:PSOY="" D
  1. . S PSOX=PSOX+1
  1. . S ^TMP(PSOMES,PSOX)=" "
  1. . S PSOX=PSOX+1
  1. . S ^TMP(PSOMES,PSOX)="Type: "_PSOY
  1. . D SECTION
  1. . S PSOZ=""
  1. . F S PSOZ=$O(^XTMP(PSOTMP,"A",PSOY,PSOZ)) Q:PSOZ="" D
  1. . . S PSOX=PSOX+1,PSOSTR=^XTMP(PSOTMP,"A",PSOY,PSOZ)
  1. . . D PSOZ
  1. Q
  1. ;
  1. SECTION ;
  1. S PSOX=PSOX+1
  1. S ^TMP(PSOMES,PSOX)="ORDERS Number Date/Time Ordered ORDERABLE ITEM Status Pkg Ref"
  1. S PSOX=PSOX+1
  1. S ^TMP(PSOMES,PSOX)=$S(PSOY["Out":"Rx IEN ",PSOY[">":"Med IEN",1:"#55 IEN")
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_" "_$S(PSOY["VA":"Documented Date ",PSOY["Out":"Issue Date ",PSOY[">":"Issue / Start Dt. ",1:"Start Date ")
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_" DRUG Status "_$S(PSOY["VA":"DC Date",1:"Exp. Date")
  1. S PSOX=PSOX+1
  1. S ^TMP(PSOMES,PSOX)=$E(PSODASH,1,13)_" "_$E(PSODASH,1,18)_" "_$E(PSODASH,1,14)_" "_$E(PSODASH,1,9)_" "_$E(PSODASH,1,18)
  1. Q
  1. ;
  1. PSOZ ;
  1. ;blank line for ease of readability
  1. S ^TMP(PSOMES,PSOX)=" ",PSOX=PSOX+1
  1. ;CPRS ordered date/time
  1. S PSODATA=$P(PSOSTR,"^",2)
  1. S ^TMP(PSOMES,PSOX)=PSOZ_$E(PSOSPACE,1,14-$L(PSOZ))_PSODATA_$E(PSOSPACE,1,19-$L(PSODATA))
  1. ;Orders (#100) file orderable item
  1. S PSODATA=$E($P(PSOSTR,"^",3),1,14)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA_$E(PSOSPACE,1,15-$L(PSODATA))
  1. ;Orders (#100) order status
  1. S PSODATA=$P(PSOSTR,"^",4),PSODATA=$S($E(PSODATA)="D":$E(PSODATA,1,7)_".",1:PSODATA)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA_$E(PSOSPACE,1,10-$L(PSODATA))
  1. ;Orders (#100) package reference
  1. S PSODATA=$P(PSOSTR,"^",5)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA
  1. S PSOX=PSOX+1
  1. ;Display package reference again except in the second line it also equals
  1. ;the Outpatient Rx# or the file 55 ien
  1. S ^TMP(PSOMES,PSOX)=PSODATA_$E(PSOSPACE,1,14-$L(PSODATA))
  1. ;Start date if UD or IV, Issue date if Outpatient, or documented date for Non-VA med
  1. S PSODATA=$P($P(PSOSTR,"^",6),":",1,2)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA_$E(PSOSPACE,1,19-$L(PSODATA))
  1. ;Drug
  1. S PSODATA=$P(PSOSTR,"^",7),PSODATA=$E(PSODATA,1,14)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA_$E(PSOSPACE,1,15-$L(PSODATA))
  1. ;Rx status (Abbreviate if discontinued.)
  1. S PSODATA=$P(PSOSTR,"^",8),PSODATA=$S(PSODATA["Death":PSODATA,$E(PSODATA)="D":$E(PSODATA,1,7)_".",1:PSODATA)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA_$E(PSOSPACE,1,10-$L(PSODATA))
  1. ;Discontinue or stop date
  1. S PSODATA=$P($P(PSOSTR,"^",9),":",1,2)
  1. S ^TMP(PSOMES,PSOX)=^TMP(PSOMES,PSOX)_PSODATA
  1. Q
  1. ;