8 Replies Latest reply on May 7, 2012 11:21 AM by NaturSalus

    Synchronized Portals

    NaturSalus

      Title

      Synchronized Portals

      Post

      Hello,

      I have two synchronized portals that are working fine, although I would like to modify their behavior and I don't know how.

       

      In a layout to Appointment_Detail TO I have the following two synchronized portals:

        • Portal to the "AppointmentDisease" TO (master portal)
        • Portal to the "MedicineDisease" TO

       

      On the portal to the  "AppointmentDisease" TO are listed the diseases that the user has added to the current "Appointment" record.

      On the portal to the "MedicineDisease" TO are listed the medicines that treat the diseases listed and selected on the master portal.

      So if the user selects just the disease diarrhea on the portal to the  "AppointmentDisease" TO, the portal to "MedicineDisease" TO list the medicines that treat that condition.

      For example,

      The disease diarrhea is treated with medicines:

        • medicine 2
        • medicine 3

       

      If the user adds only the disease diarrhea to the portal to the  "AppointmentDisease" TO (master portal), then the portal to "MedicineDisease" TO lists the medicines: medicine 2 and medicine 3.

      So far, no problem.

       

      But what happens if the user adds more that one disease and the diseases share some common medicine? In this case the shared medicine is repeated several times.

      For example,

      The disease flatulence is treated with medicines: medicine 1, medicine 3, and medicine 4.

       

      If the user adds the diseases diarrhea and flatulence to the the portal to the  "AppointmentDisease" TO (master portal), then the portal to "MedicineDisease" TO lists the medicines:

        • medicine 1
        • medicine 2
        • medicine 3
        • medicine 3
        • medicine 4

       

      And what I would line to get is a list of only the different medicines so that no repeating medicine is included. The desired outcome is:

        • medicine 1
        • medicine 2
        • medicine 3
        • medicine 4

       

      My first question is what modificationsdo I need to introduce to the "Disease & Medicine Sync Portals" script so that I don't get repeated values on the the portal to "MedicineDisease" TO list?

       

      RELATIONSHIPS

      Appointment --< AppointmentDisease >--Disease --< MedicineDisease >--Medicine

       

      Appointment::__kp_Appointement = AppointmentDisease::_kf_Appointment

      AppointmentDisease::_kf_Disease = Disease::__kp_Disease

      Disease::__kp_Disease = MedicineDisease::_kf_Disease

      MedicineDisease::_kf_Medicine = Medicine::__kp_Medicine

       

      LAYOUT

      "Appointment_Detail" layout to the “Appointment” TO with two portals:

       
      • Portal to the "AppointmentDisease" TO which is considered the "master" portal and which displays the diseases added by the user to the current Appointment record.
      • Portal to the "MedicineDisease" TO which is considered the "synchronized child" portal which displays only the medicines adequate to treat the Disease selected by the user.

       

      Portal to the "AppointmentDisease" TO

      Portal Fields:
       
          • Disease::dCommonName
          • Disease::BodySystem
          • Disease::BodyOrgan
       
      In the "Appointment_Detail" layout to the Appointment TO, there is the "Add Disease" button that triggers a script by which the user adds the diseases shown in the current appointment record.
      The three portal fields of the "AppointmentDisease" portal trigger the "Disease & Medicine Sync Portals" script and at the same time have a conditional formatting that highlights the selected portal row.

      To highlight the selected portal row of the portal to the "AppointmentDisease" TO. Conditional formatting:
      $$Disease = AppointmentDisease::_kf_Disease
       
      Here I have my second problem: the conditional formatting works only when there is only one value on the Portal to the "AppointmentDisease" TO.
      So, if for example the user have entered: diarrhea and flatulence. The only value selected is "diarrhea".
      My second question is: what modifications do I need to introduced so that the highlight is on the row selected by the user and not on the first portal row?


      "Disease & Medicine Sync Portals" script is as follows:

      Error Handling
      Allow User Abort [Off]
      Set Error Capture [On]
      #
      Go to Object [ObjectName: "aMedicine"]
      Set Variable [$$DiseaseID; Value: AppointmentDisease::_kf_Disease]
      Refresh Window [Flush cached join results]

       

      Portal to the "MedicineDisease" TO

      Portal Fields:
       
          • Medicine::mCommonName
          • Medicine::mScientificName
          • Medicine::Type

      Filter portal records: $$DiseaseID = AppointmentDisease::_kf_Disease

       

      Thanks,

      natursalus

        • 1. Re: Synchronized Portals
          philmodjunk

          First Question:

          Do you just need a list of medicines and do not need to record any patient or disease specific details (Such as a dosage...)?

          If so make your portal a portal to the Medicine table and the duplicates will be omitted.

          Second Question:

          $$Disease = AppointmentDisease::_kf_Disease

          How does the $$Disease variable get updated?

          It would seem that the variable should be updated each time the user clicks a row in the portal--which would require a line in that script to update the variable.

          • 2. Re: Synchronized Portals
            NaturSalus

            Hello Phil,

            Do you just need a list of medicines and do not need to record any patient or disease specific details (Such as a dosage...)?

            Yes I do, and all that data is kept in the Patient and Appointment tables.

            Patient --< PatientAppointment >-- Appointment

             

            If so make your portal a portal to the Medicine table and the duplicates will be omitted.

             

            If I got it right instead of:

             

            • Portal to the "AppointmentDisease" TO which is considered the "master" portal and which displays the diseases added by the user to the current Appointment record.
            • Portal to the "MedicineDisease" TO which is considered the "synchronized child" portal which displays only the medicines adequate to treat the Disease selected by the user.
            I should have instead:
            • Portal to the "AppointmentDisease" TO which is considered the "master" portal and which displays the diseases added by the user to the current Appointment record.
            • Portal to the "Medicine" TO which is considered the "synchronized child" portal which displays only the medicines adequate to treat the Disease selected by the user.

            Okay, I'll try and see what I get.

             

            Thanks

             

            natursalus

            • 3. Re: Synchronized Portals
              NaturSalus

              Hello Phil,

               

              If so make your portal a portal to the Medicine table and the duplicates will be omitted.

              Problem sorted out! 

              Many thanks.

               

              Second Question:

              $$Disease = AppointmentDisease::_kf_Disease

              How does the $$Disease variable get updated?

               

              Hhhmm...

              You are right it is not updated. I checked that with the Script debugger,

               

               

              Thanks,

               

              natursalus


               
              • 4. Re: Synchronized Portals
                NaturSalus

                One final question,

                Is there a way to prevent from showing the last empty portal row?

                Thanks,

                 

                natursalus

                • 5. Re: Synchronized Portals
                  philmodjunk

                  The last empty row is there for you to add data and automatically create a new related record when doing so. If you clear the "Allow creation" option for the portal's table in the relationship on which this portal is based, this blank row will not appear.

                  • 6. Re: Synchronized Portals
                    NaturSalus

                     

                    The last empty row is there for you to add data and automatically create a new related record when doing so. If you clear the "Allow creation" option for the portal's table in the relationship on which this portal is based, this blank row will not appear.

                     

                    Well I don't want to clear the "Allow creation" option for the portal's table in the relationship on which this portal is based, and at the same time I don't like that "weird" empty portal row showing up. So I guess this is a FM feature I have to accept.

                     

                    Thanks,

                    natursalus

                    • 7. Re: Synchronized Portals
                      philmodjunk

                      You have other options.

                      There are ways to eliminate the blank row and still be able to add related records to the portal's table:

                      1) If you need to add new records in this specific portal. Add a button that performs a script to create a new record in the portal's table. You click this button and then the new blank row appears. You can then remove the "allow creation" option for this relationship.

                      2) If you don't need to add new records on this layout, but need to in another portal elsewhere in your database file, you can define two relationships to two different occurrences of the portal's table. Make the relationships identical except for the "allow create" option and now you can control whether or not you get an 'add' row by which occurrence you select in the "show related records from" drop down in portal setup.

                      • 8. Re: Synchronized Portals
                        NaturSalus

                        Phil,

                        Many thanks

                         

                        natursalus