source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORDV04A.m@ 619

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

initial load of WorldVistAEHR

File size: 6.5 KB
Line 
1ORDV04A ; SLC/DAN/dcm - OE/RR ;7/30/01 14:33
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,243**;Dec 17,1997;Build 242
3 ;
4 Q
5ENSR ; Entry point for component
6 ;External calls to ^GMTSROB, ^DIQ, ^GMTSORC, ^DIWP
7 ;External references to ^SRF, ^DD, ^ICPT
8 N GMIDT,GMN,SURG
9 I '$D(^SRF("B",DFN)) Q
10 S GMN=0 F S GMN=$O(^SRF("B",DFN,GMN)) Q:GMN'>0 D SORT
11 I '$D(SURG) Q
12 S GMIDT=0 F S GMIDT=$O(SURG(GMIDT)) Q:GMIDT'>0!(ORCNT'<ORMAX) S GMN=SURG(GMIDT) D EXTRCT
13 Q
14 ;
15SORT ; Sort surgeries by inverted date
16 N GMDT
17 S GMDT=$P(^SRF(GMN,0),U,9) I GMDT>ORDBEG&(GMDT<ORDEND) D
18 . F Q:'$D(SURG(9999999-GMDT)) S GMDT=GMDT+.0001
19 . S SURG(9999999-GMDT)=GMN
20 Q
21EXTRCT ; Extract surgical case record
22 N X,GMI,GMDT,OPPRC,POSDX,PREDX,SPEC,STATUS,SURGEON,VER
23 N DCTDTM,TRSDTM,Y,C,DIWL,DIWF,ORSITE,ORMORE,SITE
24 S ORCNT=ORCNT+1,ORMORE=0
25 S GMDT=$$DATE^ORDVU($P(^SRF(GMN,0),U,9))
26 D STATUS^GMTSROB S:'$D(STATUS) STATUS="UNKNOWN"
27 S X=$P(^SRF(GMN,0),U,4) I X>0 S Y=X,C=$P(^DD(130,.04,0),U,2) D Y^DIQ S SPEC=Y K Y
28 I $D(^SRF(GMN,.1)) S X=$P(^SRF(GMN,.1),U,4) I X>0 S Y=X,C=$P(^DD(130,.14,0),U,2) D Y^DIQ S SURGEON=Y K Y
29 S VER=$S($G(^SRF(GMN,"VER"))'="Y":"(Unverified)",1:"")
30 S PREDX(0)=$S($G(^SRF(GMN,33))]"":$P(^(33),U),1:"") S GMI=0 F S GMI=$O(^SRF(GMN,14,GMI)) Q:GMI'>0 S PREDX(GMI)=$P(^SRF(GMN,14,GMI,0),U)
31 S POSDX(0)=$S($G(^SRF(GMN,34))]"":$P(^(34),U),1:"") S GMI=0 F S GMI=$O(^SRF(GMN,15,GMI)) Q:GMI'>0 S POSDX(GMI)=$P(^SRF(GMN,15,GMI,0),U)
32 S OPPRC(0)=$P($G(^SRF(GMN,"OP")),U,1,2) S:$P(OPPRC(0),U,2)]"" $P(OPPRC(0),U,2)=$P($$CPT^ICPTCOD($P($G(^SRF(GMN,"OP")),U,2)),U,3) D
33 . S GMI=0 F S GMI=$O(^SRF(GMN,13,GMI)) Q:GMI'>0 S OPPRC(GMI)=$P($G(^SRF(GMN,13,GMI,0)),U)_U_$G(^SRF(GMN,13,GMI,2)) S:$P(OPPRC(GMI),U,2)]"" $P(OPPRC(GMI),U,2)=$P($$CPT^ICPTCOD($P($G(^SRF(GMN,13,GMI,2)),U)),U,3)
34 S X=$P($G(^SRF(GMN,31)),U,6) S:X>0 DCTDTM=$$DATE^ORDVU(X)
35 S X=$P($G(^SRF(GMN,31)),U,7) S:X>0 TRSDTM=$$DATE^ORDVU(X)
36 S DIWL=0,DIWF="N",ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
37 K ^UTILITY($J,"W")
38 I $D(^SRF(GMN,12)) F GMI=1:1:$P(^SRF(GMN,12,0),U,4) S X=^SRF(GMN,12,GMI,0) D ^DIWP
39 S SITE=ORSITE
40 S ^TMP("ORDATA",$J,GMIDT,"WP",1)="1^"_SITE ;Station ID
41 S ^TMP("ORDATA",$J,GMIDT,"WP",2)="2^"_GMDT ; date
42 ;
43 ; Operative Procedure(s)
44 S GMI="" F S GMI=$O(OPPRC(GMI)) Q:GMI="" D S:GMI ORMORE=1
45 . S ^TMP("ORDATA",$J,GMIDT,"WP",3,GMI)="3^"_$P(OPPRC(GMI),U)_$S($P(OPPRC(GMI),U,2)]"":" - "_$P(OPPRC(GMI),U,2),1:"")
46 ;
47 S ^TMP("ORDATA",$J,GMIDT,"WP",4)="4^"_$G(SPEC) ;surgical specialty
48 ;
49 S ^TMP("ORDATA",$J,GMIDT,"WP",5)="5^"_$G(SURGEON) ; surgeon
50 S ^TMP("ORDATA",$J,GMIDT,"WP",6)="6^"_$G(STATUS) ; op status
51 ;
52 ; Pre-operative diagnosis
53 S GMI="" F S GMI=$O(PREDX(GMI)) Q:GMI="" D S:GMI ORMORE=1
54 . S ^TMP("ORDATA",$J,GMIDT,"WP",7,GMI)="7^"_PREDX(GMI)
55 ;
56 ; Post-operative diagnosis
57 S GMI="" F S GMI=$O(POSDX(GMI)) Q:GMI="" D S:GMI ORMORE=1
58 . S ^TMP("ORDATA",$J,GMIDT,"WP",8,GMI)="8^"_POSDX(GMI)
59 ;
60 ; Lab work? Y/N
61 S ^TMP("ORDATA",$J,GMIDT,"WP",9)="9^"_$S($O(^SRF(GMN,9,0)):"Yes",1:"No")
62 S ^TMP("ORDATA",$J,GMIDT,"WP",10)="10^"_$G(DCTDTM) ; dictation time
63 S ^TMP("ORDATA",$J,GMIDT,"WP",11)="11^"_$G(TRSDTM) ; transcription time
64 ;
65 ; surgeon's dictation
66 I $D(^UTILITY($J,"W")) D S ORMORE=1
67 . K ^TMP("ORHSSRT",$J)
68 . F GMI=1:1:^UTILITY($J,"W",DIWL) D
69 .. S ^TMP("ORHSSRT",$J,GMIDT,"WP",GMI)=^UTILITY($J,"W",DIWL,GMI,0)
70 . D SPMRG^ORDVU($NA(^TMP("ORHSSRT",$J,GMIDT,"WP")),$NA(^TMP("ORDATA",$J,GMIDT,"WP",12)),12)
71 . K ^UTILITY($J,"W")
72 . K ^TMP("ORHSSRT",$J)
73 I ORMORE S ^TMP("ORDATA",$J,GMIDT,"WP",13)="13^[+]" ;flag for detail
74 Q
75VS ;Continuation of Vitals Extract (from ORDV04)
76 ;Calls GMRVUT0
77 I $L($T(GCPR^OMGCOAS1)) D Q ; OMGCOAS1 routine only on Station 200
78 . D GCPR^OMGCOAS1(DFN,"VIT",ORDBEG,ORDEND,ORMAX)
79 . S ROOT=$NA(^TMP("ORDATA",$J))
80 N ORDT,I,TYPE,IEN,GMRVSTR,ORSITE,SITE,PLACE,GO,X,QUALIF,NODE,UNITS,UCNT,QCNT,ORI
81 Q:'$L(OREXT)
82 S GO=$P(OREXT,";")_"^"_$P(OREXT,";",2)
83 Q:'$L($T(@GO))
84 K ^UTILITY($J,"GMRVD"),^TMP("ORDATA",$J)
85 S GMRVSTR="T;P;R;BP;HT;WT;PN;PO2;CVP;CG",GMRVSTR(0)=ORDBEG_"^"_ORDEND_"^"_ORMAX_"^"_1
86 S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
87 D @GO
88 S ORDT=0
89 F I=1:1 S ORDT=$O(^UTILITY($J,"GMRVD",ORDT)) Q:'+ORDT!(I>ORMAX) D ;DBIA 4791
90 . S SITE=$S($L($G(^TMP("GMRVD",$J,ORDT,"facility"))):^("facility"),1:ORSITE)
91 . S ^TMP("ORDATA",$J,"WP",ORDT,1)="1^"_SITE
92 . S ^TMP("ORDATA",$J,"WP",ORDT,2)="2^"_$$DATE^ORDVU(9999999-ORDT) ;date vitals taken
93 . K UNITS,QUALIF
94 . S TYPE="",(UCNT,QCNT)=1,UNITS(UCNT)="",QUALIF(QCNT)="",QUALIF=""
95 . F S TYPE=$O(^UTILITY($J,"GMRVD",ORDT,TYPE)) Q:TYPE="" D
96 .. S IEN=$O(^UTILITY($J,"GMRVD",ORDT,TYPE,0)) Q:'IEN S NODE=$G(^(IEN))
97 .. S PLACE=$S(TYPE="T":3,TYPE="P":4,TYPE="R":5,TYPE="BP":6,TYPE="HT":7,TYPE="WT":8,TYPE="PN":9,TYPE="PO2":10,TYPE="CVP":11,TYPE="CG":12,1:0)
98 .. I PLACE S ^TMP("ORDATA",$J,"WP",ORDT,PLACE)=PLACE_"^"_$P(NODE,"^",8) ;Get value of vitals from global
99 .. S X=$$UNITMAP(TYPE) S:$L(UNITS(UCNT))>60 UCNT=UCNT+1,UNITS(UCNT)="" S UNITS(UCNT)=$S($L(UNITS(UCNT)):UNITS(UCNT)_","_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X ;Units
100 .. I TYPE="PO2" D
101 ... I $L($P(NODE,"^",15)) S ^TMP("ORDATA",$J,"WP",ORDT,13)=13_"^"_$P($G(^UTILITY($J,"GMRVD",ORDT,TYPE,IEN)),"^",15) ; Flow Rate
102 ... I $L($P(NODE,"^",16)) S ^TMP("ORDATA",$J,"WP",ORDT,14)=14_"^"_$P($G(^UTILITY($J,"GMRVD",ORDT,TYPE,IEN)),"^",16) ; O2 Concentration
103 .. I $L($P(NODE,"^",17)) S X=$P(NODE,"^",17) D
104 ... I QUALIF'[($$MAP(TYPE)_":"_X) D
105 .... S QUALIF=$S($L(QUALIF):QUALIF_" , "_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X ; Qualifier
106 .... S:$L(QUALIF(QCNT))>60 QCNT=QCNT+1,QUALIF(QCNT)=""
107 .... S QUALIF(QCNT)=$S($L(QUALIF(QCNT)):QUALIF(QCNT)_" , "_$$MAP(TYPE)_":",1:$$MAP(TYPE)_":")_X ; Qualifier
108 .. I TYPE="WT",$L($P(NODE,"^",14)) D
109 ... S ^TMP("ORDATA",$J,"WP",ORDT,16)=16_"^"_$P(NODE,"^",14) ; BMI
110 . I $O(QUALIF(0)) D
111 .. S ORI=0 F S ORI=$O(QUALIF(ORI)) Q:'ORI D
112 ... S ^TMP("ORDATA",$J,"WP",ORDT,15,ORI)="15^"_QUALIF(ORI)
113 . I $O(UNITS(0)) D
114 .. S ORI=0 F S ORI=$O(UNITS(ORI)) Q:'ORI D
115 ... S ^TMP("ORDATA",$J,"WP",ORDT,17,ORI)="17^"_UNITS(ORI)
116 K ^UTILITY($J,"GMRVD")
117 S ROOT=$NA(^TMP("ORDATA",$J))
118 Q
119MAP(TEXT) ;Map test code to abbreviation
120 Q:'$L($G(TEXT)) ""
121 I TEXT="T" Q "TEMP"
122 I TEXT="P" Q "PULSE"
123 I TEXT="R" Q "RESP"
124 I TEXT="BP" Q "BP"
125 I TEXT="HT" Q "HT"
126 I TEXT="WT" Q "WT"
127 I TEXT="PN" Q "PAIN"
128 I TEXT="PO2" Q "POx"
129 I TEXT="CVP" Q "CVP"
130 I TEXT="CG" Q "C/G"
131 Q TEXT
132UNITMAP(TEXT) ;Map units to abbreviation
133 Q:'$L($G(TEXT)) ""
134 I TEXT="T" Q "F"
135 I TEXT="P" Q "/min"
136 I TEXT="R" Q " /min"
137 I TEXT="BP" Q "mmHg"
138 I TEXT="HT" Q "in"
139 I TEXT="WT" Q "lb"
140 I TEXT="PN" Q ""
141 I TEXT="PO2" Q "%SpO2"
142 I TEXT="CVP" Q "cmH2O"
143 I TEXT="CG" Q " in"
144 Q ""
Note: See TracBrowser for help on using the repository browser.