File size: 51,908 Bytes
6aa59d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/satoc/miniforge3/envs/gradio/lib/python3.12/site-packages/IPython/core/interactiveshell.py:3577: LangChainDeprecationWarning: As of langchain-core 0.3.0, LangChain uses pydantic v2 internally. The langchain_core.pydantic_v1 module was a compatibility shim for pydantic v1, and should no longer be used. Please update the code to import from Pydantic directly.\n",
      "\n",
      "For example, replace imports like: `from langchain_core.pydantic_v1 import BaseModel`\n",
      "with: `from pydantic import BaseModel`\n",
      "or the v1 compatibility namespace if you are working in a code base that has not been fully upgraded to pydantic 2 yet. \tfrom pydantic.v1 import BaseModel\n",
      "\n",
      "  exec(code_obj, self.user_global_ns, self.user_ns)\n"
     ]
    }
   ],
   "source": [
    "from langchain_community.agent_toolkits import create_sql_agent\n",
    "from langchain_openai import ChatOpenAI\n",
    "from langchain_groq import ChatGroq\n",
    "from langchain_core.prompts import ChatPromptTemplate\n",
    "from langchain_core.pydantic_v1 import BaseModel, Field\n",
    "import pandas as pd\n",
    "from pydantic import BaseModel, Field\n",
    "\n",
    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
    "from langchain_community.vectorstores import Chroma\n",
    "from langchain.embeddings import HuggingFaceEmbeddings\n",
    "from langchain_core.runnables import RunnablePassthrough\n",
    "from langchain_core.output_parsers import StrOutputParser\n",
    "\n",
    "\n",
    "gpt = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
    "#agent_gpt_executor = create_sql_agent(gpt, db=db, agent_type=\"tool-calling\", verbose=True)\n",
    "\n",
    "## make database\n",
    "from langchain_community.utilities import SQLDatabase\n",
    "from sqlalchemy import create_engine\n",
    "\n",
    "from langchain.prompts import ChatPromptTemplate\n",
    "from langchain.schema import SystemMessage\n",
    "from langchain_core.prompts import MessagesPlaceholder\n",
    "#agent_groq_executor = create_sql_agent(llm, db=db, agent_type=\"tool-calling\", verbose=True)\n",
    "\n",
    "from OpenAITools.FetchTools import fetch_clinical_trials, fetch_clinical_trials_jp\n",
    "from OpenAITools.CrinicalTrialTools import QuestionModifierEnglish, TumorNameExtractor, SimpleClinicalTrialAgent,GraderAgent,LLMTranslator\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Define LLMS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "gpt = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
    "#agent_gpt_executor = create_sql_agent(gpt, db=db, agent_type=\"tool-calling\", verbose=True)\n",
    "groq = ChatGroq(model_name=\"llama3-70b-8192\", temperature=0)\n",
    "#agent_groq_executor = create_sql_agent(groq, db=db, agent_type=\"tool-calling\", verbose=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "age = \"65\"\n",
    "sex =\"男性\"\n",
    "tumor_type =\"胃癌\"\n",
    "#tumor_type = \"gastric cancer\"\n",
    "GeneMutation =\"HER2\"\n",
    "Meseable = \"有り\"\n",
    "Biopsiable = \"有り\"\n",
    "NCTID = 'NCT06441994'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def generate_ex_question(age, sex, tumor_type, GeneMutation, Meseable, Biopsiable):\n",
    "    # GeneMutationが空の場合はUnknownに設定\n",
    "    gene_mutation_text = GeneMutation if GeneMutation else \"Unknown\"\n",
    "    \n",
    "    # MeseableとBiopsiableの値をYes, No, Unknownに変換\n",
    "    meseable_text = (\n",
    "        \"Yes\" if Meseable == \"有り\" else \"No\" if Meseable == \"無し\" else \"Unknown\"\n",
    "    )\n",
    "    biopsiable_text = (\n",
    "        \"Yes\" if Biopsiable == \"有り\" else \"No\" if Biopsiable == \"無し\" else \"Unknown\"\n",
    "    )\n",
    "    \n",
    "    # 質問文の生成\n",
    "    ex_question = f\"\"\"{age}歳{sex}の{tumor_type}患者さんはこの治験に参加することができますか?\n",
    "判明している遺伝子変異: {gene_mutation_text}\n",
    "Meseable tumor: {meseable_text}\n",
    "Biopsiable tumor: {biopsiable_text}\n",
    "です。\n",
    "\"\"\"\n",
    "    return ex_question"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def generate_ex_question_English(age, sex, tumor_type, GeneMutation, Meseable, Biopsiable):\n",
    "    # GeneMutationが空の場合は\"Unknown\"に設定\n",
    "    gene_mutation_text = GeneMutation if GeneMutation else \"Unknown\"\n",
    "    \n",
    "    # sexの値を male または female に変換\n",
    "    sex_text = \"male\" if sex == \"男性\" else \"female\" if sex == \"女性\" else \"Unknown\"\n",
    "    \n",
    "    # MeseableとBiopsiableの値を \"Yes\", \"No\", \"Unknown\" に変換\n",
    "    meseable_text = (\n",
    "        \"Yes\" if Meseable == \"有り\" else \"No\" if Meseable == \"無し\" else \"Unknown\"\n",
    "    )\n",
    "    biopsiable_text = (\n",
    "        \"Yes\" if Biopsiable == \"有り\" else \"No\" if Biopsiable == \"無し\" else \"Unknown\"\n",
    "    )\n",
    "    \n",
    "    # 英語での質問文を生成\n",
    "    ex_question = f\"\"\"Can a {age}-year-old {sex_text} patient with {tumor_type} participate in this clinical trial?\n",
    "Known gene mutation: {gene_mutation_text}\n",
    "Measurable tumor: {meseable_text}\n",
    "Biopsiable tumor: {biopsiable_text}\n",
    "\"\"\"\n",
    "    return ex_question\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Stomach cancer\n"
     ]
    }
   ],
   "source": [
    "#Define extractor\n",
    "Translator = LLMTranslator(groq)\n",
    "TumorName = Translator.translate(tumor_type)\n",
    "print(TumorName)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "TumorName = \"gastric cancer\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Can a 65-year-old male patient with gastric cancer participate in this clinical trial?\\nKnown gene mutation: HER2\\nMeasurable tumor: Yes\\nBiopsiable tumor: Yes\\n'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ex_question = generate_ex_question_English(age, sex, TumorName, GeneMutation, Meseable, Biopsiable)\n",
    "ex_question"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ex_question = \"\"\"\"65歳男性の胃癌患者さんはこの治験に参加することができますか?\n",
    "判明している遺伝子変異:HER2\n",
    "Meseable tumor:Yes\n",
    "biopsiable tumor: Yes\n",
    "です。\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ex_question = \"65歳男性でが参加できる臨床治験を教えて下さい。\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ex_question = \"65歳男性でBRCA遺伝子の変異がある前立患者さんが参加できる臨床治験を教えて下さい。\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "modifierEnglish = QuestionModifierEnglish(groq)\n",
    "modifierEnglish.modify_question(ex_question)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fetching data from: https://clinicaltrials.gov/api/v2/studies?query.titles=gastric cancer SEARCH[Location](AREA[LocationCountry]Japan AND AREA[LocationStatus]Recruiting)&pageSize=100\n"
     ]
    }
   ],
   "source": [
    "#Make db\n",
    "df = fetch_clinical_trials(TumorName)\n",
    "# 新しい列を追加\n",
    "df['AgentJudgment'] = None\n",
    "df['AgentGrade'] = None\n",
    "#df = df.iloc[:5, :]\n",
    "NCTIDs = list(df['NCTID' ])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>NCTID</th>\n",
       "      <th>Title</th>\n",
       "      <th>Primary Completion Date</th>\n",
       "      <th>Cancer</th>\n",
       "      <th>Summary</th>\n",
       "      <th>Japanes Locations</th>\n",
       "      <th>Eligibility Criteria</th>\n",
       "      <th>AgentJudgment</th>\n",
       "      <th>AgentGrade</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NCT03505320</td>\n",
       "      <td>A Study of Zolbetuximab (IMAB362) in Adults Wi...</td>\n",
       "      <td>2025-04-30</td>\n",
       "      <td>Pharmacokinetics of Zolbetuximab, Gastric Canc...</td>\n",
       "      <td>Zolbetuximab is being studied as a treatment f...</td>\n",
       "      <td>Chiba, Tokyo</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Female subject eligib...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NCT05002127</td>\n",
       "      <td>A Study of Evorpacept (ALX148) in Patients wit...</td>\n",
       "      <td>2026-07</td>\n",
       "      <td>Gastric Cancer, Gastroesophageal Junction Aden...</td>\n",
       "      <td>A Phase 2/3 Study of Evorpacept (ALX148) in Co...</td>\n",
       "      <td>Chiba, Fukuoka, Gifu, Kumamoto, Kyoto, Nagasak...</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* HER2-overexpressing a...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NCT05365581</td>\n",
       "      <td>A Study of ASP2138 Given by Itself or Given Wi...</td>\n",
       "      <td>2026-10-31</td>\n",
       "      <td>Gastric Adenocarcinoma, Gastroesophageal Junct...</td>\n",
       "      <td>Claudin 18.2 protein, or CLDN18.2 is a protein...</td>\n",
       "      <td>Kashiwa, Nagoya, Osakasayama, Suita, Yokohama, ku</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Participant is consid...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NCT05111626</td>\n",
       "      <td>Bemarituzumab Plus Chemotherapy and Nivolumab ...</td>\n",
       "      <td>2026-09-26</td>\n",
       "      <td>Gastric Cancer, Gastroesophageal Junction Aden...</td>\n",
       "      <td>The main objective of Part 1 is to evaluate th...</td>\n",
       "      <td>Sapporo, gun, ku, shi</td>\n",
       "      <td>Inclusion Criteria Part 1 and Part 2:\\n\\n* Adu...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NCT06324357</td>\n",
       "      <td>Beamion BCGC-1: A Study to Find a Suitable Dos...</td>\n",
       "      <td>2027-02-22</td>\n",
       "      <td>Metastatic Breast Cancer, Metastatic Gastric A...</td>\n",
       "      <td>This study is open to adults aged 18 years and...</td>\n",
       "      <td>ku, shi</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Signed and dated writ...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NCT06056024</td>\n",
       "      <td>A Study to Test How Well Different Doses of BI...</td>\n",
       "      <td>2027-05-26</td>\n",
       "      <td>Solid Tumor, KRAS Mutation</td>\n",
       "      <td>This study is open to adults with advanced can...</td>\n",
       "      <td>Kashiwa, ku</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Patients with pathol...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NCT04379596</td>\n",
       "      <td>Ph1b/2 Study of the Safety and Efficacy of T-D...</td>\n",
       "      <td>2026-07-30</td>\n",
       "      <td>Gastric Cancer</td>\n",
       "      <td>DESTINY-Gastric03 will investigate the safety,...</td>\n",
       "      <td>Kashiwa, gun, ku, shi</td>\n",
       "      <td>Inclusion criteria:\\n\\n1. Male and female part...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NCT00197470</td>\n",
       "      <td>Cytokine Gene Polymorphisms in Gastric Diseases</td>\n",
       "      <td>Unknown Date</td>\n",
       "      <td>Gastric Ulcer, Duodenal Ulcer, Gastric Cancer</td>\n",
       "      <td>Recently, cytokine polymorphisms are considere...</td>\n",
       "      <td>Hamamatsu</td>\n",
       "      <td>Inclusion Criteria:\\n\\n-\\n\\nExclusion Criteria...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>NCT05205343</td>\n",
       "      <td>Trans-Pacific Multicenter Collaborative Study ...</td>\n",
       "      <td>2026-05-31</td>\n",
       "      <td>Gastrostomy, Gastric, GastroEsophageal Cancer</td>\n",
       "      <td>To compare the symptoms of patients who have a...</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Able to speak and re...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>NCT06490055</td>\n",
       "      <td>Predicting the Efficacy in Advanced Gastric Ca...</td>\n",
       "      <td>2025-12-31</td>\n",
       "      <td>Gastric Cancer, Chemotherapy Effect, Paclitaxe...</td>\n",
       "      <td>With advances in chemotherapy for gastric canc...</td>\n",
       "      <td>Kurashiki</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. unresectable or recu...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>NCT06490159</td>\n",
       "      <td>Predicting Peripheral Neuropathy of Paclitaxel...</td>\n",
       "      <td>2025-12-31</td>\n",
       "      <td>Gastric Cancer, Chemotherapy-induced Periphera...</td>\n",
       "      <td>Although advances in chemotherapy have improve...</td>\n",
       "      <td>Kurashiki</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. unresectable or recu...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>NCT05438459</td>\n",
       "      <td>GAIA-102 Intraperitoneal Administration in Pat...</td>\n",
       "      <td>2026-12-31</td>\n",
       "      <td>Gastric Cancer, Pancreatic Cancer</td>\n",
       "      <td>Phase I Part :\\n\\nConfirm the safety of GAIA-1...</td>\n",
       "      <td>shi</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Unresectable, advanc...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>NCT04745988</td>\n",
       "      <td>An Open Label Phase 2 Study to Evaluate the Sa...</td>\n",
       "      <td>2025-08</td>\n",
       "      <td>Gastric Cancer</td>\n",
       "      <td>This study is an open label phase 2 study to e...</td>\n",
       "      <td>Kashiwa</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Have gastric and gas...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>NCT06038578</td>\n",
       "      <td>A Study of TRK-950 When Used in Combination Wi...</td>\n",
       "      <td>2025-08-31</td>\n",
       "      <td>Gastric Adenocarcinoma, Gastric Cancer, Gastro...</td>\n",
       "      <td>This study will assess the efficacy, safety, o...</td>\n",
       "      <td>Chuo Ku, Kashiwa, Ku</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Histologically or cyt...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>NCT05322577</td>\n",
       "      <td>A Study Evaluating Bemarituzumab in Combinatio...</td>\n",
       "      <td>2026-03-17</td>\n",
       "      <td>Gastric Cancer, Gastroesophageal Junction Cancer</td>\n",
       "      <td>The main objectives of this study are to evalu...</td>\n",
       "      <td>Shi, gun, ku, shi</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Adults with unresecta...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>NCT05152147</td>\n",
       "      <td>A Study of Zanidatamab in Combination With Che...</td>\n",
       "      <td>2024-12-31</td>\n",
       "      <td>Gastric Neoplasms, Gastroesophageal Adenocarci...</td>\n",
       "      <td>This study is being done to find out if zanida...</td>\n",
       "      <td>Cho, Chuo Ku, Hirakata, Ina, Ku, Matsuyama, Na...</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Histologically confir...</td>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          NCTID                                              Title  \\\n",
       "0   NCT03505320  A Study of Zolbetuximab (IMAB362) in Adults Wi...   \n",
       "1   NCT05002127  A Study of Evorpacept (ALX148) in Patients wit...   \n",
       "2   NCT05365581  A Study of ASP2138 Given by Itself or Given Wi...   \n",
       "3   NCT05111626  Bemarituzumab Plus Chemotherapy and Nivolumab ...   \n",
       "4   NCT06324357  Beamion BCGC-1: A Study to Find a Suitable Dos...   \n",
       "5   NCT06056024  A Study to Test How Well Different Doses of BI...   \n",
       "6   NCT04379596  Ph1b/2 Study of the Safety and Efficacy of T-D...   \n",
       "7   NCT00197470    Cytokine Gene Polymorphisms in Gastric Diseases   \n",
       "8   NCT05205343  Trans-Pacific Multicenter Collaborative Study ...   \n",
       "9   NCT06490055  Predicting the Efficacy in Advanced Gastric Ca...   \n",
       "10  NCT06490159  Predicting Peripheral Neuropathy of Paclitaxel...   \n",
       "11  NCT05438459  GAIA-102 Intraperitoneal Administration in Pat...   \n",
       "12  NCT04745988  An Open Label Phase 2 Study to Evaluate the Sa...   \n",
       "13  NCT06038578  A Study of TRK-950 When Used in Combination Wi...   \n",
       "14  NCT05322577  A Study Evaluating Bemarituzumab in Combinatio...   \n",
       "15  NCT05152147  A Study of Zanidatamab in Combination With Che...   \n",
       "\n",
       "   Primary Completion Date                                             Cancer  \\\n",
       "0               2025-04-30  Pharmacokinetics of Zolbetuximab, Gastric Canc...   \n",
       "1                  2026-07  Gastric Cancer, Gastroesophageal Junction Aden...   \n",
       "2               2026-10-31  Gastric Adenocarcinoma, Gastroesophageal Junct...   \n",
       "3               2026-09-26  Gastric Cancer, Gastroesophageal Junction Aden...   \n",
       "4               2027-02-22  Metastatic Breast Cancer, Metastatic Gastric A...   \n",
       "5               2027-05-26                         Solid Tumor, KRAS Mutation   \n",
       "6               2026-07-30                                     Gastric Cancer   \n",
       "7             Unknown Date      Gastric Ulcer, Duodenal Ulcer, Gastric Cancer   \n",
       "8               2026-05-31      Gastrostomy, Gastric, GastroEsophageal Cancer   \n",
       "9               2025-12-31  Gastric Cancer, Chemotherapy Effect, Paclitaxe...   \n",
       "10              2025-12-31  Gastric Cancer, Chemotherapy-induced Periphera...   \n",
       "11              2026-12-31                  Gastric Cancer, Pancreatic Cancer   \n",
       "12                 2025-08                                     Gastric Cancer   \n",
       "13              2025-08-31  Gastric Adenocarcinoma, Gastric Cancer, Gastro...   \n",
       "14              2026-03-17   Gastric Cancer, Gastroesophageal Junction Cancer   \n",
       "15              2024-12-31  Gastric Neoplasms, Gastroesophageal Adenocarci...   \n",
       "\n",
       "                                              Summary  \\\n",
       "0   Zolbetuximab is being studied as a treatment f...   \n",
       "1   A Phase 2/3 Study of Evorpacept (ALX148) in Co...   \n",
       "2   Claudin 18.2 protein, or CLDN18.2 is a protein...   \n",
       "3   The main objective of Part 1 is to evaluate th...   \n",
       "4   This study is open to adults aged 18 years and...   \n",
       "5   This study is open to adults with advanced can...   \n",
       "6   DESTINY-Gastric03 will investigate the safety,...   \n",
       "7   Recently, cytokine polymorphisms are considere...   \n",
       "8   To compare the symptoms of patients who have a...   \n",
       "9   With advances in chemotherapy for gastric canc...   \n",
       "10  Although advances in chemotherapy have improve...   \n",
       "11  Phase I Part :\\n\\nConfirm the safety of GAIA-1...   \n",
       "12  This study is an open label phase 2 study to e...   \n",
       "13  This study will assess the efficacy, safety, o...   \n",
       "14  The main objectives of this study are to evalu...   \n",
       "15  This study is being done to find out if zanida...   \n",
       "\n",
       "                                    Japanes Locations  \\\n",
       "0                                        Chiba, Tokyo   \n",
       "1   Chiba, Fukuoka, Gifu, Kumamoto, Kyoto, Nagasak...   \n",
       "2   Kashiwa, Nagoya, Osakasayama, Suita, Yokohama, ku   \n",
       "3                               Sapporo, gun, ku, shi   \n",
       "4                                             ku, shi   \n",
       "5                                         Kashiwa, ku   \n",
       "6                               Kashiwa, gun, ku, shi   \n",
       "7                                           Hamamatsu   \n",
       "8                                               Tokyo   \n",
       "9                                           Kurashiki   \n",
       "10                                          Kurashiki   \n",
       "11                                                shi   \n",
       "12                                            Kashiwa   \n",
       "13                               Chuo Ku, Kashiwa, Ku   \n",
       "14                                  Shi, gun, ku, shi   \n",
       "15  Cho, Chuo Ku, Hirakata, Ina, Ku, Matsuyama, Na...   \n",
       "\n",
       "                                 Eligibility Criteria AgentJudgment AgentGrade  \n",
       "0   Inclusion Criteria:\\n\\n* Female subject eligib...          None       None  \n",
       "1   Inclusion Criteria:\\n\\n* HER2-overexpressing a...          None       None  \n",
       "2   Inclusion Criteria:\\n\\n* Participant is consid...          None       None  \n",
       "3   Inclusion Criteria Part 1 and Part 2:\\n\\n* Adu...          None       None  \n",
       "4   Inclusion Criteria:\\n\\n* Signed and dated writ...          None       None  \n",
       "5   Inclusion Criteria:\\n\\n1. Patients with pathol...          None       None  \n",
       "6   Inclusion criteria:\\n\\n1. Male and female part...          None       None  \n",
       "7   Inclusion Criteria:\\n\\n-\\n\\nExclusion Criteria...          None       None  \n",
       "8   Inclusion Criteria:\\n\\n1. Able to speak and re...          None       None  \n",
       "9   Inclusion Criteria:\\n\\n1. unresectable or recu...          None       None  \n",
       "10  Inclusion Criteria:\\n\\n1. unresectable or recu...          None       None  \n",
       "11  Inclusion Criteria:\\n\\n1. Unresectable, advanc...          None       None  \n",
       "12  Inclusion Criteria:\\n\\n1. Have gastric and gas...          None       None  \n",
       "13  Inclusion Criteria:\\n\\n* Histologically or cyt...          None       None  \n",
       "14  Inclusion Criteria:\\n\\n* Adults with unresecta...          None       None  \n",
       "15  Inclusion Criteria:\\n\\n* Histologically confir...          None       None  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "#Define agents\n",
    "#modifier = QuestionModifierEnglish(groq)\n",
    "CriteriaCheckAgent = SimpleClinicalTrialAgent(groq)\n",
    "grader_agent = GraderAgent(groq)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The patient is not eligible for this clinical trial because the inclusion criteria specify that female subjects are eligible, and the patient is a 65-year-old male.\n",
      "no\n",
      "The patient is eligible for this clinical trial based on the provided information, as he has a measurable and biopsiable tumor with a known HER2 gene mutation, which meets the inclusion criteria. However, I do not know if he has progressed on or after a prior HER2-directed agent and fluoropyrimidine- or platinum-containing chemotherapy, which is also required for inclusion.\n",
      "unclear\n",
      "The patient is eligible for this clinical trial based on the provided criteria. The patient meets the inclusion criteria, including having a measurable tumor, being at least 18 years old, and having a predicted life expectancy of at least 12 weeks. The patient also has histologically confirmed gastric/gastroesophageal junction (GEJ) adenocarcinoma, which is one of the specified disease types for this trial. Additionally, the patient has a HER2-positive tumor, which is not an exclusion criterion for this trial.\n",
      "yes\n",
      "The patient is eligible for this clinical trial based on the provided criteria, as they meet the inclusion criteria for age, measurable tumor, and biopsiable tumor. However, the patient's HER2 status is known to be positive, which is an exclusion criterion. Therefore, the patient is not eligible for this clinical trial.\n",
      "no\n",
      "The patient is not eligible for this clinical trial because the trial is for metastatic breast cancer (mBC) or metastatic gastric adenocarcinoma, gastroesophageal junction adenocarcinoma, or esophageal adenocarcinoma (mGEAC), and the patient has gastric cancer, which is not specified as an eligible type of cancer.\n",
      "no\n",
      "The patient is not eligible for this clinical trial because the trial requires a KRAS wild type (wt) amplification or a KRAS G12V mutation, but the patient has a HER2 gene mutation.\n",
      "no\n",
      "The patient is eligible for this clinical trial based on the provided criteria, as they meet the inclusion criteria (age, disease characteristics, measurable tumor, and HER2-positive status) and do not have any of the exclusion criteria mentioned.\n",
      "yes\n",
      "I do not know if the patient is eligible for this clinical trial because the criteria do not mention age or specific types of cancer, and there is no information about H. pylori status in the patient.\n",
      "unclear\n",
      "The patient is eligible for this clinical trial based on the provided criteria, as he has a biopsy-confirmed diagnosis of gastric cancer, is 65 years old (meeting the age criterion), and there is no mention of any exclusion criteria being met.\n",
      "yes\n",
      "The patient is eligible for this clinical trial based on the provided information, as he meets the inclusion criteria (age, measurable tumor, biopsiable tumor, and gastric cancer diagnosis) and does not appear to meet any of the exclusion criteria.\n",
      "yes\n",
      "The patient is eligible for this clinical trial based on the provided criteria, as they meet the inclusion criteria (age, measurable tumor, biopsiable tumor, and gastric cancer diagnosis) and do not have any of the listed exclusion criteria.\n",
      "yes\n",
      "Based on the provided criteria, the 65-year-old male patient with gastric cancer and a known HER2 gene mutation appears to be eligible for this clinical trial, as he meets the inclusion criteria (e.g., unresectable advanced gastric cancer, measurable tumor, biopsiable tumor, etc.) and does not have any obvious exclusion criteria mentioned. However, I would need to review the patient's full medical history and current condition to confirm eligibility.\n",
      "unclear\n",
      "The patient is eligible for this clinical trial based on the provided criteria, as they meet the inclusion criteria (gastric cancer, measurable tumor, biopsiable tumor, age ≥ 20, etc.) and do not have any of the exclusion criteria mentioned.\n",
      "yes\n",
      "The patient is not eligible for this clinical trial because the patient has a known HER2 gene mutation, and the exclusion criteria specify that patients with HER2 positive gastric or GEJ adenocarcinoma are not eligible.\n",
      "no\n",
      "The patient is not eligible for this clinical trial because they have a known HER2 gene mutation, which is an exclusion criterion.\n",
      "no\n",
      "Based on the provided information, the 65-year-old male patient with gastric cancer and a known HER2 gene mutation appears to be eligible for this clinical trial, as he meets the inclusion criteria of having measurable tumor and biopsiable tumor, and there is no mention of any exclusion criteria that would disqualify him.\n",
      "yes\n"
     ]
    }
   ],
   "source": [
    "for nct_id in NCTIDs:\n",
    "    TargetCriteria = df.loc[df['NCTID'] == nct_id, 'Eligibility Criteria'].values[0]\n",
    "    AgentJudgment = CriteriaCheckAgent.evaluate_eligibility(TargetCriteria, ex_question)\n",
    "    print(AgentJudgment)\n",
    "\n",
    "    AgentGrade = grader_agent.evaluate_eligibility(AgentJudgment)\n",
    "    print(AgentGrade)\n",
    "    # NCTIDに一致する行を見つけて更新\n",
    "    df.loc[df['NCTID'] == nct_id, 'AgentJudgment'] = AgentJudgment\n",
    "    df.loc[df['NCTID'] == nct_id, 'AgentGrade'] = AgentGrade\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>NCTID</th>\n",
       "      <th>Title</th>\n",
       "      <th>Primary Completion Date</th>\n",
       "      <th>Cancer</th>\n",
       "      <th>Summary</th>\n",
       "      <th>Japanes Locations</th>\n",
       "      <th>Eligibility Criteria</th>\n",
       "      <th>AgentJudgment</th>\n",
       "      <th>AgentGrade</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NCT03505320</td>\n",
       "      <td>A Study of Zolbetuximab (IMAB362) in Adults Wi...</td>\n",
       "      <td>2025-04-30</td>\n",
       "      <td>Pharmacokinetics of Zolbetuximab, Gastric Canc...</td>\n",
       "      <td>Zolbetuximab is being studied as a treatment f...</td>\n",
       "      <td>Chiba, Tokyo</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Female subject eligib...</td>\n",
       "      <td>The patient is not eligible for this clinical ...</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NCT05002127</td>\n",
       "      <td>A Study of Evorpacept (ALX148) in Patients wit...</td>\n",
       "      <td>2026-07</td>\n",
       "      <td>Gastric Cancer, Gastroesophageal Junction Aden...</td>\n",
       "      <td>A Phase 2/3 Study of Evorpacept (ALX148) in Co...</td>\n",
       "      <td>Chiba, Fukuoka, Gifu, Kumamoto, Kyoto, Nagasak...</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* HER2-overexpressing a...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>unclear</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NCT05365581</td>\n",
       "      <td>A Study of ASP2138 Given by Itself or Given Wi...</td>\n",
       "      <td>2026-10-31</td>\n",
       "      <td>Gastric Adenocarcinoma, Gastroesophageal Junct...</td>\n",
       "      <td>Claudin 18.2 protein, or CLDN18.2 is a protein...</td>\n",
       "      <td>Kashiwa, Nagoya, Osakasayama, Suita, Yokohama, ku</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Participant is consid...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NCT05111626</td>\n",
       "      <td>Bemarituzumab Plus Chemotherapy and Nivolumab ...</td>\n",
       "      <td>2026-09-26</td>\n",
       "      <td>Gastric Cancer, Gastroesophageal Junction Aden...</td>\n",
       "      <td>The main objective of Part 1 is to evaluate th...</td>\n",
       "      <td>Sapporo, gun, ku, shi</td>\n",
       "      <td>Inclusion Criteria Part 1 and Part 2:\\n\\n* Adu...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NCT06324357</td>\n",
       "      <td>Beamion BCGC-1: A Study to Find a Suitable Dos...</td>\n",
       "      <td>2027-02-22</td>\n",
       "      <td>Metastatic Breast Cancer, Metastatic Gastric A...</td>\n",
       "      <td>This study is open to adults aged 18 years and...</td>\n",
       "      <td>ku, shi</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Signed and dated writ...</td>\n",
       "      <td>The patient is not eligible for this clinical ...</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NCT06056024</td>\n",
       "      <td>A Study to Test How Well Different Doses of BI...</td>\n",
       "      <td>2027-05-26</td>\n",
       "      <td>Solid Tumor, KRAS Mutation</td>\n",
       "      <td>This study is open to adults with advanced can...</td>\n",
       "      <td>Kashiwa, ku</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Patients with pathol...</td>\n",
       "      <td>The patient is not eligible for this clinical ...</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>NCT04379596</td>\n",
       "      <td>Ph1b/2 Study of the Safety and Efficacy of T-D...</td>\n",
       "      <td>2026-07-30</td>\n",
       "      <td>Gastric Cancer</td>\n",
       "      <td>DESTINY-Gastric03 will investigate the safety,...</td>\n",
       "      <td>Kashiwa, gun, ku, shi</td>\n",
       "      <td>Inclusion criteria:\\n\\n1. Male and female part...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>NCT00197470</td>\n",
       "      <td>Cytokine Gene Polymorphisms in Gastric Diseases</td>\n",
       "      <td>Unknown Date</td>\n",
       "      <td>Gastric Ulcer, Duodenal Ulcer, Gastric Cancer</td>\n",
       "      <td>Recently, cytokine polymorphisms are considere...</td>\n",
       "      <td>Hamamatsu</td>\n",
       "      <td>Inclusion Criteria:\\n\\n-\\n\\nExclusion Criteria...</td>\n",
       "      <td>I do not know if the patient is eligible for t...</td>\n",
       "      <td>unclear</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>NCT05205343</td>\n",
       "      <td>Trans-Pacific Multicenter Collaborative Study ...</td>\n",
       "      <td>2026-05-31</td>\n",
       "      <td>Gastrostomy, Gastric, GastroEsophageal Cancer</td>\n",
       "      <td>To compare the symptoms of patients who have a...</td>\n",
       "      <td>Tokyo</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Able to speak and re...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>NCT06490055</td>\n",
       "      <td>Predicting the Efficacy in Advanced Gastric Ca...</td>\n",
       "      <td>2025-12-31</td>\n",
       "      <td>Gastric Cancer, Chemotherapy Effect, Paclitaxe...</td>\n",
       "      <td>With advances in chemotherapy for gastric canc...</td>\n",
       "      <td>Kurashiki</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. unresectable or recu...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>NCT06490159</td>\n",
       "      <td>Predicting Peripheral Neuropathy of Paclitaxel...</td>\n",
       "      <td>2025-12-31</td>\n",
       "      <td>Gastric Cancer, Chemotherapy-induced Periphera...</td>\n",
       "      <td>Although advances in chemotherapy have improve...</td>\n",
       "      <td>Kurashiki</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. unresectable or recu...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>NCT05438459</td>\n",
       "      <td>GAIA-102 Intraperitoneal Administration in Pat...</td>\n",
       "      <td>2026-12-31</td>\n",
       "      <td>Gastric Cancer, Pancreatic Cancer</td>\n",
       "      <td>Phase I Part :\\n\\nConfirm the safety of GAIA-1...</td>\n",
       "      <td>shi</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Unresectable, advanc...</td>\n",
       "      <td>Based on the provided criteria, the 65-year-ol...</td>\n",
       "      <td>unclear</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>NCT04745988</td>\n",
       "      <td>An Open Label Phase 2 Study to Evaluate the Sa...</td>\n",
       "      <td>2025-08</td>\n",
       "      <td>Gastric Cancer</td>\n",
       "      <td>This study is an open label phase 2 study to e...</td>\n",
       "      <td>Kashiwa</td>\n",
       "      <td>Inclusion Criteria:\\n\\n1. Have gastric and gas...</td>\n",
       "      <td>The patient is eligible for this clinical tria...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>NCT06038578</td>\n",
       "      <td>A Study of TRK-950 When Used in Combination Wi...</td>\n",
       "      <td>2025-08-31</td>\n",
       "      <td>Gastric Adenocarcinoma, Gastric Cancer, Gastro...</td>\n",
       "      <td>This study will assess the efficacy, safety, o...</td>\n",
       "      <td>Chuo Ku, Kashiwa, Ku</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Histologically or cyt...</td>\n",
       "      <td>The patient is not eligible for this clinical ...</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>NCT05322577</td>\n",
       "      <td>A Study Evaluating Bemarituzumab in Combinatio...</td>\n",
       "      <td>2026-03-17</td>\n",
       "      <td>Gastric Cancer, Gastroesophageal Junction Cancer</td>\n",
       "      <td>The main objectives of this study are to evalu...</td>\n",
       "      <td>Shi, gun, ku, shi</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Adults with unresecta...</td>\n",
       "      <td>The patient is not eligible for this clinical ...</td>\n",
       "      <td>no</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>NCT05152147</td>\n",
       "      <td>A Study of Zanidatamab in Combination With Che...</td>\n",
       "      <td>2024-12-31</td>\n",
       "      <td>Gastric Neoplasms, Gastroesophageal Adenocarci...</td>\n",
       "      <td>This study is being done to find out if zanida...</td>\n",
       "      <td>Cho, Chuo Ku, Hirakata, Ina, Ku, Matsuyama, Na...</td>\n",
       "      <td>Inclusion Criteria:\\n\\n* Histologically confir...</td>\n",
       "      <td>Based on the provided information, the 65-year...</td>\n",
       "      <td>yes</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          NCTID                                              Title  \\\n",
       "0   NCT03505320  A Study of Zolbetuximab (IMAB362) in Adults Wi...   \n",
       "1   NCT05002127  A Study of Evorpacept (ALX148) in Patients wit...   \n",
       "2   NCT05365581  A Study of ASP2138 Given by Itself or Given Wi...   \n",
       "3   NCT05111626  Bemarituzumab Plus Chemotherapy and Nivolumab ...   \n",
       "4   NCT06324357  Beamion BCGC-1: A Study to Find a Suitable Dos...   \n",
       "5   NCT06056024  A Study to Test How Well Different Doses of BI...   \n",
       "6   NCT04379596  Ph1b/2 Study of the Safety and Efficacy of T-D...   \n",
       "7   NCT00197470    Cytokine Gene Polymorphisms in Gastric Diseases   \n",
       "8   NCT05205343  Trans-Pacific Multicenter Collaborative Study ...   \n",
       "9   NCT06490055  Predicting the Efficacy in Advanced Gastric Ca...   \n",
       "10  NCT06490159  Predicting Peripheral Neuropathy of Paclitaxel...   \n",
       "11  NCT05438459  GAIA-102 Intraperitoneal Administration in Pat...   \n",
       "12  NCT04745988  An Open Label Phase 2 Study to Evaluate the Sa...   \n",
       "13  NCT06038578  A Study of TRK-950 When Used in Combination Wi...   \n",
       "14  NCT05322577  A Study Evaluating Bemarituzumab in Combinatio...   \n",
       "15  NCT05152147  A Study of Zanidatamab in Combination With Che...   \n",
       "\n",
       "   Primary Completion Date                                             Cancer  \\\n",
       "0               2025-04-30  Pharmacokinetics of Zolbetuximab, Gastric Canc...   \n",
       "1                  2026-07  Gastric Cancer, Gastroesophageal Junction Aden...   \n",
       "2               2026-10-31  Gastric Adenocarcinoma, Gastroesophageal Junct...   \n",
       "3               2026-09-26  Gastric Cancer, Gastroesophageal Junction Aden...   \n",
       "4               2027-02-22  Metastatic Breast Cancer, Metastatic Gastric A...   \n",
       "5               2027-05-26                         Solid Tumor, KRAS Mutation   \n",
       "6               2026-07-30                                     Gastric Cancer   \n",
       "7             Unknown Date      Gastric Ulcer, Duodenal Ulcer, Gastric Cancer   \n",
       "8               2026-05-31      Gastrostomy, Gastric, GastroEsophageal Cancer   \n",
       "9               2025-12-31  Gastric Cancer, Chemotherapy Effect, Paclitaxe...   \n",
       "10              2025-12-31  Gastric Cancer, Chemotherapy-induced Periphera...   \n",
       "11              2026-12-31                  Gastric Cancer, Pancreatic Cancer   \n",
       "12                 2025-08                                     Gastric Cancer   \n",
       "13              2025-08-31  Gastric Adenocarcinoma, Gastric Cancer, Gastro...   \n",
       "14              2026-03-17   Gastric Cancer, Gastroesophageal Junction Cancer   \n",
       "15              2024-12-31  Gastric Neoplasms, Gastroesophageal Adenocarci...   \n",
       "\n",
       "                                              Summary  \\\n",
       "0   Zolbetuximab is being studied as a treatment f...   \n",
       "1   A Phase 2/3 Study of Evorpacept (ALX148) in Co...   \n",
       "2   Claudin 18.2 protein, or CLDN18.2 is a protein...   \n",
       "3   The main objective of Part 1 is to evaluate th...   \n",
       "4   This study is open to adults aged 18 years and...   \n",
       "5   This study is open to adults with advanced can...   \n",
       "6   DESTINY-Gastric03 will investigate the safety,...   \n",
       "7   Recently, cytokine polymorphisms are considere...   \n",
       "8   To compare the symptoms of patients who have a...   \n",
       "9   With advances in chemotherapy for gastric canc...   \n",
       "10  Although advances in chemotherapy have improve...   \n",
       "11  Phase I Part :\\n\\nConfirm the safety of GAIA-1...   \n",
       "12  This study is an open label phase 2 study to e...   \n",
       "13  This study will assess the efficacy, safety, o...   \n",
       "14  The main objectives of this study are to evalu...   \n",
       "15  This study is being done to find out if zanida...   \n",
       "\n",
       "                                    Japanes Locations  \\\n",
       "0                                        Chiba, Tokyo   \n",
       "1   Chiba, Fukuoka, Gifu, Kumamoto, Kyoto, Nagasak...   \n",
       "2   Kashiwa, Nagoya, Osakasayama, Suita, Yokohama, ku   \n",
       "3                               Sapporo, gun, ku, shi   \n",
       "4                                             ku, shi   \n",
       "5                                         Kashiwa, ku   \n",
       "6                               Kashiwa, gun, ku, shi   \n",
       "7                                           Hamamatsu   \n",
       "8                                               Tokyo   \n",
       "9                                           Kurashiki   \n",
       "10                                          Kurashiki   \n",
       "11                                                shi   \n",
       "12                                            Kashiwa   \n",
       "13                               Chuo Ku, Kashiwa, Ku   \n",
       "14                                  Shi, gun, ku, shi   \n",
       "15  Cho, Chuo Ku, Hirakata, Ina, Ku, Matsuyama, Na...   \n",
       "\n",
       "                                 Eligibility Criteria  \\\n",
       "0   Inclusion Criteria:\\n\\n* Female subject eligib...   \n",
       "1   Inclusion Criteria:\\n\\n* HER2-overexpressing a...   \n",
       "2   Inclusion Criteria:\\n\\n* Participant is consid...   \n",
       "3   Inclusion Criteria Part 1 and Part 2:\\n\\n* Adu...   \n",
       "4   Inclusion Criteria:\\n\\n* Signed and dated writ...   \n",
       "5   Inclusion Criteria:\\n\\n1. Patients with pathol...   \n",
       "6   Inclusion criteria:\\n\\n1. Male and female part...   \n",
       "7   Inclusion Criteria:\\n\\n-\\n\\nExclusion Criteria...   \n",
       "8   Inclusion Criteria:\\n\\n1. Able to speak and re...   \n",
       "9   Inclusion Criteria:\\n\\n1. unresectable or recu...   \n",
       "10  Inclusion Criteria:\\n\\n1. unresectable or recu...   \n",
       "11  Inclusion Criteria:\\n\\n1. Unresectable, advanc...   \n",
       "12  Inclusion Criteria:\\n\\n1. Have gastric and gas...   \n",
       "13  Inclusion Criteria:\\n\\n* Histologically or cyt...   \n",
       "14  Inclusion Criteria:\\n\\n* Adults with unresecta...   \n",
       "15  Inclusion Criteria:\\n\\n* Histologically confir...   \n",
       "\n",
       "                                        AgentJudgment AgentGrade  \n",
       "0   The patient is not eligible for this clinical ...         no  \n",
       "1   The patient is eligible for this clinical tria...    unclear  \n",
       "2   The patient is eligible for this clinical tria...        yes  \n",
       "3   The patient is eligible for this clinical tria...         no  \n",
       "4   The patient is not eligible for this clinical ...         no  \n",
       "5   The patient is not eligible for this clinical ...         no  \n",
       "6   The patient is eligible for this clinical tria...        yes  \n",
       "7   I do not know if the patient is eligible for t...    unclear  \n",
       "8   The patient is eligible for this clinical tria...        yes  \n",
       "9   The patient is eligible for this clinical tria...        yes  \n",
       "10  The patient is eligible for this clinical tria...        yes  \n",
       "11  Based on the provided criteria, the 65-year-ol...    unclear  \n",
       "12  The patient is eligible for this clinical tria...        yes  \n",
       "13  The patient is not eligible for this clinical ...         no  \n",
       "14  The patient is not eligible for this clinical ...         no  \n",
       "15  Based on the provided information, the 65-year...        yes  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('./65yerProstateCancer.csv')"
   ]
  },
  {
   "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.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}