Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/04-api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ and runnable examples are in [examples/](examples/).
| mutation | `amendReport(id: ID!): Report!` | `report:amend` | |
| mutation | `cancelBooking(id: ID!): Booking!` | `booking:cancel` | |
| mutation | `collectSample(id: ID!, barcode: String): Sample!` | `sample:collect` | Marks the sample collected. barcode: the tube's own label, when it is not the generated one (unique in the organisation). |
| mutation | `createBooking(input: CreateBookingInput!): CreateBookingResult!` | `booking:create` | |
| mutation | `createBooking(input: CreateBookingInput!): CreateBookingResult!` | `booking:create`, `invoice:create`, `invoice:discount`, `payment:create` | |
| mutation | `createDoctor(input: DoctorInput!): Doctor!` | `doctor:manage` | |
| mutation | `createReport(bookingId: ID!, testCode: String!, testName: String): Report!` | `report:enter` | |
| mutation | `receiveSample(id: ID!): Sample!` | `sample:receive` | |
Expand All @@ -89,6 +89,7 @@ and runnable examples are in [examples/](examples/).
| mutation | `relabelSample(id: ID!, barcode: String!): Sample!` | `sample:collect` | A new barcode for a sample that the lab has not received yet (BARCODE_TAKEN when another sample has it). |
| mutation | `releaseReport(id: ID!): Report!` | `report:release` | |
| mutation | `saveResults(reportId: ID!, results: [ResultInput!]!): Report!` | `report:enter` | |
| mutation | `updateBooking(id: ID!, input: UpdateBookingInput!): UpdateBookingResult!` | `booking:update`, `invoice:cancel`, `invoice:create`, `accounts:post` | Edits a booking (booking:update): doctor, collection details, notes, tests. Samples follow the tests. Billing follows too: an unpaid invoice is cancelled and issued again (invoice:cancel when tests are removed, invoice:create), a paid one gets a credit note for removed tests (accounts:post) and an invoice for added ones (invoice:create). One transaction, audited as booking.update. |
| mutation | `updateDoctor(id: ID!, input: DoctorPatch!): Doctor!` | `doctor:manage` | |
| mutation | `updatePatient(id: ID!, input: UpdatePatientInput!): Patient!` | `patient:update` | |
| mutation | `verifyReport(id: ID!): Report!` | `report:verify` | |
Expand Down
22 changes: 21 additions & 1 deletion docs/07-domain-flows.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,32 @@ stateDiagram-v2
booked --> cancelled: cancelBooking
sample_collected --> cancelled: cancelBooking
in_process --> cancelled: cancelBooking
note right of cancelled: needs the booking's invoice cancelled first
booked --> booked: updateBooking
sample_collected --> sample_collected: updateBooking
in_process --> in_process: updateBooking
note right of cancelled: needs the booking's invoices cancelled first
```

`createBooking` accepts `tests: [{ testCode }]`; the name, price (paise) and sample type come from the
catalog unless given. One sample (with a barcode) is created per distinct sample type.

**Billing at booking.** With `bill: { payments, billDiscountPaise, applyTaxRules }` the same request issues the
invoice for the booked tests, in one transaction: a bad discount or payment leaves no booking behind. It needs
`invoice:create` (a discount `invoice:discount`, payments `payment:create`).

**Editing a booking** (`updateBooking`, `booking:update`), while it is booked, sample collected or in process:

| Change | What happens |
|---|---|
| Doctor, collection type, time, address, notes | Saved. `null` clears the doctor, time or address. |
| Add tests | New sample types get a new pending tube. |
| Remove tests | Only while the test has no results (its empty report is dropped). A tube not collected yet is dropped when no test needs it. The last test can't be removed: cancel the booking. |
| Tests change on an **unpaid** invoice | The invoice is cancelled and issued again with the booking's tests, keeping line discounts and the bill discount (capped). Needs `invoice:create`, and `invoice:cancel` when tests are removed. |
| A test is removed from a **paid** (or credited) invoice | A credit note for that line (`accounts:post`); `refundablePaise` says what can be refunded with `refundPayment`. |
| Tests are added after payment | A new invoice for the added tests (`invoice:create`). `Booking.invoice` stays the first one; `Booking.invoices` lists them all. |

Everything runs in one transaction and is audited as `booking.update` (what changed).

## Sample

```mermaid
Expand Down
19 changes: 19 additions & 0 deletions docs/examples/lab-day.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ mutation Book($branchId: ID!, $patientId: ID!) {
}
}

# Book and bill in one request: the invoice is issued with the payment taken at the counter.
mutation BookAndBill($branchId: ID!, $patientId: ID!) {
createBooking(input: { branchId: $branchId, patientId: $patientId, tests: [{ testCode: "CBC" }], bill: { payments: [{ amountPaise: 39900, mode: upi }] } }) {
booking { id bookingNo }
invoice { invoiceNo status totalPaise paidPaise }
}
}

# Add a test and remove one without results; samples and the invoice follow.
mutation EditBooking($id: ID!) {
updateBooking(id: $id, input: { addTests: [{ testCode: "TSH" }], removeTestCodes: ["LFT"], collectionType: home }) {
booking { tests { testCode } samples { sampleType status } invoice { invoiceNo totalPaise } invoices { invoiceNo status } }
issuedInvoices { invoiceNo totalPaise }
cancelledInvoices { invoiceNo }
creditNotes { noteNo totalPaise }
refundablePaise
}
}

mutation Collect($sampleId: ID!) {
collectSample(id: $sampleId) { status collectedAt }
}
Expand Down
2 changes: 1 addition & 1 deletion kits.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
{
"name": "client",
"ref": "v1.9.0"
"ref": "v1.10.0"
},
{
"name": "invoice-kit",
Expand Down
Loading
Loading