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

PSJPDCLV.m

Go to the documentation of this file.
PSJPDCLV ;PER/ME - PADE ORDER ; 11/18/19 1:17pm
 ;;5.0;INPATIENT MEDICATIONS;**405,364,420**;16 DEC 97;Build 2
 Q
 ;PSJ*5*405 routine PSJPDCLU became to large (SACC max limit) and had to be split into routine PSJPDCLV
 ;*364 - Moving CORD and SEND tags from PSJPDCLU due to SACC max limit
 ;
DOWSTR(SCHED) ; Return 7-digit binary representation for the Day-Of-Week Schedule
 ; Input: SCHED  - Schedule (e.g., "ONCE", "AC-PRN", "MO-WE-FR", "TH", etc)
 ;Output: DOWSTR - 7-digit binary representation for Day-of-Week Schedules (e.g., SU = 1000000, SU-TU-TH-SA = 1010101, etc.)
 N DOWSCH,DOWSTR,DOW,I
 S DOWSCH=1,SCHED=$P(SCHED,"@"),DOWSTR="00000000"
 F I=1:1:$L(SCHED,"-") D  I 'DOWSCH Q
 . S DOW=$P(SCHED,"-",I)
 . I '$F("-SU-MO-TU-WE-TH-FR-SA-","-"_DOW_"-") S DOWSCH=0 Q
 . S $E(DOWSTR,$S(DOW="SU":1,DOW="MO":2,DOW="TU":3,DOW="WE":4,DOW="TH":5,DOW="FR":6,DOW="SA":7))=1
 Q $S('DOWSCH:"00000000",1:DOWSTR)
 ;
CORD ;*364
 Q:'PSJQ
 N ST0,PS55,PDL S (SEQ,ST0)=0
 S PS55=$S(RXO["U":"^PS(55,DFN,5,+RXO)",1:"^PS(55,DFN,""IV"",+RXO)")
 N PSJORDER S PSJORDER=PS55,$E(PSJORDER,*)=","          ;*364
 Q:PS55=""
 M PS55=@PS55
 I RXO["U" Q:'$P($G(PS55(2)),"^",2)!('$P($G(PS55(2)),"^",4))
 I RXO["V" Q:'$G(PS55(.2))!('$P($G(PS55(0)),"^",2))
 N VAR1,VAR2,STATUS,PDDT,PDHDT
 S PDDT=$$NOW^XLFDT(),PDHDT=+$$HLDATE^HLFNC(PDDT,"TS")
 D PID^PSJPDCLU,PV1^PSJPDCLU,AGY^PSJPDCL,ORC^PSJPDCLU,RXE^PSJPDCLU,RXR^PSJPDCLU
 D:RXO["V" IVRXC^PSJPDCLU
 I RXO["U" N CNT S CNT=0 D  D:CNT>1 RXC^PSJPDCLU  ; IF THERE ARE > 1 ACTIVE DD, MAKE AN RXC FOR EACH
 . N X1 S X1=0 F  S X1=$O(PS55(1,X1)) Q:'X1  D
 .. I $P(PS55(1,X1,0),"^",3),$P(PS55(1,X1,0),"^",3)'>DT Q  ; DONT COUNT IF IT HAS AN INNACTIVATION DATE (PAST)
 .. S CNT=CNT+1
 D ZRX^PSJPDCLU
 N ZTIO,ZTRTN,ZTSAVE,ZTDESC,ZTDTH
 S ZTIO=""
 S:CLAPDT PDL(16)=CLAPDT
 S ZTRTN="SEND^PSJPDCLV"
 F XX="NSEG(","PSJQ(","PSJQ2(","SETZ","HLFS","HLECH","HL(","SNM","CNM","PDL(","FTS","ASIH","PSJDCA","PSJORDER","DFN","RXO" S ZTSAVE(XX)=""   ;*364
 S ZTDESC="PADE HL7 Order Message Router"
 S ZTDTH=$H
 D ^%ZTLOAD
 Q
 ;
SEND ;*364
 N XX,PSJND,PSJVNM,PSJDNS,PSJVP,VR,HLA,NHL,CT,PDLTMP,HAZ,HAZH,HAZD
 M PDLTMP=PDL  ; Preserve PDL array info
 M NHL=HL
 S XX=0,CT=$O(NSEG(9999),-1)+1
 F  S XX=$O(PSJQ(XX)) Q:'XX  D
 .M PDL=PDLTMP  ; Restore PDL array after cleaned up by LOG^PSJPADE
 .M HL=NHL
 .S PSJND=$G(^PS(58.7,XX,0))
 .Q:PSJND=""
 .S PSJVNM=$P(PSJND,"^"),PSJDNS=$P(PSJND,"^",2),PSJVP=$P(PSJND,"^",3)
 .Q:PSJVNM=""!(PSJDNS="")!('PSJVP)
 .N HLP,PSJSND
 .S HLP("SUBSCRIBER")="^^^^~"_PSJDNS_":"_PSJVP_"~DNS"
 .N ZZ1,ZZ2 S (ZZ1,ZZ2)=""
 .I SETZ="C" S ZZ2=$P($G(PSJQ2(XX)),"^",2)
 .I SETZ="IC" S ZZ1=$P($G(PSJQ2(XX)),"^",2),ZZ2=$P($G(PSJQ(XX)),"^",2)
 .I SETZ="I" S ZZ1=$P($G(PSJQ(XX)),"^",2)
 .S HAZ=$$HAZDRUG^PSJHLU(PSJORDER)    ;PSJORDER prev saved by JOBQ *364
 .S HAZH=$S($P(HAZ,U):"Y",1:"N"),HAZD=$S($P(HAZ,U,2):"Y",1:"N")
 .S NSEG(CT)="ZZZ"_HL("FS")_ZZ1_HL("FS")_ZZ2_HL("FS")_FTS_HL("FS")_HAZH_HL("FS")_HAZD
 .D PV19^PSJPDAPP
 .K HLA M HLA("HLS")=NSEG
 .D GENERATE^HLMA(SNM,"LM",1,.PSJSND,"",.HLP)
 .D LOG^PSJPADE
 Q