Skip to content

Commit

Permalink
GetBedByPatient
Browse files Browse the repository at this point in the history
  • Loading branch information
FoseFx committed Sep 18, 2024
1 parent b4598d0 commit 1957652
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 33 deletions.
13 changes: 11 additions & 2 deletions services/tasks-svc/internal/bed/bed.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,19 @@ func (ServiceServer) GetBedByPatient(ctx context.Context, req *pb.GetBedByPatien

return &pb.GetBedByPatientResponse{
Room: hwutil.MapNillable(result, func(res bed_repo.GetBedWithRoomByPatientRow) pb.GetBedByPatientResponse_Room {
return pb.GetBedByPatientResponse_Room{Id: res.RoomID.String(), Name: res.RoomName, WardId: res.WardID.String()}
return pb.GetBedByPatientResponse_Room{
Id: res.RoomID.String(),
Name: res.RoomName,
WardId: res.WardID.String(),
Consistency: strconv.FormatUint(uint64(res.RoomConsistency), 10),
}
}),
Bed: hwutil.MapNillable(result, func(res bed_repo.GetBedWithRoomByPatientRow) pb.GetBedByPatientResponse_Bed {
return pb.GetBedByPatientResponse_Bed{Id: res.BedID.String(), Name: res.BedName}
return pb.GetBedByPatientResponse_Bed{
Id: res.BedID.String(),
Name: res.BedName,
Consistency: strconv.FormatUint(uint64(res.BedConsistency), 10),
}
}),
}, nil
}
Expand Down
1 change: 1 addition & 0 deletions services/tasks-svc/migrations/000028_consistency.down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ALTER TABLE rooms DROP COLUMN IF EXISTS consistency;
ALTER TABLE beds DROP COLUMN IF EXISTS consistency;

1 change: 1 addition & 0 deletions services/tasks-svc/migrations/000028_consistency.up.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ALTER TABLE beds ADD COLUMN IF NOT EXISTS consistency BIGINT NOT NULL DEFAULT 0;
ALTER TABLE rooms ADD COLUMN IF NOT EXISTS consistency BIGINT NOT NULL DEFAULT 0;

9 changes: 7 additions & 2 deletions services/tasks-svc/repos/bed_repo.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ LIMIT 1;

-- name: GetBedWithRoomByPatient :one
SELECT
beds.id as bed_id, beds.name as bed_name,
rooms.id as room_id, rooms.name as room_name, rooms.ward_id as ward_id
beds.id as bed_id,
beds.name as bed_name,
beds.consistency as bed_consistency,
rooms.id as room_id,
rooms.name as room_name,
rooms.ward_id as ward_id,
rooms.consistency as room_consistency
FROM patients
JOIN beds ON patients.bed_id = beds.id
JOIN rooms ON beds.room_id = rooms.id
Expand Down
26 changes: 18 additions & 8 deletions services/tasks-svc/repos/bed_repo/bed_repo.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions services/tasks-svc/repos/bed_repo/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions services/tasks-svc/repos/patient_repo/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions services/tasks-svc/repos/room_repo/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions services/tasks-svc/repos/room_repo/room_repo.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions services/tasks-svc/repos/task_repo/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions services/tasks-svc/repos/task_template_repo/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions services/tasks-svc/repos/ward_repo/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion services/tasks-svc/schema.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1957652

Please sign in to comment.