1

I have three content types: patient, patient medication, and physician.

Using the Node Reference module, patient medication references the patient content type and the physician content type. How can I create a view with a contextual filter that does the following: When I view a physician node, I want to view all patients that the physician has interacted with. Using the two Node Reference fields in the patient medication content type, how can I display a block of unique patients that the physician has prescribed a medication to?

I basically have it set up like a relational table: Patient <-- Patient Medication --> Physician (The arrows represent the node reference)

1

Create a view of content type Physician and set relationship between Patient --- Patient Medication & Patient Medication --- Physician keep both relationship required. Now add all field related with Patient nodes. Here only a block display with patient and Patient Medication.

| improve this answer | |
  • Thanks for the reply, can you clarify what you mean by set a relationship between patient -- Patient Medication & Patient Medication -- Physician? When I try to add a relationship to the view, I can only add one field. – JavaScript_Guru Sep 24 '15 at 17:33
  • You can add multiple relationship ,one-by-one – Aruna Singh Sep 24 '15 at 17:43
1

Let's suppose that that's your Patient Medication structure:

  • Title
  • Patient (field_ref_patient) (node reference to Patient content type)
  • Physician (field_ref_physician) (node reference to Physician content type)

So, let's make a view with these settings:

Fields

  • Patient (field_ref_patient) (Relation: Patient)

Relations

  • Physician (field_ref_physician) (The reverse version)

Contextual Filters

  • Content NID (Default value: Content ID from URL)

This might give you the patients of Patient Medication where Physician is the node that you are viewing

I created an example here: http://dfjfp.ply.st/ (you have 24 hours to check it until it die), go to Structure > Views > Physician and give it a node ID, in my example the ID is 3, that id belongs to the Patient Medication that i created.

| improve this answer | |
  • So? did you tried that idea? – xstean Oct 27 '15 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.