source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORCSEND3.m@ 1604

Last change on this file since 1604 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.2 KB
Line 
1ORCSEND3 ;SLC/MKB,AGP-Release cont ;05/20/2008
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
3 ;
4CHILD(STRT) ; Create child order, send to package
5 N ORAPPT
6 K ORIFN D EN^ORCSAVE Q:'$G(ORIFN) D STARTDT^ORCSAVE2(ORIFN)
7 I $G(STRT) D DATES^ORCSAVE2(ORIFN,STRT)
8 S ORCHLD=+$G(ORCHLD)+1,^OR(100,ORPARENT,2,ORIFN,0)=ORIFN,ORLAST=ORIFN
9 S ORAPPT=$P($G(^OR(100,ORPARENT,0)),U,18)
10 S $P(^OR(100,ORIFN,0),U,18)=ORAPPT,$P(^(3),U,9)=ORPARENT
11 I $G(PKG)="LR" S $P(^OR(100,ORIFN,8,1,0),U,4)=8 K ^OR(100,"AS",ORVP,9999999-ORLOG,ORIFN,1) ;signature tracked on parent order only, for Labs
12 I $G(PKG)?1"PS".E D
13 . N X0 S X0=$G(^OR(100,ORPARENT,8,1,0))
14 . I $P(X0,U,4)'=2 D SIGN^ORCSAVE2(ORIFN,+$P(X0,U,5),ORNOW,$P(X0,U,4),1)
15 . I $D(^OR(100,ORPARENT,9)) M ^OR(100,ORIFN,9)=^OR(100,ORPARENT,9)
16 . I $G(ORENEW) S OLD=$O(ORENEW(0)) I OLD S $P(^OR(100,OLD,3),U,6)=ORIFN,$P(^OR(100,ORIFN,3),U,5)=OLD,$P(^(3),U,11)=2 K ORENEW(OLD)
17 D RELEASE^ORCSAVE2(ORIFN,1,ORNOW,DUZ,$G(NATURE)),NEW^ORMBLD(ORIFN)
18 Q
19 ;
20DOSES(IFN) ;
21 N I,CNT S CNT=0
22 S I=+$O(^OR(100,+$G(IFN),4.5,"ID","NOW",0)) I I,$G(^OR(100,+$G(IFN),4.5,I,1)) S CNT=CNT+1
23 Q CNT
24 ;
25GETORDER(IFN) ; Set ORX(Inst,Ptr)=Value
26 N I,X,Y,PTR,INST,TYPE,SOLCNT,ADDCNT
27 S (SOLCNT,ADDCNT)=0
28 S I=0 F S I=$O(^OR(100,IFN,4.5,I)) Q:I'>0 S X=$G(^(I,0)),Y=$G(^(1)) D
29 . S PTR=+$P(X,U,2),INST=+$P(X,U,3),TYPE=$P($G(^ORD(101.41,PTR,1)),U)
30 . I TYPE'="W" S ORX(PTR,INST)=Y Q
31 . ;S ORX(INST,PTR)="^OR(100,"_IFN_",4.5,"_I_",2)"
32 . S ORX(PTR,INST)="^OR(100,"_IFN_",4.5,"_I_",2)"
33 Q
34PSJI ;
35 ;IV dialog
36 N ORPARENT,OR0,ORNP,ORDIALOG,ORDUZ,ORLOG,ORL,ORDG,ORCAT,ORX,ORP,ORI,STS
37 N ORDOSE,ORT,ORSCH,ORDUR,ORSTRT,ORFRST,ORCONJ,ORID,ORDD,ORSTR,ORDGNM
38 N ORSTART,ORCHLD,ORLAST,ORSIG,OROI,ID,OR3,ORIG,CODE,PKG,ORENEW,I,ORADMIN
39 N ORDUR
40 N CNT
41 S ORPARENT=+ORIFN,OR0=$G(^OR(100,ORPARENT,0)),OR3=$G(^OR(100,ORPARENT,3))
42 S ORCAT="I",ORNP=+$P(OR0,U,4)
43 ;Q:$P(OR0,U,12)'="I" S ORCAT="I",ORNP=+$P(OR0,U,4)
44 S ORDIALOG=+$P(OR0,U,5),ORDUZ=+$P(OR0,U,6),ORLOG=$P(OR0,U,7)
45 S ORL=$P(OR0,U,10),ORDG=+$P(OR0,U,11),PKG=$$GET1^DIQ(9.4,+$P(OR0,U,14)_",",1)
46 ;Build ORDIALOG Array and ORX local array
47 D GETDLG1^ORCD(ORDIALOG),GETORDER(ORPARENT)
48 ;
49 S ORSCH=$$PTR("SCHEDULE"),ORDUR=$$PTR("DURATION")
50 D STRT S ORSTART=$G(ORSTRT("BEG"))
51 S ORADMIN=$$PTR("ADMIN TIMES")
52 D DATES^ORCSAVE2(ORPARENT,ORSTART) Q:$$DOSES(ORPARENT)<1
53 S ORFRST=$$PTR("NOW"),ORSIG=$$PTR("SIG")
54 ;
55 I $P(OR3,U,11)=2,$O(^OR(100,+$P(OR3,U,5),2,0)) D
56 . S ORENEW=+$P(OR3,U,5),I=0
57 . I $$VALUE^ORX8(ORENEW,"NOW") S I=$O(^OR(100,ORENEW,2,0))
58 . F S I=$O(^OR(100,ORENEW,2,I)) Q:I<1 S ORENEW(I)=""
59 ;
60PSJI1 ;
61 ;Build Order Dialog Prompts that can have Multiple Responses
62 F ORP="ADDITIVE","ORDERABLE ITEM","STRENGTH PSIV","UNITS","VOLUME" D
63 . N PTR S PTR=$$PTR(ORP) Q:PTR'>0 Q:'$D(ORX(PTR,1))
64 . S CNT=0 F S CNT=$O(ORX(PTR,CNT)) Q:CNT'>0 S ORDIALOG(PTR,CNT)=ORX(PTR,CNT)
65 ;
66 ;Build Order Dialog Responses that should be in both Child Orders
67 F ORP="INFUSION RATE","IV TYPE","ROUTE","URGENCY","WORD PROCESSING 1" D
68 . N PTR S PTR=$$PTR(ORP) Q:PTR'>0 Q:'$D(ORX(PTR,1))
69 . S ORDIALOG(PTR,1)=ORX(PTR,1) S:$E(ORP)="O" OROI=ORX(PTR,1) Q
70 ;
71 ;If NOW order create NOW Child Order
72 I $G(ORX(ORFRST,1)) D
73 . S:$D(ORX(ORP,1)) ORDIALOG(ORP,1)=ORX(ORP,1)
74 . ;S ID=$G(ORX(ORI,ORID)) S:$P(ID,"&",6) ORDIALOG(ORDD,1)=$P(ID,"&",6)
75 . S ORDIALOG(ORSCH,1)="NOW",ORSTART=$$NOW^XLFDT
76 . D CHILD(ORSTART)
77 ;
78 ;Build Order Fields for non-NOW Child Order
79 F ORP=ORSCH,ORADMIN,ORDUR S:$D(ORX(ORP,1)) ORDIALOG(ORP,1)=ORX(ORP,1) K:'$D(ORX(ORP,1)) ORDIALOG(ORP,1)
80 S ORSTART=$G(ORSTRT(1))
81 D CHILD(ORSTART)
82 ;
83 S:$G(ORCHLD) ^OR(100,ORPARENT,2,0)="^100.002PA^"_ORLAST_U_ORCHLD
84 S ORIFN=ORPARENT,ORQUIT=1,OR3=$G(^OR(100,ORIFN,3)),STS=$P(OR3,U,3)
85 I (STS=1)!(STS=13)!(STS=11) S ORERR="1^Unable to release orders"
86 D RELEASE^ORCSAVE2(ORIFN,1,ORNOW,DUZ,$G(NATURE)) K ^TMP("ORWORD",$J)
87 S $P(^OR(100,ORIFN,3),U,8)=1 ;veil parent order - set stop date/time?
88 Q:(STS=1)!(STS=13)!(STS=11) ;unsuccessful
89PSJI2 ; ck if parent is unsigned or edit
90 I $P($G(^OR(100,ORIFN,8,1,0)),U,4)=2 S $P(^(0),U,4)="" K ^OR(100,"AS",ORVP,9999999-ORLOG,ORIFN,1) ;clear ES
91 Q:$P(OR3,U,11)'=1 S ORIG=$P(OR3,U,5) Q:ORIG'>0
92 S CODE=$S($P($G(^OR(100,ORIG,3)),U,3)=5:"CA",1:"DC")
93 D MSG^ORMBLD(ORIG,CODE) I "^1^13^"[(U_$P($G(^OR(100,ORIG,3)),U,3)_U) D
94 . N NATR S NATR=+$O(^ORD(100.02,"C","C",0))
95 . S $P(^OR(100,ORIG,3),U,3)=12,$P(^(3),U,7)=0,^(6)=NATR_U_DUZ_U_ORNOW
96 . D CANCEL^ORCSEND(ORIG) ;ck for unrel actions
97 Q
98PTR(X) ; Returns ptr of prompt X in Order Dialog file
99 Q +$O(^ORD(101.41,"AB",$E("OR GTX "_X,1,63),0))
100 ;
101STRT ; Build ORSTRT(inst)=date.time array of start times by dose
102 N OI,PSOI,XD,XH,XM,XS,ORWD,ORI,SCH,ORSD,X,ORD K ORSTRT
103 S OI=$G(ORX($$PTR^ORCD("OR GTX ORDERABLE ITEM"),1))
104 ;if OI is null assume Intermittent IV order this does not required a
105 ;solution check for an additive only value
106 I OI="" S OI=$G(ORX($$PTR^ORCD("OR GTX ADDITIVE"),1))
107 S PSOI=+$P($G(^ORD(101.43,+OI,0)),U,2),(XD,XH,XM,XS)=0
108 S ORWD=+$G(^SC(+$G(ORL),42)) ;ward
109 ;S ORI=0 F S ORI=$O(ORX(ORI)) Q:ORI<1 D
110 S SCH=$G(ORX(ORSCH,1)),ORSD="" S:'$L(SCH) X=$$NOW^XLFDT
111 S:$L(SCH) ORSD=$$STARTSTP^PSJORPOE(+ORVP,SCH,PSOI,ORWD),X=$P(ORSD,U,4)
112 S ORSTRT(1)=$$FMADD^XLFDT(X,XD,XH,XM,XS) ;START+OFFSET
113 ; find beginning date.time for parent
114 S ORI=0,X=9999999 F S ORI=$O(ORSTRT(ORI)) Q:ORI<1 I ORSTRT(ORI)<X S X=ORSTRT(ORI)
115 S ORSTRT("BEG")=X
116 Q
Note: See TracBrowser for help on using the repository browser.