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

APSPESG2.m

Go to the documentation of this file.
APSPESG2 ;IHS/MSC/PLS - SureScripts Refill Request;30-Jul-2013 18:59;DU
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1016**;Sep 23, 2004;Build 40
 Q
 ;
LOADRSP(LST,IEN) ;EP to return data
 N ROOT,CHKDOSE,DOSE,INST,ILST,I,ID,DLG,VAL,J,LIST
 K LST
 I '$D(^APSPRREQ(IEN,4.5)) D
 .D DLGDEF^ORWDX1(.LIST,"PSO OERR")
 .S I=0 F  S I=$O(LIST(I)) Q:'I  D
 ..I $P(LIST(I),U)="ORDERABLE" D
 ...N ITM
 ...S DLG=$P(LIST(I),U,2)
 ...S ITM=$$GET1^DIQ(9009033.91,IEN,1.1,"I")
 ...S LST(1)="~"_DLG_U_1_U_"ORDERABLE"
 ...S LST(2)="i"_ITM,LST(3)="e"_$$GET1^DIQ(101.43,ITM,.01)
 .;ADDED FROM PREVIOUS
 .N ITEM,OI,EXT,INT,DATA
 .S ILST=0
 .D DLGDEF^ORWDX1(.LIST,"PSO OERR")
 .D GETS^DIQ(9009033.91,IEN,".01:1.9;2*;3*;4.1;7.1","E","EXT")
 .D GETS^DIQ(9009033.91,IEN,".01:1.9;2*;3*;4.1;7.1","I","INT")
 .S ITEM="" F  S ITEM=$O(LIST(ITEM)) Q:'+ITEM  D
 ..S DATA=$G(LIST(ITEM))
 ..Q:DATA=""
 ..S DLG=$P(DATA,U,2),INST=1,ID=$P(DATA,U,1)
 ..I ID="ORDERABLE" D GET(1.1,DLG,INST,ID)
 ..I ID="START" D NEW(DLG,INST,ID),VAL(0,0)
 ..I ID="URGENCY" D NEW(DLG,INST,ID),VAL(9,"ROUTINE")
 ..;I ID="DRUG" D GET(1.8,DLG,INST,ID)
 ..I ID="PICKUP" D NEW(DLG,INST,ID) D
 ...I $$ERXOI^APSPFNC6($$GET1^DIQ(9009033.91,IEN,1.1,"I"),2) D
 ....D VAL("P","PRINT")
 ...E  D VAL("E","ELECTRONIC")
 ..I ID="QTY" D GET(1.4,DLG,INST,ID)
 ..I ID="REFILLS" D GET(1.9,DLG,INST,ID)
 ..I ID="SCHEDULE" D SUB(1.8,DLG,INST,ID)
 ..I ID="INSTR" D INSTR(DLG,INST,ID)
 ..I ID="ROUTE" D SUB(1.7,DLG,INST,ID)
 ..I ID="DAW" D GET(1.12,DLG,INST,ID)
 ..;I ID="DAYS" D SUB(4,DLG,INST,ID)
 ..;I ID="CLININD" D NEW(DLG,INST,ID)
 ..I ID="CLININD" D GET(7.1,DLG,INST,ID)
 ..I ID="CLININD2" D NEW(DLG,INST,ID)
 ..I ID="SNMDCNPTID" D NEW(DLG,INST,ID)
 ..I ID="SSREQIEN" D NEW(DLG,INST,ID),VAL(IEN,IEN)
 ..I ID="SSDENYRSN" D NEW(DLG,INST,ID)
 ..;I ID="PHARMACY",'$$ERXOI^APSPFNC6($$GET1^DIQ(9009033.91,IEN,1.1,"I"),2) D GET(1.7,DLG,INST,ID)
 ..I ID="PHARMACY" D GET(1.7,DLG,INST,ID)
 ..I ID="STRENGTH" D NEW(DLG,INST,ID)
 ..I ID="SIG" D SUB2(DLG,INST,ID)
 ..I ID="CONJ" D SUB(1.6,DLG,INST,ID)
 ..I ID="SUPPLY" D GET(1.5,DLG,INST,ID)
 ..I ID="CMF" D NEW(DLG,INST,ID)
 ..I ID="DOSE" D DOSE(DLG,INST,ID)
 ..;I ID="PI" D PI(4.1,DLG,INST,ID)
 ..I ID="COMMENT" D NP(4.1,DLG,INST,ID)
 E  D
 .S ROOT="^APSPRREQ("_+IEN_",4.5)"
 .S (ILST,I)=0,CHKDOSE=$$CHKDOSES^ORWDX2()
 .F  S I=$O(@ROOT@(I)) Q:I'>0  D
 ..S DLG=$P(@ROOT@(I,0),U,2),INST=$P(^(0),U,3)
 ..S ID=$P($G(^ORD(101.41,DLG,1)),U,3)
 ..I '$L(ID) S ID="ID"_DLG
 ..S VAL=$G(@ROOT@(I,1))
 ..I $P($G(^ORD(101.41,DLG,0)),U)="OR GTX ADDITIVE" S ID="ADDITIVE"
 ..S LST($$NXT)="~"_DLG_U_INST_U_ID
 ..I $L(VAL) D
 ...S LST($$NXT)="i"_VAL,LST($$NXT)="e"_$$EXTVAL^ORWDX2(VAL,DLG)
 ...I CHKDOSE D DOSEINFO^ORWDX2
 ..I $D(@ROOT@(I,2))>1 D
 ...S J=0 F  S J=$O(@ROOT@(I,2,J)) Q:J'>0  D
 ....S LST($$NXT())="t"_$G(@ROOT@(I,2,J,0))
 .I CHKDOSE D FIXDOSES^ORWDX2
 Q
NEW(DLG,INST,ID) ;
 S LST($$NXT)="~"_DLG_U_INST_U_ID
 Q
VAL(IVAL,EVAL) ;
 I $L(IVAL) D
 .S LST($$NXT)="i"_IVAL,LST($$NXT)="e"_EVAL
 Q
PI(FIELD,DLG,INST,ID) ;
 N I,E
 D NEW(DLG,INST,ID)
 S I=$G(^APSPRREQ(IEN,FIELD))
 S E=I
 D VAL(I,E)
 Q
NP(FIELD,DLG,INST,ID) ;
 N I,E
 D NEW(DLG,INST,ID)
 S I=$G(^APSPRREQ(IEN,FIELD))
 S E=I
 D VAL(I,E)
 Q
GET(FIELD,DLG,INST,ID) ;
 N I,E
 D NEW(DLG,INST,ID)
 S I=$G(INT(9009033.91,IEN_",",FIELD,"I"))
 S E=$G(EXT(9009033.91,IEN_",",FIELD,"E"))
 I FIELD=1.9 D
 .S I=$S(I>0:I-1,1:0),E=$S(E>0:E-1,1:0)
 D VAL(I,E)
 Q
SUB(SFIELD,DLG,INST,ID) ;
 N I,E,IENS,AIEN
 S IENS=0 F  S IENS=$O(^APSPRREQ(IEN,2,IENS)) Q:'+IENS  D
 .D NEW(DLG,IENS,ID)
 .S AIEN=IENS_","_IEN_","
 .S I=$G(INT(9009033.912,AIEN,SFIELD,"I"))
 .S E=$G(EXT(9009033.912,AIEN,SFIELD,"E"))
 .D VAL(I,E)
 Q
INSTR(DLG,INST,ID) ;Do instr
 N I,E,IENS,AIEN
 S IENS=0 F  S IENS=$O(^APSPRREQ(IEN,2,IENS)) Q:'+IENS  D
 .D NEW(DLG,IENS,ID)
 .S I=$P($G(^APSPRREQ(IEN,2,IENS,0)),"&",5)
 .S E=$P($G(^APSPRREQ(IEN,2,IENS,0)),"&",5)
 .D VAL(I,E)
SUB2(DLG,INST,ID) ; Do sig
 N SIG
 D NEW(DLG,INST,ID)
 S SIG=0 F  S SIG=$O(^APSPRREQ(IEN,3,SIG)) Q:'+SIG  D
 .S LST($$NXT)="t"_$G(^APSPRREQ(IEN,3,SIG,0))
 Q
DOSE(DLG,INST,ID) ;Do dosing
 N CHKDOSE,INSTR,DOSE,PSOI,DFN,CONJ,ORWDOSES,IENS
 S DFN=$G(INT(9009033.91,IEN_",",1.2,"I"))
 S FIELD=1.1
 S OI=$G(INT(9009033.91,IEN_",",FIELD,"I"))
 S PSOI=+$P($G(^ORD(101.43,OI,0)),U,2)
 S IENS=0 F  S IENS=$O(^APSPRREQ(IEN,2,IENS)) Q:IENS=""  D
 .D NEW(DLG,IENS,ID)
 .S I=$G(^APSPRREQ(IEN,2,IENS,0))
 .S E=$G(^APSPRREQ(IEN,2,IENS,0))
 .D VAL(I,E)
 ;D DOSE^PSSORUTL(.ORDOSE,PSOI,"O",DFN)
 ;S CONJ=$P($G(ORDOSE("MISC")),U,3),ORWDOSES=0
 ;S:$L(CONJ) CONJ=" "_CONJ_" " S:'$L(CONJ) CONJ=" "
 ;S I=0 F  S I=$O(ORDOSE(I)) Q:I'>0  D
 ;. S X=$$BLDDOSE^ORWDPS2(ORDOSE(I))
 ;. S ILST=ILST+1
 ;. S LST(ILST)="i"_$P(X,U,5)_U_$P($P(X,U,4),"&",6)_U_$P(X,U,4)
 ;. S J=0 F  S J=$O(ORDOSE(I,J)) Q:J'>0  D
 ;. . S X=$$BLDDOSE^ORWDPS2(ORDOSE(I,J))
 ;. . S ILST=ILST+1
 ;. . S LST(ILST)="i"_$P(X,U,5)_U_$P($P(X,U,4),"&",6)_U_$P(X,U,4)
 Q
 ;
NXT() ; -- Gets index in array
 S ILST=ILST+1
 Q ILST
 ;
 ;Input parameters
 ;IEN=Internal number from APAP REFILL REQUEST file
 ;DFN=Patient IEN
 ;ORNP=Provider IEN
 ;ORL=IEN of location
 ;DLG=Defaults to PSO OERR
 ;STAT=Interval value of status
 ; 2        PROCESSED - ACCEPTED
 ; 3        PROCESSED - DENIED
 ; 5        PROCESSED - DENIED (NEW RX)
 ;LIST=Array of pieces to store similar to ORWDX SAVE
 ;REASON=Reason for denial
UPDATE(REC,IEN,DFN,ORNP,ORL,STAT,LIST,REASON,DLG) ;EP-
 N IFN,ORDIALOG,ERR,NAME,FLD,FLD2,SUB
 S REC=""
 S DLG=$G(DLG,"PSO OERR")
 S IFN=$O(^ORD(101.41,"B",DLG,""))
 Q:'IFN
 M ORDIALOG=LIST
 D GETDLG1^ORCD(IFN)
 S:STAT>-1 FDA(9009033.91,IEN_",",.03)=STAT
 S FDA(9009033.91,IEN_",",.07)=$$NOW^XLFDT
 S:DFN FDA(9009033.91,IEN_",",1.2)=DFN
 S:ORNP FDA(9009033.91,IEN_",",1.3)=ORNP
 S:ORL FDA(9009033.91,IEN_",",1.6)=ORL
 S:$L($G(REASON)) FDA(9009033.91,IEN_",",4)=$G(REASON)
 D RESPUPD(.ORDIALOG)
 S FLD="" F  S FLD=$O(ORDIALOG(FLD)) Q:FLD=""  D
 .S FLD2=+FLD
 .I $D(ORDIALOG(FLD)) D
 ..S NAME=$P($G(ORDIALOG(FLD2)),U,2)
 ..I NAME="ORDERABLE" D TOP(1.1) Q
 ..I NAME="QTY" D TOP(1.4) Q
 ..I NAME="DRUG" D TOP(1.8) Q
 ..I NAME="SUPPLY" D TOP(1.5) Q
 ..I NAME="DAW" D TOP(1.12) Q
 ..I NAME="PHARMACY" D TOP(1.7) Q
 ..I NAME="REFILLS" D FILL(1.9) Q
 ..I NAME="CLININD" D TOP(7.1) Q
 ..I NAME="CLININD2" D TOP(7.2) Q
 ..I NAME="SNMDCNPTID" D TOP(7.3) Q
 ..;I NAME="PI" D TOP(4.1) Q
 ..I NAME="PI" D PI2(FLD,1) Q
 ..S SUB="" F  S SUB=$O(LIST(FLD,SUB)) Q:SUB=""  D
 ...I NAME="ROUTE" D SUBFLD(1.7,SUB)
 ...I NAME="SCHEDULE" D SUBFLD(1.8,SUB)
 ...I NAME="DOSE" D DOSAGE(SUB)
 ...I NAME="SIG" D SIG(SUB)
 ;When all finished file the data
 D FILE^DIE("","FDA","ERR")
 I $D(ERR)>0 S REC="0^Unable to Update Record" Q
 E  S REC=1
 K FDA,ERR
 Q
 ;Place responses into multiple
RESPUPD(ORDIALOG) ;EP- Copied from RESPONSE^ORCSAVE
 N CNT,PROMPT,ITM,TYPE,VALUE
 K ^APSPRREQ(IEN,4.5)
 S (PROMPT,CNT)=0 F  S PROMPT=$O(ORDIALOG(PROMPT)) Q:PROMPT'>0  D
 .S ITM=$G(ORDIALOG(PROMPT)) Q:'ITM
 .S TYPE=$E($G(ORDIALOG(PROMPT,0))) Q:'$L(TYPE)
 .S INST=0 F  S INST=$O(ORDIALOG(PROMPT,INST)) Q:INST'>0  D
 ..S VALUE=$G(ORDIALOG(PROMPT,INST)) Q:VALUE=""  S CNT=CNT+1
 ..S ^APSPRREQ(IEN,4.5,CNT,0)=+ITM_U_PROMPT_U_INST_U_$P(ITM,U,2)
 ..S:$L($P(ITM,U,2)) ^APSPRREQ(IEN,4.5,"ID",$P(ITM,U,2),CNT)=""
 ..I VALUE<1,TYPE="N" S VALUE=0_+VALUE I VALUE="00" S VALUE=0
 ..S:TYPE'="W" ^APSPRREQ(IEN,4.5,CNT,1)=VALUE
 ..M:TYPE="W" ^APSPRREQ(IEN,4.5,CNT,2)=@VALUE  ; array root
 S ^APSPRREQ(IEN,4.5,0)="^9009033.913A^"_CNT_U_CNT
 Q
TOP(FIELD) ;Set top fields for update
 N DATA
 S DATA=$G(LIST(FLD,"1"))
 S FDA(9009033.91,IEN_",",FIELD)=DATA
 Q
FILL(FIELD) ;Set refills
 ;Set sub fields for update
 N DATA
 S DATA=$G(LIST(FLD,"1"))+1
 S FDA(9009033.91,IEN_",",FIELD)=DATA
 Q
SUBFLD(FIELD,SUB) N DATA,AIEN
 S AIEN=+SUB_","_IEN_","
 S DATA=$G(LIST(FLD,SUB))
 S FDA(9009033.912,AIEN,FIELD)=DATA
 Q
DOSAGE(SUB) ;Set dose fields
 N DATA,AIEN,UNITS,UIEN
 S DATA=$G(LIST(FLD,SUB))
 S AIEN=+SUB_","_IEN_","
 S FDA(9009033.912,AIEN,.01)=DATA
 S FDA(9009033.912,AIEN,1.1)=$P(DATA,"&",1)
 S FDA(9009033.912,AIEN,1.2)=$P(DATA,"&",3)
 S UNITS=$P(DATA,"&",2)
 I UNITS'="" D
 .S UIEN="" S UIEN=$O(^PS(50.607,"B",UNITS,UIEN))
 .I +UIEN S FDA(9009033.912,AIEN,1.3)=UIEN
 S FDA(9009033.912,AIEN,1.4)=$P(DATA,"&",4)
 S FDA(9009033.912,AIEN,1.9)="TAKE"
 Q
SIG(SUB) ;Get sig segment
 N X,DATA,ARRAY,CNT,DA,DIK,ERR,FDA2
 S CNT=0
 S DATA=$G(LIST(FLD,SUB))
 S X=9009033.913 D DELSF(X,+IEN_",")
 S X=0 S X=$O(LIST("WP",FLD,SUB,X)) Q:X=""  D
 .S AIEN="+1,"_IEN_","
 .S FDA2(9009033.913,AIEN,.01)=$G(LIST("WP",FLD,SUB,X,0))
 D UPDATE^DIE(,"FDA2","AIEN","ERR")
 I $D(ERR)>0 S REC="0^Unable to update sig"
 Q
PI2(FLD,SUB) ;EP-
 N X,DATA,TXT
 S DATA=$G(LIST(FLD,SUB))
 S TXT=""
 S X=0 S X=$O(LIST("WP",FLD,SUB,X)) Q:X=""  D
 .S TXT=TXT_$G(LIST("WP",FLD,SUB,X,0))
 S FDA(9009033.91,IEN_",",4.1)=TXT
 Q
DELSF(SFN,IEN) ;
 N DIK,DA,LP,GBL,IEN2
 S IEN2=","_IEN,DIK=$$ROOT^DILFD(SFN,IEN2),GBL=$$ROOT^DILFD(SFN,IEN2,1),DA=0
 F  S DA=$O(@GBL@(DA)),DA(1)=+IEN Q:'DA  D ^DIK
 Q
 ; Process a mapped SureScripts Refill Request
PROCESS(DATA,IEN) ;EP-
 S DATA=$$CREATE(IEN)
 Q
 ;
CREATE(ITEM) ; Create new OE/RR order
 N HLMSG,APSPMSH,APSPPID,APSPORC,APSPRXO,APSPRXE,IEN,IENS,ID,IDIEN,DAT,DFN,PROV,UNITS,NOUN
 N DUR,CONJ,VERB,SIGNOD,INSTNOD,SIG,DUPD,X,Z,ORDIALOG,NORIFN,ORVP,DIALOG,ORNP,STATUS,APSPRXO
 N APSPRXE,APSPRXR,APSPORC,APSPPID,DIEN,IDIEN,DUOUT,FIL2,FIL3,FIL,LIST,LOC,ROUTE,CNT,DIR,PHARM
 N CLININD,OPSIEN,SSRTEXT,DAW,MISLIST,REFIL,HLDATA,DAW,SNMDCID
 N DATA,DRUG,FCNT,NOD0,NOD1,TXT,NSSRTXT
 S FIL=9009033.91,FIL2=9009033.912,FIL3=9009033.913
 ; set up hl7 variables
 S NOD0=$G(^APSPRREQ(ITEM,0))
 S NOD1=$G(^APSPRREQ(ITEM,1))
 Q:(NOD0="")!(NOD1="") "1 ^Entry not available"
 S HLMSG=$$GHLDAT(ITEM) D SHLVARS
 ; get data from APSP REFILL REQUESTS FILE
 D PREPPTXT^APSPES2("PTXT",ITEM)
 D GETS^DIQ(FIL,ITEM,"**","IE","DATA")
 S IEN=ITEM_","
 S LOC=$P(NOD1,U,6)
 S PHARM=$P(NOD1,U,7)
 S DRUG=$P(NOD1,U,8)
 S FCNT=$P(NOD1,U,9)
 S DAW=$P(NOD1,U,12)
 S DFN=$G(DATA(FIL,IEN,1.2,"I"))
 S PROV=$G(DATA(FIL,IEN,1.3,"I"))
 ;S DAT("REFILLS")=$S(FCNT>0:FCNT-1,1:0)
 S ORDIALOG($$PTR^ORCD("OR GTX SSRREQIEN"),1)=ITEM
 D PREPPTXT^APSPES2("SSRTEXT",ITEM)
 S I=0 F  S I=$O(SSRTEXT(I)) Q:'I  D
 .S TXT=$G(SSRTEXT(I))
 .S NSSRTXT(I,0)=TXT
 S ORDIALOG($$PTR^ORCD("OR GTX SSREFREQ"),1)="NSSRTXT"
 D BLDRSP(.ORDIALOG,ITEM)
 S DIALOG=$O(^ORD(101.41,"B","PSO OERR",0))
 S ORDIALOG($$PTR^ORCD("OR GTX DISPENSE DRUG"),1)=DRUG
 S ORDIALOG($$PTR^ORCD("OR GTX ROUTING"),1)="E"
 S ORDIALOG($$PTR^ORCD("OR GTX URGENCY"),1)=$O(^ORD(101.42,"B","ROUTINE",0))
 S ORDIALOG($$PTR^ORCD("OR GTX LOCATION"),1)=LOC
 S ORDIALOG($$PTR^ORCD("OR GTX DAW"),1)=DAW
 S ORVP=DFN_";DPT(",ORNP=PROV
 D SAVE^ORWD(.Y,DFN,PROV,$G(LOC),DIALOG,"N",.ORDIALOG)
 I $G(Y) S NORIFN=$P($P($P(Y(1),U),";"),"~",2)
 I '$G(NORIFN) Q "1^Order not filed. Check data and try again."
 D EN^OCXOERR(DFN_U_+NORIFN_U_PROV_"^^^^^1")
 S FDA(9009033.91,ITEM_",",.02)=NORIFN
 S FDA(9009033.91,ITEM_",",.03)=1
 S FDA(9009033.91,ITEM_",",.07)=$$NOW^XLFDT()
 S FDA(9009033.91,ITEM_",",1.11)=2
 D FILE^DIE(,"FDA") K FDA
 Q "0^Order created."
 ; Display missing data elements to user.
 ; input - MLIST (from CHKORD), passed by reference
DISPMIS(MLIST) ;
 N ITEM,LINE
 S $P(LINE,"-",80)="" W !!,LINE
 W !,"The following items are not defined. This order can not be created."
 W !,"Please correct these items and try again."
 S ITEM="" F  S ITEM=$O(MLIST(ITEM)) Q:ITEM']""  D
 .W !,ITEM
 W !,LINE
 Q
 ; Input: OARY - ORDIALOG passed in by reference
 ;        MLIST - List of data elements that are missing from the order (pass by ref.), returned to calling module
CHKORD(OARY,MLIST) ;
 N STAT,I,DONE,CHKITEM,CHKIEN
 S STAT=1,DONE=0
 F I=1:1 D  Q:DONE
 .S CHKITEM=$P($T(REQFLDS+I),";;",2)
 .I '$L(CHKITEM) S DONE=1 Q
 .S CHKIEN=$O(^ORD(101.41,"B",CHKITEM,0))
 .I 'CHKIEN Q
 .; if the array item doesn't exist, place it in the 'missing' array and set stat to zero
 .I '$D(OARY(CHKIEN)) S MLIST(CHKITEM)=CHKIEN,STAT=0 Q
 .; if the array item exists, but there is no data populated, set the 'missing' array item and stat to zero
 .I $D(OARY(CHKIEN)),'$L($G(OARY(CHKIEN,1))) S MLIST(CHKITEM)=CHKIEN,STAT=0 Q
 Q STAT
 ;
GHLDAT(IEN) ; Get HL7 message data from APSP REFILL REQUEST FILE
 N HLMSG
 S HLMSG=$$GET1^DIQ(9009033.91,IEN,5,"","HLDATA")
 Q HLMSG
 ;
SHLVARS ; Set up HL segment data
 N SEGTYP,VAR
 F SEGTYP="MSH","PID","ORC","RXO","RXE","RXR" S VAR="APSP"_SEGTYP,@VAR="",@VAR=$$GETSEG(.HLDATA,SEGTYP)
 Q
 ; Input:  DATA - HL7 data from APSP REFILL REQUEST file
 ;         TYPE - Message segment requested
GETSEG(DATA,TYPE) ;
 N X,RET,Q
 S RET="",(X,Q)=0 F  S X=$O(DATA(X)) Q:'X!(Q)  D
 .S DAT=$G(DATA(X)) I DAT="" S RET="" Q
 .I $P(DAT,"|")=TYPE S RET=DAT,Q=1 Q
 Q RET
 ; Build ORDIALOG array for creation of order
BLDRSP(ORDIALOG,IEN) ;EP-
 N LP,LP1,NOD0,INST,ITM,VAL
 S LP=0 F  S LP=$O(^APSPRREQ(IEN,4.5,LP)) Q:'LP  D
 .S NOD0=^APSPRREQ(IEN,4.5,LP,0)
 .S ITM=$P(NOD0,U,2)
 .S INST=$P(NOD0,U,3)
 .S VAL=$G(^APSPRREQ(IEN,4.5,LP,1))
 .I $D(^APSPRREQ(IEN,4.5,LP,2))>1 D
 ..S LP1=0 F  S LP1=$O(^APSPRREQ(IEN,4.5,LP,2,LP1)) Q:'LP1  D
 ...S ORDIALOG("WP",ITM,INST,LP1,0)=^APSPRREQ(IEN,4.5,LP,2,LP1,0)
 ..S ORDIALOG(ITM,INST)="ORDIALOG(""WP"","_ITM_","_INST_")"
 .E  D
 ..S ORDIALOG(ITM,INST)=VAL
 Q
REQFLDS ;
 ;;OR GTX ORDERABLE ITEM
 ;;OR GTX INSTRUCTIONS
 ;;OR GTX ROUTE
 ;;OR GTX SCHEDULE
 ;;OR GTX URGENCY
 ;;OR GTX ROUTING
 ;;OR GTX REFILLS
 ;;OR GTX DAYS SUPPLY
 ;;OR GTX PHARMACY
 ;;OR GTX DAW
 ;;OR GTX SSREFREQ
 ;;OR GTX SSRREQIEN
 ;;
 Q