Formula to get last record entered for a specific code in a field

I work at an inpatient facility where our patients experience several movement actions -- transfers from unit to unit, Leaves, return from leaves, and change in commitment status.  We collect all of these actions in one table.  For our census report we use a subreport to show the list of patients who are on leave.  The problem I am having is pulling the most current movement that was a leave if the last movement action code entered was a change in commitment status.  We really should not have put the change in commitment in this table as it is not a movement.  When a change in commitment occurs and the patient is on leave, they drop off my report because the last change was not a leave.  We have to enter the leave again so it is the last record entered to fix. 
The table contains these fields:
Doc_ID
Parent_ID
Folder_ID
Effective Date
From_Unit
To_Unit
Time_of_Change
Leave_status_Code
Move_Action_Code
Commit_Status_Code
The Move_Action_Code field contains these codes:
L = Leave
C = Change in Commitment Status
B = Return From Leave
I = Initial Admission
D = Discharge
R = Recommitment
V = Unit to unit transfer
A patient may have several leaves in the same admission (home visit, then back, etc.).  I need a formula to show only most current leave if they haven't returned from leave and need to totally ignore any change in commitment status.
Thanks in advance to everyone for your help in this forum!

Hi Jerri,
To identify a patient, I assume it would be Folder_ID.  Create a group on this field.  Also create a group on Effective Date. 
Hide the Detail section and the Group Headers for both of these.  You can also hide the Group Footer for Effective Date. 
In the Group Footer for Folder_ID, drop in the Move_Action_Code and any other fields you want. 
When you look at your report, this will show you the last Move_Action_Code for that patient. 
If you can group your data properly, the Group header will always show the first record and the Group Footer will always show the last record. 
Hope this helps,
Brian

Similar Messages

  • Sql query - Selecting last recorded values for each date in specified period

    Hello,
    Can someone please help me with my problem.
    I'm trying to get last recorded balance for each day for specific box (1 or 2) in specified period of days from ms access database using ADOTool.
    I'm trying to get that information with SQL query but so far unsuccessfully...  
    My table looks like this:
    Table name: TestTable
    Date Time Location Box Balance
    20.10.2014. 06:00:00 1 1 345
    20.10.2014. 12:00:00 1 1 7356
    20.10.2014. 18:45:00 1 1 5678
    20.10.2014. 23:54:00 1 1 9845
    20.10.2014. 06:00:02 1 2 35
    20.10.2014. 12:00:04 1 2 756
    20.10.2014. 18:45:06 1 2 578
    20.10.2014. 23:54:10 1 2 845
    21.10.2014. 06:00:00 1 1 34
    21.10.2014. 12:05:03 1 1 5789
    21.10.2014. 15:00:34 1 1 1237
    21.10.2014. 06:00:00 1 2 374
    21.10.2014. 12:05:03 1 2 54789
    21.10.2014. 15:00:34 1 2 13237
    22.10.2014. 06:00:00 1 1 8562
    22.10.2014. 10:00:00 1 1 1234
    22.10.2014. 17:03:45 1 1 3415
    22.10.2014. 22:00:00 1 1 6742
    22.10.2014. 06:00:05 1 2 562
    22.10.2014. 10:00:16 1 2 123
    22.10.2014. 17:03:50 1 2 415
    22.10.2014. 22:00:10 1 2 642
    23.10.2014. 06:00:00 1 1 9876
    23.10.2014. 09:13:00 1 1 223
    23.10.2014. 13:50:17 1 1 7768
    23.10.2014. 19:47:40 1 1 3456
    23.10.2014. 21:30:00 1 1 789
    23.10.2014. 23:57:12 1 1 25
    23.10.2014. 06:00:07 1 2 976
    23.10.2014. 09:13:45 1 2 223
    23.10.2014. 13:50:40 1 2 78
    23.10.2014. 19:47:55 1 2 346
    23.10.2014. 21:30:03 1 2 89
    23.10.2014. 23:57:18 1 2 25
    24.10.2014. 06:00:55 1 1 346
    24.10.2014. 12:30:22 1 1 8329
    24.10.2014. 23:50:19 1 1 2225
    24.10.2014. 06:01:00 1 2 3546
    24.10.2014. 12:30:26 1 2 89
    24.10.2014. 23:51:10 1 2 25
    Let's say the period is 21.10.2014. - 23.10.2014. and I want to get last recorded balance for box 1. for each day. The result should look like this:
    Date Time Location Box Balance
    21.10.2014. 15:00:34 1 1 1237
    22.10.2014. 22:00:00 1 1 6742
    23.10.2014. 23:57:12 1 1 25
    So far I've managed to write a query that gives me balance for ONLY ONE date (date with highest time in whole table), but I need balance for EVERY date in specific period.
    My incorrect code (didn't manage to implement "BETWEEN" for dates...):
    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    Tnx!
    Solved!
    Go to Solution.

    For loop
    following query keep day (here 24 in below query) Variable from ( 1 to 28-29/30/31 as per month)
    SELECT TOP 1 TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM Test Table.
    WHERE  Time=(SELECT MAX(Time) FROM TestTable WHERE Location=1 AND Box=1 )
    AND DATE = "2014-10-24";
    PBP (CLAD)
    Labview 6.1 - 2014
    KUDOS ARE WELCOMED.
    If your problem get solved then mark as solution.

  • How to get last Record ior Total rows in For Loop Cursor ?

    Hi Friends
    I would like to know , the last record in for loop cursor, i have the code in following format
    cursor c1 is
    select * from emp;
    begin
    for r1 in c1 loop
    v_total_rec := ? ( i would like to know total rows in the cursor , say for example if cursor has 10 rows, i want10 into this variable )
    v_count := v_count +1;
    dbms_output.put_line(r1.emp_name);
    end loop;
    end;
    Hope i am clear
    Any suggestions?
    Thanks
    Ravi

    Even though cursor loops are generally a Bad Idea ^tm^ as Dan says, here's an example of how you can get the information you wanted within the query itself...
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    cursor c1 is
      3      select emp.*
      4            ,count(*) over (order by empno) as cnt
      5            ,count(*) over () as total_cnt
      6      from emp
      7      order by empno;
      8  begin
      9    for r1 in c1 loop
    10      dbms_output.put_line(r1.ename||' - row: '||r1.cnt||' of '||r1.total_cnt);
    11    end loop;
    12* end;
    SQL> /
    SMITH - row: 1 of 14
    ALLEN - row: 2 of 14
    WARD - row: 3 of 14
    JONES - row: 4 of 14
    MARTIN - row: 5 of 14
    BLAKE - row: 6 of 14
    CLARK - row: 7 of 14
    SCOTT - row: 8 of 14
    KING - row: 9 of 14
    TURNER - row: 10 of 14
    ADAMS - row: 11 of 14
    JAMES - row: 12 of 14
    FORD - row: 13 of 14
    MILLER - row: 14 of 14
    PL/SQL procedure successfully completed.
    SQL>

  • Getting last record from mseg

    Hi,
    Can any one tell me how to get last record from any db(MSEG) table?
    reward guaranteed
    kaki

    Hello,
    Entries have no "natural order" within a database, apart from the primary key. If you need the "last entry" then you need to know what defines the last entry. If the last entry is the one with the highest year (MJAHR) the you could select it like this:
    data: ls_mseg type mseg.
    select * from mseg into ls_mseg.
        where bwart = 321
          and ebeln = 400000005
          and mjahr = ( select max( mjahr ) from mseg
                          where bwart = 321
                            and ebeln = 400000005 ).
    "process result in ls_mseg
    endselect.
    Note: This is a loop because there might be more than one matching entry.
    best regards
    Roland

  • While doing MIRO i am getting an error: Enter a tax jurisdiction code

    Hi,
    While doing a MIRO, i am getting an error :
    Enter a tax jurisdiction code
    Message no. M8757
    How to Resolve
    Pratik

    Hi
    Try this
    1.To enter the tax amounts of the G/L account items, choose Extras ® Tax amounts. The Tax Amounts screen appears.
    You can branch to this screen at any point during document entry.
    The Tax Amounts screen shows the tax amount, tax code, posting key, tax base amount, and jurisdiction code for all the items already entered. When you call up this screen after entering the G/L account items, it displays the amounts that have already been entered.
    2.You can now choose how you want to enter the taxes.
    The tax jurisdiction codes represent the different taxing authorities to which you submit payment for taxes EG: the state, county, city etc. 
    In SAP you can have as many as 4 levels. Configuration is done in 2 steps :
    First step :
    The tax jurisdiction structure (structure of the tax code) is set up with following menu path : 
    IMG >Financial accounting> Fi Accounting basic settings> tax on sales/purchases > basic settings > specify structure for tax jurisdiction code.
    Alternatively you can use t-code OBCO
    This step allows you the enter the character length of your various level of hierarchy within your tax jurisdiction code structure (State 2 char, county 3, city 4, etc...).
    Second step:
    You configure the tax jurisdiction code using the structure defined earlier, menu path :
    IMG >Financial accounting> Fi Accounting basic settings> tax on sales/purchases > basic settings > define tax jurisdiction codes.
    Alternatively t-code  OBCP
    Define your tax jurisdiction codes, EG GA0000000 for Georgia, GA001000 for Georgia, douglas county, GA001001 for georgia, douglas county, city of lithia springs.

  • Which table stores VAT number entered for a company code using T Code oby6?

    Hi
    Which table stores VAT number entered for a company code using T Code oby6?
    please advice.
    Thanks,
    Vaishnavi

    T001

  • How to Incorporate formula in QE51 (result recording screen for insp char)?

    Hi,
        Kindly help me in incorporating a formula field in QE51 screen where we record results for inspection characteristics. I need to add a formula in a field which should be a qualitative characteristics which should make calculations of few quantitative fields
    EX:
    Field 1 = xxx
    Field 2 = yyy
    Field 3 = zzz
    Field 4 = Field 1 - field 2 - field 3
    If the Field 4 has someother value other than zero upon saving the result it should throw some error.
    How can i add this formula in the system.. can anyone help me?
    Thanks in Advance
    Best Regards
    P.K.Senthil Kumar
    Edited by: senthil kumar on Apr 5, 2008 10:55 AM

    See the std sap help, then if you have any aboubt come back
    Formula Evaluation 
    Use
    You can have the measured values of a characteristic (calculated characteristic) automatically calculated from the input and results of other characteristics (calculation input characteristics). The formula is automatically evaluated when the characteristic is valuated. You can trigger the formula evaluation before the characteristic valuation.
    You can determine the weight of a glass bottle, by determining the weight of the empty bottle and the volume of water needed to fill it. Both these measurements are represented as calculation input characteristics; the total weight is then the calculated characteristic.
    Prerequisites
    For formula calculation, the following prerequisites must be fulfilled:
    •     You have defined the formula that is used in the inspection characteristic for the task list.
    You can use standard mathematical functions in this formula, as well as the following operands:
    o     Numerical constants
    o     The specifications and results of other characteristics in the same operation
    o     External function modules
    •     For inspection lots with an assigned serial number profile or units to be inspected with external numbering, the following applies:
    To evaluate the formula for original values, you must ensure that a reference is made to the same serial number for the calculation input characteristics. The "Serial number - original value" assignment is the decisive factor for the first (leading) calculation input characteristic. If a serial number is not available for the first calculation input characteristic in another calculation input characteristic, you cannot evaluate the formula.
    Activities
    To calculate the formula from the valuation, choose:
    •     Evaluate formula on the characteristic overview screen
    •     Extras  Formula  Evaluate formula on the characteristic single screen
    If values from other characteristics are used in the formula, these calculation input characteristics must have already been valuated before the formula can be calculated.
    To display the formula, choose Extras  Formula  Display formula on the characteristic overview screen or the characteristic single screen.
    The formula printout is then displayed in a window.

  • Last Record Values for a given Date Range

    Hi, I have a unique requirement to process/report only the values of the last record found in a date range for a given set of characteristics.  The order would be by FISCPER.
    For example:  I have some data with 3 characteristics.
    STORE001 MATN001 2004001 100 PCS
    STORE001 MATN001 2004005 75  PCS
    STORE001 MATN001 2004006 80  PCS
    STORE002 MATN002 2003008 10  PCS
    STORE002 MATN002 2004001 15  PCS
    STORE002 MATN002 2004004 40  PCS
    A selected date range of 2003008 to 2004001 would result in the following records being processed.
    STORE001 MATN001 2004001 100  PCS
    STORE002 MATN002 2004001 15   PCS
    A selected date range of 2004002 to 2004006 would result in the following records being processed.
    STORE001 MATN001 2004006 80  PCS
    STORE002 MATN002 2004004 40  PCS
    How can I accomplish this at runtime?  Any ideas?

    Nope, it's not an inventory scenario.  It could be say the last status of a gas meter within a selected date range. 
    Any other ideas? 
    I've considered using VKF, but haven't figured out how this would work yet.  If I could modify the selected query data prior to query processing I might be able to number the records and then filter on that.....  Anyway I'm open to any suggestions or leads!
    I won't forget the points for anyone with a solution!
    Thanks!

  • How to retrieve last record entered into database

    Hi all,
    I want to retrieve the last resord entered into a database table.
    I have a MS Access database.
    This code does not return the last record but its my nearest attempt to.
    Can anyone suggest the correct SQL or Solution.
    Help is greatly appriciated.
    Thanks.
    String str = "SELECT * FROM Missions WHERE Mission = (SELECT MAX(Mission) FROM MISSIONS)";
            ResultSet rs = null;
                String f1 = null, f2 = null, f3 = null, f4 = null;
                try{   
                    rs = statement.executeQuery(str);
                    txtMissionInformation.setText("");
                    int row = 0;
                    while(rs.next()){
                        f1 = rs.getString(1);
                        f2 = rs.getString(2);
                        f3 = rs.getString(3);
                        f4 = rs.getString(4);
                        System.out.println(f1 + " " + f2 + " "+f3+" "+f4);
                        txtMissionInformation.append(f1 + ", "+ f2 + ""+","+f3+","+f4);
                    System.out.println("Query Complete !");
                } catch(Exception e){
                    e.printStackTrace();
                }

    I fixed my problem, i aded an autonumber field to my database set it as primary key and called it ID. i then used the syntax from before and it worked.

  • How to get all oneorder header_guids for a specific reference PRODUCT_ID?

    Hi,
    in servicerequest we add iobjects as reference objects.
    The iobject represents the machine a customer has an issue with.
    Within the iobject master we have a PRODUCT_ID. The product_ID represents the machine type.
    So:
    1 product_id could have 1:n iobjects (machines)
    1 servicerequest has 1:1 iobject.
    The requirement is to select all oneorder documents with a specific product_id within the assigned iobject.
    I do not realy know which database tables i have to join?
    Or is there already a function module in standard which can be used?
    Thank you
    Kind regards
    Manfred

    Hi,
    OBJECT_ID can´t be the import parameter for IOBJECTs because it is from type CRMT_OBJECT_ID - which is the ID of transactions and not IOBJECTs.
    I have played arround with this function module CRM_SERVICE_PORTAL_SEARCH but haven´t found an option to get all servicerequests (one order documents) for a specific reference object or a list of reference objects.
    Are there other ideas how to use this or another function module for my requirement.
    Thanks a lot.
    Kind regards
    Manfred

  • How do I record sports for one specific team for the channels I subscribe?

    For example, I want to record all the Golden State Warriors games that occur on HDTV or if not available on HDTV then record them on normal TV, without recording blank channels that I are not on my subscription or a lot of superfluous programs that use some of the key words but aren't the game itself. If I record a series for the key word search "Golden State Warriors" or "Golden State" or "Golden State NBA" I miss games, record some non-game programs, or record channels that are blacked out to me.  I could do more selective searches with TiVo so that I just got the games I wanted, but I can't find enough granularity in the Comcast DVR system to record Warriors, Giants, or 49ers games.  The closest I can come is to save these searches, and every few days sit down and manually scan through all the items the return and select the right ones!  Even dong that, none of the searches turned up yesterday's Warriors game on 720 at &;30pm.  So I assumed it wasn't televised.  But I happened to look at channel 720 that evening - and the game was there!  What's going on? The Comcast system seems to work fine for the simple task of recording a TV sitcom series such as Chuck or The Mentalist.  But to record the games of my favorite sports teams requires a DVR system that can find the games on whatever channel they are on, and only record those channels which I subscribe to. Any suggestions on how best to record my favorite teams using the Comcast DVR?

    So I was able to find my teams and set them up as favorites... but the recording options are very limited. For example I can only record all shows that this team is listed, once per day, or once per week. The problem with the once per day option is that it records the very first time the team shows up in a show title. So for example it records the pre-game show and not the game (this would be a baseball team). And the problem with once per week is the same thing. If there is a program that has a football team listed before Sunday arrives then it records that show and not the game! All I want to do is record all the games the first time they air! Is that so hard? Also, for some reason it won't let me set up a series recording for my teams nightly replay on COMCAST SPORTS NET! For crying out loud your sports channel does a nightly replay of my baseball team and it won't let me record it as a series. I even tried setting up a manual recording sessions but guess what... It does not have the option to do it every night. So I can only manually record one day then I have to set up another one each night. Which ends up being the same as not being able to record the series. Basically Comcast has not figured out a way for sports fans to record their favorite teams as a series. Instead you either record EVERY show that has that team in the title (which includes things like celebrity golf shootouts, pre-game shows, replays, discussions shows, etc...) or you have to hit the record button for every game (and for baseball that means doing it almost every day). So, is there some solution I am missing? 

  • JAAS - How to set up permissions for a specific code?

    I would like to set up permissions for specific code in JAAS policy files.
    In other words, let's say I have the followiong entry:
    permission java.util.PropertyPermission "java.home", "read";
    Then, when I do Subject.doAsPrivileged(..., MyAction), if this permission is absent, I will not be able to access the "java.home" property in my MyAction.
    If I, let's say, set up a file permission, I will not be able to read certain files if the permission is absent.
    I want something simpler. I want to be able to specify that the whole class MyAction cannot be executed if the permission is absent - I do not want the code to even go there. Basically, if the necessary entry in the Policy file is not present, I do not want the calling code to have access to class com.mypackage.MyAction.
    This must be really straight-forward, what am I missing?

    Thank you for your input.
    My case is a little bit more complex.
    There is a request and approval process attached to the provision to this target system.
    The approval process has a first level of approval (including 1 to many approval steps) and the user gets the basic access to this target system. The user can then access the target system but is limited to what he/she can do.
    Then the approval goes to a second level of approval (including many approval steps) and if approved the user gets the elevated access to this target system.
    To accomplish this, the previous implementer created 2 resources for the same target. After the first level of approval, he provisioned resource A to the user. After the second level of approval, he provisioned resource B to the user, revoked resource B, and updated resource A.
    This is very confusing because we are dealing with 2 resources for the same target.
    I am looking for way to take advantage of the GTC to provision and reconcile with a system that takes a flat file and can write a flat file. But I also need to make it work with this approval nightmare.
    Do you have any ideas on how to make this better and simpler?
    Thanks
    Khanh

  • Last record entered

    hi all,
    In the detail block i have 5 records to be entered.Now i want retieve the last recordentered wherever primary key in the detail is
    codes only,(i mean no serial).
    Best Regards,
    Hany

    Hi Hany,
    Well i am not sure abt this but plz try if it works out your problem.
    select PK_col from Detail
    where rowid=(select max(a.rowid)from Detail a,
    (select translate(PK_col,'1234567890',' ') ID from Detail
    where PK_col is not null) b
    where a.PK_col=b.PK_col)
    Well plz if it works out or u modify it and get the results right
    do mail me the query at [email protected]
    Navneet Jain

  • Get last record inserted

    Hi i am inserting into 2 tables. I am first inserting into
    client id. I then want to get that client id and insert it into the
    sale table.
    What is the easist way to get this.

    You have a couple options depending on your database.
    1. The best, in my opinion, is to wrap this functionality
    into a stored procedure that will handle the multiple inserts, then
    run that stored procedure inside a transaction (or include the
    transaction inside the stored procedure).
    2. Use the result object returned by cfquery on the first
    insert to get the ID of the new record from result_name.IDENTITYCOL
    (or whatever property is set for your database). Then use the ID
    value in a second cfquery for the sales table.
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_17.html#1102316
    What is your database product and version?

  • Cannot get a recording signal for acoustic guitar thru Mbox 2. All cords, batteries, etc are checked and good.

    Done this a million times. Today it decides to ignore the input. Done all the usual checks in system preferences, batteries, cords, rebooted, etc.

    Thanks for the help mate, just gave the speed tester another bash and managed to get something back.....As predicted, results werent exactly brilliant....
    FAQ
    Test1 comprises of two tests
    1. Best Effort Test: -provides background information.
    Download Speed
    55 Kbps
    0 Kbps
    250 Kbps
    Max Achievable Speed
     Download speedachieved during the test was - 55 Kbps
     For your connection, the acceptable range of speedsis 100-250 Kbps.
     Additional Information:
     Your DSL Connection Rate :287 Kbps(DOWN-STREAM), 440 Kbps(UP-STREAM)
     IP Profile for your line is - 135 Kbps
    The throughput of Best Efforts (BE) classes achieved during the test is - 2.17:4.67:93.87 (SBE:NBEBE)
    These figures represent the ratio while sententiously passing Sub BE, Normal BE and Priority BE marked traffic.
    The results of this test will vary depending on the way your ISP has decided to use these traffic classes.
    2. Upstream Test: -provides background information.
    Upload Speed
    259 Kbps
    0 Kbps
    440 Kbps
    Max Achievable Speed
    >Upload speed achieved during the test was - 259 Kbps
     Additional Information:
     Upstream Rate IP profile on your line is - 440 Kbps
    This test was not conclusive and further testing is required.This might be useful for your ISP to investigate the fault.

Maybe you are looking for

  • Java call to a VB COM code

    Hello, I have a standalone java application making call to a 3rd party VBCOM code. Im using EZCOM bridge. I get the following exception when i try to make a call. can anyone help me as to why this comes. Exception in thread "main" java.lang.Unsatisfi

  • JRockit SDK 1.4.2_03 does not install at all on Win2k SP4

    Trying to install the JRockit SDK under Windows 2000 SP4, it successfully unpacks the archive and then dies with a pop-up box titled "javaw.exe - application error" and the error is: The instruction at "0x7c34feb4" referenced memory at "0x00000001".

  • Sale invoice problem :

    Dear All, Please help me in this i am getting when i am trying to post the Sales invoice after doing Post Good issue. Request all experts to help me in this. waiting for reply in anticipation. Details of Error given below Delivered/invoiced quantitie

  • RAD 7.0

    Hi, I have a questions that maybe some one on this forum can aswer or point me to the correct place to look for an answer. I just finish installing RAD 7.0 but when I try to create a project I don't see the option to create a Portle projectI can see

  • 7610 says 'contact retail service' when switched o...

    nokia 7610 fell in water. and now when switched on it says contact retail service. please help.