Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 2 months ago by MeteorStargazer867

How can I open a patient note page using the same patient ID?

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

Hi all,

I'm working on a Django project with three concatenated pages, and I'm trying to open a new page to add a patient note using the same patient ID passed through as a URL parameter. The current routes are defined as follows:

PYTHON
path('admin-view-patient', patientView.admin_view_patient_view, name='admin-view-patient'),
PYTHON
path('update-patient/<int:pk>', patientView.update_patient_view, name='update-patient'),
PYTHON
path('add-patient-note/<int:pk>', patientView.add_patient_note_view, name='add-patient-note'),

On the first HTML page, I display patients and have a button to update a patient, like this:

HTML
<div class="container"> <div class="panel panel-primary"> <div class="panel-heading"> <h6 class="panel-title">Patient</h6> </div> <table class="table table-hover" id="dev-table"> <thead> <tr> <th>Name</th> <th>Address</th> <th>Update</th> </tr> </thead> {% for p in patients %} <tr> <td> {{p.get_name}}</td> <td>{{p.address}}</td> <td><a class="btn btn-primary btn-xs" href="{% url 'update-patient' p.id %}"><span class="glyphicon glyphicon-edit"></span></a></td> </tr> {% endfor %} </table> </div> </div>

Clicking on the update button opens the update page (example URL: http://127.0.0.1:8000/update-patient/1) which contains the following form:

HTML
<form method="post" enctype="multipart/form-data"> {% csrf_token %} <div class="container register-form"> <div class="form"> <div class="note"> <p>Update Patient Details</p> </div> <div class="form-content"> <div class="row"> <div class="col-md-6"> <div class="form-group"> {% render_field userForm.first_name class="form-control" placeholder="First Name" %} </div> <div class="form-group"> {% render_field patientForm.address class="form-control" placeholder="Address" %} </div> </div> </div> <button type="submit" class="btnSubmit">Update</button> </div> <a href="{% url 'add-patient-note' p.id %}"> <h6 class="m-b-20">Admit Patient</h6> </a> </div> </div> </form>

When clicking on the "Admit Patient" link, I want to open a page for adding a patient note using the same patient ID so that the foreign key in the note model can be correctly associated with that patient. Below is the model and form code for patient notes:

PYTHON
class PatientsNotes(models.Model): patient = models.ForeignKey(Patient, on_delete=models.CASCADE) title = models.CharField(max_length=20, default=None) body = models.TextField(default=None) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) active = models.BooleanField(default=True) class Meta: ordering = ['created'] indexes = [ models.Index(fields=['created']), ] def __str__(self): return f'Comment by {self.name} on {self.post}'
PYTHON
class PatientNotesForm(forms.ModelForm): class Meta: model = models.PatientsNotes fields = ['title', 'body']

Is it possible to load the add patient note page with the same patient ID? Many thanks in advance.

0

Comments 0

Answers 0

Views 41

0 Answers

Discussion

No comments yet.