source: qrda/C0Q/trunk/p/C0QIMMUN.m@ 1582

Last change on this file since 1582 was 1501, checked in by Sam Habiel, 12 years ago

Latest routines; T11 copy

File size: 2.3 KB
Line 
1C0QIMMUN ;Prep Immunization Order data for HL7 Message creation ; 5/23/12 5:40pm
2 ;;1.0;C0Q;;May 21, 2012;Build 63
3 ; ^XTMP("C0QIMMUN",0)=purge date^create date
4 ; ^XTMP("C0QIMMUN",order_date,order#,item_name)=item_value
5 ; ^XTMP("C0QIMMUN","LASTORDR")=last order processed
6 ; Changed by VEN/SMH to add timeout to the locks on May 23 2012
7FIND ; Find the next set of immunization orders
8 N X1,X2,X,%,%DT,%H,%T,NOW,ORDER,LASTORDR,SUBSC,DIR
9 S LASTORDR=+$G(^XTMP("C0QIMMUN","LASTORDR"))
10 N C0QFAIL S C0QFAIL=0 ; Lock fail flag
11 W !,"The ""Last Order"" from which to begin checking for Immunization orders is: ",LASTORDR
12 S DIR("A")="Do you want to reset that value"
13 S DIR(0)="Y",DIR("B")="NO" D ^DIR D:Y=1
14 . S DIR("A")="What value shall be used?"
15 . S DIR(0)="NO",DIR("B")=LASTORDR D ^DIR
16 . W:Y'>0 !,"We'll skip reseting it then."
17 . D:Y>0
18 . . S LASTORDR=+Y
19 . . L +^XTMP("C0QIMMUN"):0
20 . . E S C0QFAIL=1 QUIT
21 . . S X1=DT,X2=365 D C^%DTC
22 . . S ^XTMP("C0QIMMUN",0)=X_U_DT
23 . . S ^XTMP("C0QIMMUN","LASTORDR")=LASTORDR
24 . . L -^XTMP("C0QIMMUN")
25 . . Q
26 . Q
27 I C0QFAIL W !,"Failed to acquire lock, exiting..." QUIT
28 S DIR("A")="Ready to prep more immunization orders for HL7 messages"
29 S DIR(0)="Y",DIR("B")="YES" D ^DIR Q:Y'=1
30 L +^XTMP("C0QIMMUN"):0
31 E W !,"Failed to acquire lock; exiting..." QUIT
32 I '$D(^XTMP("C0QIMMUN",0)) D
33 . S X1=DT,X2=365 D C^%DTC
34 . S ^XTMP("C0QIMMUN",0)=X_U_DT
35 . S ^XTMP("C0QIMMUN","LASTORDR")=0
36 S ORDER=^XTMP("C0QIMMUN","LASTORDR")
37 F S ORDER=$O(^OR(100,ORDER)) Q:ORDER'>0 D
38 . S LASTORDR=ORDER
39 . D:$D(^OR(100,ORDER,4.5,"ID","ORZ HL7")) GOTONE
40 . Q
41 S ^XTMP("C0QIMMUN","LASTORDR")=LASTORDR
42 W !,"Done",!,"Last Order processed: ",LASTORDR,!
43 L -^XTMP("C0QIMMUN")
44 Q
45GOTONE ; Take the order number and move the relevant HL7 information into ^XTMP
46 S NOW=$P(^OR(100,ORDER,0),U,7)
47 S ^XTMP("C0QIMMUN",NOW,ORDER,"PATIENT")=$P(^OR(100,ORDER,0),U,2)
48 S ^XTMP("C0QIMMUN",NOW,ORDER,"LOCATION")=$P(^OR(100,ORDER,0),U,10)
49 S ^XTMP("C0QIMMUN",NOW,ORDER,"ORDEREDBY")=$P(^OR(100,ORDER,0),U,6)
50 S ENTRY=0 F S ENTRY=$O(^OR(100,ORDER,4.5,ENTRY)) Q:ENTRY'>0 D
51 . S SUBSC=$P($G(^OR(100,ORDER,4.5,ENTRY,0)),U,4)
52 . Q:'$L(SUBSC)
53 . I SUBSC'="TIME" S ^XTMP("C0QIMMUN",NOW,ORDER,SUBSC)=^OR(100,ORDER,4.5,ENTRY,1)
54 . E S X=^OR(100,ORDER,4.5,ENTRY,1),%DT="TS" D ^%DT S ^XTMP("C0QIMMUN",NOW,ORDER,SUBSC)=Y
55 . Q
56 S ^XTMP("C0QIMMUN",NOW,ORDER,"ORDERTEXT")=$G(^OR(100,ORDER,8,1,.1,1,0))
57 Q
Note: See TracBrowser for help on using the repository browser.