From ea477bf7cea4f10ab4bd2305671f1e61be40a6da Mon Sep 17 00:00:00 2001 From: FalloutFalcon Date: Tue, 28 May 2024 21:15:32 -0500 Subject: [PATCH] notekeeper! --- code/__DEFINES/datacore.dm | 20 +-- code/controllers/subsystem/datacore.dm | 11 +- .../game/machinery/computer/record/medical.dm | 45 +++++- code/modules/datacore/medical_note.dm | 15 ++ shiptest.dme | 1 + .../interfaces/MedicalRecords/NoteKeeper.tsx | 129 ++++++++++++++++++ .../interfaces/MedicalRecords/RecordView.tsx | 26 ++-- .../tgui/interfaces/MedicalRecords/types.ts | 10 +- .../interfaces/SecurityRecords/RecordView.tsx | 12 +- .../tgui/interfaces/SecurityRecords/types.ts | 12 +- 10 files changed, 227 insertions(+), 54 deletions(-) create mode 100644 code/modules/datacore/medical_note.dm create mode 100644 tgui/packages/tgui/interfaces/MedicalRecords/NoteKeeper.tsx diff --git a/code/__DEFINES/datacore.dm b/code/__DEFINES/datacore.dm index 275cff49d01a..53f51e587813 100644 --- a/code/__DEFINES/datacore.dm +++ b/code/__DEFINES/datacore.dm @@ -5,31 +5,31 @@ #define DATACORE_AGE "age" #define DATACORE_GENDER "gender" #define DATACORE_SPECIES "species" -#define DATACORE_FINGERPRINT "fingerprint" + #define DATACORE_APPEARANCE "character_appearance" -#define DATACORE_MINDREF "mind" -#define DATACORE_DNA_IDENTITY "identity" -#define DATACORE_DNA_FEATURES "features" +#define DATACORE_NOTES "notes" #define DATACORE_PHYSICAL_HEALTH "p_stat" #define DATACORE_MENTAL_HEALTH "m_stat" + #define DATACORE_BLOOD_TYPE "blood_type" #define DATACORE_BLOOD_DNA "b_dna" #define DATACORE_DISEASES "cdi" #define DATACORE_DISEASES_DETAILS "cdi_d" #define DATACORE_DISABILITIES "ma_dis" #define DATACORE_DISABILITIES_DETAILS "ma_dis_d" +#define DATACORE_NOTES_MEDICAL "medical_note" +#define DATACORE_FINGERPRINT "fingerprint" #define DATACORE_CRIMES "crim" #define DATACORE_CRIMINAL_STATUS "criminal" -//#define DATACORE_CITATIONS "citation" +#define DATACORE_NOTES_SECURITY "security_note" +//Not very used #define DATACORE_IMAGE "image" - -#define DATACORE_NOTES "notes" -//#define DATACORE_NOTES_DETAILS "notes_d" -#define DATACORE_NOTES_SECURITY "security_note" -#define DATACORE_NOTES_MEDICAL "medical_note" +#define DATACORE_DNA_IDENTITY "identity" +#define DATACORE_DNA_FEATURES "features" +#define DATACORE_MINDREF "mind" /// Keys for SSdatacore.library #define DATACORE_RECORDS_OUTPOST "outpost" diff --git a/code/controllers/subsystem/datacore.dm b/code/controllers/subsystem/datacore.dm index df5433681256..1319397aae0d 100644 --- a/code/controllers/subsystem/datacore.dm +++ b/code/controllers/subsystem/datacore.dm @@ -182,25 +182,26 @@ SUBSYSTEM_DEF(datacore) //General Record var/datum/data/record/G = new() G.fields[DATACORE_ID] = id - G.fields[DATACORE_NAME] = H.real_name G.fields[DATACORE_RANK] = assignment G.fields[DATACORE_INITIAL_RANK] = assignment + G.fields[DATACORE_NAME] = H.real_name G.fields[DATACORE_AGE] = H.age + G.fields[DATACORE_GENDER] = person_gender G.fields[DATACORE_SPECIES] = H.dna.species.name - G.fields[DATACORE_PHYSICAL_HEALTH] = PHYSICAL_ACTIVE - G.fields[DATACORE_MENTAL_HEALTH] = MENTAL_STABLE - G.fields[DATACORE_GENDER] = person_gender G.fields[DATACORE_APPEARANCE] = character_appearance G.fields[DATACORE_NOTES] = "No notes." + G.fields[DATACORE_PHYSICAL_HEALTH] = PHYSICAL_ACTIVE + G.fields[DATACORE_MENTAL_HEALTH] = MENTAL_STABLE + G.fields[DATACORE_BLOOD_TYPE] = H.dna.blood_type.name G.fields[DATACORE_BLOOD_DNA] = H.dna.unique_enzymes G.fields[DATACORE_DISABILITIES] = "None" G.fields[DATACORE_DISABILITIES_DETAILS] = "No minor disabilities have been declared." G.fields[DATACORE_DISEASES] = "None" G.fields[DATACORE_DISEASES_DETAILS] = "No diseases have been diagnosed at the moment." - G.fields[DATACORE_NOTES_MEDICAL] = "No medical notes." + G.fields[DATACORE_NOTES_MEDICAL] = list() G.fields[DATACORE_FINGERPRINT] = md5(H.dna.uni_identity) G.fields[DATACORE_CRIMINAL_STATUS] = "None" diff --git a/code/game/machinery/computer/record/medical.dm b/code/game/machinery/computer/record/medical.dm index 1204d1b28787..686e40dc5682 100644 --- a/code/game/machinery/computer/record/medical.dm +++ b/code/game/machinery/computer/record/medical.dm @@ -24,18 +24,26 @@ var/list/records = list() for(var/datum/data/record/target in SSdatacore.get_records(linked_ship)) + var/list/notes = list() + for(var/datum/medical_note/note in target.fields[DATACORE_NOTES_MEDICAL]) + notes += list(list( + author = note.author, + content = note.content, + note_ref = REF(note), + time = note.time, + )) records += list(list( - age = target.fields[DATACORE_AGE], - blood_type = target.fields[DATACORE_BLOOD_TYPE], record_ref = REF(target), - dna = target.fields[DATACORE_BLOOD_DNA], + rank = target.fields[DATACORE_RANK], + age = target.fields[DATACORE_AGE], + name = target.fields[DATACORE_NAME], gender = target.fields[DATACORE_GENDER], - disabilities = target.fields[DATACORE_DISABILITIES], + species = target.fields[DATACORE_SPECIES], physical_status = target.fields[DATACORE_PHYSICAL_HEALTH], mental_status = target.fields[DATACORE_MENTAL_HEALTH], - name = target.fields[DATACORE_NAME], - rank = target.fields[DATACORE_RANK], - species = target.fields[DATACORE_SPECIES], + blood_type = target.fields[DATACORE_BLOOD_TYPE], + dna = target.fields[DATACORE_BLOOD_DNA], + notes = notes, )) data["records"] = records @@ -65,6 +73,29 @@ return FALSE switch(action) + if("add_note") + if(!params["content"]) + return FALSE + var/content = trim(params["content"], MAX_MESSAGE_LEN) + + var/datum/medical_note/new_note = new(usr.name, content) + while(length(target.fields[DATACORE_NOTES_MEDICAL]) > 5) + target.fields[DATACORE_NOTES_MEDICAL].Cut(1, 2) + + target.fields[DATACORE_NOTES_MEDICAL] += new_note + + return TRUE + + if("delete_note") + var/datum/medical_note/old_note = locate(params["note_ref"]) in target.fields[DATACORE_NOTES_MEDICAL] + if(!old_note) + return FALSE + + target.fields[DATACORE_NOTES_MEDICAL] -= old_note + qdel(old_note) + + return TRUE + if("set_physical_status") var/physical_status = params["physical_status"] if(!physical_status || !(physical_status in PHYSICAL_STATUSES)) diff --git a/code/modules/datacore/medical_note.dm b/code/modules/datacore/medical_note.dm new file mode 100644 index 000000000000..a1843394c2ae --- /dev/null +++ b/code/modules/datacore/medical_note.dm @@ -0,0 +1,15 @@ +/** + * Player-written medical note. + */ +/datum/medical_note + /// Player that wrote the note + var/author + /// Details of the note + var/content + /// Station timestamp + var/time + +/datum/medical_note/New(author = "Anonymous", content = "No details provided.") + src.author = author + src.content = content + src.time = station_time_timestamp() diff --git a/shiptest.dme b/shiptest.dme index f9c1ffec43e0..47e9be81433c 100644 --- a/shiptest.dme +++ b/shiptest.dme @@ -2050,6 +2050,7 @@ #include "code\modules\clothing\under\jobs\Plasmaman\security.dm" #include "code\modules\datacore\crime.dm" #include "code\modules\datacore\library.dm" +#include "code\modules\datacore\medical_note.dm" #include "code\modules\datacore\records.dm" #include "code\modules\detectivework\detective_work.dm" #include "code\modules\detectivework\evidence.dm" diff --git a/tgui/packages/tgui/interfaces/MedicalRecords/NoteKeeper.tsx b/tgui/packages/tgui/interfaces/MedicalRecords/NoteKeeper.tsx new file mode 100644 index 000000000000..3b940a1f69fe --- /dev/null +++ b/tgui/packages/tgui/interfaces/MedicalRecords/NoteKeeper.tsx @@ -0,0 +1,129 @@ +import { useBackend, useLocalState } from 'tgui/backend'; +import { + BlockQuote, + Box, + Button, + Icon, + LabeledList, + Section, + Tabs, + TextArea, + Tooltip, +} from 'tgui/components'; + +import { getMedicalRecord } from './helpers'; +import { MedicalNote, MedicalRecordData } from './types'; + +/** Small section for adding notes. Passes a ref and note to Byond. */ +export const NoteKeeper = (props, context) => { + const foundRecord = getMedicalRecord(props, context); + if (!foundRecord) return <> ; + + const { act } = useBackend(context); + const { record_ref } = foundRecord; + + const [selectedNote, setSelectedNote] = useLocalState< + MedicalNote | undefined + >(context, 'selectedNote', undefined); + + const [writing, setWriting] = useLocalState(context, 'note', false); + + const addNote = (event, value: string) => { + act('add_note', { + record_ref: record_ref, + content: value, + }); + setWriting(false); + }; + + const deleteNote = () => { + if (!selectedNote) return; + act('delete_note', { + record_ref: record_ref, + note_ref: selectedNote.note_ref, + }); + setSelectedNote(undefined); + }; + + return ( +
} fill scrollable title="Notes"> + {writing && ( +