Skip to content

Commit 862872e

Browse files
authored
Merge pull request #60 from CodeForPhilly/listOfMed
List of med
2 parents 433af2d + 6447c7d commit 862872e

17 files changed

Lines changed: 250 additions & 58 deletions

File tree

config/env/env.dev

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
DEBUG=1
22
SECRET_KEY=foo
33
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
4-
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
54
SQL_ENGINE=django.db.backends.postgresql
65
SQL_DATABASE=balancer_dev
76
SQL_USER=balancer

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
ports:
1717
- "8000:8000"
1818
env_file:
19-
- ./config/env/.env.dev
19+
- ./config/env/env.dev
2020
depends_on:
2121
- db
2222
frontend:

frontend/src/pages/PatientManager/NewPatientForm.tsx

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

frontend/src/pages/PatientManager/PatientManager.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const PatientManager = () => {
1919
Description: "",
2020
CurrentMedications: "",
2121
PriorMedications: "",
22-
PossibleMedications: { drugs: [] },
2322
Depression: "",
2423
Hypomania: "",
2524
Mania: "",
@@ -31,6 +30,11 @@ const PatientManager = () => {
3130
weight_gain: "",
3231
Reproductive: "",
3332
risk_pregnancy: "",
33+
PossibleMedications: {
34+
first: "",
35+
second: "",
36+
third: "",
37+
},
3438
});
3539

3640
const handlePatientDeleted = (deletedId: string) => {
@@ -42,7 +46,6 @@ const PatientManager = () => {
4246
Description: "",
4347
CurrentMedications: "",
4448
PriorMedications: "",
45-
PossibleMedications: { drugs: [] },
4649
Depression: "",
4750
Hypomania: "",
4851
Mania: "",

frontend/src/pages/PatientManager/PatientSummary.tsx

Lines changed: 99 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,17 @@ const PatientSummary = ({
319319
Possible Medications:
320320
</dt>
321321
<dd className="mt-2 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
322+
<dt className="ml-2 flex text-sm font-medium leading-6 text-gray-900">
323+
Tier 1: First-line Options:
324+
</dt>
322325
<ul
323326
role="list"
324327
className="divide-y divide-gray-100 rounded-md border border-gray-200"
325328
>
326329
{patientInfo.PossibleMedications &&
327-
patientInfo.PossibleMedications.drugs?.map(
328-
(medication: string) => (
330+
patientInfo.PossibleMedications.first
331+
?.split(", ")
332+
.map((medication: string) => (
329333
<li
330334
className={`flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-4 hover:bg-indigo-100
331335
${
@@ -356,8 +360,99 @@ const PatientSummary = ({
356360
</span>
357361
</div>
358362
</li>
359-
)
360-
)}
363+
))}
364+
</ul>
365+
</dd>
366+
<dt className="flex text-sm font-medium leading-6 text-gray-900"></dt>
367+
<dd className="mt-2 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
368+
<dt className="ml-2 flex text-sm font-medium leading-6 text-gray-900">
369+
Tier 2: Second-line Options:
370+
</dt>
371+
<ul
372+
role="list"
373+
className="divide-y divide-gray-100 rounded-md border border-gray-200"
374+
>
375+
{patientInfo.PossibleMedications &&
376+
patientInfo.PossibleMedications.second
377+
?.split(", ")
378+
.map((medication: string) => (
379+
<li
380+
className={`flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-4 hover:bg-indigo-100
381+
${
382+
medication === clickedMedication
383+
? "bg-indigo-100"
384+
: ""
385+
} cursor-pointer`}
386+
onClick={() =>
387+
handleMedicationClick(medication)
388+
}
389+
>
390+
<div className="flex w-0 flex-1 items-center">
391+
<div className="ml-4 flex min-w-0 flex-1 gap-2">
392+
<span className="truncate font-medium">
393+
{medication}
394+
</span>
395+
<div className="ml-3 mt-0 flex max-w-sm items-start text-white">
396+
{loading &&
397+
medication === clickedMedication ? (
398+
<TypingAnimation />
399+
) : null}
400+
</div>
401+
</div>
402+
</div>
403+
<div className="ml-4 flex-shrink-0">
404+
<span className="font-medium text-indigo-600 hover:text-indigo-500">
405+
Benefits and risks
406+
</span>
407+
</div>
408+
</li>
409+
))}
410+
</ul>
411+
</dd>
412+
<dt className="flex text-sm font-medium leading-6 text-gray-900"></dt>
413+
<dd className="mt-2 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
414+
<dt className="ml-2 flex text-sm font-medium leading-6 text-gray-900">
415+
Tier 3: Third-line Options:
416+
</dt>
417+
<ul
418+
role="list"
419+
className="divide-y divide-gray-100 rounded-md border border-gray-200"
420+
>
421+
{patientInfo.PossibleMedications &&
422+
patientInfo.PossibleMedications.third
423+
?.split(", ")
424+
.map((medication: string) => (
425+
<li
426+
className={`flex items-center justify-between py-4 pl-4 pr-5 text-sm leading-4 hover:bg-indigo-100
427+
${
428+
medication === clickedMedication
429+
? "bg-indigo-100"
430+
: ""
431+
} cursor-pointer`}
432+
onClick={() =>
433+
handleMedicationClick(medication)
434+
}
435+
>
436+
<div className="flex w-0 flex-1 items-center">
437+
<div className="ml-4 flex min-w-0 flex-1 gap-2">
438+
<span className="truncate font-medium">
439+
{medication}
440+
</span>
441+
<div className="ml-3 mt-0 flex max-w-sm items-start text-white">
442+
{loading &&
443+
medication === clickedMedication ? (
444+
<TypingAnimation />
445+
) : null}
446+
</div>
447+
</div>
448+
</div>
449+
<div className="ml-4 flex-shrink-0">
450+
<span className="font-medium text-indigo-600 hover:text-indigo-500">
451+
Benefits and risks
452+
</span>
453+
</div>
454+
</li>
455+
))}
361456
</ul>
362457
</dd>
363458
</div>

frontend/src/pages/PatientManager/PatientTypes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export interface PatientInfo {
99
CurrentMedications?: string;
1010
PriorMedications?: string;
1111
PossibleMedications?: {
12-
drugs?: string[];
12+
first?: string;
13+
second?: string;
14+
third?: string;
1315
};
1416
Psychotic: string;
1517
Suicide: string;
@@ -32,7 +34,9 @@ export interface NewPatientInfo {
3234
CurrentMedications?: string;
3335
PriorMedications?: string;
3436
PossibleMedications?: {
35-
drugs?: string[];
37+
first?: string[];
38+
second?: string[];
39+
third?: string[];
3640
};
3741
Psychotic: string;
3842
Suicide: string;

server/api/admin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
from django.contrib import admin
2+
from .views.listMeds.models import StateMedication
23

3-
# Register your models here.
4+
5+
@admin.register(StateMedication)
6+
class StateMedicationAdmin(admin.ModelAdmin):
7+
list_display = ['state', 'first', 'second', 'third']

server/api/management/__init__.py

Whitespace-only changes.

server/api/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from django.core.management.base import BaseCommand
2+
from django.contrib.auth import get_user_model
3+
4+
5+
class Command(BaseCommand):
6+
help = 'Create a default superuser'
7+
8+
def handle(self, *args, **kwargs):
9+
User = get_user_model()
10+
if not User.objects.filter(username='admin').exists():
11+
User.objects.create_superuser(
12+
'admin', 'admin@example.com', 'adminpassword')
13+
self.stdout.write(self.style.SUCCESS(
14+
'Successfully created a new superuser'))
15+
else:
16+
self.stdout.write(self.style.SUCCESS(
17+
'Superuser already exists. Skipping.'))

0 commit comments

Comments
 (0)