Support the ongoing development of Laravel.io →
Database Blade Forms
Last updated 1 year ago.
0

Instead of redirecting to another view, treat those fields like a new record, and submit through a route
to a controller action which saves the entered information. Then retrieve the new info and return View::make(to your view). As far as linked tables, it would be exactly like a blog. A blog record has many comments. You have a blog table and a
comments table linked by blogid (or whatever the id field is named). Go through the eloquent info and look at one to many. A patient has many assessments, thus parent child table.

Last updated 1 year ago.
0

That is a good Idea, i will try.

Thanks.

Last updated 1 year ago.
0

On the way, i found View::composer, so i'm trying to use it to bind the patient to the assessment view.

So, in the PatientController function i have this:

public function viewPatient($code){
		
		// Get the patient
		$patient = Patient::where('document', '=', $code)->first();

		View::composer('assessments.assesment', function($view){
			$view->with('patient', $this->patient);
		});
		
		return View::make('patient.detail', compact('patient'));
	}

So, inside the function i declare the view::composer, then i return the patient detail, but when i try to load the assessment the patient is not passed

[2014-12-04 22:48:28] production.ERROR: exception 'ErrorException' with message 'Undefined variable: patient' in <laravel_path>/app/storage/views/dad925a60f2a5f58d48b0c2294dba5ae:8

the folder structure in the views are:

views/patients ---- detail ---- register ---- list views/assessments -----assessment -----list

Thanks

Last updated 1 year ago.
0

jpilldev said: there is a button to apply the assessment that loads another blade
Do you currently have an assessment table and a patient table? Is the patient id being passed to the form
where you add an assessment. The 2 tables must be linked by patientid. Of coure each assessment will have an
unique id also, but the id of a patient must also be a field in assessments. In your Patient model you need a function
something like:

public function assessments()
    {
        return $this->hasMany(Assessment', 'patientid'); //
    }

and a function to retrieve assessments on a patient:

public function assessments() {
            $assessments = Powner::find(1)->assessments;
           return View::make('yourviewr/viewname')
            
        }

Usually it takes a for inside a foreach to step through the data. Or
Once assessment is added search for all assessments where the patientid is $varpatientid: Display that assessment list, (passing patient info as a header) and have a detail button attached to each record that brings up a
details view.
You must have that parent child table for this to work. You may want to break from this and
find a blog tutorial to go through, its set up basically the same way. I am also uploadin a pic, don't have it ready yet.

Last updated 1 year ago.
0

Above post powner is supposed to read patient.
I guess I can't upload an image, but somethig like this is what you are probably after:

Top table or para or whatever html tag:

patient: joe blow 1234567 plus whatever

under this a table:

1     assessment 1 info  |  bla   |   bla   |  details  
2     assessment 2 info  |  bla   |   bla   |  details  
3     assessment 3 info  |  bla   |   bla   |  details

Where details is a link to open the details view of that assessment only.
A good one to many database management system takes a little while, it's not a 15 minute thing.

Last updated 1 year ago.
0

Hi jimgwhit.

I save the patient id in a variable session, so, when i load the assessment to fill the form, i can use that variable to access the patient through Eloquent and save the assessment related with patient.

So i am looking for a method which i can avoid to make another Query to get the same patient from before.

Thanks.

Last updated 1 year ago.
0

Everyone might do it a little different, but once the assessment is saved you are done, Now to bring up that patient
I'd use 2 queries, one to get the patient information you want displayed at the top of an assessment list. Two the
list of assessments for that patient sorted by date time. Then the doctor or nurse can click one of the assessments to get more detail.
The detail of course being another route, controller method, and another query to show more detail. Sometimes
it takes more than one operation to go through everything.
Maybe a customer - orders is a better example.
Example:

  1. You query for all orders that joe blow made between november 5, 2014 to dec 5, 2014.
  2. You display this in a table in a view. Not all details are there just general date order no...
  3. You wand to see in detail the order he placed on nov 10, 2014, thus the details link.
  4. You query for this record only to display in the details view. This is fairly standard to have edit/details on such records. I.e., modify an assessment where something
    was entered wrong. These things aren't usually done all in a single query.
Last updated 1 year ago.
0

Yeah, that's right,

The patient details view, has a but ton to open the assessment view, so, what i need is carry the patient information when the assessment viewis load.

As i mentioned you, i try saving the id patient and when i open the assessment, from the controller get the patient: Patient::find(id) , i have to make that query again, so, i think View::composer is a good option to pass the patient to the assessment view from the PatientController, but it doesn't working for me (as i place in the code above).

Last updated 1 year ago.
0

Yes and this works too. Mine is a test database where you have owner - pets one to many.
controller:

public function ownerpet() {
            $ownerid = $_GET['ownerid'];
            $data['owners']=Powner::find($ownerid);
            $data['pets'] = DB::table('pets')
                        ->where('ownerid', '=', $ownerid)
                        ->orderBy('petname', 'asc')->get();
            
            return View::make('owner/ownerpet')->with('data',$data['owners'])->with('data2',$data['pets']);
        }

View:

<html>
<head>
</head>
<body>


<?php
echo $data->oname;     ////////////This would be like your patient info
echo "<br>";
echo "======================";
echo "<br>";
foreach ($data2 as $pet){
    echo $pet->petid."   ".$pet->petname."<br>";
    
}    //////////////////////  lower part would assessments  of course a details view could be added.
?>
</body>
</html>

Of course you would use blade. And if for real I'd have a neatly formatted html table.

Last updated 1 year ago.
0

You are probably on the right track with the View::composer technique, sorry I haven't used it. But code wise,
if it doesn't work an extra small query probably won't hurt.

Last updated 1 year ago.
0

Yes, i follow your idea and it works, so, i'm just trying to save one query.

Thanks a lot.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jpilldev jpilldev Joined 28 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.