has_condition from the answers and creating a MedicalQuestionLog. Served by MedicalController::submit(). Blocked entirely while a non-expired medical log already exists.App\Http\Controllers\Api\V1\Diver\MedicalController::submit()api.v1.diver.medical.submitAuthorization: Bearer {token}POST/api/v1/diver/medicalapplication/json{
"disclaimer_accepted": true,
"answers": { "43": true, "44": false, "45": false },
"group_answers": { "43": { "53": false, "54": false } },
"policies": { "p1": true, "p2": true }
}| Field | Type | Required | Validation | Description |
|---|---|---|---|---|
disclaimer_accepted | boolean | Yes | required|boolean|accepted | Must be true — accepted rejects false |
answers | object | Yes | required|array|min:1 | {questionId: bool}, keyed by GET_questions.md's questions[].id |
answers.* | boolean | Yes | required|boolean | |
group_answers | object | No | nullable|array | {parentQuestionId: {subQuestionId: bool}}. Only consulted when the parent's own answer is true — see Notes |
group_answers.* | object | No | array | |
group_answers.*.* | boolean | No | boolean | |
policies | object | Yes | required|array|min:1 | {"p{policyId}": bool}, keyed by GET_questions.md's policies[].id prefixed with p |
policies.* | boolean | Yes | required|boolean|accepted | Every supplied policy value must itself be true |
App\Http\Requests\Api\V1\Diver\SubmitMedicalRequest, extends ApiFormRequest — full envelope 422.201 Created{
"success": true,
"status": "success",
"message": "Medical form submitted successfully",
"data": {
"has_condition": false,
"expire_date": "2027-09-17"
}
}| Field | Type | Nullable | Notes |
|---|---|---|---|
has_condition | boolean | No | true if any leaf answer (a non-group question answered true, or a sub-question answered true) was positive |
expire_date | string | No | Y-m-d, now()->addMonths($expireMonths), where $expireMonths comes from the diver's distributor settings (medical_expire_months) — not a fixed value across the platform |
true alone does not set has_condition when that parent has_group_questions — only the sub-question answers matter for a grouped question. In the example above, 43 (a grouped question) was answered true but every sub-answer under it was false, and has_condition came back false.401 Unauthorized{
"success": false,
"status": "error",
"message": "Unauthenticated"
}422 Unprocessable Entity — a non-expired medical log already exists{
"success": false,
"status": "error",
"message": "Medical form cannot be submitted until the current one expires"
}422 Unprocessable Entity — validation{
"success": false,
"status": "error",
"message": "Validation failed",
"errors": {
"disclaimer_accepted": ["The disclaimer accepted field is required."],
"answers": ["The answers field is required."],
"policies": ["The policies field is required."]
}
}MedicalQuestionLog row.accept_safe_diving and accept_risks are hardcoded to true on the created log regardless of the actual submitted policies values (both are still required to be individually true by validation, but their specific values are not what gets stored — the stored flags don't distinguish which policy was which). TO VERIFY: intentional simplification vs. an oversight; not resolved by reading the controller alone.answers keys that don't correspond to an active question id are stored as submitted but never evaluated for has_condition (the code looks up $activeQuestions->get((int) $questionId) and only acts when found) — inactive/unknown question ids are silently accepted and recorded without affecting the outcome.group_answers when the corresponding parent question was answered true; a true sub-answer submitted under a parent answered false is ignored entirely, not stored, not evaluated.docs/api/diver/medical/POST_submit.mdcurl --location 'https://test.diveraid.com/api/v1/diver/medical' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"disclaimer_accepted": true,
"answers": {
"property1": true,
"property2": true
},
"group_answers": {
"property1": {
"property1": true,
"property2": true
},
"property2": {
"property1": true,
"property2": true
}
},
"policies": {
"property1": true,
"property2": true
}
}'{
"status": "success",
"message": "string",
"data": {
"has_condition": true,
"expire_date": "2019-08-24"
}
}