[613] | 1 | MAGXCVI ;WOIFO/SEB,MLH - Image Index Conversion Generate ; 24 Mar 2005 10:52 AM
|
---|
| 2 | ;;3.0;IMAGING;**17,25,31**;Mar 31, 2005
|
---|
| 3 | ;; +---------------------------------------------------------------+
|
---|
| 4 | ;; | Property of the US Government. |
|
---|
| 5 | ;; | No permission to copy or redistribute this software is given. |
|
---|
| 6 | ;; | Use of unreleased versions of this software requires the user |
|
---|
| 7 | ;; | to execute a written test agreement with the VistA Imaging |
|
---|
| 8 | ;; | Development Office of the Department of Veterans Affairs, |
|
---|
| 9 | ;; | telephone (301) 734-0100. |
|
---|
| 10 | ;; | |
|
---|
| 11 | ;; | The Food and Drug Administration classifies this software as |
|
---|
| 12 | ;; | a medical device. As such, it may not be changed in any way. |
|
---|
| 13 | ;; | Modifications to this software may result in an adulterated |
|
---|
| 14 | ;; | medical device under 21CFR820, the use of which is considered |
|
---|
| 15 | ;; | to be a violation of US Federal Statutes. |
|
---|
| 16 | ;; +---------------------------------------------------------------+
|
---|
| 17 | ;;
|
---|
| 18 | Q
|
---|
| 19 | ; Extract fields from an image record and look them up in the
|
---|
| 20 | ; conversion global ^XTMP("MAG30P25","MAPPING") for possible values for
|
---|
| 21 | ; Package, Class, Type, Procedure/Event and Specialty.
|
---|
| 22 | ; Currently uses the following fields:
|
---|
| 23 | ; #3 - Object Type (0;6)
|
---|
| 24 | ; #6 - Procedure (0;8)
|
---|
| 25 | ; #8 - Image Save By (2;2)
|
---|
| 26 | ; #10 - Short Desc (2;4)
|
---|
| 27 | ; #14 - Group Parent (0;10)
|
---|
| 28 | ; #16 - Parent Data File (2;6)
|
---|
| 29 | ; #100 - Document Category (100;1)
|
---|
| 30 | ;
|
---|
| 31 | ; Entry point for the generate image indices option (MAG IMAGE INDEX GEN indices)
|
---|
| 32 | GEN N START,END,RUN,TMF
|
---|
| 33 | N ZTRTN,ZTDESC,ZTSAVE,ZTSK,ZTDTH,ZTIO ; -- TaskMan control variables
|
---|
| 34 | N RECFLAG ; ------------------------------ true (1) if all image index entries should be recreated
|
---|
| 35 | ;
|
---|
| 36 | I '$D(^XTMP("MAG30P25","MAPPING")) D Q
|
---|
| 37 | . W !,"You must load the mapping file before running this option."
|
---|
| 38 | . Q
|
---|
| 39 | L +MAGTMP("IMAGE INDEX GENERATION"):0 E D Q
|
---|
| 40 | . W !,"Image index generation still in progress. Please try again later."
|
---|
| 41 | . Q
|
---|
| 42 | L +MAGTMP("IMAGE INDEX COMMIT"):0 E D Q
|
---|
| 43 | . W !,"Image index commit still in progress. Please try again later."
|
---|
| 44 | . Q
|
---|
| 45 | S (START,END)=0,RECFLAG=""
|
---|
| 46 | D BOUNDS^MAGXCVP(.START,.END) I START="^" Q
|
---|
| 47 | D RECREATE^MAGXCVP(.RECFLAG) I RECFLAG="^" Q
|
---|
| 48 | D TASKMAN^MAGXCVP(.TMF) I TMF="^" G DONE
|
---|
| 49 | S ZTSK=0 I TMF="" D GEN1(START,END,RECFLAG,0) G DONE
|
---|
| 50 | S ZTRTN="GENTM^MAGXCVI",ZTDESC="GENERATE IMAGE INDEX VALUES",ZTDTH=TMF
|
---|
| 51 | S ZTSAVE("START")=START,ZTSAVE("END")=END,ZTSAVE("RECFLAG")=RECFLAG,ZTIO=""
|
---|
| 52 | D ^%ZTLOAD
|
---|
| 53 | W !!,"Image index generation has been queued as task #"_ZTSK_"."
|
---|
| 54 | L -MAGTMP("IMAGE INDEX COMMIT")
|
---|
| 55 | L -MAGTMP("IMAGE INDEX GENERATION")
|
---|
| 56 | Q
|
---|
| 57 | ;
|
---|
| 58 | ; TaskMan entry point for generating image indices
|
---|
| 59 | GENTM D GEN1(START,END,RECFLAG,1)
|
---|
| 60 | Q
|
---|
| 61 | ;
|
---|
| 62 | GEN1(START,END,RECFLAG,QUEUED) ; Main entry point.
|
---|
| 63 | ;
|
---|
| 64 | N MAGIEN,CT,RESULT,STARTDT,ENDDT,SUMMARY,STOP
|
---|
| 65 | N CURDAT ; -- current FileMan date
|
---|
| 66 | N EXPDAT ; -- expiration date for ^XTMP
|
---|
| 67 | ;
|
---|
| 68 | ; Don't let others run while we're running, but give adequate quit time
|
---|
| 69 | ; to the foreground process that generated us.
|
---|
| 70 | L +MAGTMP("IMAGE INDEX GENERATION"):1800 E Q
|
---|
| 71 | ; 10-day retention for the ^XTMP output node
|
---|
| 72 | S CURDAT=$$DT^XLFDT
|
---|
| 73 | S EXPDAT=$$FMADD^XLFDT(CURDAT,10)
|
---|
| 74 | K ^XTMP("MAGCVIXGEN")
|
---|
| 75 | S ^XTMP("MAGCVIXGEN",0)=EXPDAT_U_CURDAT_U_"IMAGE INDEX CONVERSION"
|
---|
| 76 | K ^XTMP("MAG30P25","SUMMARY"),^TMP($J)
|
---|
| 77 | S $P(^XTMP("MAG30P25","STATUS"),U,13,14)=1_U_ZTSK
|
---|
| 78 | D NOW^%DTC S Y=% D DD^%DT S STARTDT=Y
|
---|
| 79 | S START=+$G(START),END=+$G(END),STOP=0
|
---|
| 80 | I END=0 S END=+$P($G(^MAG(2005,0)),U,3)
|
---|
| 81 | S $P(^XTMP("MAG30P25","STATUS"),U,1,5)=DUZ_U_START_U_STARTDT_U_U
|
---|
| 82 | S MAGIEN=START-1 I MAGIEN=-1 S MAGIEN=0
|
---|
| 83 | I 'QUEUED W !!
|
---|
| 84 | F CT=0:1 S MAGIEN=$O(^MAG(2005,MAGIEN)) Q:MAGIEN>END!(+MAGIEN'=MAGIEN) D I STOP Q
|
---|
| 85 | . D GEN2(MAGIEN,CT,RECFLAG,QUEUED) S $P(^XTMP("MAG30P25","STATUS"),U,6)=MAGIEN
|
---|
| 86 | . I QUEUED,$$S^%ZTLOAD S STOP=1,$P(^XTMP("MAG30P25","STATUS"),U,13)=2
|
---|
| 87 | . Q
|
---|
| 88 | D NOW^%DTC S Y=% D DD^%DT S ENDDT=Y
|
---|
| 89 | S $P(^XTMP("MAG30P25","STATUS"),U,4,5)=$S(STOP:MAGIEN,1:END)_U_ENDDT
|
---|
| 90 | S ^XTMP("MAG30P25","SUMMARY")=$P(^XTMP("MAG30P25","STATUS"),U,2,5)
|
---|
| 91 | I 'STOP S $P(^XTMP("MAG30P25","STATUS"),U,13)=3
|
---|
| 92 | D NOTIFY^MAGXCVP(.RESULT,1,STARTDT,ENDDT,START,END,RECFLAG)
|
---|
| 93 | L -MAGTMP("IMAGE INDEX GENERATION") ; now others can get in
|
---|
| 94 | Q
|
---|
| 95 | ;
|
---|
| 96 | GEN2(MAGIEN,CT,XFREC,QUEUED) N INDXDATA
|
---|
| 97 | N SUMMARY ; ---- summary node for this set of index field values
|
---|
| 98 | N FQUIT ; -- flag to bypass records w/existing values not to be regen'd
|
---|
| 99 | ;
|
---|
| 100 | ;Patch 8 has been installed
|
---|
| 101 | ;or "recreate previously calculated indices" question answered no.
|
---|
| 102 | I $TR($G(^MAG(2005,MAGIEN,40)),"^")'="" D Q:$G(FQUIT)
|
---|
| 103 | . S FQUIT=1 ; Assume they may not recreate.
|
---|
| 104 | . ; "Recreate previously calculated indices" question answered no?
|
---|
| 105 | . I $E($G(XFREC))="N" K ^XTMP("MAGIXCVGEN",MAGIEN) Q ; yes
|
---|
| 106 | . ; Don't allow generation unless the previous calculation was done by us.
|
---|
| 107 | . I $D(^MAGIXCVT(2006.96,MAGIEN)) K FQUIT ; ok
|
---|
| 108 | . Q
|
---|
| 109 | I 'QUEUED,CT#100=0 W MAGIEN
|
---|
| 110 | I 'QUEUED,CT#10=0 W "."
|
---|
| 111 | I XFREC="N",$D(^XTMP("MAGIXCVGEN",MAGIEN)) Q
|
---|
| 112 | K ^XTMP("MAGIXCVGEN",MAGIEN)
|
---|
| 113 | D GENIEN(MAGIEN,.INDXDATA)
|
---|
| 114 | D NOW^%DTC S ^XTMP("MAGIXCVGEN",MAGIEN)=%_U_INDXDATA
|
---|
| 115 | I INDXDATA="" S INDXDATA="(none)"
|
---|
| 116 | S SUMMARY=$G(^XTMP("MAG30P25","SUMMARY",INDXDATA))
|
---|
| 117 | I $P(SUMMARY,U,2)="" S $P(SUMMARY,U,2)=MAGIEN
|
---|
| 118 | S $P(SUMMARY,U,3)=MAGIEN
|
---|
| 119 | S $P(SUMMARY,U)=$P(SUMMARY,U)+1
|
---|
| 120 | S ^XTMP("MAG30P25","SUMMARY",INDXDATA)=SUMMARY,^(INDXDATA,MAGIEN)=""
|
---|
| 121 | Q
|
---|
| 122 | ;
|
---|
| 123 | ; Generate indices for one image (IEN=MAGIEN), return indices in INDXDATA
|
---|
| 124 | GENIEN(MAGIEN,INDXDATA) N GRPIEN,MAGTMP,MAGVALS,FLDDATA,MAPDATA,FLDNUM,UTYPE
|
---|
| 125 | N D0,D1,INDXVAL,UNIQUE,FIRSTVAL,DESC,CHILD1
|
---|
| 126 | N I ; --------- loop index
|
---|
| 127 | N MAGNOD ; ---- nodes of the current record, for fast lookup
|
---|
| 128 | N HITDESC ; --- flag set to TRUE if we get a hit on SHORT DESCRIPTION
|
---|
| 129 | N SHDSCTXT ; -- short description text
|
---|
| 130 | N CMPIDX ; ---- index array for comparison (to see if we already mapped)
|
---|
| 131 | ;
|
---|
| 132 | S GRPIEN=$P($G(^MAG(2005,MAGIEN,0)),U,10)
|
---|
| 133 | I GRPIEN="" S GRPIEN=MAGIEN ; this image is not in a group
|
---|
| 134 | I '$D(^MAG(2005,GRPIEN)) S GRPIEN=MAGIEN
|
---|
| 135 | F I=0,2,100 S MAGNOD(I)=$G(^MAG(2005,GRPIEN,I))
|
---|
| 136 | K MAGVALS
|
---|
| 137 | S MAGVALS(3,"I")=$P(MAGNOD(0),U,6) ; object type
|
---|
| 138 | S MAGVALS(6,"I")=$P(MAGNOD(0),U,8) ; procedure
|
---|
| 139 | S MAGVALS(8,"I")=$P(MAGNOD(2),U,2) ; image save by
|
---|
| 140 | S MAGVALS(10,"I")=$P(MAGNOD(2),U,4) ; short description
|
---|
| 141 | S MAGVALS(16,"I")=$P(MAGNOD(2),U,6) ; parent data file
|
---|
| 142 | S MAGVALS(100,"I")=$P(MAGNOD(100),U) ; descriptive category
|
---|
| 143 | S CHILD1=$P($G(^MAG(2005,GRPIEN,1,1,0)),U)
|
---|
| 144 | I CHILD1="" S CHILD1=MAGIEN ; this image is not in a group
|
---|
| 145 | I CHILD1'="" S MAGVALS(3,"I")=$P($G(^MAG(2005,CHILD1,0)),U,6)
|
---|
| 146 | S INDXDATA=""
|
---|
| 147 | ; If these field values have already been indexed, reuse the previously
|
---|
| 148 | ; mapped-to values.
|
---|
| 149 | F FLDNUM=3,6,8,10,16,100 D
|
---|
| 150 | . S X=$G(MAGVALS(FLDNUM,"I")),CMPIDX(FLDNUM)=$S(X]"":X,1:"@")
|
---|
| 151 | . Q
|
---|
| 152 | S INDXDATA=$G(^TMP($J,"CMPIDX",CMPIDX(3),CMPIDX(6),CMPIDX(8),CMPIDX(10),CMPIDX(16),CMPIDX(100)))
|
---|
| 153 | I INDXDATA="" D GENINEW^MAGXCVI1 ; no previous indexing on these values
|
---|
| 154 | ; save indices for possible later re-use
|
---|
| 155 | S ^TMP($J,"CMPIDX",CMPIDX(3),CMPIDX(6),CMPIDX(8),CMPIDX(10),CMPIDX(16),CMPIDX(100))=INDXDATA
|
---|
| 156 | Q
|
---|
| 157 | ;
|
---|
| 158 | DONE W !!,"Done!"
|
---|
| 159 | Q
|
---|
| 160 | ;
|
---|
| 161 | ; Silent call to generate and commit image indices for one image (IEN=MAGIEN)
|
---|
| 162 | ONE(MAGIEN) N INDXDATA
|
---|
| 163 | D GENIEN(MAGIEN,.INDXDATA),COMIEN^MAGXCVC(MAGIEN,.INDXDATA)
|
---|
| 164 | Q
|
---|