Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLPOST16

HLPOST16.m

Go to the documentation of this file.
  1. HLPOST16 ;AISC/SAW,JRP - Post-init Routine for DHCP HL7 v. 1.6 ;1/24/95
  1. ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
  1. ;Declare variables
  1. N DA,DIC,DIE,DR,X,Y,HLAPP,HLMID,HLST,HLX,HLORIGDT,HLORIGMI
  1. N HLX1,HLCNVCNT,HLPRTDOT,HLABORT,HLAPNM,HLTMP,HLORIGAP,HLORIGST
  1. S HLABORT=0
  1. W !!,"- File conversions started on ",$$DH4PRT^HLCSFMN1()," -"
  1. ;Add entries in file 770 into file 771
  1. W !!,"Copying entries from HL7 NON-DHCP APPLICATION PARAMETER file (#770)"
  1. W !,"to HL7 APPLICATION PARAMETER file (#771) "
  1. ;Lock files
  1. L +^HL(771):10 I ('$T) D Q
  1. .W !!,"** Conversion halted **"
  1. .W !,"** Unable to lock HL7 APPLICATION PARAMETER file **"
  1. .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
  1. .S:($D(ZTQUEUED)) ZTREQ="@"
  1. L +^HL(770):10 I ('$T) D Q
  1. .L -^HL(771)
  1. .W !!,"** Conversion halted **"
  1. .W !,"** Unable to lock HL7 NON-DHCP APPLICATION PARAMETER file **"
  1. .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
  1. .S:($D(ZTQUEUED)) ZTREQ="@"
  1. ;Loop through 770
  1. S HLX=0 F HLCNVCNT=1:1 S HLX=$O(^HL(770,HLX)) Q:HLX'>0 D Q:(HLABORT)
  1. .W:('(HLCNVCNT#5)) "." W:($X>(IOM-2)) !
  1. .;User aborted
  1. .S HLABORT=$$S^%ZTLOAD
  1. .Q:(HLABORT)
  1. .;Get application name
  1. .S HLX1=$G(^HL(770,HLX,0))
  1. .S HLAPNM=$P(HLX1,"^",1)
  1. .I (HLAPNM="") D Q
  1. ..W !,?5,"* Entry number ",HLX," does not have an application name"
  1. .;Entry already converted
  1. .Q:($P(HLX1,"^",12))
  1. .;If entry exists in 770 and 771 with same name, change name of
  1. .; entry in 771 by appending "-DHCP" to it
  1. .S DA=$O(^HL(771,"B",HLAPNM,0)) I DA D
  1. ..S DIE="^HL(771,",DR=".01///"_HLAPNM_"-DHCP" D ^DIE K DIE,DR
  1. .K DA,DD,DO S DIC="^HL(771,",X=HLAPNM,DIC(0)="" D FILE^DICN
  1. .I ('Y) D Q
  1. ..W !,?5,"* Unable to copy ",HLAPNM," (entry #",HLX,")"
  1. .S DIE="^HL(771,",DR="2///a;3///"_$P(HLX1,"^",3),DA=+Y D ^DIE K DIE,DR
  1. .;Stuff pointer to 771 in field 12 of file 770
  1. .S DR="12///"_DA,DA=HLX,DIE="^HL(770," D ^DIE
  1. L -^HL(771)
  1. L -^HL(770)
  1. I (HLABORT) D Q
  1. .W !!,"** Conversion of files has been asked to stop **"
  1. .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
  1. .S:($D(ZTQUEUED)) ZTREQ="@"
  1. ;Purge data in file 772 so that only last seven days are retained
  1. W !!,"Purging data from HL7 MESSAGE TEXT file (#772) "
  1. S HLPRTDOT=1
  1. D DQ^HLUOPT1
  1. I ($$S^%ZTLOAD) D Q
  1. .W !!,"** Conversion of files has been asked to stop **"
  1. .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
  1. .S:($D(ZTQUEUED)) ZTREQ="@"
  1. ;Convert data in fields .01,3 and 20 of file 772 to new format
  1. W !!,"Converting newly defined fields in HL7 MESSAGE TEXT file (#772) "
  1. ;Loop through 772
  1. S HLX=0
  1. F HLCNVCNT=1:1 S HLX=+$O(^HL(772,HLX)) Q:(HLX'>0) D Q:(HLABORT)
  1. .;Lock entry
  1. .L +^HL(772,HLX):10 I ('$T) D Q
  1. ..W !,?5,"* Unable to lock entry number ",HLX," - entry not converted"
  1. ..;Check for user aborted
  1. ..S HLABORT=$$S^%ZTLOAD
  1. .W:('(HLCNVCNT#5)) "." W:($X>(IOM-2)) !
  1. .;User aborted
  1. .S HLABORT=$$S^%ZTLOAD
  1. .I (HLABORT) L -^HL(772,HLX) Q
  1. .;Get date/time of message (field #.01)
  1. .S HLX1=$G(^HL(772,HLX,0))
  1. .S HLORIGDT=+HLX1
  1. .I ('HLORIGDT) D Q
  1. ..W !,?5,"* Entry number ",HLX," does not have a date & time of message"
  1. ..L -^HL(772,HLX)
  1. .;Already converted
  1. .I ((HLORIGDT'?7N.1".".6N)!($D(^HLMA(HLORIGDT)))) L -^HL(772,HLX) Q
  1. .;Get application name (field #3)
  1. .S HLORIGAP=$P($G(^HL(770,+$P(HLX1,"^",3),0)),"^")
  1. .;Get status (field #20)
  1. .S HLORIGST=$P($G(^HL(772,HLX,"P")),"^")
  1. .;Get message ID (field #6)
  1. .S HLORIGMI=$P(HLX1,"^",6)
  1. .;Convert .01 field by creating entry in file #773 to point to
  1. .; HLMID will be a pointer to file #773, if it is KILLED before
  1. .; making the call
  1. .K HLMID D MA^HLTF(HLORIGDT) K HLDT
  1. .;Convert field 3
  1. .S HLAPP=""
  1. .S:(HLORIGAP'="") HLAPP=+$O(^HL(771,"B",HLORIGAP,0))
  1. .;Convert field 20
  1. .S HLST=$S(HLORIGST="P":1,HLORIGST="A":2,HLORIGST="E":4,1:3)
  1. .;Store converted values
  1. .I $G(HLMID) D
  1. ..S DIE="^HL(772,"
  1. ..S DA=HLX
  1. ..S DR=".01////"_HLMID_";3////"_HLAPP_";20////"_HLST
  1. ..D ^DIE
  1. ..;Change message IDs to match original message ID
  1. ..S DIE="^HL(772,"
  1. ..S DA=HLX
  1. ..S DR="6////"_HLORIGMI
  1. ..D ^DIE
  1. ..S DIE="^HLMA("
  1. ..S DA=HLMID
  1. ..S DR="2////"_HLORIGMI
  1. ..D ^DIE
  1. .;Unlock entry
  1. .L -^HL(772,HLX)
  1. I (HLABORT) D Q
  1. .W !!,"** Conversion of files has been asked to stop **"
  1. .W !,"** Use the entry point REQUEUE^HLPOST to requeue the file conversions **"
  1. .S:($D(ZTQUEUED)) ZTREQ="@"
  1. W !!,"- File conversions completed on ",$$DH4PRT^HLCSFMN1()," -",!!
  1. S:($D(ZTQUEUED)) ZTREQ="@"
  1. Q