source: FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAG7RSD.m

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

initial load of FOIAVistA 6/30/08 version

File size: 3.5 KB
Line 
1MAG7RSD ;WOIFO/PMK,MLH - copy radiology message from HLSDATA to ^MAGDHL7 - add admitting diagnosis data ; 07 Jul 2003 12:43 PM
2 ;;3.0;IMAGING;**11**;14-April-2004
3 ;; +---------------------------------------------------------------+
4 ;; | Property of the US Government. |
5 ;; | No permission to copy or redistribute this software is given. |
6 ;; | Use of unreleased versions of this software requires the user |
7 ;; | to execute a written test agreement with the VistA Imaging |
8 ;; | Development Office of the Department of Veterans Affairs, |
9 ;; | telephone (301) 734-0100. |
10 ;; | |
11 ;; | The Food and Drug Administration classifies this software as |
12 ;; | a medical device. As such, it may not be changed in any way. |
13 ;; | Modifications to this software may result in an adulterated |
14 ;; | medical device under 21CFR820, the use of which is considered |
15 ;; | to be a violation of US Federal Statutes. |
16 ;; +---------------------------------------------------------------+
17 ;;
18 ;
19DG1DGADM ; SUBROUTINE - called by PV1ADD
20 ; Add admitting diagnosis to ADT and ORM messages.
21 ; Expects: MAG7WRK() HL7 message array
22 ;
23 N IXSEG ; ---------- segment index
24 N IXPRED,IXSUCC ; -- indices to segments to be inserted between
25 N IXDG1 ; ---------- index of DG1 segment on MAG7WRK()
26 ;
27 ; are there already diagnosis segments out there?
28 I $D(MAG7WRK("B","DG1")) D
29 . ; yes, add another DG1 after the last DG1 we find
30 . S IXPRED=$O(MAG7WRK("B","DG1"," "),-1)
31 . S IX=$O(MAG7WRK(IXPRED)),IXDG1=$S(IX:IXPRED+IX/2,1:IXPRED+1)
32 . ; fill in set ID (must follow in lockstep sequence)
33 . S MAG7WRK(IXDG1,1,1,1,1)=$G(MAG7WRK(IXPRED,1,1,1,1))+1
34 . Q
35 E D DG1DGAD1 ; no, find a place to insert a DG1 into the message
36 I $G(IXDG1) D ; we found a place - insert
37 . S MAG7WRK(IXDG1,3,1,2,1)=VAIN(9),MAG7WRK(IXDG1,6,1,1,1)="A"
38 . S MAG7WRK("B","DG1",IXDG1)="",MAG7WRK(IXDG1,0)="DG1"
39 . Q
40 Q
41 ;
42DG1DGAD1 ; SUBROUTINE - called by DG1DGADM
43 ; Find optional segments between the required PV1 and where we will insert
44 ; a DG1. If message structure is corrupt (i.e., no PV1 segment in an ADT
45 ; message) don't try to insert a DG1 segment. If we don't recognize the
46 ; message type, don't try to insert a DG1 segment.
47 ;
48 ; Expects: MAG7WRK() HL7 message array
49 ;
50 ; Returns: IXDG1 index of the DG1 segment to be inserted into
51 ;
52 N IXSEG ; ---------- segment index
53 N IXPRED,IXSUCC ; -- indices to segments to be inserted between
54 N DG1SETID ; ------- set ID for DG1
55 ;
56 ; are there any DG1 segments on file?
57 I $D(MAG7WRK("B","DG1")) D ; yes, get index and set ID of the last one
58 . S IXPRED=$O(MAG7WRK("B","DG1"," "),-1)
59 . S DG1SETID=MAG7WRK(IXPRED,1,1,1,1)
60 . Q
61 E D ; no, find a place to insert, and initialize the set ID
62 . I $G(MAG7WRK(1,9,1,1,1))="ADT" D
63 . . S (IXSEG,IXPRED)=$O(MAG7WRK("B","PV1","")) Q:'IXSEG
64 . . F S IXSEG=$O(MAG7WRK(IXSEG)) Q:'IXSEG Q:"^PV2^ROL^DB1^OBX^AL1^"'[("^"_$G(MAG7WRK(IXSEG,0))_"^") S IXPRED=IXSEG
65 . . Q
66 . E I $G(MAG7WRK(1,9,1,1,1))="ORM" D
67 . . S (IXSEG,IXPRED)=$O(MAG7WRK("B","OBR","")) Q:'IXSEG
68 . . F S IXSEG=$O(MAG7WRK(IXSEG)) Q:'IXSEG Q:"^NTE^CTD^"'[("^"_$G(MAG7WRK(IXSEG,0))_"^") S IXPRED=IXSEG
69 . . Q
70 . S DG1SETID=0
71 . Q
72 ; now compute the index of the DG1 segment, and fill in the Set ID
73 S IXSUCC=$O(MAG7WRK(IXPRED)),IXDG1=$S(IXSUCC:IXPRED+IXSUCC/2,1:IXPRED+1)
74 S MAG7WRK(IXDG1,1,1,1,1)=DG1SETID+1 ; set ID always begins at 1
75 Q
Note: See TracBrowser for help on using the repository browser.