source: FOIAVistA/tag/r/SURGERY-SR/SRHLUI.m@ 1093

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

initial load of FOIAVistA 6/30/08 version

File size: 5.5 KB
Line 
1SRHLUI ;B'ham ISC/DLR - Surgery Interface Utility to process incoming segments ; [ 02/06/01 9:53 PM ]
2 ;;3.0; Surgery ;**41,100**;24 Jun 93
3 ; Per VHA Directive 10-93-142, this routine SHOULD NOT be modified.
4 ;;This routine utilizes the Surgery Interface file (133.2).
5OBR(CASE,DFN,IEN,MSG) ;process Observation Request Segment (OBR) fields 3-4,7-8,27
6 ;variables set in the calling routine SRHLORU
7 ; CASE - IEN of the case # in Surgery Case file (#130)
8 ; DFN - IEN of the patient
9 ; IEN - The Observation ID's internal entry number in file 133.2
10 ; MSG - (parameter) HL7 incoming segment
11 ;
12 K DA,DR,DIE
13 N LVL,OBR,SRNOCON,SRX
14 Q:$G(MSG)="" ""
15 ;set the surgery no concurrent case flag
16 S SRNOCON=1
17 S OBR=MSG,DA=CASE,DIE=$P(^SRO(133.2,IEN,0),U,2) K DR,DO
18 ;if there is a VISTA Surgery field(s) associated with this entry process the DR strings
19 I $P(^SRO(133.2,IEN,0),U,3)!($D(^(1,0))) D
20 .S:$P(^SRO(133.2,IEN,0),U,3) DR=$P(^(0),U,3)_"///^S X="_$$VALUE(IEN) D:$D(^SRO(133.2,IEN,1,0))
21 ..;sets the DR string level (DR and DR(2,...)) for the standard DIE call
22 ..S SRX=0 F S SRX=$O(^SRO(133.2,IEN,1,SRX)) Q:'SRX S LVL=$P(^SRO(133.2,SRX,0),U,9) Q:"12"[$G(LVL)&($G(LVL)="") I $$VALUE(SRX)'="" D:$$CHECK(SRX) DR(LVL,SRX)
23 .I $D(DR) N SRESQ D
24 ..D ^SROESHL Q:SRESQ
25 ..D DRCHK D ^DIE K DIE,DA,DR,DO I $D(Y) S SRDISC="Unknown OBR identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL)
26 Q OBR
27CHECK(IEN) ;check universal id or observation id sequence to the Surgery Interface file
28 I $G(IEN)="" Q 0
29 Q $P($G(^SRO(133.2,IEN,0)),U,4)["R"
30VALUE(XX) ;SET the value of the identified segment field in file 133.2
31 S ^TMP("SR7",XX)=^SRO(133.2,XX,0)
32 N VALUE
33 ;set the value of the identifiers based on the sequences identified in file 133.2
34 S:$P(^SRO(133.2,XX,0),U,6)'="CN" VALUE=$P($P(@$P(^SRO(133.2,XX,0),U,5),HL("FS"),$P($P(^(0),U,8),"-")+1),HLCOMP,$P($P(^(0),U,8),"-",2))
35 S:$P(^SRO(133.2,XX,0),U,6)="CN" VALUE=$P(@$P(^SRO(133.2,XX,0),U,5),HL("FS"),$P($P(^(0),U,8),"-")+1)
36 S:VALUE'="" VALUE=$S($P(^SRO(133.2,XX,0),U,6)="TS":$$FMDATE^HLFNC(VALUE),$P(^(0),U,6)="CE":""""_VALUE_"""",$P(^(0),U,6)="TX":""""_VALUE_"""",$P(^(0),U,6)="FT":""""_VALUE_"""",$P(^(0),U,6)="NM":+VALUE,1:VALUE)
37 I $P(^SRO(133.2,XX,0),U,6)="CN" S VALUE=$$DNAME^SRHLU(VALUE),VALUE=$S(VALUE="":"",1:""""_VALUE_"""")
38 Q VALUE
39DR(LVL,IEN) ;set DR or DR(... string for the FileMan DIE call
40 Q:$G(LVL)=""!$G(IEN)=""
41 ;set DR string but do not four slash stuff Time Stamped values for multiples
42 I LVL=1 S VALUE=$$VALUE(IEN) S:VALUE'="" DR=$G(DR)_$S($D(DR):";",1:"")_$P(^SRO(133.2,IEN,0),U,3)_$S($P(^(0),U,6)="TS"&($P(^(0),U,3)'=".01")&('$D(^(1,0))):"/",1:"")_"///"_VALUE
43 ;set DR string but do not four slash stuff Time Stamped values for multiples
44 I LVL'=1 S VALUE=$$VALUE(IEN) S:VALUE'="" DR(LVL,$P(^SRO(133.2,IEN,0),U,2))=$G(DR(LVL,$P(^(0),U,2)))_$S($D(DR(LVL,$P(^(0),U,2))):";",1:"")_$P(^(0),U,3)_$S($P(^(0),U,6)="TS"&($P(^(0),U,3)'=".01")&('$D(^(1,0))):"/",1:"")_"///"_VALUE
45 Q
46NTE(MSG,OBR,CASE) ;process Observation Segment (OBX) fields 3,5,14,16 and NTE-3
47 ;anesthesia comments
48 Q:MSG=""
49 N ID
50 S ID=$P($P(OBR,HL("FS"),5),HLCOMP,2) I $G(ID)="" S SRDISC="Unknown OBR identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
51 S IEN=$O(^SRO(133.2,"AC",ID,0)) I $G(IEN)="" S SRDISC="Unknown OBR identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
52 Q:$$CHECK(IEN)'=1
53 I ID="ANESTHESIA" D
54 .I $P(MSG,HL("FS"),2)>1,'$D(^SRF(CASE,6,1,7,0)) S SRDISC="Invalid sequence this NTE segment, '"_MSG_"'." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
55 .S:$P(MSG,HL("FS"),2)=1 ^SRF(CASE,6,1,7,0)="^^0^0^"_DT_"^^^^" S ^SRF(CASE,6,1,7,$P(^SRF(CASE,6,1,7,0),U,3)+1,0)=$P(MSG,HL("FS"),4),$P(^(0),U,3)=$P(^SRF(CASE,6,1,7,0),U,3)+1,$P(^(0),U,4)=$P(^(0),U,4)+1,$P(^(0),U,5)=DT
56 Q
57OBX(MSG,OBR,CASE) ;process Observation Segment (OBX) fields 3,5,14,16 and NTE-3
58 N ID,IEN,NM,OBX,SRESQ,TYPE
59 S DA=CASE,OBX=MSG
60 S ID=$P($P(OBR,HL("FS"),5),HLCOMP,2) I $G(ID)="" S SRDISC="Unknown OBR identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
61 S IEN=$O(^SRO(133.2,"AC",ID,0)) I $G(IEN)="" S SRDISC="Unknown OBX identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
62 Q:$$CHECK(IEN)'=1
63 I $P(^SRO(133.2,IEN,0),U,3) S NM=$$VALUE(IEN) I NM="" S SRDISC="Unknown OBX identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
64 K DIE,DR,DO S DIE=$P(^SRO(133.2,IEN,0),U,2) I DIE="" S SRDISC="Unknown OBX identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
65 I $P(^SRO(133.2,IEN,0),U,3) S DR=$P(^(0),U,3)_"///^S X="_NM D:$D(^SRO(133.2,IEN,1,0))
66 .S SRX=0 F S SRX=$O(^SRO(133.2,IEN,1,SRX)) Q:'SRX S LVL=$P(^SRO(133.2,SRX,0),U,9) Q:"12"[$G(LVL)&($G(LVL)="") I $$VALUE(SRX)'="" D DR(LVL,SRX)
67 ;set the msg variable to the segment type for the VALUE subroutine
68 I $P(MSG,HL("FS"))="OBX" S ID=$P($P(MSG,HL("FS"),4),HLCOMP,2) I $G(ID)="" S SRDISC="Unknown OBX identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
69 S IEN=$O(^SRO(133.2,"AC",ID,0)) I $G(IEN)="" S SRDISC="Unknown OBX identifier ("_$G(ID)_")." D SETDSC^SRHLU(.HL,SRDISC,.SRHL) Q
70 S NM=$$VALUE(IEN) I NM="" Q
71 ;if field is set to receive, then set DR string for DIE call
72 I $$CHECK(IEN)=1 S LVL=$P(^SRO(133.2,IEN,0),U,9) D DR(LVL,IEN) D:$D(^SRO(133.2,IEN,1,0)) N SRESQ D ^SROESHL Q:SRESQ D ^DIE K DIE,DA,DR,DO
73 .S SRX=0 F S SRX=$O(^SRO(133.2,IEN,1,SRX)) Q:'SRX S LVL=$P(^SRO(133.2,SRX,0),U,9) Q:"12"[$G(LVL)&($G(LVL)="") I $$VALUE(SRX)'="" D DR(LVL,SRX)
74 Q
75DRCHK ;CHECK DR STRING (for debugging only)
76 ;Check DR string by removing the Quit and adding TMP( global to the loop
77 Q
78 S SRCNT=+$G(SRCNT)+1 S SRJ="" F S SRJ=$O(DR(SRJ)) Q:'SRJ S SRK="" F S SRK=$O(DR(SRJ,SRK)) Q:'SRK S SRCNT=SRCNT+1
79 Q
Note: See TracBrowser for help on using the repository browser.