VistA-FOIAVistA/r/REGISTRATION-DGQE-DG-DPT-GR.../VAFHQRY.m

47 lines
1.4 KiB
Mathematica

VAFHQRY ;ALB/RJS - MCCR DATA CAPTURE HANDLES QUERY MESSAGES ; 6/7/95
;;5.3;Registration;**91,415**;Jun 06, 1996
;;HL7v1.6
;
; THIS ROUTINE HANDLES THE QUERY MESSAGES FOR THE HL7 ADT
; PROJECT
;
; INPUT IS THE IEN OF THE MESSAGE IN THE ^HL(772 GLOBAL, "HLDA"
;
; THE ROUTINE PARSES THE MESSAGE AND DETERMINES IF THERE IS A QUERY
; SEGMENT PRESENT. IF SO, THE QUERY IS REQUESTING PATIENT DEMOGRAPHIC
; DATA IN A PID SEGMENT
;
N ERR1,ERR2,ERR3,COMPNENT,SSN,DFN,VAQD
S ERR1="Invalid or missing access code"
S ERR2="Missing QRD Segment"
S ERR3="Could not resolve DFN"
;I $G(HLDUZ)'>0 S HLERR=ERR1 G ACK ;Invalid or missing access code
S HLQ=HL("Q"),HLFS=HL("FS"),HLECH=HL("ECH")
;
S COMPNENT=$E(HL("ECH")) ;hlech
K VADC,HLERR
;D INITIZE^VAFHUTL9(HLDA) ;QUERY MESSAGE RETURNED IN VADC() ARRAY
D INIT1
S VAQD=$$SEG1^VAFHUTL9("QRD",1,"QRD")
I VAQD="" S HLERR=ERR2 G ACK ;Missing QRD segment
;
PARSE ;
S SSN=$P(VAQD,HLFS,9)
S DFN=$$SSNDFN^VAFHUTL9(SSN)
I DFN'>0 S HLERR=ERR3 G ACK
;
S HLA("HLS",1)="MSA"_HL("FS")_$S(HL:$S(HL("VER")=2.1:"AR",1:"CR"),1:"CA")_HL("FS")_HL("MID")_HL("FS")_$P(HL,"^",2)
S HLA("HLS",2)=VAQD
;
S HLA("HLS",3)=$$EN^VAFHLPID(DFN,",2,3,4,5,6,7,8,9,10B,11,12,13,14,15,16,17,18,19,22B")
;
ACK I $D(HLERR) S HLA("HLS",2)="MSA"_HLFS_"AE"_HLFS_HLMID_HLFS_HLERR G EXIT
;
EXIT S HLDT=$$NOW^XLFDT()
D GENERATE^HLMA("VAFH A19","LM",1,.HLRESLT,"",.HL)
Q
;
INIT1 F I=1:1 X HLNEXT Q:HLQUIT'>0 S X(I)=HLNODE MERGE X(I)=HLNODE
MERGE VADC=X
Q