# Inpatient — Bed Board The **Bed Board** is a graphical, map-like view of your hospital. Instead of a table of rooms, it shows a drawing of the site that you can click into — site → building → floor → unit — drilling down through the real layout of your hospital. Beds are colour-coded by their live status (Available, Occupied, Housekeeping, and so on). **Page:** `Inpatient → Room → Bed Board` **XHTML:** `/inward/inward_bed_board.xhtml` **Controller:** `AdmissionController.navigateToBedBoard()` / `BedBoardController` **Privilege:** `InwardRoomRoomOccupency` --- ## How the picture is built The map you see is **assembled at runtime** from small drawings (SVGs) stored on each entity. Every level of the hierarchy — the **Site** (an `Institution`), each **Building / Floor / Unit** (a `Department`), and each **Bed** (a `Room`) — can store **two** drawings: | Field | What it is | When it shows | |-------|------------|---------------| | **Parent View** (`svgParentView`) | The entity's own floor-plan canvas — an *empty map* of just this place (e.g. the outline of the site, or the rectangle of a building). It contains **no** child information. | When you are **looking at** this entity (it fills the page). | | **Child View** (`svgChildView`) | A small shape showing how this entity looks as a tile **inside its parent's** canvas, already positioned in the right place. | When you are looking at the **parent** (it is overlaid on the parent's canvas). | When you open a level, the system draws that entity's **Parent View** as the background and then lays every child's **Child View** on top of it, on the **same coordinate grid**, so together they form one complete picture. Click a child and its **Parent View** becomes the new background, with *its* children filling in — and so on, all the way down to the beds. > **No drawing stored?** The Bed Board still works — it falls back to an automatically generated grid of coloured cards. The SVGs are optional; they just make it look like a real map. ### The golden rule: a shared coordinate grid For the overlay to line up, **every SVG at every level uses the same `viewBox`**. Throughout this guide we use: ``` viewBox="0 0 1000 600" ``` That gives you a drawing area 1000 units wide and 600 units tall. A child's shape is placed using coordinates inside that same 1000×600 grid, so when it is overlaid on the parent it lands exactly where you drew it. --- ## Where the drawings are stored in the database | Hospital level | Entity | Table | Parent View column | Child View column | |----------------|--------|-------|--------------------|-------------------| | Site | `Institution` (type **Site**) | `institution` | `SVGPARENTVIEW` | `SVGCHILDVIEW` | | Building / Floor / Unit | `Department` | `department` | `SVGPARENTVIEW` | `SVGCHILDVIEW` | | Bed | `Room` | `category` *(Room is stored in the `category` table)* | *(not used)* | `SVGCHILDVIEW` | The hierarchy is built from existing relationships: - A **Building** is a `Department` whose **Site** is set and which has **no parent department**. - A **Floor / Unit** is a `Department` whose **parent department** (`superDepartment`) is the level above it. So before you draw anything, make sure your departments are linked: buildings point at the site, floors point at their building, units point at their floor. --- ## A complete worked example Below is a full, copy-paste example that builds this map: ``` Site (oval) ├─ Building One (large, left) │ ├─ Floor One │ │ ├─ ETU │ │ └─ HDU │ └─ Floor Two └─ Building Two (small, right) ``` Replace the IDs and names with your own. Every `` uses `viewBox="0 0 1000 600"`. ### Step 1 — The Site (oval canvas) This is the empty site map — just the outline. Paste it into the site institution's `SVGPARENTVIEW`. ```sql UPDATE institution SET SVGPARENTVIEW = ' My Hospital Site ' WHERE ID = ; ``` ### Step 2 — Buildings (their Child Views sit inside the site oval) Each building stores **two** drawings: - a **Child View** — the rectangle as it appears inside the site oval, and - a **Parent View** — the empty building canvas you'll see after clicking into it. **Building One** — large, on the left: ```sql UPDATE department SET SVGCHILDVIEW = ' Building One ', SVGPARENTVIEW = ' Building One ' WHERE ID = ; ``` **Building Two** — smaller, on the right: ```sql UPDATE department SET SVGCHILDVIEW = ' Building Two ', SVGPARENTVIEW = ' Building Two ' WHERE ID = ; ``` Notice how Building One's rectangle (`x="120"`) sits to the left and is bigger (`width="360"`), while Building Two's (`x="600"`) is to the right and smaller (`width="240"`). Because both use the same 1000×600 grid as the site oval, they land neatly inside it. ### Step 3 — Floors (their Child Views sit inside Building One) **Floor One** — the top half of the building: ```sql UPDATE department SET SVGCHILDVIEW = ' Floor One ', SVGPARENTVIEW = ' Floor One ' WHERE ID = ; ``` **Floor Two** — the bottom half: ```sql UPDATE department SET SVGCHILDVIEW = ' Floor Two ', SVGPARENTVIEW = ' Floor Two ' WHERE ID = ; ``` ### Step 4 — Units (their Child Views sit inside Floor One) **ETU** — left half of the floor: ```sql UPDATE department SET SVGCHILDVIEW = ' ETU ', SVGPARENTVIEW = ' ETU ' WHERE ID = ; ``` **HDU** — right half: ```sql UPDATE department SET SVGCHILDVIEW = ' HDU ', SVGPARENTVIEW = ' HDU ' WHERE ID = ; ``` That's it. Open the Bed Board and you'll see the oval site with the two buildings; click Building One to see its two floors; click Floor One to see ETU and HDU. --- ## Drawing your own shapes You don't need to be a designer. A few `` shapes cover almost everything: **A rectangle** (a building, a room): ```xml ``` - `x` / `y` — the top-left corner, on the 0–1000 (across) / 0–600 (down) grid - `width` / `height` — the size - `rx` — rounded corners (optional) - `fill` — inside colour; `stroke` — border colour; `stroke-width` — border thickness **An oval / circle** (a site, a round ward): ```xml ``` - `cx` / `cy` — the centre point - `rx` / `ry` — half-width and half-height (use the same value for a perfect circle) **A label**: ```xml Building One ``` - `x` / `y` — where the text sits (`text-anchor="middle"` centres it on that point) **Free-form outlines** (an L-shaped ward, an irregular building) use ``: ```xml ``` Each pair is an `x,y` point on the grid; the shape connects them in order. ### Tips for a clean map - **Keep the same `viewBox` everywhere** (`0 0 1000 600`). This is what makes the pieces line up. - In a **Child View**, draw only *this* place's own shape, positioned where it belongs inside the parent. Don't draw the parent or the siblings. - In a **Parent View**, draw only the empty container (the outline and a title). The children are added automatically. - Use distinct `fill` colours per area so the map is easy to read. - You can design visually in any free tool (e.g. a browser-based SVG editor) and paste the resulting `` code into the database column — just set the `viewBox` to `0 0 1000 600` and remove width/height attributes from the root `` tag. --- ## Bed status colours Beds (the leaf level) are coloured by their live status. The legend at the bottom of the Bed Board shows the colour key: | Status | Meaning | |--------|---------| | **Available** (green) | No active patient; the bed is free. | | **Occupied** (red) | A patient is currently admitted to this bed. | | **Housekeeping** (orange) | Being cleaned / turned over. | | **Contaminated** (purple) | Requires deep cleaning / decontamination. | | **Isolated** (yellow) | In use for isolation. | | **Out of Order** (grey) | Not usable (maintenance, etc.). | **Available** and **Occupied** are worked out automatically from whether the bed has an undischarged patient. The other statuses are set explicitly on the room. When a status is set explicitly, it takes priority over the automatic Available/Occupied calculation. --- ## Troubleshooting | Symptom | Likely cause | |---------|--------------| | The Bed Board shows coloured cards instead of a map | No `svgParentView` is stored on the site/department you're viewing. Add one (Step 1). | | A child shape doesn't appear on the parent's map | That child has no `svgChildView`, or it isn't linked to the right parent (`site` for buildings, `superDepartment` for floors/units). | | A child appears in the wrong place or off-canvas | Its `svgChildView` uses coordinates outside `0 0 1000 600`, or a different `viewBox`. Make every SVG use the same `viewBox`. | | Shapes overlap and you can't click the one underneath | Two child shapes are drawn on top of each other. Move them apart on the grid. | | The board opens on the wrong site | The Bed Board opens the first **Site** that has a `svgParentView` stored. Configure the site you want, or clear `svgParentView` on sites you don't. | --- ## Related Articles - [Inpatient — Room Occupancy and Vacancy](Inpatient-Room-Occupancy-and-Vacancy) — the table-based view of the same rooms - [Admin — Room Categories, Rooms, and Room Fees](Admin-Inpatient-Room-Categories-Rooms-Fees) — setting up rooms and beds - [Inpatient — Admit a Patient](Inpatient-Admit-a-Patient) — admitting a patient occupies a bed - [Inpatient — Room Discharge](Inpatient-Room-Discharge) — discharge frees the bed - [Add New Institution](Add-New-Institution) — creating the Site institution