| 1 | SRHLZIU ;B'HAM ISC/DLR - Surgery Interface Sender of Scheduling Information Unsolicited ; [ 05/19/98  9:35 AM ]
 | 
|---|
| 2 |  ;;3.0; Surgery ;**41**;24 Jun 93
 | 
|---|
| 3 |  ; Per VHA Directive 10-93-142, this routine SHOULD NOT be modified.
 | 
|---|
| 4 | MSG(CASE,SRSTATUS,SREVENT) ;Send ZSQ message.
 | 
|---|
| 5 |  ;This message is sent for every event point within the surgery options.
 | 
|---|
| 6 |  ;There will be a ZIU message sent for each of the following surgery
 | 
|---|
| 7 |  ;events: S12 New Appointment; S13 Reschedule; S14 Modification; 
 | 
|---|
| 8 |  ;S15 Cancellation; and S17 Deletion.  The events codes are set to
 | 
|---|
| 9 |  ;SREVENT within the surgery routine options.
 | 
|---|
| 10 |  ;
 | 
|---|
| 11 | START ;
 | 
|---|
| 12 |  I $$V^SRHLU D MSG^SRHLVZIU(CASE,SRSTATUS,SREVENT) Q
 | 
|---|
| 13 |  S HLDAP=$O(^HL(771,"B","SR SURGERY",0)) Q:$G(HLDAP)=""
 | 
|---|
| 14 |  Q:$P($G(^HL(771,HLDAP,0)),U,2)'="a"
 | 
|---|
| 15 |  K ^TMP("HLS",$J)
 | 
|---|
| 16 |  N HLSUB,HLREP,SRX,SRDSP,SRET,UPDATE,PRT,OUT
 | 
|---|
| 17 |  ;V. 1.6 interface
 | 
|---|
| 18 |  ;EID - IEN of event protocol
 | 
|---|
| 19 |  ;HL - array of output parameters
 | 
|---|
| 20 |  ;INT - only for VISTA-to-VISTA message exchange
 | 
|---|
| 21 |  ;SRET - Surgery Event Trigger
 | 
|---|
| 22 |  D EVNTP
 | 
|---|
| 23 |  S EID=$O(^ORD(101,"B",SRET,0)),HL="HL",INT=0
 | 
|---|
| 24 |  D INIT^HLFNC2(EID,.HL,INT) S HLCOMP=$E(HL("ECH"),1),HLREP=$E(HL("ECH"),2),HLSUB=$E(HL("ECH"),4),HLFS=HL("FS"),HLQ=HL("Q"),HLECH=HL("ECH")
 | 
|---|
| 25 |  ;Q:'$O(HL("")) ;read HL for the error message 
 | 
|---|
| 26 |  D SEG
 | 
|---|
| 27 |  D CHECK I $D(UPDATE) D GEN,DISPLAY
 | 
|---|
| 28 | EXIT ;
 | 
|---|
| 29 |  K EID,HL,INT,^TMP("HLS",$J)
 | 
|---|
| 30 |  Q
 | 
|---|
| 31 | GEN ;generate the message
 | 
|---|
| 32 |  ;HLEID - IEN of event protocol
 | 
|---|
| 33 |  ;HLARYTYP - acknowledgement array (see V. 1.6 HL7 doc)
 | 
|---|
| 34 |  ;HLFORMAT - is HLMA is pre-formatted HL7 form
 | 
|---|
| 35 |  ;HLMTIEN - IEN in 772
 | 
|---|
| 36 |  ;HLRESLT - message ID and/or the error message (for output)
 | 
|---|
| 37 |  ;HLP("CONTPTR") - continuation pointer field value (not used)
 | 
|---|
| 38 |  ;HLP("PRIORITY") - priority field value (not used)
 | 
|---|
| 39 |  ;HLP("SECURITY") - security information (not used)
 | 
|---|
| 40 |  S HLEID=EID,HLARYTYP="GM",HLFORMAT=1,HLMTIEN="",HLRESLT=""
 | 
|---|
| 41 |  D GENERATE^HLMA(HLEID,HLARYTYP,HLFORMAT,.HLRESLT,HLMTIEN,.HLP)
 | 
|---|
| 42 |  Q
 | 
|---|
| 43 | SEG ;segments
 | 
|---|
| 44 |  N SRI
 | 
|---|
| 45 |  S SRI=1
 | 
|---|
| 46 |  D ZCH^SRHLUO1(.SRI,.SREVENT,.SRSTATUS,"HLS")
 | 
|---|
| 47 |  D PID^SRHLUO(.SRI,"HLS")
 | 
|---|
| 48 |  D AL1^SRHLUO(.SRI,"HLS")
 | 
|---|
| 49 |  D OBX^SRHLUO(.SRI,"HLS")
 | 
|---|
| 50 |  D DG1^SRHLUO(.SRI,"HLS")
 | 
|---|
| 51 |  D ZIS^SRHLUO2(.SRI,"HLS")
 | 
|---|
| 52 |  D ZIG^SRHLUO1(.SRI,"HLS")
 | 
|---|
| 53 |  D ZIP^SRHLUO1(.SRI,"HLS")
 | 
|---|
| 54 |  D ZIL^SRHLUO1(.SRI,"HLS")
 | 
|---|
| 55 |  Q
 | 
|---|
| 56 | CHECK ;checks ^XTMP for duplicate modification messages
 | 
|---|
| 57 |  N X
 | 
|---|
| 58 |  I $D(^XTMP("SRHL7"_CASE,EID,0)) D
 | 
|---|
| 59 |  .S X=0 F  S X=$O(^TMP("HLS",$J,X)) Q:'X!($D(UPDATE))  D
 | 
|---|
| 60 |  ..I '$D(^XTMP("SRHL7"_CASE,EID,X)) S UPDATE=1 Q
 | 
|---|
| 61 |  ..I ^TMP("HLS",$J,X)'=^XTMP("SRHL7"_CASE,EID,X) S UPDATE=1
 | 
|---|
| 62 |  .I $O(^XTMP("SRHL7"_CASE,EID,X)) S UPDATE=1
 | 
|---|
| 63 |  I '$D(^XTMP("SRHL7"_CASE,EID,0))!$D(UPDATE) K ^XTMP("SRHL7"_CASE,EID) S UPDATE=1,^XTMP("SRHL7"_CASE,EID,0)=DT D
 | 
|---|
| 64 |  .S X=0 F  S X=$O(^TMP("HLS",$J,X)) Q:'X  S ^XTMP("SRHL7"_CASE,EID,X)=^TMP("HLS",$J,X)
 | 
|---|
| 65 |  Q
 | 
|---|
| 66 | DISPLAY ;screen message to user
 | 
|---|
| 67 |  W !,SRDSP
 | 
|---|
| 68 |  Q
 | 
|---|
| 69 | EVNTP ;set Surgery event trigger protocol and display
 | 
|---|
| 70 |  S SRDSP="Sending a Notification of Appointment "
 | 
|---|
| 71 |  I SREVENT="S12" S X="Booking"
 | 
|---|
| 72 |  I SREVENT="S13" S X="Rescheduling"
 | 
|---|
| 73 |  I SREVENT="S14" S X="Modification"
 | 
|---|
| 74 |  I SREVENT="S15" S X="Cancellation"
 | 
|---|
| 75 |  I SREVENT="S17" S X="Deletion"
 | 
|---|
| 76 |  S SRDSP=SRDSP_X_" for case #"_CASE
 | 
|---|
| 77 |  S SRET="SR Notification of Appointment "_X
 | 
|---|
| 78 |  Q
 | 
|---|