edit form

This commit is contained in:
Dr Masroor Ehsan 2025-01-13 19:40:00 +06:00
parent 381f01ff6b
commit 2800786c94
4 changed files with 32 additions and 24 deletions

View File

@ -3,9 +3,10 @@
namespace App\Http\Controllers\Staff; namespace App\Http\Controllers\Staff;
use App\Domain\ACL\Permission; use App\Domain\ACL\Permission;
use App\Domain\Report\ReportStatus;
use App\Http\Controllers\HashidControllerBase; use App\Http\Controllers\HashidControllerBase;
use App\Http\Requests\StudyMetadataUpdateRequest;
use App\Models\Study; use App\Models\Study;
use Illuminate\Http\Request;
class MetadataController extends HashidControllerBase class MetadataController extends HashidControllerBase
{ {
@ -27,16 +28,19 @@ public function edit()
return view('staff.meta.edit', compact('study')); return view('staff.meta.edit', compact('study'));
} }
public function save(Request $request) public function save(StudyMetadataUpdateRequest $request)
{ {
dd($request);
abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403); abort_unless(auth()->user()->may(Permission::StudyMetadataEdit), 403);
$this->decodeKeys(); $this->decodeKeys();
$study = Study::find($this->key); $study = Study::findOrFail($this->key);
$payload = array_trim_strings($request->validated()); $payload = array_trim_strings($request->validated());
if ($request->has('cancel_read')) {
$payload['report_status'] = ReportStatus::Cancelled->value;
unset($payload['cancel_read']);
}
$study->update($payload); $study->update($payload);
// return redirect()->route('staff.history.view', _h($this->key)); // return redirect()->route('staff.history.view', _h($this->key));
return redirect()->route('staff.meta.view', $study->hash); return view('content.pages.close-window');
} }
} }

View File

@ -4,31 +4,30 @@
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
class StudyMetadataUpdateRequest extends FormRequest final class StudyMetadataUpdateRequest extends FormRequest
{ {
public function rules(): array public function rules(): array
{ {
return [ return [
'patient_id' => ['nullable'],
'patient_name' => ['required'], 'patient_name' => ['required'],
'patient_id' => ['nullable'],
'patient_sex' => ['nullable'], 'patient_sex' => ['nullable'],
'patient_birthdate' => ['nullable', 'date'], 'patient_birthdate' => ['nullable', 'date'],
'study_id' => ['nullable'],
'accession_number' => ['nullable'], 'accession_number' => ['nullable'],
'study_description' => ['nullable'],
'body_part_examined' => ['nullable'], //'study_date' => ['required', 'date'],
'station_name' => ['nullable'], 'study_description' => ['required'],
'operators_name' => ['nullable'], 'body_part_examined' => ['required'],
'manufacturer' => ['nullable'],
'manufacturer_model_name' => ['nullable'],
'referring_physician_name' => ['nullable'], 'referring_physician_name' => ['nullable'],
'study_modality' => ['nullable'], 'institution_name' => ['nullable'],
'study_date' => ['required', 'date'], 'priority' => ['required', 'integer'],
'receive_date' => ['required', 'date'], 'cancel_read' => ['nullable', 'boolean'],
'assigned_physician_id' => ['nullable', 'exists:users,id'],
/*
'referring_physician_id' => ['nullable', 'exists:users,id'], 'referring_physician_id' => ['nullable', 'exists:users,id'],
'access_flags' => ['required', 'integer'], 'access_flags' => ['required', 'integer'],
'access_password' => ['nullable'], 'access_password' => ['nullable'],
*/
]; ];
} }

View File

@ -25,10 +25,7 @@
@include('staff.meta.partials._text', ['name' => 'patient_id', 'label' => 'Patient ID', 'value' => $study->patient_id]) @include('staff.meta.partials._text', ['name' => 'patient_id', 'label' => 'Patient ID', 'value' => $study->patient_id])
@include('staff.meta.partials._text', ['name' => 'patient_name', 'label' => 'Patient Name', 'value' => $study->patient_name]) @include('staff.meta.partials._text', ['name' => 'patient_name', 'label' => 'Patient Name', 'value' => $study->patient_name])
@include('staff.meta.partials._text', ['name' => 'patient_sex', 'label' => 'Sex', 'value' => $study->patient_sex]) @include('staff.meta.partials._text', ['name' => 'patient_sex', 'label' => 'Sex', 'value' => $study->patient_sex])
<div class="form-floating form-floating-outline mb-6"> @include('staff.meta.partials._date', ['name' => 'patient_birthdate', 'label' => 'Birth Date', 'value' => $study->patient_birthdate->toDateString()])
<input type="text" name="patient_birthdate" id="patient_birthdate" class="form-control dob-picker" placeholder="YYYY-MM-DD" value="{{ $study->patient_birthdate->toDateString() }}" />
<label for="patient_birthdate">Birth Date</label>
</div>
@include('staff.meta.partials._text', ['name' => 'accession_number', 'label' => 'Accession number', 'value' => $study->accession_number]) @include('staff.meta.partials._text', ['name' => 'accession_number', 'label' => 'Accession number', 'value' => $study->accession_number])
</div> </div>
</div> </div>
@ -63,6 +60,10 @@
</div> </div>
<button type="submit" class="btn btn-primary">Save</button> <button type="submit" class="btn btn-primary me-4">
<i class="fa-regular fa-cloud-arrow-up me-1"></i>
Save</button>
<button type="button" class="btn btn-danger" onclick="window.open('', '_self', ''); window.close();">Cancel
</button>
</form> </form>
@endsection @endsection

View File

@ -0,0 +1,4 @@
<div class="form-floating form-floating-outline mb-6">
<input type="text" name="{{ $name }}" id="{{ $name }}" class="form-control dob-picker" placeholder="YYYY-MM-DD" value="{{ $value }}" />
<label for="{{ $name }}">{{ $label }}</label>
</div>