2人確認CoSignExperimental

Two-person verification (2人確認 / ダブルチェック / co-sign): a second actor enters their id (guarded to differ from the primary), ticks the required attestations, and signs — producing a timestamped signed value the consumer reads to gate an action. For medication double-checks, controlled substances, transfusion, surgical time-outs, and finance maker-checker approvals.

プレビュー

麻薬:モルヒネ 10mg

主担当: 田中(ns-tanaka)

2人確認 要
薬剤名・規格・用量を確認した患者・指示を確認した

ヒント: 確認者IDに「ns-tanaka」を入れると同一人物ガードが働きます。別IDで署名できます。

Props

表は横にスクロールできます
プロパティ初期値説明
primaryIdstring-The primary actor's id — the second signer must differ from this (same-person guard).
attestations{ id: string; label: ReactNode }[]-Attestation checkboxes — all must be ticked before signing.
valueCoSignValue-Controlled signed value (undefined = pending). When set, renders the signed read-only state.
onSign(value: CoSignValue) => void-Fired when the second person signs. CoSignValue = { signerId, reason?, attestedAt, attestations }.
requireReasonboolean-Require a reason before signing. Default false.
minSignerLengthnumber1Minimum signer-id length.
signerLabel / reasonLabel / samePersonErrorReactNode-Field labels and the same-person error message.
CoSignBadge{ value?: CoSignValue }-Companion badge — renders "2人確認 済" (success) when signed, "2人確認 要" (warning) when pending.
classNamestring-Additional CSS class names.

Usage

import { CoSign, CoSignBadge, type CoSignValue } from "@gunjo/ui"

const [value, setValue] = useState<CoSignValue>()

<CoSign
  primaryId="ns-tanaka"                      // the 2nd signer must differ from this
  attestations={[
    { id: "drug", label: "薬剤名・規格・用量を確認した" },
    { id: "patient", label: "患者・指示を確認した" },
  ]}
  value={value}            // set ⇒ signed (read-only); undefined ⇒ pending
  onSign={setValue}        // CoSignValue { signerId, reason?, attestedAt, attestations }
/>

<Button disabled={!value}>麻薬を投与</Button>   // gate the action on the co-sign