Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Query filter problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Query filter problem

    Hi,

    I can't figure out how to know if a person has not had a BM for the past 3 days!! You can image the problems this might cause.

    The code below tells me who has not had a BM (bm=none) on any one day, but I need to know who hasn't had a BM for all three days. Seems I need to use a ".and." in the filter, but that doesn't work, neither does a "between".

    Code:
    inputf = table.open("Vitals",FILE_RO_SHARED)
    query.description = ""
    query.order = "PTEID"
    query.filter = "BM='None'.and.(T_date=date().or.T_date=date()-2.or.T_date=date()-3).and.unique_key_value()"
    query.options = "MU" '"I"
    qry=inputf.query_create()
    Thanks for taking a look,

    ~ Tom

    #2
    Re: Query filter problem

    Quite irregular!


    Maybe

    query.filter = "(BM='None' .and. (T_date=date() .or. T_date=date()-2 .or. T_date=date()-3)) .and.unique_key_value()"

    Added parentheses.
    There can be only one.

    Comment


      #3
      Re: Query filter problem

      Nope - they have to have NOT had a BM for 3 days (72 hours). The ".or." says they could have had a BM on any of the three days. Changing the ".or." to ".and." doesn't work.

      Hhmmmmm... Am I missing something obvious!

      Comment


        #4
        Re: Query filter problem

        Tom,

        I would try ,
        change
        BM = "+quote("none") +" .and.
        between_date(t_date,*lower date=> today-3 day, *higher date => today )
        and without the Unique_key_value

        Comment


          #5
          Re: Query filter problem

          Can you give it to me again in the following format:

          query.filter = "(bm='none').and.between_date(t_date,*lower date=> today-3 day, *higher date => today).and.unique_key_value()"
          It may be correct, but it gives me a filter error and when I convert it to the above format.

          ~ Tom

          Comment


            #6
            Re: Query filter problem

            I tried it without the unique_key_value also.

            query.filter = "(bm='none').and.between_date(t_date,*lower date=> today-3 day, *higher date => today)"
            And it didn't work.

            ~ Tom
            Last edited by Tom Patten; 04-25-2015, 09:38 PM.

            Comment


              #7
              Re: Query filter problem

              Let's try a little more information. What is t_date? What is the record structure?

              And wouldn't it be date(), date()-1, and date()-2?
              There can be only one.

              Comment


                #8
                Re: Query filter problem

                t_date is the date of the last BM note. The note (BM) values are: None / Hard / soft / loose

                Hope is isn't too much information.

                Below is my full script

                dim inputf as p
                dim count as n

                inputf = table.open("Vitals",FILE_RO_SHARED)
                query.description = ""
                query.order = "PTEID"
                'query.filter = "BM='None'.and.T_date>=date()-3.and.unique_key_value()"
                'query.filter = "BM='None'.and.(T_date=date().or.T_date=date()-2.or.T_date=date()-3).and.unique_key_value()"
                'query.filter = "(BM='None'.and.T_date=date()).or.(BM='None'.and.T_date=date()-1)"
                query.filter = "(BM='None' .and. (T_date=date() .or. T_date=date()-1 .or. T_date=date()-2 .or. t_date=Date()-3))" '.and.unique_key_value()"
                'query.filter = "BM='none'.and. between_date(t_date,*lower date>= today-3 day, *higher date >= today)"

                query.options = "I" '"mu"
                qry=inputf.query_create()

                count = inputf.records_get()+1

                dim choices[count] as c

                i = 1
                inputf.fetch_first()
                while .not. inputf.fetch_eof()
                choices[i] = trim(lookupc("F",inputf.pteid,"Fullname","Patients","pteid"))+" - "+dtoc(inputf.t_date)+" - "+inputf.bm 'Trim(inputf.pteid)
                inputf.fetch_next()
                i = i + 1
                end while
                sort_array("choices")
                var->v_Char = ui_get_list_array("NO BM in any of the past 3 Days", 1,"Choices")
                qry.drop()
                inputf.close()
                ~ Tom

                Comment


                  #9
                  Re: Query filter problem

                  I think this works in the context of a report filter. Group report on pteid.

                  Order
                  pteid+invert(cdate(t_date))

                  Filter

                  tablemax("tablename","bm <> 'none' .and. id = "+quote(pteid),"t_date")< date()-2 .and. unique_key_value()

                  Sort of the inverse. Show unique records where bm is not "none" and its t_date is earlier than 2 days ago.
                  There can be only one.

                  Comment


                    #10
                    Re: Query filter problem

                    Stan

                    I need this code to fill the array above so I can show it when a button is pushed.

                    ~ Tom

                    Comment


                      #11
                      Re: Query filter problem

                      Tom, I think you're going to have to build a custom function (or script) and use it instead of a query

                      If the table were sorted by patient id, and then by inverted T_date I can imagine a function that
                      - steps through the table one record at a time
                      - if bm today then skip ahead to next patient
                      - else
                      - skip forward one record
                      - bm? if so, skip to next patient
                      - else
                      - skip forward to next record
                      - bm? if so, skip to next patient
                      - else ' you've found a patient who's gone 3 days, so store the patient id in a list somewhere
                      - then skip to the next patient

                      - display the list when the last patient's records have been processed

                      This approach assumes each patient has a new record for each day, otherwise you must put in some
                      logic to deal with skipped dates.

                      Comment


                        #12
                        Re: Query filter problem

                        Thanks Tom.

                        Since I can query to find who did NOT have a BM in any of the last 3 days

                        Could I not

                        1. Step through the query doing a record count on the original (unqueried) table and if the Count was>2 then
                        2. Capture the pteid into a variable
                        3. show this variable in an array.

                        But I also plan to create a report using Stan's suggestion. This would also let staff see who they need to watch for and even print the list.

                        Another day, another opportunity to keep my brain working.

                        ~Tom

                        Comment


                          #13
                          Re: Query filter problem

                          Tom

                          query.filter = "(bm='none').and.between_date(t_date,*lower date=> today-3 day, *higher date => today)"
                          Sorry, Tom. This code was just for sample with "How or what to do " with code and not active code. You cannot copy and paste into your code. It will not work with it.

                          another idea for checking your filter,
                          vFilter = "your filter code "
                          vReturnList = table.external......("your table","your table fields(one or more","your order field",vFilter) '*see table.external_record.. not full code because not remember.
                          showvar(vReturnList,"shows your filter result ") '*

                          Comment


                            #14
                            Re: Query filter problem

                            I would approach this need by using a summary operation to gather the data into a single record that has the indicators for the last 3 days in one record.

                            Or a crosstab operation to do something similar.

                            Then build the list from the combined table.
                            Al Buchholz
                            Bookwood Systems, LTD
                            Weekly QReportBuilder Webinars Thursday 1 pm CST

                            Occam's Razor - KISS
                            Normalize till it hurts - De-normalize till it works.
                            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                            When we triage a problem it is much easier to read sample systems than to read a mind.
                            "Make it as simple as possible, but not simpler."
                            Albert Einstein

                            http://www.iadn.com/images/media/iadn_member.png

                            Comment


                              #15
                              Re: Query filter problem

                              I think this is a variation of Tom's idea. Creates a variable with patient id and t_date for patients. You should be able to fill the array from the variable.

                              Code:
                              'variable to hold record values of patient ids and last none bm dates
                              lbm_arr_var = ""
                              tbl = table.open("dataf")
                              'query for last not none in descending date order by patient
                              tbl.query_create("T","bm <> 'none'","pteid+invert(cdate(t_date))")
                              tbl.fetch_first()
                              tid = tbl.pteid
                              while .not. tbl.fetch_eof()
                              	'if the date of the last not none record is four days ago 
                              	'write the patient id and the next day's date to the variable 
                              	lbm_arr_var = lbm_arr_var+ crlf()+if(tbl.t_date < date()-3,tbl.pteid + " " + (tbl.t_date+1),"")
                              'skip over the rest of the records for this patient
                              	while tbl.id = tid .and. .not. tbl.fetch_eof()
                              		tbl.fetch_next()
                              	end while
                              	tid = tbl.pteid
                              end while
                              tbl.close()
                              msgbox(lbm_arr_var)
                              You would change to your table name.
                              Last edited by Stan Mathews; 04-26-2015, 01:50 PM.
                              There can be only one.

                              Comment

                              Working...
                              X