source: FOIAVistA/trunk/r/AUTOMATED_INFO_COLLECTION_SYS-IBD/IBDFBKR.m@ 794

Last change on this file since 794 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1IBDFBKR ;ALB/AAS - EF utilite, receive and format data for PCE ; OCT 1,1994
2 ;;3.0;AUTOMATED INFO COLLECTION SYS;;APR 24, 1997
3 ;
4PCE(IB,PXCA) ;
5 ; -- Entry point from Broker receiver to parse data and
6 ; either send to PCE or store until all pages received
7 ;
8 N %,%H,%I,I,J,X,Y,IBDATA,BUBBLES,HANDPRNT,DYNAMIC,RESULT,NEEDMORE,IBDA
9 S RESULT=1
10 ;
11 ; -- Move data from input format to data format
12 S RESULT=$$BRKARY(.IB,.IBDATA)
13 ;
14 ; -- check for valid data
15 S RESULT=$$VALIDD(.IBDATA) I RESULT>3 G PCEQ
16 ;
17 ; -- mark the page as having been received
18 S IBDA=$O(^IBD(357.96,IBDATA("FORMID"),9,"B",+IBDATA("PAGE"),0))_","_IBDATA("FORMID")_","
19 S FDA(357.969,IBDA,.02)=$$NOW^XLFDT
20 ; -- marked stored image as received
21 S X=$O(^IBD(357.96,"AD",IBDATA("PAGE"),IBDATA("FORMID"),0)) I X D
22 .S FDA(357.963,X_","_IBDATA("FORMID")_",",.07)=1
23 D FILE^DIE("","FDA","IBDERR")
24 K DIC,DIE,DR,DA
25 ;
26 ; -- check if all pages have been rec'd (if not freeing ft entry)
27 S NEEDMORE=$$NEEDMOR(.IBDATA)
28 ;
29 I NEEDMORE D
30 .S RESULT=6
31 .S I=0 F S I=$O(IBDF(I)) Q:'I D FILAD(IBDF(I)) Q:RESULT=11
32 .N SUCCESS S SUCCESS=$$FSCND^IBDF18C(IBDATA("FORMID"),11)
33 ;
34 I 'NEEDMORE D
35 .N SUCCESS S SUCCESS=$$FSCND^IBDF18C(IBDATA("FORMID"),2)
36 .S RESULT=7
37 .S I=0 F S I=$O(IBDF(I)) Q:'I D ARYAD(IBDF(I))
38 .;
39 .; -- add to the arrays data from other pages stored in form tracking
40 .S I=0
41 .F S I=$O(^IBD(357.96,IBDATA("FORMID"),10,I)) Q:'I D ARYAD($G(^IBD(357.96,IBDATA("FORMID"),10,I,0)))
42 .;
43 .; -- don't need the raw data kept in form tracking anymore
44 .; -- maybe we do for formtracking???
45 .;K ^IBD(357.96,IBDATA("FORMID"),10)
46 .;
47 .I $$SEND^IBDF18E(IBDATA("FORMID"),"","",.BUBBLES,.HANDPRNT,"",.PXCA,.DYNAMIC)
48 .S RESULT=8
49 .;S RESULT=$S($G(PXCASTAT)=1:8,$G(PXCASTAT)=0:9,1:10)
50 .Q
51 ;
52PCEQ I +RESULT>10 D RECVERR^IBDFBK2(.IBDATA,+RESULT)
53 Q +RESULT_"^"_$P($T(RESULT+RESULT),";;",2)
54 ;
55FILAD(REC) ;
56 ; -- adds the data to the FORM TRACKING file
57 ; -- awaiting all of the pages to be sent
58 ; REC is the line of raw data, as received
59 ; -- may change to FM call???
60 ;N CNT
61 Q:REC=""
62 ; -- remove hard sets and replace with FM call
63 ;S CNT=+$P($G(^IBD(357.96,IBDATA("FORMID"),10,0)),"^",3)
64 ;F S CNT=CNT+1 Q:'$D(^IBD(357.96,IBDATA("FORMID"),10,CNT))
65 ;S ^IBD(357.96,IBDATA("FORMID"),10,CNT,0)=REC
66 ;S ^IBD(357.96,IBDATA("FORMID"),10,0)=$P($G(^IBD(357.96,IBDATA("FORMID"),10,0)),1,2)_"^"_CNT_"^"_CNT
67 ;S ^IBD(357.96,IBDATA("FORMID"),10,"B",$E(REC,1,30),CNT)=""
68 ;
69 L +^IBD(357.96,IBDATA("FORMID")):3 I '$T S RESULT=11 Q
70 S DIC="^IBD(357.96,"_IBDATA("FORMID")_",10,",DIC(0)="L",DIC("P")=$P(^DD(357.96,10,0),"^",2),DA(1)=IBDATA("FORMID"),X=REC,DLAYGO=357.96
71 K DD,DO D FILE^DICN K DIC,DA,DLAYGO,DD,DO
72 L -^IBD(357.96,IBDATA("FORMID"))
73 Q
74 ;
75ARYAD(DATA) ;
76 ; -- Input DATA
77 ; -- DATA format B=bubble or
78 ; H=handprint>:<ien of form element in the form
79 ; definition table>:<value entered
80 ; D=dynamic bubble>:<field identifier>:<number of choice>
81 ; -- Output Bubbles,Dynamic, or Handprint Array.
82 ;
83 I $E(DATA,1)="""",$E(DATA,$L(DATA))="""" S DATA=$P(DATA,"""",2)
84 I $P(DATA,":")="B" S BUBBLES($P(DATA,":",2))=$P(DATA,":",3)
85 I $P(DATA,":")="D" S DYNAMIC($P(DATA,":",2),$P(DATA,":",3))=DATA
86 I $P(DATA,":")="H" S HANDPRNT($P(DATA,":",2))=$P(DATA,":",3,10)
87 Q
88 ;
89BRKARY(IB,IBDATA) ;
90 ; -- break array of data into known parts
91 ; -- Input IB(array) contains raw data from receiver
92 ; IBDATA(array) called by reference
93 ; -- Output IBDATA(array) of new formated data
94 ; result message indicator
95 ;
96 N I,X,CNT
97 S (I,CNT)=0
98 F S I=$O(IBDF(I)) Q:'I!(CNT>3) D
99 .I $P(IB(I),"=")="FORMTYPE" S IBDATA("FORMTYPE")=+$P(IBDF(I),"=",2),CNT=CNT+1 K IBDF(I) Q
100 .I $P(IB(I),"=")="FORMID" S IBDATA("FORMID")=+$P(IBDF(I),"=",2),CNT=CNT+1 K IBDF(I) Q
101 .I $P(IB(I),"=")="PAGE" S IBDATA("PAGE")=+$P(IBDF(I),"=",2),CNT=CNT+1 K IBDF(I) Q
102 .I $P(IB(I),"=")="DATA" S CNT=CNT+1 K IBDF(I) Q ; shouldn't contain data
103BRKQ Q 2
104 ;
105VALIDD(IBDATA) ;
106 ; -- Determine if data contains Formtype, FormID, and Page
107 ; -- Does form ID and form type match entry in Form Tracking
108 ; -- is the form supposed to have this page?
109 ; -- Input IBDATA(array)
110 ; -- Output result message indicator (3=valid, 4=invalid, 5=already recvd)
111 ;
112 N X S X=12 D
113 .I '$G(IBDATA("FORMTYPE")) S X=13 Q
114 .I '$G(IBDATA("FORMID")) S X=14 Q
115 .I '$G(IBDATA("PAGE")) S X=15 Q
116 .;
117 .I $G(^IBD(357.96,+IBDATA("FORMID"),0))="" S X=16 Q
118 .I $P($G(^IBD(357.96,+IBDATA("FORMID"),0)),"^",4)'=IBDATA("FORMTYPE") S X=17 Q
119 .;
120 .I '$O(^IBD(357.96,IBDATA("FORMID"),9,"B",IBDATA("PAGE"),0)) S X=18 Q
121 .;
122 .; -- if pce returned an error then all pages flagged as not received
123 .I $P(^IBD(357.96,IBDATA("FORMID"),9,+$O(^IBD(357.96,IBDATA("FORMID"),9,"B",IBDATA("PAGE"),0)),0),"^",2) S X=5 Q
124 .S X=3
125VQ Q X
126 ;
127NEEDMOR(IBDATA) ;
128 ; -- check to see if all the pages have been received
129 N I,X
130 S (I,X)=0
131 F S I=$O(^IBD(357.96,IBDATA("FORMID"),9,I)) Q:'I D
132 .I $G(^IBD(357.96,IBDATA("FORMID"),9,I,0)),'$P(^(0),"^",2) S X=1 Q
133 .Q
134NMQ Q X
135 ;
136RESULT ;;
137 ;;Beginning to Format Data for PCE
138 ;;Data Accepted, Beginning Validity Check
139 ;;Valid Form Identity Received
140 ;;Form ID Validity Rejected
141 ;;Data from Page already Received
142 ;;Waiting for more pages to be recognized
143 ;;Formatting data for PCE
144 ;;Data Sent to PCE
145 ;;Data Rejected by PCE
146 ;;Unknown result in sending data to PCE
147 ;;Form Tracking Entry locked by another user, Editing not allowed
148 ;;Form ID Validity Rejected
149 ;;Form Definition of zero or null is invalid
150 ;;Form ID of zero or null is invalid
151 ;;Form Page number of zero or null is invalid
152 ;;Form Tracking entry does not exist
153 ;;Form Definition from scanning doesn't match data in Form Tracking
154 ;;Data from non-scannable page was passed
155 ;;Form Rejected, Patient not in clinic
Note: See TracBrowser for help on using the repository browser.