@extends('layouts.app')
@section('title', 'Order Lab — ' . $patient->patient_name)
@section('content')
<section class="content-header"><h1><i class="fas fa-vials"></i> Order Lab Test
    <small>{{ $patient->patient_name }}</small></h1></section>
<section class="content">
    <div class="row"><div class="col-md-8">
        @component('components.widget', ['class' => 'box-primary', 'title' => 'New lab order'])
            <form method="POST" action="{{ route('clinic-lab.order.store', $patient->id) }}">
                @csrf
                @if(request('appointment_id'))
                    <input type="hidden" name="clc_appointment_id" value="{{ (int) request('appointment_id') }}">
                @endif
                <div class="row">
                    <div class="col-md-6"><div class="form-group">
                        <label>Analyzer / device</label>
                        <select name="device_id" class="form-control">
                            <option value="">— Manual / unassigned —</option>
                            @foreach($devices as $d)
                                <option value="{{ $d->id }}">{{ $d->name }} ({{ $d->vendor }})</option>
                            @endforeach
                        </select>
                        <small class="text-muted">Leave blank to record a manual order.</small>
                    </div></div>
                    <div class="col-md-6"><div class="form-group">
                        <label>Sample no.</label>
                        <input type="text" name="sample_no" class="form-control" placeholder="Auto-generated if blank">
                    </div></div>
                </div>
                <div class="form-group">
                    <label>Tests <small class="text-muted">(comma-separated, e.g. CBC, Glucose, Creatinine)</small></label>
                    <textarea name="tests" class="form-control" rows="3" placeholder="CBC, Glucose, Creatinine"></textarea>
                </div>
                <button type="submit" class="btn btn-primary"><i class="fas fa-paper-plane"></i> Create order</button>
                <a href="{{ route('clinic-lab.results', $patient->id) }}" class="btn btn-link">View results</a>
            </form>
        @endcomponent
    </div></div>
</section>
@endsection
