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

APSPESLR.m

Go to the documentation of this file.
APSPESLR ;IHS/BWF - Report for APSP REFILL REQUEST file ;14-Oct-2009 14:53;SM
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1008**;Sep 23,2004
EN ; -- main entry point for APSP LM REFILL REQUEST
 N SRCHSEL,APSPPOP,DONE
 S APSPPOP=0
 K ^XTMP("APSPESLR",$J)
 D FULL^VALM1
 S SRCHSEL=$$DIR^APSPUTIL("SO^D:Date Range;P:Patient Name;PR:Provider;S:Status","Search by",,.APSPPOP)
 I APSPPOP D BACK^APSPESLP Q
 S SCHLOGIC=$S(SRCHSEL="P":"PAT",SRCHSEL="PR":"PROV",SRCHSEL="S":"STAT",1:"DR") D @SCHLOGIC
 I '$D(^XTMP("APSPESLR",$J)) S DONE=$$DIR^APSPUTIL("FO","No data found, press <RETURN> to continue") D BACK^APSPESLP Q
 D EN^VALM("APSP LM REFREQ REPORT")
 K ^XTMP("APSPESLR",$J)
 Q
 ;
HDR ; -- header code
 Q
 ;
INIT ; -- init variables and list array
 N LINE,LDT,IEN
 S (LINE,VALMCNT)=0
 S LDT=0 F  S LDT=$O(^XTMP("APSPESLR",$J,LDT)) Q:'LDT  D
 .S IEN=0 F  S IEN=$O(^XTMP("APSPESLR",$J,LDT,IEN)) Q:'IEN  D
 ..S DAT=$G(^XTMP("APSPESLR",$J,LDT,IEN))
 ..S PATN=$P(DAT,U,2),DRUG=$P(DAT,U,6),PROV=$P(DAT,U,3),DATE=$P(DAT,U,4)
 ..S LINE=LINE+1,VALMCNT=VALMCNT+1
 ..S LINEVAR=""
 ..S LINEVAR=$$SETFLD^VALM1(LINE_".",LINEVAR,"ITEM")
 ..S LINEVAR=$$SETFLD^VALM1(PATN,LINEVAR,"PATIENT")
 ..S LINEVAR=$$SETFLD^VALM1(DRUG,LINEVAR,"DRUG")
 ..S LINEVAR=$$SETFLD^VALM1(PROV,LINEVAR,"PROV")
 ..S LINEVAR=$$SETFLD^VALM1(DATE,LINEVAR,"DATE")
 ..D SET^VALM10(LINE,LINEVAR,IEN)
 Q
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ; -- exit code
 D CLEAN^VALM10
 D FULL^VALM1
 K ^XTMP("APSPESLR",$J)
 ;D BACK^APSPESLP
 Q
 ;
EXPND ; -- expand code
 Q
DR ; date range
 N APSPPOP,START,END
 S APSPPOP=0
 D ASKDATES^APSPUTIL(.START,.END,.APSPPOP,,DT) Q:APSPPOP
 S LSTART=START-.01,LEND=END+.99
 F  S LSTART=$O(^APSPRREQ("D",LSTART)) Q:'LSTART!(LSTART>LEND)  D
 .S RRIEN=0 F  S RRIEN=$O(^APSPRREQ("D",LSTART,RRIEN)) Q:'RRIEN  D
 ..D ADDREC(RRIEN)
 Q
PAT ; patient name
 N APSPPOP,PAT,RRIEN
 S APSPPOP=0
 S PAT=$$DIR^APSPUTIL("9000001,.01","Select Patient",,,.APSPPOP) Q:APSPPOP
 S DFN=+PAT Q:'DFN
 S RRIEN=0 F  S RRIEN=$O(^APSPRREQ("E",DFN,RRIEN)) Q:'RRIEN  D
 .D ADDREC(RRIEN)
 Q
PHARM ; pharmacy
 N APSPPOP,PHARM,RRIEN,SPHARM
 S APSPPOP=0
 S PHARM=$$DIR^APSPUTIL("9009033.91,1.7","Select Pharmacy",,,.APSPPOP) Q:APSPPOP
 S SPHARM=+PHARM Q:'SPHARM
 S RRIEN=0 F  S RRIEN=$O(^APSPRREQ("APHM",SPHARM,RRIEN)) Q:'RRIEN  D
 .D ADDREC(RRIEN)
 Q
PROV ;
 N APSPPOP,PROV,RRIEN,SPROV
 S APSPPOP=0
 S PROV=$$DIR^APSPUTIL("9009033.91,1.3","Select Provider",,,.APSPPOP) Q:APSPPOP
 S SPROV=+PROV Q:'SPROV
 S RRIEN=0 F  S RRIEN=$O(^APSPRREQ("APRV",SPROV,RRIEN)) Q:'RRIEN  D
 .D ADDREC(RRIEN)
 Q
STAT ;
 N APSPPOP,STAT,RRIEN
 S APSPPOP=0
 S STAT=$$DIR^APSPUTIL("9009033.91,.03","Select Status",,,.APSPPOP) Q:APSPPOP
 I '$L(STAT) Q
 S RRIEN=0 F  S RRIEN=$O(^APSPRREQ("F",STAT,RRIEN)) Q:'RRIEN  D
 .D ADDREC(RRIEN)
 Q
ADDREC(IEN) ;
 N DATA,F,IENS,MSGID,MSGDTM,MSGPRV,MSGSTAT,MSGPAT,MSGDRUG,MSGPHARM
 S F=9009033.91,IENS=IEN_","
 D GETS^DIQ(9009033.91,IEN,"**","IE","DATA")
 ; get some variables and have fun
 S MSGID=$G(DATA(F,IENS,.01,"E"))
 S MSGIDTM=$G(DATA(F,IENS,.04,"I")) I 'MSGIDTM Q
 S MSGDTM=$$FMTE^XLFDT($P($G(DATA(F,IENS,.04,"E")),"."),"5Z")
 S MSGPRV=$G(DATA(F,IENS,1.3,"E"))
 S MSGSTAT=$G(DATA(F,IENS,.03,"E"))
 S MSGPAT=$G(DATA(F,IENS,1.2,"E"))
 S MSGDRUG=$G(DATA(F,IENS,1.1,"E"))
 S MSGPHARM=$G(DATA(F,IENS,1.7,"E"))
 S MSGORD=$G(DATA(F,IENS,1.1,"I"))
 S ^XTMP("APSPESLR",$J,MSGIDTM,IEN)=MSGID_U_MSGPAT_U_MSGPRV_U_MSGDTM_U_MSGSTAT_U_MSGDRUG_U_MSGPHARM_U_MSGORD
 Q
 ; prompt for item and display pertinent information to the user.
VIEW ;
 N IEN,SSRTEXT,LINE,DONE
 S IEN=$$SELITEM^APSPESLP()
 I 'IEN D BACK Q
 D PREPPTXT("SSRTEXT",IEN)
 D FULL^VALM1
 I $D(SSRTEXT) D
 .S $P(LINE,"-",80)="" W !,LINE,!,"Displaying order information:",!,"-----------------------------",!
 .D FULL^VALM1
 .S I=0 F  S I=$O(SSRTEXT(I)) Q:'I  W !,SSRTEXT(I)
 .W !,LINE
 S DONE=$$DIRYN^APSPUTIL("Press Return to continue")
 D BACK
 Q
PREPPTXT(RET,RRIEN) ;
 N SIGNODE,SIG
 S RRIEN=$G(RRIEN,0)
 S SIGNODE=$O(^APSPRREQ(RRIEN,3,0)) I 'SIGNODE S SIG=""
 I SIGNODE S SIG=$G(^APSPRREQ(RRIEN,3,SIGNODE,0))
 S @RET@(1)="Pharmacy: "_$$GET1^DIQ(9009033.91,RRIEN,1.7,"E")
 S @RET@(2)="Drug description: "_$$GET1^DIQ(9009033.91,RRIEN,1.1,"E")
 S @RET@(3)="Quantity: "_$$GET1^DIQ(9009033.91,RRIEN,1.4,"E")
 S @RET@(4)="Days Supply: "_$$GET1^DIQ(9009033.91,RRIEN,1.5,"E")
 S @RET@(5)="Sig-Directions: "_$G(SIG)
 S @RET@(6)="Provider: "_$$GET1^DIQ(9009033.91,RRIEN,1.3,"E")
 S @RET@(7)="Status: "_$$GET1^DIQ(9009033.91,RRIEN,.03,"E")
 S @RET@(8)="Last Updated: "_$$FMTE^XLFDT($$GET1^DIQ(9009033.91,RRIEN,.07,"I"),"5Z")
 S @RET@(9)="OE/RR Order #: "_$$GET1^DIQ(9009033.91,RRIEN,.02,"E")
 S @RET@(10)="Patient: "_$$GET1^DIQ(9009033.91,RRIEN,1.2,"E")
 Q
BACK ;
 S VALMBCK="R" D INIT Q
 Q