File size: 35,726 Bytes
0827183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "from app import connector\n",
    "import time\n",
    "conn=connector()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GENERATE\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'conversationId': 'FDfvsSZMkEa2wQkHX58myW-eu',\n",
       " 'token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsIng1dCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsInR5cCI6IkpXVCJ9.eyJib3QiOiI0OWU3Mzc4Yy02MGEyLTk0MTAtZmVhYy0zNjNjYzBiZjYzMjgiLCJzaXRlIjoiV2lkbl9BY05tWTQiLCJjb252IjoiRkRmdnNTWk1rRWEyd1FrSFg1OG15Vy1ldSIsIm5iZiI6MTcxOTgzMjY0MywiZXhwIjoxNzE5ODM2MjQzLCJpc3MiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLCJhdWQiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8ifQ.Qvm73JBGautoQ60MqoxRlmbjrYFwcTS7_6Y2VjnWFKEvIdUHd2CWoTlpL1aUqtlnZvvpaBA8iFraC3z9Lj-9thi0l83bWmMABZ_9ZVc6T0pBzwG0QtFNHASjnfCzrAT5fBQ3AWXNEIPxgnPPOi503j71eJhG4fqgsV2ZQYA-4UNstujTwVtIpm0pga-C4Bks7UIzGvOcdyq53R-SvUR7rqKksIgeZHDR0GRUz0aCAdiWxEZe2DQbjxTqlu5lvCb5bVz9S069fdXDF4jARqal4IhIcHzvOc7FVyDrhjbHL3stN7fc-o5mG2fn5JjAy5OHNtp2tYxUJcu9w0cqJTV-7A',\n",
       " 'expires_in': 3600}"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info=conn.generate()\n",
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "START CONVERSATION\n",
      "\n",
      "{'conversationId': 'FDfvsSZMkEa2wQkHX58myW-eu', 'token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsIng1dCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsInR5cCI6IkpXVCJ9.eyJib3QiOiI0OWU3Mzc4Yy02MGEyLTk0MTAtZmVhYy0zNjNjYzBiZjYzMjgiLCJzaXRlIjoiV2lkbl9BY05tWTQiLCJjb252IjoiRkRmdnNTWk1rRWEyd1FrSFg1OG15Vy1ldSIsIm5iZiI6MTcxOTgzMjY0NCwiZXhwIjoxNzE5ODM2MjQ0LCJpc3MiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLCJhdWQiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8ifQ.pEGceF3_8aeYExZHifP8Gy16Nx4gj8UOES2o2u7X54So90CcVeDgbpiRZ1QdKcsEsruO-9KXoOJFvKIAV342Zwf15r8GtLdZSxPUCsER16QXxGc0TxC_Gi_8bBec-ILHPe52EqiDfotReOv9TDcYkiegGGZENdIC_9lpULJVJXTbugBBCLTVIwlB4VRvpvJItYMwosRXV6w3XvQ6CABH1hvKRLDfFfytjm0UeURC-GSEWWl8ViS2JEylYlyh9aN2GR2xB13yRqgr-SjTF7m2bAMkKooOPlT0YXQMS17KpIUw_oCSDHKvUNul1QgyM4_nl6bnv7f--_SAi9CoinMd7A', 'expires_in': 3600, 'streamUrl': 'wss://europe.directline.botframework.com/v3/directline/conversations/FDfvsSZMkEa2wQkHX58myW-eu/stream?watermark=-&t=eyJhbGciOiJSUzI1NiIsImtpZCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsIng1dCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsInR5cCI6IkpXVCJ9.eyJib3QiOiI0OWU3Mzc4Yy02MGEyLTk0MTAtZmVhYy0zNjNjYzBiZjYzMjgiLCJzaXRlIjoiV2lkbl9BY05tWTQiLCJjb252IjoiRkRmdnNTWk1rRWEyd1FrSFg1OG15Vy1ldSIsIm5iZiI6MTcxOTgzMjY0NCwiZXhwIjoxNzE5ODMyNzA0LCJpc3MiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLCJhdWQiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8ifQ.dgzf_ywaa2D8EQQjaGRfpM1TESXAV0LJwQSjvZq3TK-lamrPYpNN42SvNM9T6k-wAra_vX36Xk2i1i4-QqGXKTESeBEPIQ2n936fUFHZDtYZwsID4idQSXxysW5B7IIuQ3QBMZU3PLH0SPCw_fCdEW80KWyoWsnIjxniKA4sPB2_HogWWGixfbYa_djZKWLWkYvOusqxVuoPfFPuO8M3fQJQhWiE3r5o4251Of7fAe-dmQG5vXeWl3PJowq1m76jCGbc16UR_ldtsxkMKqdSoEtkEbTP0NvnibMHwbdSQMj4IXyptFido9Xc0fR2y7cj98SNfc7anH7ydlX5_tdobw', 'referenceGrammarId': 'f81d2e90-3197-775d-ac27-3daecccb560d'}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'conversationId': 'FDfvsSZMkEa2wQkHX58myW-eu',\n",
       " 'token': 'eyJhbGciOiJSUzI1NiIsImtpZCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsIng1dCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsInR5cCI6IkpXVCJ9.eyJib3QiOiI0OWU3Mzc4Yy02MGEyLTk0MTAtZmVhYy0zNjNjYzBiZjYzMjgiLCJzaXRlIjoiV2lkbl9BY05tWTQiLCJjb252IjoiRkRmdnNTWk1rRWEyd1FrSFg1OG15Vy1ldSIsIm5iZiI6MTcxOTgzMjY0NCwiZXhwIjoxNzE5ODM2MjQ0LCJpc3MiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLCJhdWQiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8ifQ.pEGceF3_8aeYExZHifP8Gy16Nx4gj8UOES2o2u7X54So90CcVeDgbpiRZ1QdKcsEsruO-9KXoOJFvKIAV342Zwf15r8GtLdZSxPUCsER16QXxGc0TxC_Gi_8bBec-ILHPe52EqiDfotReOv9TDcYkiegGGZENdIC_9lpULJVJXTbugBBCLTVIwlB4VRvpvJItYMwosRXV6w3XvQ6CABH1hvKRLDfFfytjm0UeURC-GSEWWl8ViS2JEylYlyh9aN2GR2xB13yRqgr-SjTF7m2bAMkKooOPlT0YXQMS17KpIUw_oCSDHKvUNul1QgyM4_nl6bnv7f--_SAi9CoinMd7A',\n",
       " 'expires_in': 3600,\n",
       " 'streamUrl': 'wss://europe.directline.botframework.com/v3/directline/conversations/FDfvsSZMkEa2wQkHX58myW-eu/stream?watermark=-&t=eyJhbGciOiJSUzI1NiIsImtpZCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsIng1dCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsInR5cCI6IkpXVCJ9.eyJib3QiOiI0OWU3Mzc4Yy02MGEyLTk0MTAtZmVhYy0zNjNjYzBiZjYzMjgiLCJzaXRlIjoiV2lkbl9BY05tWTQiLCJjb252IjoiRkRmdnNTWk1rRWEyd1FrSFg1OG15Vy1ldSIsIm5iZiI6MTcxOTgzMjY0NCwiZXhwIjoxNzE5ODMyNzA0LCJpc3MiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLCJhdWQiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8ifQ.dgzf_ywaa2D8EQQjaGRfpM1TESXAV0LJwQSjvZq3TK-lamrPYpNN42SvNM9T6k-wAra_vX36Xk2i1i4-QqGXKTESeBEPIQ2n936fUFHZDtYZwsID4idQSXxysW5B7IIuQ3QBMZU3PLH0SPCw_fCdEW80KWyoWsnIjxniKA4sPB2_HogWWGixfbYa_djZKWLWkYvOusqxVuoPfFPuO8M3fQJQhWiE3r5o4251Of7fAe-dmQG5vXeWl3PJowq1m76jCGbc16UR_ldtsxkMKqdSoEtkEbTP0NvnibMHwbdSQMj4IXyptFido9Xc0fR2y7cj98SNfc7anH7ydlX5_tdobw',\n",
       " 'referenceGrammarId': 'f81d2e90-3197-775d-ac27-3daecccb560d'}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "info=conn.start_conversation(info['token'])\n",
    "info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "PROMT =  \"\"\"Viedoc EC testing: Check that the end date is not prior to start date, code: var a = EXISTDAT; \n",
    "                        if !(a) \n",
    "                            return true; \n",
    "                        else \n",
    "                            return (EX1STDAT > =a); querytext: Note that 'End date' is before 'Start date'. Please reconcile. check that all items aligned with the description\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "SEND\n",
      "\n",
      "200\n",
      "{'id': 'FDfvsSZMkEa2wQkHX58myW-eu|0000000'}\n",
      "\n",
      "FETCH\n",
      "\n",
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'It seems like you are referring to a code snippet for Viedoc EC testing. The code provided checks if the end date is not prior to the start date. If the variable `EXISTDAT` is not defined, it returns true. Otherwise, it compares the start date `EX1STDAT` with `EXISTDAT` and returns the result.\\n\\nThe query text states that the end date is before the start date and suggests reconciling the issue. It also advises checking if all items align with the description.\\n\\nIf you need further assistance or have any specific questions regarding this code or the query text, please let me know.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conn.send_message(info['token'],info['conversationId'],'cohitai',PROMT)\n",
    "time.sleep(4)\n",
    "a= conn.get_message(info['token'],info['conversationId'])\n",
    "a[\"activities\"][-1][\"text\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "PROMT = \"\"\"Viedoc EC testing: Check that the end date is equal to start date, code: var a = EX1STDAT; \n",
    "                        if !(a) \n",
    "                            return true; \n",
    "                        else \n",
    "                            return (EX1STDAT >=a); querytext: Note that 'End date' is before 'Start date'. Please reconsile. check that all items aligned with the description\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "SEND\n",
      "\n",
      "200\n",
      "{'id': 'FDfvsSZMkEa2wQkHX58myW-eu|0000002'}\n",
      "\n",
      "FETCH\n",
      "\n",
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'To modify the code and check if the end date is equal to the start date, you can update the code snippet as follows:\\n\\n```javascript\\nvar a = EXISTDAT;\\nif (!a) {\\n    return true;\\n} else {\\n    return (EX1STDAT === a);\\n}\\n```\\n\\nBy using the strict equality operator (`===`), the code will compare if the start date `EX1STDAT` is exactly equal to `EXISTDAT`, ensuring that the end date is equal to the start date.\\n\\nTo ensure that all items align with the description provided in the query text, you would need to provide more specific details or requirements about the items and their alignment. Based on the given information, it is not clear how the items should align with the description. Please provide more details or specific requirements so that I can assist you further.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conn.send_message(info['token'],info['conversationId'],'cohitai',PROMT)\n",
    "time.sleep(4)\n",
    "a=conn.get_message(info['token'],info['conversationId'])\n",
    "a[\"activities\"][-1][\"text\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "PROMPT = \"\"\"If ((Associated visit in Disease Assessment (iwCLL) in Discease Assessment with record position 0 isEqualTo Schedualed Discease Assessment) Or (Associated visit in Disease Assessment (iwCLL) in Deseaace Assessment with record position 0 IsEqualTo Unschedualed Disease Assessment) And (CLC Was Assessment Performed? in Desease Assessment (iwCLL) in Disease Assessment with record position Y) then .. CLC Was Assessment Performed?\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "SEND\n",
      "\n",
      "200\n",
      "{'id': 'FDfvsSZMkEa2wQkHX58myW-eu|0000004'}\n",
      "\n",
      "FETCH\n",
      "\n",
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Based on your question, it seems like you are asking about a condition related to disease assessment in the context of iwCLL (International Workshop on Chronic Lymphocytic Leukemia). \\n\\nIf the associated visit in Disease Assessment (iwCLL) in Disease Assessment with record position 0 is equal to Scheduled Disease Assessment or Unscheduled Disease Assessment, and CLC Was Assessment Performed in Disease Assessment (iwCLL) in Disease Assessment with record position Y, then the question is asking whether the CLC Assessment was performed.\\n\\nTo provide a more accurate response, I would need additional information such as the specific values or conditions for the associated visit, record positions, and the CLC assessment. Please provide more details so that I can assist you further.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conn.send_message(info['token'],info['conversationId'],'cohitai',PROMPT)\n",
    "time.sleep(4)\n",
    "a=conn.get_message(info['token'],info['conversationId'])\n",
    "a[\"activities\"][-1][\"text\"]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "PROMPT = \"\"\"in Medidate EC testing- description \" check that end date of AE is not after date of death, if yes fire query. inflix- if End Date of Adverse Event in Adverse Events in Adverse Events isGreaterThan Date of Death in Death Form in Adverse Events. with record postion 0 then... open a query to Site from System on End End Date of Adverse Event in Adverse Events in Adverse Events, displaying \"AE End date is fter Date of Death. Please review.\" (requires response) (requires manual close), does it in allignment with description ?\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "SEND\n",
      "\n",
      "200\n",
      "{'id': 'FDfvsSZMkEa2wQkHX58myW-eu|0000006'}\n",
      "\n",
      "FETCH\n",
      "\n",
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Yes, the provided description aligns with the given statement for Medidate EC testing. The description states that you need to check if the end date of an Adverse Event (AE) is after the date of death. If the end date of the Adverse Event in the Adverse Events table is greater than the Date of Death in the Death Form in the Adverse Events table with record position 0, then a query should be opened to the Site from the System. The query should be related to the End Date of the Adverse Event in the Adverse Events table and should display the message \"AE End date is after Date of Death. Please review.\" This query requires a response and manual closure.\\n\\nIf you have any further questions or need assistance with implementing this logic, please let me know.\\nAI-generated content may be incorrect \\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conn.send_message(info['token'],info['conversationId'],'cohitai',PROMPT)\n",
    "time.sleep(4)\n",
    "a=conn.get_message(info['token'],info['conversationId'])\n",
    "a[\"activities\"][-1][\"text\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "PROMPT = \"\"\"would it function properly ?\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "SEND\n",
      "\n",
      "200\n",
      "{'id': 'FDfvsSZMkEa2wQkHX58myW-eu|0000008'}\n",
      "\n",
      "FETCH\n",
      "\n",
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'Based on the provided description, the functionality appears to be designed to work correctly as described. It checks if the end date of an Adverse Event is after the date of death, and if it is, it opens a query to the Site from the System. The query message clearly states the issue, and it requires a response and manual closure.\\n\\nHowever, please note that without access to the actual implementation and testing, it is difficult to guarantee the functionality will work exactly as described. It is always recommended to thoroughly test the functionality to ensure it behaves as expected in your specific system and environment.\\n\\nIf you have any specific concerns or questions about the implementation or need further assistance, please let me know.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conn.send_message(info['token'],info['conversationId'],'cohitai',PROMPT)\n",
    "time.sleep(4)\n",
    "a=conn.get_message(info['token'],info['conversationId'])\n",
    "a[\"activities\"][-1][\"text\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res=a[\"activities\"]\n",
    "type(res)\n",
    "len(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Viedoc EC testing: Check that the end date is not prior to start date, code: var a = EXISTDAT; \\n                        if !(a) \\n                            return true; \\n                        else \\n                            return (EX1STDAT > =a); querytext: Note that 'End date' is before 'Start date'. Please reconcile. check that all items aligned with the description\""
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[0]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'It seems like you are referring to a code snippet for Viedoc EC testing. The code provided checks if the end date is not prior to the start date. If the variable `EXISTDAT` is not defined, it returns true. Otherwise, it compares the start date `EX1STDAT` with `EXISTDAT` and returns the result.\\n\\nThe query text states that the end date is before the start date and suggests reconciling the issue. It also advises checking if all items align with the description.\\n\\nIf you need further assistance or have any specific questions regarding this code or the query text, please let me know.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[1]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"Viedoc EC testing: Check that the end date is equal to start date, code: var a = EX1STDAT; \\n                        if !(a) \\n                            return true; \\n                        else \\n                            return (EX1STDAT >=a); querytext: Note that 'End date' is before 'Start date'. Please reconsile. check that all items aligned with the description\""
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[2]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'To modify the code and check if the end date is equal to the start date, you can update the code snippet as follows:\\n\\n```javascript\\nvar a = EXISTDAT;\\nif (!a) {\\n    return true;\\n} else {\\n    return (EX1STDAT === a);\\n}\\n```\\n\\nBy using the strict equality operator (`===`), the code will compare if the start date `EX1STDAT` is exactly equal to `EXISTDAT`, ensuring that the end date is equal to the start date.\\n\\nTo ensure that all items align with the description provided in the query text, you would need to provide more specific details or requirements about the items and their alignment. Based on the given information, it is not clear how the items should align with the description. Please provide more details or specific requirements so that I can assist you further.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[3]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'If ((Associated visit in Disease Assessment (iwCLL) in Discease Assessment with record position 0 isEqualTo Schedualed Discease Assessment) Or (Associated visit in Disease Assessment (iwCLL) in Deseaace Assessment with record position 0 IsEqualTo Unschedualed Disease Assessment) And (CLC Was Assessment Performed? in Desease Assessment (iwCLL) in Disease Assessment with record position Y) then .. CLC Was Assessment Performed?'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[4]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Based on your question, it seems like you are asking about a condition related to disease assessment in the context of iwCLL (International Workshop on Chronic Lymphocytic Leukemia). \\n\\nIf the associated visit in Disease Assessment (iwCLL) in Disease Assessment with record position 0 is equal to Scheduled Disease Assessment or Unscheduled Disease Assessment, and CLC Was Assessment Performed in Disease Assessment (iwCLL) in Disease Assessment with record position Y, then the question is asking whether the CLC Assessment was performed.\\n\\nTo provide a more accurate response, I would need additional information such as the specific values or conditions for the associated visit, record positions, and the CLC assessment. Please provide more details so that I can assist you further.\\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[5]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'in Medidate EC testing- description \" check that end date of AE is not after date of death, if yes fire query. inflix- if End Date of Adverse Event in Adverse Events in Adverse Events isGreaterThan Date of Death in Death Form in Adverse Events. with record postion 0 then... open a query to Site from System on End End Date of Adverse Event in Adverse Events in Adverse Events, displaying \"AE End date is fter Date of Death. Please review.\" (requires response) (requires manual close), does it in allignment with description ?'"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[6]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Yes, the provided description aligns with the given statement for Medidate EC testing. The description states that you need to check if the end date of an Adverse Event (AE) is after the date of death. If the end date of the Adverse Event in the Adverse Events table is greater than the Date of Death in the Death Form in the Adverse Events table with record position 0, then a query should be opened to the Site from the System. The query should be related to the End Date of the Adverse Event in the Adverse Events table and should display the message \"AE End date is after Date of Death. Please review.\" This query requires a response and manual closure.\\n\\nIf you have any further questions or need assistance with implementing this logic, please let me know.\\nAI-generated content may be incorrect \\r\\nAI-generated content may be incorrect'"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res[7]['text']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[\"cohitai: Viedoc EC testing: Check that the end date is not prior to start date, code: var a = EXISTDAT; \\n                        if !(a) \\n                            return true; \\n                        else \\n                            return (EX1STDAT > =a); querytext: Note that 'End date' is before 'Start date'. Please reconcile. check that all items aligned with the description\",\n",
       " 'Dev Bot 1: It seems like you are referring to a code snippet for Viedoc EC testing. The code provided checks if the end date is not prior to the start date. If the variable `EXISTDAT` is not defined, it returns true. Otherwise, it compares the start date `EX1STDAT` with `EXISTDAT` and returns the result.\\n\\nThe query text states that the end date is before the start date and suggests reconciling the issue. It also advises checking if all items align with the description.\\n\\nIf you need further assistance or have any specific questions regarding this code or the query text, please let me know.\\r\\nAI-generated content may be incorrect',\n",
       " \"cohitai: Viedoc EC testing: Check that the end date is equal to start date, code: var a = EX1STDAT; \\n                        if !(a) \\n                            return true; \\n                        else \\n                            return (EX1STDAT >=a); querytext: Note that 'End date' is before 'Start date'. Please reconsile. check that all items aligned with the description\",\n",
       " 'Dev Bot 1: To modify the code and check if the end date is equal to the start date, you can update the code snippet as follows:\\n\\n```javascript\\nvar a = EXISTDAT;\\nif (!a) {\\n    return true;\\n} else {\\n    return (EX1STDAT === a);\\n}\\n```\\n\\nBy using the strict equality operator (`===`), the code will compare if the start date `EX1STDAT` is exactly equal to `EXISTDAT`, ensuring that the end date is equal to the start date.\\n\\nTo ensure that all items align with the description provided in the query text, you would need to provide more specific details or requirements about the items and their alignment. Based on the given information, it is not clear how the items should align with the description. Please provide more details or specific requirements so that I can assist you further.\\r\\nAI-generated content may be incorrect',\n",
       " 'cohitai: If ((Associated visit in Disease Assessment (iwCLL) in Discease Assessment with record position 0 isEqualTo Schedualed Discease Assessment) Or (Associated visit in Disease Assessment (iwCLL) in Deseaace Assessment with record position 0 IsEqualTo Unschedualed Disease Assessment) And (CLC Was Assessment Performed? in Desease Assessment (iwCLL) in Disease Assessment with record position Y) then .. CLC Was Assessment Performed?',\n",
       " 'Dev Bot 1: Based on your question, it seems like you are asking about a condition related to disease assessment in the context of iwCLL (International Workshop on Chronic Lymphocytic Leukemia). \\n\\nIf the associated visit in Disease Assessment (iwCLL) in Disease Assessment with record position 0 is equal to Scheduled Disease Assessment or Unscheduled Disease Assessment, and CLC Was Assessment Performed in Disease Assessment (iwCLL) in Disease Assessment with record position Y, then the question is asking whether the CLC Assessment was performed.\\n\\nTo provide a more accurate response, I would need additional information such as the specific values or conditions for the associated visit, record positions, and the CLC assessment. Please provide more details so that I can assist you further.\\r\\nAI-generated content may be incorrect',\n",
       " 'cohitai: in Medidate EC testing- description \" check that end date of AE is not after date of death, if yes fire query. inflix- if End Date of Adverse Event in Adverse Events in Adverse Events isGreaterThan Date of Death in Death Form in Adverse Events. with record postion 0 then... open a query to Site from System on End End Date of Adverse Event in Adverse Events in Adverse Events, displaying \"AE End date is fter Date of Death. Please review.\" (requires response) (requires manual close), does it in allignment with description ?',\n",
       " 'Dev Bot 1: Yes, the provided description aligns with the given statement for Medidate EC testing. The description states that you need to check if the end date of an Adverse Event (AE) is after the date of death. If the end date of the Adverse Event in the Adverse Events table is greater than the Date of Death in the Death Form in the Adverse Events table with record position 0, then a query should be opened to the Site from the System. The query should be related to the End Date of the Adverse Event in the Adverse Events table and should display the message \"AE End date is after Date of Death. Please review.\" This query requires a response and manual closure.\\n\\nIf you have any further questions or need assistance with implementing this logic, please let me know.\\nAI-generated content may be incorrect \\r\\nAI-generated content may be incorrect',\n",
       " 'cohitai: would it function properly ?',\n",
       " 'Dev Bot 1: Based on the provided description, the functionality appears to be designed to work correctly as described. It checks if the end date of an Adverse Event is after the date of death, and if it is, it opens a query to the Site from the System. The query message clearly states the issue, and it requires a response and manual closure.\\n\\nHowever, please note that without access to the actual implementation and testing, it is difficult to guarantee the functionality will work exactly as described. It is always recommended to thoroughly test the functionality to ensure it behaves as expected in your specific system and environment.\\n\\nIf you have any specific concerns or questions about the implementation or need further assistance, please let me know.\\r\\nAI-generated content may be incorrect']"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "conn.transcript"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'wss://europe.directline.botframework.com/v3/directline/conversations/FDfvsSZMkEa2wQkHX58myW-eu/stream?watermark=-&t=eyJhbGciOiJSUzI1NiIsImtpZCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsIng1dCI6Ik5MZjUwanFheTN1R0VpQUpOV29EWmZzRnE4QSIsInR5cCI6IkpXVCJ9.eyJib3QiOiI0OWU3Mzc4Yy02MGEyLTk0MTAtZmVhYy0zNjNjYzBiZjYzMjgiLCJzaXRlIjoiV2lkbl9BY05tWTQiLCJjb252IjoiRkRmdnNTWk1rRWEyd1FrSFg1OG15Vy1ldSIsIm5iZiI6MTcxOTgzMjY0NCwiZXhwIjoxNzE5ODMyNzA0LCJpc3MiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLCJhdWQiOiJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8ifQ.dgzf_ywaa2D8EQQjaGRfpM1TESXAV0LJwQSjvZq3TK-lamrPYpNN42SvNM9T6k-wAra_vX36Xk2i1i4-QqGXKTESeBEPIQ2n936fUFHZDtYZwsID4idQSXxysW5B7IIuQ3QBMZU3PLH0SPCw_fCdEW80KWyoWsnIjxniKA4sPB2_HogWWGixfbYa_djZKWLWkYvOusqxVuoPfFPuO8M3fQJQhWiE3r5o4251Of7fAe-dmQG5vXeWl3PJowq1m76jCGbc16UR_ldtsxkMKqdSoEtkEbTP0NvnibMHwbdSQMj4IXyptFido9Xc0fR2y7cj98SNfc7anH7ydlX5_tdobw'"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "URL_WSS=info[\"streamUrl\"]\n",
    "URL_WSS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "ename": "RuntimeError",
     "evalue": "This event loop is already running",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mRuntimeError\u001b[0m                              Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[44], line 10\u001b[0m\n\u001b[1;32m      7\u001b[0m         response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m websocket\u001b[38;5;241m.\u001b[39mrecv()\n\u001b[1;32m      8\u001b[0m         \u001b[38;5;28mprint\u001b[39m(response)\n\u001b[0;32m---> 10\u001b[0m \u001b[43masyncio\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_event_loop\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_until_complete\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtest\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/.pyenv/versions/3.11.7/lib/python3.11/asyncio/base_events.py:629\u001b[0m, in \u001b[0;36mBaseEventLoop.run_until_complete\u001b[0;34m(self, future)\u001b[0m\n\u001b[1;32m    618\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Run until the Future is done.\u001b[39;00m\n\u001b[1;32m    619\u001b[0m \n\u001b[1;32m    620\u001b[0m \u001b[38;5;124;03mIf the argument is a coroutine, it is wrapped in a Task.\u001b[39;00m\n\u001b[0;32m   (...)\u001b[0m\n\u001b[1;32m    626\u001b[0m \u001b[38;5;124;03mReturn the Future's result, or raise its exception.\u001b[39;00m\n\u001b[1;32m    627\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m    628\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_closed()\n\u001b[0;32m--> 629\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_check_running\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    631\u001b[0m new_task \u001b[38;5;241m=\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m futures\u001b[38;5;241m.\u001b[39misfuture(future)\n\u001b[1;32m    632\u001b[0m future \u001b[38;5;241m=\u001b[39m tasks\u001b[38;5;241m.\u001b[39mensure_future(future, loop\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n",
      "File \u001b[0;32m~/.pyenv/versions/3.11.7/lib/python3.11/asyncio/base_events.py:588\u001b[0m, in \u001b[0;36mBaseEventLoop._check_running\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    586\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_check_running\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[1;32m    587\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mis_running():\n\u001b[0;32m--> 588\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mThis event loop is already running\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m    589\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m events\u001b[38;5;241m.\u001b[39m_get_running_loop() \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m    590\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mRuntimeError\u001b[39;00m(\n\u001b[1;32m    591\u001b[0m             \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCannot run the event loop while another loop is running\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
      "\u001b[0;31mRuntimeError\u001b[0m: This event loop is already running"
     ]
    }
   ],
   "source": [
    "import asyncio\n",
    "import websockets\n",
    "\n",
    "async def test():\n",
    "    async with websockets.connect(URL_WSS) as websocket:\n",
    "        await websocket.send(\"hello\")\n",
    "        response = await websocket.recv()\n",
    "        print(response)\n",
    "\n",
    "asyncio.get_event_loop().run_until_complete(test())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "gradio",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}