source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORDV05E.m@ 794

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1ORDV05E ; slc/jdl - Microbiology Extract Routine ;6/13/01 11:49
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,208**;Dec 17, 1997
3 ;;Called from ORDV05, return ^TMP("ORM",$J in GCPR format
4 ;;For Bacteriology,Sterility,Gram stain
5GET ;Extract data from LR global
6 N I,IX,IXO,PNM,AGE,SEX,LRDFN,ALL,FORMAT,DONE,OUTCNT
7 S LRDFN="",ALL=1,FORMAT=0,DONE=0,OUTCNT=1 ;Parameters required by MI^LR7OGMM
8 D DEMO^LR7OGU(DFN,.LRDFN,.PNM,.AGE,.SEX) ;Demograph required by LR7OGMM
9 I '$G(LRDFN) Q
10 S ^TMP("OR7OG",$J,"G")=DFN_U_PNM_U_LRDFN_U_AGE_U_SEX_"^8"
11 S IX=GMTS1
12 F IXO=1:1:GMTSNDM S IX=$O(^LR(LRDFN,"MI",IX)) Q:'IX!(IX>GMTS2) D XTRCT
13 Q
14XTRCT N ACC,CDT,SS,CS,X,X0,DIC,DIQ,DA,DR,MICRO,LOC,RDT,MICCOM,RPT
15 S RPT=IX,X0=^LR(LRDFN,"MI",IX,0),X=$P(X0,U),RDT=$P(X0,U,3),ACC=$P(X0,U,6),LOC=$P(X0,U,8)
16 Q:'X Q:'$P(X0,"^",5)
17 S CDT=$$REGDTM4^ORDVU(X)
18 D LABTEST(X,ACC)
19 ; External format of site/specimen, collection sample, and comment
20 S DIC=63,DIQ="MICRO",DIQ(0)="E",DA=LRDFN,DA(63.05)=IX,DR=5,DR(63.05)=".05;.055;.99"
21 D EN^DIQ1
22 S SS=MICRO(63.05,IX,.05,"E"),CS=MICRO(63.05,IX,.055,"E"),MICCOM=MICRO(63.05,IX,.99,"E")
23 S ^TMP("ORM",$J,RPT,SS)=CDT_U_ACC_U_CS_U_SS_U_LRTSTS
24 S ^TMP("ORM",$J,RPT,SS,"IMP")=MICCOM
25 D ABXLEV,BACT,GRAM,STER,PARA^ORDV05X,MYCO^ORDV05X,TB^ORDV05X,VIRO^ORDV05X
26 D MI^ORDV05T(LRDFN,IX,ALL,.OUTCNT,FORMAT,.DONE)
27 I $D(^TMP("OR7OGX",$J,"OUTPUT"))>0 M ^TMP("ORM",$J,RPT,SS,"REPORT")=^TMP("OR7OGX",$J,"OUTPUT")
28 K ^TMP("OR7OGX",$J,"OUTPUT")
29 K LRTSTS
30 Q
31BACT ; Get Bacteriology Work-up
32 N DA,DIC,DIQ,DR,STATUS,ISO,ORG,RMK,COM,SMEAR,ORGIEN
33 I $D(^LR(LRDFN,"MI",IX,1)) D
34 . S DIC=63,DA=LRDFN,DA(63.05)=IX,DR=5,DR(63.05)="11.5",DIQ="STATUS"
35 . S DIQ(0)="E" D EN^DIQ1
36 . S ^TMP("ORM",$J,RPT,SS)=^TMP("ORM",$J,RPT,SS)_U_STATUS(63.05,IX,11.5,"E")
37 S ISO=0 F S ISO=$O(^LR(LRDFN,"MI",IX,3,ISO)) Q:+ISO'>0 D
38 . S ORGIEN=+^LR(LRDFN,"MI",IX,3,ISO,0)
39 . D ORGNSM
40 . S ^TMP("ORM",$J,RPT,SS,"RPT",ORGIEN)="B"_U_$S($D(EXPAND):ISO_";"_ORG,1:ORG)
41 . I $O(^LR(LRDFN,"MI",IX,3,ISO,1)) D ANTIBX
42 ; Bacteriology smear/prep
43 S SMEAR=0
44 F S SMEAR=$O(^LR(LRDFN,"MI",IX,25,SMEAR)) Q:SMEAR'>0 S ^TMP("ORM",$J,RPT,SS,"IMP","BACT","SMEAR",SMEAR)=^(SMEAR,0)
45 ; remark
46 S RMK=0
47 F S RMK=$O(^LR(LRDFN,"MI",IX,4,RMK)) Q:RMK="" S ^TMP("ORM",$J,RPT,SS,"IMP","BACT","RMK",RMK)=^(RMK,0)
48 Q
49ORGNSM N QTY
50 S QTY=$P(^(0),U,2)
51 S ORG=$$GET1^DIQ(61.2,ORGIEN,.01,"I")
52 S ORG=ORG_U_QTY
53 Q
54ANTIBX ; Get Antibitiotic susceptibility results on demand
55 N ABX S ABX=1
56 F S ABX=$O(^LR(LRDFN,"MI",IX,3,ISO,ABX)) Q:ABX=""!(ABX'<3) D ABXSET
57 Q
58ABXSET ; Set Antibiotic Susceptability data, when appropriate
59 ; Separate out by Susceptable, Intermediate, and Resistant
60 N FOUND,GMTSR,GMABX,ABXI,ABXNM,ABXN
61 S ABXI=$$ABXI(ABX),ABXNM=$$ABXNM(ABXI),ABXN=ABX_";"_ABXNM
62 I $P(ABXN,";",2)']"" S $P(ABXN,";",2)="UNKNOWN"
63 I ("A"[$P(^LR(LRDFN,"MI",IX,3,ISO,ABX),U,3)) D
64 . S GMABX=$G(^LR(LRDFN,"MI",IX,3,ISO,ABX))
65 . ;Check for interpreted result being S, I, or R first
66 . S FOUND=0
67 . S GMTSR=$P(GMABX,U,2) D SAVE Q:FOUND
68 . ;If not found then check reported result for S, I, or R
69 . S GMTSR=$P(GMABX,U) D SAVE Q:FOUND
70 Q
71ABXI(X) ; Antibiotic Susceptability IEN
72 S X=$G(X) Q:'$L(X) 0 N D,DIC,DTOUT,DUOUT,Y S DIC="^LAB(62.06,",D="AD",DIC(0)="" D MIX^DIC1 S X=+($G(Y)) S:X'>0 X=0 Q X
73ABXNM(X) ; Antibiotic Susceptability Name
74 S X=$G(X) Q:+X'>0 "" S X=$$GET1^DIQ(62.06,+X,.01) Q X
75ABXLEV ; Get Serum antibiotic level
76 Q:'$D(^LR(LRDFN,"MI",IX,14)) N GMI S GMI=0
77 F S GMI=$O(^LR(LRDFN,"MI",IX,14,GMI)) Q:GMI'>0 S ^TMP("ORM",$J,"CABXL",GMI)=$G(^(GMI,0))
78 Q
79STER ; Get sterility results if they exist
80 N RESULT,STER
81 S STER=0
82 F S STER=$O(^LR(LRDFN,"MI",IX,31,STER)) Q:STER'>0 D
83 . S DIQ(0)="E",DIC=63,DA=LRDFN,DA(63.05)=IX,DR=5,DR(63.05)=11.52
84 . S DR(63.292)=.01,DIQ="RESULT"
85 . S DA(63.292)=STER
86 . D EN^DIQ1
87 . S ^TMP("ORM",$J,RPT,SS,"IMP","BSTER",STER)=RESULT(63.292,STER,.01,"E")
88 Q
89GRAM ; Get Gram Stain Results
90 N ISO
91 Q:'$D(^LR(LRDFN,"MI",IX,2))
92 S ISO=0
93 F S ISO=$O(^LR(LRDFN,"MI",IX,2,ISO)) Q:ISO="" S ^TMP("ORM",$J,RPT,SS,"IMP","GRAM",ISO)=^(ISO,0)
94 Q
95LABTEST(SDT,LRACC) ;Get lab test names and results
96 N X,Y,LRAA,LRAN,LRAD,LRBRR,LRTS
97 K LRTSTS
98 S LRTSTS="UNKNOWN"
99 S LRAD=+$E(SDT)_$P(LRACC," ",2)_"0000",X=$P(LRACC," "),DIC=68,DIC(0)="M"
100 Q:'$L(X) D ^DIC S LRAA=+Y,LRAN=+$P(LRACC," ",3)
101 S LRBRR=0
102 F S LRBRR=+$O(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LRBRR)) Q:LRBRR'>0 D
103 . S LRTS=+^LRO(68,LRAA,1,LRAD,1,LRAN,4,LRBRR,0),LRTS(1)=$P(^(0),U,5)
104 . Q:"BO"'[$P($G(^LAB(60,LRTS,0)),U,3)
105 . S LRTSTS=$S($D(^LAB(60,LRTS,0)):$P(^(0),U),1:"deleted test")
106 Q
107SAVE ;If result = S, I, or R then save
108 I $S(GMTSR="I":1,GMTSR="R":1,GMTSR="S":1,1:0) S ^TMP("ORM",$J,RPT,SS,"RPT",ORGIEN,ABX)=ABXNM_U_GMABX S FOUND=1
109 Q
Note: See TracBrowser for help on using the repository browser.