Skip to content

Commit a9b5d30

Browse files
authored
Merge branch 'master' into CC-shuttles
Signed-off-by: Field Command <159087063+FieldCommand@users.noreply.github.com>
2 parents cedd1fe + 7d3f15b commit a9b5d30

118 files changed

Lines changed: 46760 additions & 37406 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,18 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)
287287
return;
288288
}
289289

290+
TriageControls.Visible = true;
290291
_triageControls[records.Status].Pressed = true;
292+
293+
// Update claim button based on claimed status
294+
if (records.ClaimedName != null)
295+
{
296+
ClaimButton.Text = Loc.GetString("health-analyzer-window-triage-unclaim", ("claimedBy", records.ClaimedName));
297+
}
298+
else
299+
{
300+
ClaimButton.Text = Loc.GetString("health-analyzer-window-triage-claim");
301+
}
291302
// End DeltaV - Medical Records
292303
}
293304
// Shitmed Change End

Content.Client/_DV/Overlays/ShowTriageIconsSystem.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace Content.Client._DV.Overlays;
1212

1313
public sealed class ShowTriageIconsSystem : EquipmentHudSystem<ShowTriageIconsComponent>
1414
{
15-
[Dependency] private readonly SharedIdCardSystem _idCard = default!;
1615
[Dependency] private readonly IPrototypeManager _prototype = default!;
1716
[Dependency] private readonly IPlayerManager _player = default!;
17+
[Dependency] private readonly SharedIdCardSystem _idCard = default!;
1818

1919
private static readonly ProtoId<HealthIconPrototype> Minor = "TriageStatusMinor";
2020
private static readonly ProtoId<HealthIconPrototype> Delayed = "TriageStatusDelayed";
@@ -47,10 +47,8 @@ private void OnGetStatusIconsEvent(Entity<MedicalRecordComponent> ent, ref GetSt
4747
_ => null,
4848
};
4949

50-
if (triageStatusIcon is not { } statusPrototype)
51-
return;
52-
53-
ev.StatusIcons.Add(statusPrototype);
50+
if (triageStatusIcon is { } statusPrototype)
51+
ev.StatusIcons.Add(statusPrototype);
5452

5553
if (ent.Comp.Record.ClaimedName is not { } claimedName)
5654
{

Content.Server/_DV/MedicalRecords/MedicalRecordsSystem.cs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
using Content.Shared._DV.MedicalRecords;
22
using Content.Shared.Access.Systems;
3+
using Content.Shared.IdentityManagement;
34
using Content.Shared.StationRecords;
45
using Content.Server.StationRecords.Systems;
6+
using Content.Server.Access.Systems;
7+
using Content.Shared.Access.Components;
8+
using Robust.Shared.Timing;
59

610
namespace Content.Server._DV.MedicalRecords;
711

812
public sealed class MedicalRecordsSystem : SharedMedicalRecordsSystem
913
{
14+
[Dependency] private readonly IGameTiming _timing = default!;
1015
[Dependency] private readonly StationRecordsSystem _records = default!;
1116
[Dependency] private readonly AccessReaderSystem _access = default!;
17+
[Dependency] private readonly IdCardSystem _idCard = default!;
18+
private static readonly TimeSpan ExpirationTime = TimeSpan.FromMinutes(5);
1219

1320
public override void Initialize()
1421
{
@@ -26,7 +33,7 @@ private void OnGeneralRecordCreated(AfterGeneralRecordCreatedEvent evt)
2633
public void SetStatus(StationRecordKey key, MedicalRecord record)
2734
{
2835
var name = _records.RecordName(key);
29-
if (name != string.Empty)
36+
if (!string.IsNullOrEmpty(name))
3037
UpdateMedicalRecords(name, record);
3138

3239
_records.AddRecordEntry(key, record);
@@ -39,7 +46,15 @@ public void SetStatus(StationRecordKey key, MedicalRecord record)
3946
foreach (var key in keys)
4047
{
4148
if (_records.TryGetRecord<MedicalRecord>(key, out var record))
49+
{
50+
// Check if expired when accessed
51+
if (record.LastUpdated != null && (_timing.CurTime - record.LastUpdated.Value) >= ExpirationTime)
52+
{
53+
record = record with { Status = TriageStatus.None, ClaimedName = null, LastUpdated = null };
54+
SetStatus(key, record);
55+
}
4256
return record;
57+
}
4358
}
4459
foreach (var key in keys)
4560
{
@@ -70,7 +85,7 @@ public void SetPatientStatus(StationRecordKey patient, TriageStatus status)
7085
{
7186
if (_records.TryGetRecord<MedicalRecord>(patient, out var record) && status != TriageStatus.None)
7287
{
73-
SetStatus(patient, record with { Status = status });
88+
SetStatus(patient, record with { Status = status, LastUpdated = _timing.CurTime });
7489
}
7590
else
7691
{
@@ -80,18 +95,26 @@ public void SetPatientStatus(StationRecordKey patient, TriageStatus status)
8095

8196
public void ClaimPatient(StationRecordKey patient, EntityUid claimer)
8297
{
83-
_access.FindStationRecordKeys(claimer, out var keys);
84-
foreach (var key in keys)
85-
{
86-
var name = _records.RecordName(key);
87-
if (name == string.Empty)
88-
continue;
98+
// Require ID card with medical access to claim patient
99+
if (!_idCard.TryFindIdCard(claimer, out var idCard))
100+
return;
89101

90-
if (!_records.TryGetRecord<MedicalRecord>(patient, out var record) || record.ClaimedName == name)
91-
continue;
102+
// Check if ID card has medical access
103+
if (!TryComp<AccessComponent>(idCard.Owner, out var access) ||
104+
!access.Tags.Contains("Medical"))
105+
return;
92106

93-
SetStatus(patient, record with { ClaimedName = name });
94-
break;
95-
}
107+
var claimerName = idCard.Comp.FullName;
108+
if (string.IsNullOrEmpty(claimerName))
109+
return;
110+
111+
if (!_records.TryGetRecord<MedicalRecord>(patient, out var record))
112+
return;
113+
114+
// Makes claim patient toggleable
115+
var newClaim = record.ClaimedName == claimerName ? null : claimerName;
116+
var newTime = newClaim != null ? (TimeSpan?)_timing.CurTime : null;
117+
118+
SetStatus(patient, record with { ClaimedName = newClaim, LastUpdated = newTime });
96119
}
97120
}

Content.Shared/_DV/MedicalRecords/MedicalRecord.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ public sealed partial record MedicalRecord
3535
/// The name of the doctor who has claimed care of this patient
3636
/// </summary>
3737
public string? ClaimedName;
38+
39+
/// <summary>
40+
/// The time when this record was last updated (for expiration tracking)
41+
/// </summary>
42+
public TimeSpan? LastUpdated;
3843
}

Content.Shared/_DV/MedicalRecords/SharedMedicalRecordsSystem.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public void UpdateMedicalRecords(string name, MedicalRecord status)
1414
if (!Identity.Name(uid, EntityManager).Equals(name))
1515
continue;
1616

17-
if (status.Status == TriageStatus.None)
17+
// Only remove the component if both status is None AND patient is unclaimed
18+
if (status is { Status: TriageStatus.None, ClaimedName: null })
1819
{
1920
RemComp<MedicalRecordComponent>(uid);
2021
}
979 KB
Binary file not shown.
Binary file not shown.
809 KB
Binary file not shown.
716 KB
Binary file not shown.
549 KB
Binary file not shown.

0 commit comments

Comments
 (0)