@@ -33,7 +33,6 @@ const NewPatientForm = ({
3333 Description : "" ,
3434 CurrentMedications : "" ,
3535 PriorMedications : "" ,
36- PossibleMedications : { drugs : [ ] } ,
3736 Mania : "False" ,
3837 Depression : "False" ,
3938 Hypomania : "False" ,
@@ -72,7 +71,7 @@ const NewPatientForm = ({
7271 e . preventDefault ( ) ;
7372
7473 const payload = {
75- diagnosis :
74+ state :
7675 newPatientInfo . Diagnosis !== null ? newPatientInfo . Diagnosis : "Null" ,
7776 } ;
7877
@@ -91,34 +90,32 @@ const NewPatientForm = ({
9190
9291 const { data } = await axios . post ( url + `/list_meds` , payload ) ;
9392
94- const drugsResponse = await axios . post ( url + `/list_drugs` , payload ) ;
93+ console . log ( data ) ;
9594
96- const possibleMedicationsData = drugsResponse . data ;
95+ const categorizedMedications = {
96+ first : data . first ?? [ ] ,
97+ second : data . second ?? [ ] ,
98+ third : data . third ?? [ ] ,
99+ } ;
97100
98- if ( possibleMedicationsData && Array . isArray ( possibleMedicationsData ) ) {
99- // Extract drugs property from each object and flatten it into a single array
100- const possibleMedicationNames = possibleMedicationsData
101- . map ( ( medication : { drugs : string [ ] } ) => medication . drugs )
102- . flat ( ) ;
101+ console . log ( categorizedMedications . first ) ;
102+ console . log ( categorizedMedications . second ) ;
103+
104+ setPatientInfo ( ( prev ) => ( {
105+ ...prev ,
106+ PossibleMedications : categorizedMedications ,
107+ } ) ) ;
103108
104- setPatientInfo ( ( prev ) => ( {
105- ...prev ,
106- PossibleMedications : { drugs : possibleMedicationNames } ,
107- } ) ) ;
108- }
109109 const generatedGuid = uuidv4 ( ) ;
110110 const firstFiveCharacters = generatedGuid . substring ( 0 , 5 ) ;
111111
112112 setPatientInfo ( { ...newPatientInfo , ID : firstFiveCharacters } ) ;
113113
114114 if ( data ) {
115- const description = data . message . choices [ 0 ] . message . content ;
116-
117115 const newDescription = {
118116 ...newPatientInfo ,
119- Description : description ,
120117 ID : firstFiveCharacters ,
121- PossibleMedications : possibleMedicationsData ,
118+ PossibleMedications : categorizedMedications ,
122119 } ;
123120
124121 const updatedAllPatientInfo = [ newDescription , ...allPatientInfo ] ;
@@ -161,7 +158,6 @@ const NewPatientForm = ({
161158 Description : "" ,
162159 CurrentMedications : "" ,
163160 PriorMedications : "" ,
164- PossibleMedications : { drugs : [ ] } ,
165161 Mania : "False" ,
166162 Depression : "False" ,
167163 Hypomania : "False" ,
@@ -187,7 +183,6 @@ const NewPatientForm = ({
187183 Description : "" ,
188184 CurrentMedications : "" ,
189185 PriorMedications : "" ,
190- PossibleMedications : { drugs : [ ] } ,
191186 Mania : "False" ,
192187 Depression : "False" ,
193188 Hypomania : "False" ,
@@ -303,10 +298,10 @@ const NewPatientForm = ({
303298 className = { isLoading ? " url_input_loading" : "dropdown" }
304299 >
305300 < option value = "Null" > </ option >
306- < option value = "Manic " > Manic </ option >
307- < option value = "Depressed " > Depressed</ option >
308- < option value = "Hypomanic " > Hypomanic</ option >
309- < option value = "Euthymic " > Euthymic</ option >
301+ < option value = "mania " > Manic </ option >
302+ < option value = "depression " > Depressed</ option >
303+ < option value = "hypomania " > Hypomanic</ option >
304+ < option value = "euthymic " > Euthymic</ option >
310305 < option value = "Mixed" > Mixed</ option >
311306 </ select >
312307 </ div >
0 commit comments