Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit d13b287

Browse files
committed
Med records
1 parent cf2dcb6 commit d13b287

File tree

2 files changed

+148
-52
lines changed

2 files changed

+148
-52
lines changed

code/modules/mob/living/silicon/pai/software.dm

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
/mob/living/silicon/pai/var/list/med_record = list()
4646
/mob/living/silicon/pai/var/list/sec_record = list()
47+
/mob/living/silicon/pai/var/selected_med_record
48+
/mob/living/silicon/pai/var/selected_sec_record
4749

4850
/mob/living/silicon/pai/ui_interact(mob/user, datum/tgui/ui)
4951
ui = SStgui.try_update_ui(user, src, ui)
@@ -78,7 +80,7 @@
7880
med_record = list() //Important to reset it here so it doesn't readd records endlessly
7981
for(var/datum/data/record/M in sortRecord(GLOB.data_core.medical))
8082
for(var/datum/data/record/R in sortRecord(GLOB.data_core.general))
81-
if(R.fields["name"] == M.fields["name"])
83+
if(R.fields["id"] == M.fields["id"])
8284
var/list/new_record = list("name" = R.fields["name"], "id" = R.fields["id"], "gender" = R.fields["gender"], "age" = R.fields["age"], "fingerprint" = R.fields["fingerprint"], "p_state" = R.fields["p_stat"], "m_state" = R.fields["m_stat"], "blood_type" = M.fields["blood_type"], "dna" = M.fields["b_dna"], "minor_disabilities" = M.fields["mi_dis"], "minor_disabilities_details" = M.fields["mi_dis_d"], "major_disabilities" = M.fields["ma_dis"], "major_disabilities_details" = M.fields["ma_dis_d"], "allergies" = M.fields["alg"], "allergies_details" = M.fields["alg_d"], "current_diseases" = M.fields["cdi"], "current_diseases_details" = M.fields["cdi_d"], "important_notes" = M.fields["notes"])
8385
med_record += list(new_record)
8486
break
@@ -98,6 +100,8 @@
98100
break
99101
data["med_records"] = med_record
100102
data["sec_records"] = sec_record
103+
data["selected_med_record"] = selected_med_record
104+
data["selected_sec_record"] = selected_sec_record
101105
return data
102106

103107
/mob/living/silicon/pai/ui_act(action, params)
@@ -225,6 +229,20 @@
225229
hackdoor = null
226230
cable = null
227231
cable_status = "Retracted"
232+
if("med_record")
233+
if(!GLOB.data_core.general||!GLOB.data_core.medical)
234+
return
235+
for(var/datum/data/record/M in sortRecord(GLOB.data_core.medical))
236+
var/done = FALSE
237+
for(var/datum/data/record/R in sortRecord(GLOB.data_core.general))
238+
if(M.fields["id"] == params["record"])
239+
selected_med_record = list("name" = R.fields["name"], "id" = R.fields["id"], "gender" = R.fields["gender"], "age" = R.fields["age"], "fingerprint" = R.fields["fingerprint"], "p_state" = R.fields["p_stat"], "m_state" = R.fields["m_stat"], "blood_type" = M.fields["blood_type"], "dna" = M.fields["b_dna"], "minor_disabilities" = M.fields["mi_dis"], "minor_disabilities_details" = M.fields["mi_dis_d"], "major_disabilities" = M.fields["ma_dis"], "major_disabilities_details" = M.fields["ma_dis_d"], "allergies" = M.fields["alg"], "allergies_details" = M.fields["alg_d"], "current_diseases" = M.fields["cdi"], "current_diseases_details" = M.fields["cdi_d"], "important_notes" = M.fields["notes"])
240+
done = TRUE
241+
break
242+
if(done)
243+
break
244+
if("med_record back")
245+
selected_med_record = null
228246
update_appearance(UPDATE_ICON)
229247

230248
/mob/living/silicon/pai/ui_state(mob/user)

tgui/packages/tgui/interfaces/PaiInterface.tsx

Lines changed: 129 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ type Data = {
7070
color: string;
7171
med_records: MedRecord[];
7272
sec_records: SecRecord[];
73+
selected_med_record: MedRecord[];
74+
selected_sec_record: SecRecord[];
7375
}
7476

7577
export const AirlockJackTextSwitch = params => {
@@ -87,12 +89,24 @@ export const AirlockJackTextSwitch = params => {
8789
}
8890
};
8991

92+
export const MedRecordColour = (mental, physical) => {
93+
if(mental === "*Insane*"||physical === "*Deceased*") {
94+
return "#990000;";
95+
} else if(mental === "*Unstable*"||physical === "*Unconscious*") {
96+
return "#CD6500;";
97+
} else if(mental === "*Watch*"||physical === "Physically Unfit") {
98+
return "#3BB9FF;";
99+
} else {
100+
return "#4F7529;";
101+
}
102+
};
103+
90104
export const PaiInterface = (props, context) => {
91105
const { act, data } = useBackend<Data>(context);
92106
const { modules_tabs = [] } = data;
93107
const [selectedMainTab, setMainTab] = useLocalState(context, "selectedMainTab", 0);
94108
return (
95-
<Window width={600} height={550}>
109+
<Window width={650} height={550}> {/* Width matters for medical records, height matters for download more software */}
96110
<Window.Content>
97111
<Flex>
98112
<Flex.Item grow={1}>
@@ -127,6 +141,8 @@ const PaiBox = (props, context) => {
127141
const { hacking, hackprogress, cable, door } = data;
128142
const { code, frequency, minFrequency, maxFrequency, color } = data;
129143
const { med_records, sec_records } = data;
144+
const [record_view, set_record_view] = useLocalState(context, "record_view", 0);
145+
const { selected_med_record } = data;
130146
switch(modules_tabs[selectedMainTab].module_name) {
131147
case "directives":
132148
return (
@@ -347,56 +363,118 @@ const PaiBox = (props, context) => {
347363
</Section>
348364
);
349365
case "medical records":
350-
return (
351-
<Section title={modules_tabs[selectedMainTab].title}>
352-
{med_records[0].name}
353-
<Table>
354-
<Table.Row>
355-
<Table.Cell>
356-
Name:
357-
</Table.Cell>
358-
<Table.Cell>
359-
ID:
360-
</Table.Cell>
361-
<Table.Cell>
362-
Fingerprint:
363-
</Table.Cell>
364-
<Table.Cell>
365-
Blood type:
366-
</Table.Cell>
367-
<Table.Cell>
368-
Physical state:
369-
</Table.Cell>
370-
<Table.Cell>
371-
Mental state:
372-
</Table.Cell>
373-
</Table.Row>
374-
{med_records.map(MedRecord => (
375-
<Table.Row
376-
key={MedRecord}>
377-
<Table.Cell>
378-
{MedRecord.name}
379-
</Table.Cell>
380-
<Table.Cell>
381-
{MedRecord.id}
382-
</Table.Cell>
383-
<Table.Cell>
384-
{MedRecord.fingerprint}
385-
</Table.Cell>
386-
<Table.Cell>
387-
{MedRecord.blood_type}
388-
</Table.Cell>
389-
<Table.Cell>
390-
{MedRecord.p_state}
391-
</Table.Cell>
392-
<Table.Cell>
393-
{MedRecord.m_state}
394-
</Table.Cell>
395-
</Table.Row>
396-
))}
397-
</Table>
398-
</Section>
399-
);
366+
if(selected_med_record) {
367+
return (
368+
<Section title={modules_tabs[selectedMainTab].title}>
369+
<Button icon="arrow-left"
370+
onClick={() => act("med_record back")}>
371+
Back
372+
</Button>
373+
<Stack vertical ml={2}>
374+
<Stack.Item>
375+
Name: {selected_med_record.name}
376+
</Stack.Item>
377+
<Stack.Item>
378+
ID: {selected_med_record.id}
379+
</Stack.Item>
380+
<Stack.Item>
381+
Gender: {selected_med_record.gender}
382+
</Stack.Item>
383+
<Stack.Item>
384+
Physical status: {selected_med_record.p_state}
385+
</Stack.Item>
386+
<Stack.Item>
387+
Mental status: {selected_med_record.m_state}
388+
</Stack.Item>
389+
<Stack.Item>
390+
Blood type: {selected_med_record.blood_type}
391+
</Stack.Item>
392+
<Stack.Item>
393+
DNA: {selected_med_record.dna}
394+
</Stack.Item>
395+
<br />
396+
<Stack.Item>
397+
Minor disabilities: {selected_med_record.minor_disabilities}
398+
</Stack.Item>
399+
<Stack.Item>
400+
Details: {selected_med_record.minor_disabilities_details}
401+
</Stack.Item>
402+
<Stack.Item>
403+
Major disabilities: {selected_med_record.major_disabilities}
404+
</Stack.Item>
405+
<Stack.Item>
406+
Details: {selected_med_record.major_disabilities_details}
407+
</Stack.Item>
408+
<Stack.Item>
409+
Allergies: {selected_med_record.allergies}
410+
</Stack.Item>
411+
<Stack.Item>
412+
Details: {selected_med_record.allergies_details}
413+
</Stack.Item>
414+
<Stack.Item>
415+
Current diseases: {selected_med_record.current_diseases}
416+
</Stack.Item>
417+
<Stack.Item>
418+
Details: {selected_med_record.current_diseases_details}
419+
</Stack.Item>
420+
<Stack.Item>
421+
Important notes: {selected_med_record.important_notes}
422+
</Stack.Item>
423+
<Stack.Item>
424+
Comments: {selected_med_record.comments}
425+
</Stack.Item>
426+
</Stack>
427+
</Section>
428+
);
429+
} else {
430+
return (
431+
<Section title={modules_tabs[selectedMainTab].title}>
432+
<Table>
433+
<Table.Row>
434+
<Table.Cell textAlign={"center"} bold={1}>
435+
Name:
436+
</Table.Cell>
437+
<Table.Cell textAlign={"center"} bold={1}>
438+
ID:
439+
</Table.Cell>
440+
<Table.Cell textAlign={"center"} bold={1}>
441+
Blood type:
442+
</Table.Cell>
443+
<Table.Cell textAlign={"center"} bold={1}>
444+
Physical status:
445+
</Table.Cell>
446+
<Table.Cell textAlign={"center"} bold={1}>
447+
Mental status:
448+
</Table.Cell>
449+
</Table.Row>
450+
{med_records.map(MedRecord => (
451+
<Table.Row
452+
key={MedRecord}
453+
height={3}>
454+
<Table.Cell backgroundColor={MedRecordColour(MedRecord.m_state, MedRecord.p_state)}>
455+
<Button
456+
onClick={() => act("med_record", { record: MedRecord.id })} m={1}>
457+
{MedRecord.name}
458+
</Button>
459+
</Table.Cell>
460+
<Table.Cell backgroundColor={MedRecordColour(MedRecord.m_state, MedRecord.p_state)}>
461+
{MedRecord.id}
462+
</Table.Cell>
463+
<Table.Cell backgroundColor={MedRecordColour(MedRecord.m_state, MedRecord.p_state)} textAlign={"center"}>
464+
{MedRecord.blood_type}
465+
</Table.Cell>
466+
<Table.Cell backgroundColor={MedRecordColour(MedRecord.m_state, MedRecord.p_state)} textAlign={"center"}>
467+
{MedRecord.p_state}
468+
</Table.Cell>
469+
<Table.Cell backgroundColor={MedRecordColour(MedRecord.m_state, MedRecord.p_state)} textAlign={"center"}>
470+
{MedRecord.m_state}
471+
</Table.Cell>
472+
</Table.Row>
473+
))}
474+
</Table>
475+
</Section>
476+
);
477+
}
400478
case "host scan":
401479
return (
402480
<Section title={modules_tabs[selectedMainTab].title}>

0 commit comments

Comments
 (0)