source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORQQVI2.m@ 613

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

initial load of WorldVistAEHR

File size: 6.2 KB
Line 
1ORQQVI2 ;SLC/dee- RPC calls to GMRVPCE0, Vitals data event drivers ;2/2/98
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10**;Dec 17, 1997
3 ;
4 Q
5 ;
6 ; ORQDATA is in the format
7 ; ORQDATA(i)="VST^DT^encounter date" required
8 ; ORQDATA(i)="VST^PT^pointer to patient" required
9 ; ORQDATA(i)="VST^HL^pointer to Hospital Location" required
10 ; ORQDATA(i)="VIT^vital type^^^value^provider^units^date/time"
11 ; ORVITALS is the array passed to GMRV in the PCE Device Interface
12 ; format.
13 ; ORQVIT is an array subscipted by the index in ORVITALS that contains
14 ; the subscript of the data gotten from ORQDATA. This is used to tell
15 ; the caller which item had an ERROR or WARNING.
16 ; ORRETURN(0) is 1 if no ERRORs or WARNINGs
17 ; 0 if there are WARNING(s) but no ERRORs
18 ; -1 if there are ERROR(s)
19 ; ORRETURN(n) where n>0 is an error or warning in validating the data
20 ; 1 piece: subscript of ORQDATA that the error or warning is on
21 ; 2 piece: "ERROR" or "WARNING"
22 ; 3 piece: text message about error or warning
23 ; 4 piece: data item that generated the error or warning
24 ;
25VALIDATE(ORRETURN,ORQDATA) ;
26 ; Given the array ORQDATA passed in by PCE Device Interface whose
27 ; format is described in the PCE Device Interface documentation, this
28 ; procedure will validate the Vitals data. If the data is invalid,
29 ; the procedure will return the errors in the form given above.
30 ;
31 N ORVITALS,ORQVIT
32 ;Initialize RETURN to no errors
33 K ORRETURN
34 S ORRETURN(0)=1
35 D PREVITAL(.ORRETURN,.ORVITALS,.ORQVIT,.ORQDATA)
36 D VALIDATE^GMRVPCE0(.ORVITALS)
37 D POSTVIT(.ORRETURN,.ORQVIT,.ORVITALS)
38 Q
39 ;
40VALSTORE(ORRETURN,ORQDATA) ;Calls VALIDATE and if no errors calls STORE
41 ; Given the array ORQDATA passed in by PCE Device Interface whose
42 ; format is described in the PCE Device Interface documentation, this
43 ; procedure will validate the Vitals data. If the data is invalid,
44 ; the procedure will return the errors in the form given above.
45 ; If there are no errors then this procedure will call
46 ; Vitals/Measurements to store the data in the GMRV's
47 ; Patient Measurements (120.5) file.
48 ;
49 N ORVITALS,ORQVIT
50 ;Initialize RETURN to no errors
51 K ORRETURN
52 S ORRETURN(0)=1
53 D PREVITAL(.ORRETURN,.ORVITALS,.ORQVIT,.ORQDATA)
54 D VALIDATE^GMRVPCE0(.ORVITALS)
55 D POSTVIT(.ORRETURN,.ORQVIT,.ORVITALS)
56 I ORRETURN(0)=1 D STORE^GMRVPCE0(.ORVITALS)
57 Q
58 ;
59PREVITAL(ORRETURN,ORVITALS,ORQVIT,ORQDATA) ;format array for call to Vitlals
60 N ORQTYPE,ORQCODE,ORINDEX1,ORINDEX2,ORRETINX,ORQITEM
61 N ORQNODT,ORQNOPT,ORQNOHL
62 S (ORQNODT,ORQNOPT,ORQNOHL)=1
63 S ORVITALS("SOURCE")="^"_DUZ
64 S ORINDEX2=0
65 S ORRETINX=$O(ORRETURN(""),-1)
66 S ORINDEX1=""
67 F S ORINDEX1=$O(ORQDATA(ORINDEX1)) Q:'ORINDEX1 D
68 . S ORQDATAX=ORQDATA(ORINDEX1),ORQTYPE=$P(ORQDATAX,"^"),ORQCODE=$P(ORQDATAX,"^",2)
69 . I ORQTYPE="PRV" S ORVITALS("PROVIDER",1)=ORQCODE Q
70 . I ORQTYPE="VST" D Q
71 .. I ORQCODE="DT" D Q
72 ... S ORQNODT=0
73 ... S ORQITEM=$P(ORQDATAX,"^",3)
74 ... S $P(ORVITALS("ENCOUNTER"),"^",1)=ORQITEM
75 ... I ORQITEM>$$NOW^XLFDT D
76 .... S ORRETINX=ORRETINX+1
77 .... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Date/Time entered cannot be in the future^"_$$FMTE^XLFDT(ORQITEM)
78 .... S ORRETURN(0)=-1
79 ... I ORQITEM'>1800000 D
80 .... S ORRETINX=ORRETINX+1
81 .... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Encounter Date/Time not valid^"_ORQITEM
82 .... S ORRETURN(0)=-1
83 .. I ORQCODE="PT" D Q
84 ... S ORQNOPT=0
85 ... S ORQITEM=$P(ORQDATAX,"^",3)
86 ... S $P(ORVITALS("ENCOUNTER"),"^",2)=ORQITEM
87 ... I '($D(^DPT(+ORQITEM,0))#2) D
88 .... S ORRETINX=ORRETINX+1
89 .... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^Patient missing or invalid in file 2^"_ORQITEM
90 .... S ORRETURN(0)=-1
91 .. I ORQCODE="HL" D Q
92 ... S ORQNOHL=0
93 ... S ORQITEM=$P(ORQDATAX,"^",3)
94 ... S $P(ORVITALS("ENCOUNTER"),"^",3)=ORQITEM
95 ... I '$D(^SC(ORQITEM,0)) D
96 .... S ORRETINX=ORRETINX+1
97 .... S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^HOSPITAL LOCATION Missing is not in file 44^"_ORQITEM
98 .... S ORRETURN(0)=-1
99 ...; I $D(^PX(815,1,"DHL","B",ORQITEM)) D
100 ...;. S ORRETINX=ORRETINX+1
101 ...;. S ORRETURN(ORRETINX)=ORINDEX1_"^ERROR^HOSPITAL LOCATION Can not be a disposition clinic^"_ORQITEM
102 ...;. S ORRETURN(0)=-1
103 . I ORQTYPE="VIT" D Q
104 .. S ORINDEX2=ORINDEX2+1
105 .. S ORQVIT(ORINDEX2)=ORINDEX1
106 .. S ORVITALS("VITALS",+$P(ORQDATAX,"^",6),ORINDEX2)=ORQCODE_"^"_$P(ORQDATAX,"^",5)_"^"_$P(ORQDATAX,"^",7,8)
107 I ORQNODT D
108 . S ORRETINX=ORRETINX+1
109 . S ORRETURN(ORRETINX)="^ERROR^Required data item, ENCOUNTER DATE/TIME, is missing^"
110 . S ORRETURN(0)=-1
111 I ORQNOPT D
112 . S ORRETINX=ORRETINX+1
113 . S ORRETURN(ORRETINX)="^ERROR^Required data item, PATIENT, is missing^"
114 . S ORRETURN(0)=-1
115 I ORQNOHL D
116 . S ORRETINX=ORRETINX+1
117 . S ORRETURN(ORRETINX)="^ERROR^Required data item, HOSPITAL LOCATION, is missing^"
118 . S ORRETURN(0)=-1
119 Q
120 ;
121POSTVIT(ORRETURN,ORQVIT,ORVITALS) ;return errors and warnings
122 N ORVAR,ORINDEX,ORQTYPE
123 S ORINDEX=$O(ORRETURN(""),-1)
124 F ORQTYPE="WARNING","ERROR" D
125 . S ORVAR="ORVITALS("""_ORQTYPE_""")"
126 . F S ORVAR=$Q(@ORVAR) Q:ORVAR'[("ORVITALS("""_ORQTYPE_"""") D
127 .. S ORINDEX=ORINDEX+1
128 .. S ORRETURN(ORINDEX)=$G(ORQVIT($P(ORVAR,",",4)))_"^"_ORQTYPE_"^"_@ORVAR
129 .. I ORQTYPE="WARNING" S:ORRETURN(0)>0 ORRETURN(0)=0
130 .. E S ORRETURN(0)=-1
131 Q
132 ;
133HELP(ORQLST,ORQTYPE) ; This procedure will return help for a particular
134 ; measurement type in an array.
135 ; Input
136 ; Variables: ORQTYPE=Type of measurement (abbreviation
137 ; (req.) from PCE Device Interface Specification).
138 ; ORQLST=Array root to store help text in
139 ;
140 D HELP^GMRVPCE0(ORQTYPE,"ORQLST")
141 Q
142 ;
143RATECHK(ORRETURN,ORQTYPE,ORQRATE,ORQUNIT) ;
144 ; Extrinsic function to validate the
145 ; rate for a particular measurement
146 ; Input
147 ; Variables: ORQTYPE=Type of measurement (abbreviation
148 ; (req.) from PCE Device Interface Specification).
149 ; ORQRATE=Measurement rate to be validated.
150 ; (req.)
151 ; ORQUNIT=Unit of measurement for rate, if specified.
152 ; (opt.)
153 ; Return value: 1 if rate is valid.
154 ; 0 if rate is invalid.
155 ;
156 S ORRETURN=$$RATECHK^GMRVPCE0(ORQTYPE,ORQRATE,$G(ORQUNIT))
157 Q
158 ;
159VMTYPES(ORRETURN,ORQTYPE) ;
160 ; This function returns one if ORQTYPE is a valid type abbrev.
161 ; from the PCE Device Interface Specification.
162 S ORRETURN=$$VMTYPES^GMRVPCE0(ORQTYPE)
163 Q
Note: See TracBrowser for help on using the repository browser.