source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHV7BU.m@ 1006

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

initial load of WorldVistAEHR

File size: 4.9 KB
Line 
1MHV7BU ;WAS/EFJ - HL7 message builder UTILITY ; [12/14/06 11:10am]
2 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; Utilities common to message and segment builders.
6 ;
7 Q
8 ;
9PID3(PID,ICN,DFN,SSN) ;Build PID3 - Patient Identifier List
10 ; Populates PID array with Patient Identifier List Entries for
11 ; ICN, DFN, and SSN.
12 ;
13 ; Integration Agreements:
14 ; 10112 : $$SITE^VASITE
15 ;
16 ; Input:
17 ; ICN, DFN, SSN - Identifiers
18 ;
19 ; Output:
20 ; PID - PID array
21 ;
22 N STATION,IDCNT
23 S STATION=$P($$SITE^VASITE,"^",3)
24 S IDCNT=0
25 I ICN'="" D
26 . S IDCNT=IDCNT+1
27 . S PID(3,IDCNT,1)=ICN ;Patient ID - ICN
28 . S PID(3,IDCNT,4,1)="USVHA" ;assigning authority ID
29 . S PID(3,IDCNT,4,3)="HL70363" ;assigning authority type
30 . S PID(3,IDCNT,5)="NI" ;Patient ID type
31 . S PID(3,IDCNT,6,1)="VA FACILITY ID" ;assigning facility
32 . S PID(3,IDCNT,6,2)=STATION ;Station number
33 . S PID(3,IDCNT,6,3)="L" ;facility ID type
34 ;
35 I DFN'="" D
36 . S IDCNT=IDCNT+1
37 . S PID(3,IDCNT,1)=DFN ;Patient ID - DFN
38 . S PID(3,IDCNT,4,1)="USVHA" ;assigning authority ID
39 . S PID(3,IDCNT,4,3)="HL70363" ;assigning authority type
40 . S PID(3,IDCNT,5)="PI" ;Patient ID type
41 . S PID(3,IDCNT,6,1)="VA FACILITY ID" ;assigning facility
42 . S PID(3,IDCNT,6,2)=STATION ;Station number
43 . S PID(3,IDCNT,6,3)="L" ;facility ID type
44 ;
45 I SSN'="" D
46 . S IDCNT=IDCNT+1
47 . S PID(3,IDCNT,1)=SSN ;Patient ID - SSN
48 . S PID(3,IDCNT,4,1)="USSSA" ;assigning authority ID
49 . S PID(3,IDCNT,4,3)="HL70363" ;assigning authority type
50 . S PID(3,IDCNT,5)="SS" ;Patient ID type
51 . S PID(3,IDCNT,6,1)="VA FACILITY ID" ;assigning facility
52 . S PID(3,IDCNT,6,2)=STATION ;Station number
53 . S PID(3,IDCNT,6,3)="L" ;facility ID type
54 Q
55 ;
56FMTNAME(NAME,SUBSEG,HL,DATATYPE) ;Format comma/space delimited name
57 ; Populates SUBSEG array with formatted and escaped name components
58 ; based on the DATATYPE passed. XCN types and XPN types differ in
59 ; that XCN has an ID in the first component effectively shifting the
60 ; name components by one.
61 ;
62 ; Integration Agreements:
63 ; 3065 : NAMEFMT^XLFNAME
64 ;
65 ; Input:
66 ; NAME - FileMan formatted name Ex: PATIENT,FIRST M
67 ; HL - HL7 package array variable
68 ; DATATYPE - HL7 data type to be formatted Ex: XCN, XPN
69 ;
70 ; Output:
71 ; SUBSEG - Array to hold the formatted name.
72 ;
73 ; Example Usage:
74 ; S NAME="SMITH,BOB A"
75 ; K NMARR
76 ; D FMTNAME^MHV7BU(NAME,.NMARR,.HL,"XCN")
77 ; M PD1(4,1)=NMARR
78 ;
79 N OFFSET
80 S OFFSET=(DATATYPE="XCN")
81 S NAME=$$NAMEFMT^XLFNAME(.NAME,"F","DSP")
82 S SUBSEG(1+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",1),.HL) ;family
83 S SUBSEG(2+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",2),.HL) ;given
84 S SUBSEG(3+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",3),.HL) ;middle
85 S SUBSEG(4+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",4),.HL) ;suffix
86 S SUBSEG(5+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",5),.HL) ;prefix
87 S SUBSEG(6+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",6),.HL) ;degree
88 Q
89 ;
90FMTNAME2(IEN,FILE,SUBSEG,HL,DATATYPE) ;Lookup and format name
91 ; Looks up name components based on IEN and FILE passed.
92 ; Populates SUBSEG array with formatted and escaped name components
93 ; based on the DATATYPE passed. XCN types and XPN types differ in
94 ; that XCN has an ID in the first component effectively shifting the
95 ; name components by one.
96 ;
97 ; Integration Agreements:
98 ; 3065 : NAMEFMT^XLFNAME
99 ;
100 ; Input:
101 ; IEN - IEN of patient/person in FILE
102 ; FILE - File number of file Ex: 2 - PATIENT file
103 ; HL - HL7 package array variable
104 ; DATATYPE - HL7 data type to be formatted Ex: XCN, XPN
105 ;
106 ; Output:
107 ; SUBSEG - Array to hold the formatted name.
108 ;
109 ; Example Usage:
110 ; K NMARR
111 ; D FMTNAME^MHV7BU(DFN,2,.NMARR,.HL,"XPN")
112 ; M PID(5,1)=NMARR
113 ;
114 N NAME,OFFSET
115 S OFFSET=(DATATYPE="XCN")
116 S NAME("FILE")=FILE,NAME("FIELD")=.01,NAME("IENS")=IEN_","
117 S NAME=$$NAMEFMT^XLFNAME(.NAME,"F","DSP")
118 S SUBSEG(1+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",1),.HL) ;family
119 S SUBSEG(2+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",2),.HL) ;given
120 S SUBSEG(3+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",3),.HL) ;middle
121 S SUBSEG(4+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",4),.HL) ;suffix
122 S SUBSEG(5+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",5),.HL) ;prefix
123 S SUBSEG(6+OFFSET)=$$ESCAPE^MHV7U($P(NAME," ",6),.HL) ;degree
124 Q
125 ;
126FMTHL7(DT) ;Convert Fileman formatted dates to HL7 format
127 ; Handles imprecise dates properly because $$FMTHL7^XLFDT does not.
128 ; Strips Timezone offset
129 ;
130 ; Integration Agreements:
131 ; 10103 : FMTHL7^XLFDT
132 ;
133 ; Input:
134 ; DT - Fileman formatted date/time
135 ;
136 ; Output: Returns HL7 formatted date/time
137 ;
138 S DT=$$FMTHL7^XLFDT(DT)
139 I $E(DT,7,8)="00" S DT=$E(DT,1,6)
140 I $E(DT,5,6)="00" S DT=$E(DT,1,4)
141 S DT=$P(DT,"-")
142 S DT=$P(DT,"+")
143 Q DT
144 ;
Note: See TracBrowser for help on using the repository browser.