Forum Discussion

bdeleur's avatar
bdeleur
Icon for Helper III rankHelper III
3 years ago
Solved

Discharge department

Hi,

 

I want to make a report witch contains the following information.

Out of a big data file I want to extract the follow up department.

So I have department A and how many have a transfer (discharge) to deparment B & C etc.

 

ReferenceStart dateEnd dateDischarge (out of hospital)Department
11-11-2022 16:0010-11-2022 10:11 A
110-11-2022 10:11  B
22-11-2022 15:353-11-2022 13:343-11-2022 13:34A
31-11-2022 09:152-11-2022 10:24 A
32-11-2022 10:243-11-2022 18:123-11-2022 18:12C

 

So you can see that reference 1 transfer from department A to B at 10-11-2022 10:11. 

Reference 2 is discharged out of the hospital direct from department A.

Reference 3 transfers to department C and gets discharged out of that department (I don't want to know that discharge, only the report of department A to witch department the patient is transferd or discharged).

 

The file contains every department in the hospital.

 

Hope some can make the measure because with my knowledge... 🙂

  • bdeleur 
    For now this is what I can provide you. The difference between Count 2 and Count 3 is that count 3 shall not count discharged from same department unless there is a discharge date. The difference shall not be noticed using the sample data as there are no blanks in the end date.

24 Replies

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi bdeleur 
    Please refer to attached sample file with the proposed solution

    Count = 
    SUMX ( 
        VALUES ( 'Table'[Reference] ),
        VAR CurrentTable = CALCULATETABLE ( 'Table' ) 
        VAR FirstRecord = TOPN ( 1, CurrentTable, 'Table'[Start date], ASC )
        VAR LastRecord = TOPN ( 1, CurrentTable, 'Table'[Start date] )
        VAR FirstDepartment = MAXX ( FirstRecord, 'Table'[Department] )
        VAR LastDepartment = MAXX ( LastRecord, 'Table'[Department] )
        RETURN
            IF ( 
                FirstDepartment <> LastDepartment
                    && MAX ( 'To'[Department] ) = LastDepartment
                    && MAX ( 'FROM'[Department] ) = FirstDepartment,
                1
            )
    
    • bdeleur's avatar
      bdeleur
      Icon for Helper III rankHelper III

      Hi tamerj1 ,

       

      Tnx. I will aply it to my data and see what the code makes of it. I will come back with the result.

    • bdeleur's avatar
      bdeleur
      Icon for Helper III rankHelper III

      Hi,

       

      I applied the code and it seems to work fine. I have to do and check to the outcome to be sure. Just 1 thing is missing: the code doesn't count the patients who have a discharge out of hospital.

      How can we do that?

      • tamerj1's avatar
        tamerj1
        Icon for Community Champion rankCommunity Champion

        bdeleur 
        Please try

        Count =
        SUMX (
            VALUES ( 'Table'[Reference] ),
            VAR CurrentTable =
                CALCULATETABLE ( 'Table' )
            VAR FirstRecord =
                TOPN ( 1, CurrentTable, 'Table'[Start date], ASC )
            VAR LastRecord =
                TOPN ( 1, CurrentTable, 'Table'[Start date] )
            VAR FirstDepartment =
                MAXX ( FirstRecord, 'Table'[Department] )
            VAR LastDepartment =
                MAXX ( LastRecord, 'Table'[Department] )
            VAR DischargeDate =
                MAXX ( LastRecord, 'Table'[End Date] )
            RETURN
                IF (
                    AND ( FirstDepartment = LastDepartment, DischargeDate <> BLANK () )
                        && MAX ( 'To'[Department] ) = LastDepartment
                        && MAX ( 'FROM'[Department] ) = FirstDepartment,
                    1
                )
        )
  • Hi, 
    can you please give more information what the measure should count exactly:
    Tranfer of patient from A,B,C, to A,B,C? Like a matrix? 

    From / to ABC
    A14 
    B2.... 
    C3.... 
    • bdeleur's avatar
      bdeleur
      Icon for Helper III rankHelper III

      Hi,

       

      I really like the idea of the matrix. Didn't think about that. So I would like tot see that.

      From there I think it is easy to filter for every department.

      Is that possible?

  • Yes, you can have one filter for the starting and one filter for the ending department. 

    But i need more example data to create the measure and you have to make more clear how you handle or want to see the discharge out of the hospital. Also what is with cases like A -> B -> A -> out of the hospital how you count it? without the station between start and end? 

    • bdeleur's avatar
      bdeleur
      Icon for Helper III rankHelper III

      Hi, andhiii079845 

       

      A movement between departments uses the start and end date. When the end date and dismissal date are the same then the patient is discharged form that department.

       

      patient 1 only had a transfer a to B, no discharge out of hospital

      patient 2 didn't moved to another department and gets discharged out of hospital

      patient 3 moved from department  A to B and gets discharged out of B

       

      Is that what you need?

      • andhiii079845's avatar
        andhiii079845
        Icon for Solution Sage rankSolution Sage

        Thank you for the explanation. So the discharge out of the hospital is not relevant, right? How you want to handle the case if a person go from A to B to C or A to B to A. ? Should every transfer should be count ?