source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWOR1.m@ 1211

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

initial load of WorldVistAEHR

File size: 4.7 KB
RevLine 
[613]1ORWOR1 ; slc/dcm - PKI RPC functions
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**132,141,163**;Dec 17, 1997
3SIG(RET,ID,X1,X2,X3,X4,ORX5,X6) ;Store the signature.
4 ;ID = orifn;action
5 ;X1 = Hash
6 ;X2 = Length of the array
7 ;X3 = Datafile (100)
8 ;X4 = Provider DUZ
9 ;ORX5 = Array for the sig
10 ;X6 = CRLURL
11 N Y1,ORIFN,ACT
12 S Y1=$$STORESIG^XUSSPKI(X1,X2,.ORX5,X4,X3)
13 I +Y1>0,$L($G(X6)) S Y1=$$CRLURL^XUSSPKI(X6)
14 I +Y1>0 D
15 . S ORIFN=+ID,ACT=$P(ID,";",2)
16 . S $P(^OR(100,ORIFN,8,+ACT,2),"^",3)=X1
17 S RET=Y1
18 Q
19CRLURL(RET,X1) ;Store the URL's
20 S RET=$$CRLURL^XUSSPKI(X1)
21 Q
22VERIFY(RET,ORDER,DFN) ;Verify PKI Data
23 ;DBIA #3750
24 ;ORDER = ORIFN;ACTION - NOTE: if no ACTION then 1 (new order) is assumed
25 ;Returned values: "1" if digital signature verifies
26 ; "-1^error message" if DS fails during initial parameter checking
27 ; "898020xx^message" if DS fails during verification
28 N ORIFN,ORACTION,HASH,DATE
29 K ^TMP("ORPKIDATA",$J)
30 I '$G(ORDER) S RET="-1^No order number passed" Q
31 I '$G(DFN) S RET="-1^No DFN passed" Q
32 S ORIFN=$P(ORDER,";"),ORACTION=$P(ORDER,";",2)
33 I 'ORACTION S ORACTION=1
34 I '$D(^OR(100,ORIFN,0)) S RET="-1^Invalid order number" Q
35 I DFN'=+$P(^OR(100,ORIFN,0),"^",2) S RET="-1^DFN does not match patient on order" Q
36 I '$D(^OR(100,ORIFN,8,ORACTION)) S RET="-1^Invalid order action passed" Q
37 S HASH=$P($G(^OR(100,ORIFN,8,ORACTION,2)),"^",3)
38 I '$L(HASH) S RET="-1^Order has no PKI Hash" Q
39 I '$O(^OR(100,ORIFN,8,ORACTION,.2,0)) S RET="-1^Order has no PKI Data" Q
40 S DATE=$P($G(^OR(100,ORIFN,8,ORACTION,.2,1,0)),"^")
41 I '$L(DATE) S RET="-1^No date associated with PKI Data" Q
42 S DATE=$$HL7TFM^XLFDT(DATE),I=0
43 F S I=$O(^OR(100,ORIFN,8,ORACTION,.2,I)) Q:'I S ^TMP("ORPKIDATA",$J,I)=^(I,0)
44 S RET=$$VERIFY^XUSSPKI(HASH,$NA(^TMP("ORPKIDATA",$J)),DATE)
45 I RET="OK" S RET=1 Q
46 I $E(RET,1,7)="-898020" S RET=$E(RET,2,99)
47 Q
48CHKDIG(REQ,ORDER) ;Check if Digital Signature is required
49 N IFN,ACTION
50 S REQ=0,IFN=+ORDER,ACTION=$P(ORDER,";",2)
51 I +$P($G(^OR(100,+IFN,8,+ACTION,2)),U,5) S REQ=1
52 Q
53GETDTEXT(TEXT,ORDER) ;Get External Text
54 N IFN,ACTION
55 S IFN=+ORDER,ACTION=$P(ORDER,";",2),I=0
56 F S I=$O(^OR(100,+IFN,8,+ACTION,.2,I)) Q:'I S TEXT(I)=^(I,0)
57 Q
58GETDSIG(SIG,ORDER) ;Get Digital Signature
59 N IFN,ACTION
60 S SIG=0,IFN=+ORDER,ACTION=$P(ORDER,";",2)
61 I +$P($G(^OR(100,+IFN,8,+ACTION,2)),U,3) S SIG=$P(^(2),"^",3)
62 Q
63GETDEA(Y,ORUSER) ;Get user DEA
64 S Y=$$DEA^XUSER(,$G(ORUSER))
65 Q
66GETDSCH(Y,ORDER) ;Check if Drug Schedule
67 N IFN,ACTION
68 S IFN=+ORDER,ACTION=$P(ORDER,";",2)
69 S Y=$P($G(^OR(100,+IFN,8,+ACTION,2)),U,4)
70 Q
71SETDTEXT(Y,ORDER,ORDEA,ORSIGNER) ;Set Digital Text data into file 100 & return the array
72 ;ORDER = ORIFN;ACTION
73 ;ORDEA = Schedule of Drug (2-5)
74 ;ORSIGNER = DUZ of signer
75 N ORSET,IFN,ACT,I
76 S Y="-1^Digital Text failed to build",IFN=+ORDER,ACT=$P(ORDER,";",2)
77 I '$G(ORDEA) Q
78 I '$G(ORSIGNER) S ORSIGNER=DUZ
79 D DIGTEXT^ORCSAVE1(IFN,ORDEA,ORSIGNER)
80 S Y=0
81 I '$G(ORSET) Q
82 K ^OR(100,IFN,8,ACT,.2)
83 F I=1:1:ORSET S (Y(I),^OR(100,IFN,8,ACT,.2,I,0))=ORSET(I)
84 S ^OR(100,IFN,8,ACT,.2,0)="^^"_ORSET_"^"_ORSET_"^"_DT_"^",Y=ORSET
85 Q
86GETDATA(Y,ORDER,DFN) ;Get PKI Data
87 ;DBIA #3750
88 ;On error: Y = -1^Error message
89 ;Else: Y = 1^ Order # ^ Nature of order ^ Order Status ^ Date Signed
90 ;Y(1) = Patient name ^ Street1 ^ Street2 ^ Street3 ^ City ^ State ^ Zip
91 ;Y(2) = Drug name_strength_dosage form (Dispense drug) ^ Drug IEN (file 50) ^ Drug quantity prescribed ^ Schedule of medication ^ DEA Schedule
92 ;Y(3) = Directions for use (SIG)
93 ;Y(4) = Practitioner's name ^ DUZ ^ Practitioner's (DEA) registration number
94 ;Y(5) = SiteName ^ SiteStreet1 ^ SiteStreet2 ^ SiteCity ^ SiteState ^ SiteZip
95 ;Y(6) = Orderable Item ^ Orderable Item IEN (file 101.43)
96 N X0,X1,X2,X3,X4,X5,X6,ORNAT,ORSTAT
97 I '$D(^OR(100,+$G(ORDER),0)) S Y="-1^INVALID ORDER #" Q
98 I $G(DFN)'=+$P(^OR(100,ORDER,0),"^",2) S Y="-1^INVALID PATIENT ID" Q
99 I '$D(^OR(100,ORDER,8,1,.2,0)) S Y="-1^MISSING DIGITAL SIGNATURE TEXT" Q
100 S X0=$G(^OR(100,ORDER,8,1,0))
101 I $P($G(^OR(100,ORDER,8,1,0)),"^",4)'=7 S Y="-1^ORDER HAS NOT BEEN DIGITALLY SIGNED" Q
102 S X1=$G(^OR(100,ORDER,8,1,.2,1,0))
103 I DFN'=$P(X1,"^",4) S Y="-1^PKI PATIENT ID DOES NOT MATCH DFN" Q
104 S ORNAT=$P(X0,"^",12),ORSTAT=$P($G(^OR(100,ORDER,3)),"^",3)
105 I ORNAT S ORNAT=$P($G(^ORD(100.02,ORNAT,0)),"^")
106 I ORSTAT S ORSTAT=ORSTAT_";"_$P(^ORD(100.01,ORSTAT,0),"^")
107 S Y="1^"_ORDER_"^"_ORNAT_"^"_ORSTAT_"^"_$P(X0,"^",6)
108 S X2=$G(^OR(100,ORDER,8,1,.2,2,0)),X3=$G(^OR(100,ORDER,8,1,.2,3,0)),X4=$G(^OR(100,ORDER,8,1,.2,4,0)),X5=$G(^OR(100,ORDER,8,1,.2,5,0)),X6=$G(^OR(100,ORDER,8,1,.2,6,0))
109 S X3=$$VALUE^ORX8(ORDER,"DRUG",,"E")_"^"_$$VALUE^ORX8(ORDER,"DRUG",,"I")_"^"_$P(X3,"^",3,99)
110 S Y(1)=$P(X1,"^",2)_"^"_X2
111 S Y(2)=X3,Y(3)=X4,Y(4)=X5,Y(5)=X6
112 S Y(6)=$$VALUE^ORX8(ORDER,"ORDERABLE",,"E")_"^"_$$VALUE^ORX8(ORDER,"ORDERABLE",,"I")
113 Q
Note: See TracBrowser for help on using the repository browser.