1 | HLPOST16 ;AISC/SAW,JRP - Post-init Routine for DHCP HL7 v. 1.6 ;1/24/95
|
---|
2 | ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
|
---|
3 | ;Declare variables
|
---|
4 | N DA,DIC,DIE,DR,X,Y,HLAPP,HLMID,HLST,HLX,HLORIGDT,HLORIGMI
|
---|
5 | N HLX1,HLCNVCNT,HLPRTDOT,HLABORT,HLAPNM,HLTMP,HLORIGAP,HLORIGST
|
---|
6 | S HLABORT=0
|
---|
7 | W !!,"- File conversions started on ",$$DH4PRT^HLCSFMN1()," -"
|
---|
8 | ;Add entries in file 770 into file 771
|
---|
9 | W !!,"Copying entries from HL7 NON-DHCP APPLICATION PARAMETER file (#770)"
|
---|
10 | W !,"to HL7 APPLICATION PARAMETER file (#771) "
|
---|
11 | ;Lock files
|
---|
12 | L +^HL(771):10 I ('$T) D Q
|
---|
13 | .W !!,"** Conversion halted **"
|
---|
14 | .W !,"** Unable to lock HL7 APPLICATION PARAMETER file **"
|
---|
15 | .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
|
---|
16 | .S:($D(ZTQUEUED)) ZTREQ="@"
|
---|
17 | L +^HL(770):10 I ('$T) D Q
|
---|
18 | .L -^HL(771)
|
---|
19 | .W !!,"** Conversion halted **"
|
---|
20 | .W !,"** Unable to lock HL7 NON-DHCP APPLICATION PARAMETER file **"
|
---|
21 | .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
|
---|
22 | .S:($D(ZTQUEUED)) ZTREQ="@"
|
---|
23 | ;Loop through 770
|
---|
24 | S HLX=0 F HLCNVCNT=1:1 S HLX=$O(^HL(770,HLX)) Q:HLX'>0 D Q:(HLABORT)
|
---|
25 | .W:('(HLCNVCNT#5)) "." W:($X>(IOM-2)) !
|
---|
26 | .;User aborted
|
---|
27 | .S HLABORT=$$S^%ZTLOAD
|
---|
28 | .Q:(HLABORT)
|
---|
29 | .;Get application name
|
---|
30 | .S HLX1=$G(^HL(770,HLX,0))
|
---|
31 | .S HLAPNM=$P(HLX1,"^",1)
|
---|
32 | .I (HLAPNM="") D Q
|
---|
33 | ..W !,?5,"* Entry number ",HLX," does not have an application name"
|
---|
34 | .;Entry already converted
|
---|
35 | .Q:($P(HLX1,"^",12))
|
---|
36 | .;If entry exists in 770 and 771 with same name, change name of
|
---|
37 | .; entry in 771 by appending "-DHCP" to it
|
---|
38 | .S DA=$O(^HL(771,"B",HLAPNM,0)) I DA D
|
---|
39 | ..S DIE="^HL(771,",DR=".01///"_HLAPNM_"-DHCP" D ^DIE K DIE,DR
|
---|
40 | .K DA,DD,DO S DIC="^HL(771,",X=HLAPNM,DIC(0)="" D FILE^DICN
|
---|
41 | .I ('Y) D Q
|
---|
42 | ..W !,?5,"* Unable to copy ",HLAPNM," (entry #",HLX,")"
|
---|
43 | .S DIE="^HL(771,",DR="2///a;3///"_$P(HLX1,"^",3),DA=+Y D ^DIE K DIE,DR
|
---|
44 | .;Stuff pointer to 771 in field 12 of file 770
|
---|
45 | .S DR="12///"_DA,DA=HLX,DIE="^HL(770," D ^DIE
|
---|
46 | L -^HL(771)
|
---|
47 | L -^HL(770)
|
---|
48 | I (HLABORT) D Q
|
---|
49 | .W !!,"** Conversion of files has been asked to stop **"
|
---|
50 | .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
|
---|
51 | .S:($D(ZTQUEUED)) ZTREQ="@"
|
---|
52 | ;Purge data in file 772 so that only last seven days are retained
|
---|
53 | W !!,"Purging data from HL7 MESSAGE TEXT file (#772) "
|
---|
54 | S HLPRTDOT=1
|
---|
55 | D DQ^HLUOPT1
|
---|
56 | I ($$S^%ZTLOAD) D Q
|
---|
57 | .W !!,"** Conversion of files has been asked to stop **"
|
---|
58 | .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
|
---|
59 | .S:($D(ZTQUEUED)) ZTREQ="@"
|
---|
60 | ;Convert data in fields .01,3 and 20 of file 772 to new format
|
---|
61 | W !!,"Converting newly defined fields in HL7 MESSAGE TEXT file (#772) "
|
---|
62 | ;Loop through 772
|
---|
63 | S HLX=0
|
---|
64 | F HLCNVCNT=1:1 S HLX=+$O(^HL(772,HLX)) Q:(HLX'>0) D Q:(HLABORT)
|
---|
65 | .;Lock entry
|
---|
66 | .L +^HL(772,HLX):10 I ('$T) D Q
|
---|
67 | ..W !,?5,"* Unable to lock entry number ",HLX," - entry not converted"
|
---|
68 | ..;Check for user aborted
|
---|
69 | ..S HLABORT=$$S^%ZTLOAD
|
---|
70 | .W:('(HLCNVCNT#5)) "." W:($X>(IOM-2)) !
|
---|
71 | .;User aborted
|
---|
72 | .S HLABORT=$$S^%ZTLOAD
|
---|
73 | .I (HLABORT) L -^HL(772,HLX) Q
|
---|
74 | .;Get date/time of message (field #.01)
|
---|
75 | .S HLX1=$G(^HL(772,HLX,0))
|
---|
76 | .S HLORIGDT=+HLX1
|
---|
77 | .I ('HLORIGDT) D Q
|
---|
78 | ..W !,?5,"* Entry number ",HLX," does not have a date & time of message"
|
---|
79 | ..L -^HL(772,HLX)
|
---|
80 | .;Already converted
|
---|
81 | .I ((HLORIGDT'?7N.1".".6N)!($D(^HLMA(HLORIGDT)))) L -^HL(772,HLX) Q
|
---|
82 | .;Get application name (field #3)
|
---|
83 | .S HLORIGAP=$P($G(^HL(770,+$P(HLX1,"^",3),0)),"^")
|
---|
84 | .;Get status (field #20)
|
---|
85 | .S HLORIGST=$P($G(^HL(772,HLX,"P")),"^")
|
---|
86 | .;Get message ID (field #6)
|
---|
87 | .S HLORIGMI=$P(HLX1,"^",6)
|
---|
88 | .;Convert .01 field by creating entry in file #773 to point to
|
---|
89 | .; HLMID will be a pointer to file #773, if it is KILLED before
|
---|
90 | .; making the call
|
---|
91 | .K HLMID D MA^HLTF(HLORIGDT) K HLDT
|
---|
92 | .;Convert field 3
|
---|
93 | .S HLAPP=""
|
---|
94 | .S:(HLORIGAP'="") HLAPP=+$O(^HL(771,"B",HLORIGAP,0))
|
---|
95 | .;Convert field 20
|
---|
96 | .S HLST=$S(HLORIGST="P":1,HLORIGST="A":2,HLORIGST="E":4,1:3)
|
---|
97 | .;Store converted values
|
---|
98 | .I $G(HLMID) D
|
---|
99 | ..S DIE="^HL(772,"
|
---|
100 | ..S DA=HLX
|
---|
101 | ..S DR=".01////"_HLMID_";3////"_HLAPP_";20////"_HLST
|
---|
102 | ..D ^DIE
|
---|
103 | ..;Change message IDs to match original message ID
|
---|
104 | ..S DIE="^HL(772,"
|
---|
105 | ..S DA=HLX
|
---|
106 | ..S DR="6////"_HLORIGMI
|
---|
107 | ..D ^DIE
|
---|
108 | ..S DIE="^HLMA("
|
---|
109 | ..S DA=HLMID
|
---|
110 | ..S DR="2////"_HLORIGMI
|
---|
111 | ..D ^DIE
|
---|
112 | .;Unlock entry
|
---|
113 | .L -^HL(772,HLX)
|
---|
114 | I (HLABORT) D Q
|
---|
115 | .W !!,"** Conversion of files has been asked to stop **"
|
---|
116 | .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
|
---|
117 | .S:($D(ZTQUEUED)) ZTREQ="@"
|
---|
118 | W !!,"- File conversions completed on ",$$DH4PRT^HLCSFMN1()," -",!!
|
---|
119 | S:($D(ZTQUEUED)) ZTREQ="@"
|
---|
120 | Q
|
---|