[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1949: Added Service to get ProgramInstances by Orgunit; Changed accordingly in MultiDataEntry&SummaryRe...

revision-diff.txt (9.76 KB)

Just a question Bahrath,

Once you have a program can’t you use Collection getProgramInstances( Program program, boolean completed );

Do you want to display status of programs per orgunit?

If so I think you can still use the existing API and do some sort of mapping. Because I see you kind of hardcoding a bit … “get programInstances whose endData is null” - I think you can play around with the completed attribute of programInstance.

Abyot.

···

On Mon, Oct 25, 2010 at 1:13 PM, noreply@launchpad.net wrote:


revno: 1949

committer: Bharath chbharathk@gmail.com

branch nick: trunk

timestamp: Mon 2010-10-25 16:42:04 +0530

message:

Added Service to get ProgramInstances by Orgunit; Changed accordingly in MultiDataEntry&SummaryReport

modified:

dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java

dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java

dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java

dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java

dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java

dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java

lp:dhis2

https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.

To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription

=== modified file ‘dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java’

— dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2009-11-13 15:59:13 +0000

+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2010-10-25 11:12:04 +0000

@@ -28,6 +28,7 @@

import java.util.Collection;

+import org.hisp.dhis.organisationunit.OrganisationUnit;

import org.hisp.dhis.patient.Patient;

/**

@@ -66,4 +67,5 @@

 Collection<ProgramInstance> getProgramInstances( Patient patient, Program program, boolean completed );
  • Collection getProgramInstances( Program program, OrganisationUnit organisationUnit );

}

=== modified file ‘dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java’

— dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2009-10-29 16:22:42 +0000

+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2010-10-25 11:12:04 +0000

@@ -29,6 +29,7 @@

import java.util.Collection;

import org.hisp.dhis.common.GenericStore;

+import org.hisp.dhis.organisationunit.OrganisationUnit;

import org.hisp.dhis.patient.Patient;

/**

@@ -57,4 +58,6 @@

 Collection<ProgramInstance> get( Patient patient, Program program );



 Collection<ProgramInstance> get( Patient patient, Program program, boolean completed );
  • Collection get( Program program, OrganisationUnit organisationUnit );

}

=== modified file ‘dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java’

— dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2009-11-19 18:43:20 +0000

+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2010-10-25 11:12:04 +0000

@@ -28,6 +28,7 @@

import java.util.Collection;

+import org.hisp.dhis.organisationunit.OrganisationUnit;

import org.hisp.dhis.patient.Patient;

import org.springframework.transaction.annotation.Transactional;

@@ -123,4 +124,10 @@

 {

     return programInstanceStore.get( patient, program, completed );

 }
  • public Collection getProgramInstances( Program program, OrganisationUnit organisationUnit )

  • {

  •    return programInstanceStore.get( program, organisationUnit );
    
  • }

}

=== modified file ‘dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java’

— dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2009-10-29 16:22:42 +0000

+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2010-10-25 11:12:04 +0000

@@ -31,6 +31,7 @@

import org.hibernate.criterion.Restrictions;

import org.hisp.dhis.hibernate.HibernateGenericStore;

+import org.hisp.dhis.organisationunit.OrganisationUnit;

import org.hisp.dhis.patient.Patient;

import org.hisp.dhis.program.Program;

import org.hisp.dhis.program.ProgramInstance;

@@ -98,4 +99,12 @@

     return getCriteria( Restrictions.eq( "patient", patient ), Restrictions.eq( "program", program ),

         Restrictions.eq( "completed", completed ) ).list();

 }
  • @SuppressWarnings( “unchecked” )

  • public Collection get( Program program, OrganisationUnit organisationUnit )

  • {

  •    return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) ).createAlias( "patient", "patient" )
    
  •    .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ).list();
    
  • }

}

=== modified file ‘dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java’

— dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2010-10-20 13:34:22 +0000

+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java 2010-10-25 11:12:04 +0000

@@ -204,23 +204,10 @@

     selectedStateManager.setSelectedProgram( program );



     // ---------------------------------------------------------------------
  •    // Getting the list of Patients that are related to selected OrganisationUnit
    
  •    // ---------------------------------------------------------------------
    
  •    patientListByOrgUnit = new ArrayList<Patient>();
    
  •    patientListByOrgUnit.addAll( patientService.getPatients( organisationUnit ) );
    
  •    if( sortPatientAttributeId != null )
    
  •    {
    
  •        sortingAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId );
    
  •    }
    
  •    // ---------------------------------------------------------------------
    
       // Program instances for the selected program
    
       // ---------------------------------------------------------------------
    
  •    Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program );
    
  •    Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program, organisationUnit );
    
    
    
       Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
    

@@ -228,13 +215,6 @@

     {

         Patient patient = programInstance.getPatient();
  •        //taking patient present in selected orgunit
    
  •        if ( !patientListByOrgUnit.contains( patient ) || programInstance.getEndDate() != null )
    
  •        {
    
  •            patientListByOrgUnit.remove( patient );
    
  •            continue;
    
  •        }
    
         if ( !programInstance.isCompleted() )

         {

             programInstanceMap.put( patient, programInstance );

@@ -244,21 +224,21 @@

             PatientAttributeValue patientAttributeValue = patientAttributeValueService.getPatientAttributeValue( patient, sortingAttribute );



             patinetAttributeValueMap.put( patient, patientAttributeValue );
  •            System.out.println( patient.getFullName() );
    
  •        }
    
  •        else
    
  •        {
    
  •            patientListByOrgUnit.remove( patient );
    
           }
    
    
    
           programStageInstances.addAll( programInstance.getProgramStageInstances() );
    
       }
    
  •    // ---------------------------------------------------------------------
    
       // Sorting PatientList by slected Patient Attribute
    
  •    // ---------------------------------------------------------------------
    
  •    patientListByOrgUnit = new ArrayList<Patient>();
    
    
    
       if( sortPatientAttributeId != null )
    
       {
    
  •        sortingAttribute = patientAttributeService.getPatientAttribute( sortPatientAttributeId );
    
         patientListByOrgUnit = patientService.sortPatientsByAttribute( programInstanceMap.keySet(), sortingAttribute );

     }

     else

@@ -266,10 +246,8 @@

         patientListByOrgUnit = programInstanceMap.keySet();

     }
  •    System.out.println("sortPatientAttributeId : "+sortPatientAttributeId);
    
       colorMap = programStageInstanceService.colorProgramStageInstances( programStageInstances );
    
     return SUCCESS;

 }

=== modified file ‘dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java’

— dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2010-10-20 13:34:22 +0000

+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java 2010-10-25 11:12:04 +0000

@@ -35,7 +35,6 @@

import org.hisp.dhis.caseentry.state.SelectedStateManager;

import org.hisp.dhis.i18n.I18nFormat;

import org.hisp.dhis.organisationunit.OrganisationUnit;

-import org.hisp.dhis.patient.Patient;

import org.hisp.dhis.patient.PatientService;

import org.hisp.dhis.program.Program;

import org.hisp.dhis.program.ProgramInstance;

@@ -188,28 +187,16 @@

     programs = programService.getPrograms( organisationUnit );
  •    // Getting the list of Patients that are related to selected OrganisationUnit
    
  •    Collection<Patient> patientListByOrgUnit = new ArrayList<Patient>();
    
  •    patientListByOrgUnit.addAll( patientService.getPatients( organisationUnit ) );
    
     // ---------------------------------------------------------------------

     // Program instances for the selected program

     // ---------------------------------------------------------------------
  •    Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program );
    
  •    Collection<ProgramInstance> selectedProgramInstances = programInstanceService.getProgramInstances( program, organisationUnit );
    
    
    
       Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
    
    
    
       for ( ProgramInstance programInstance : selectedProgramInstances )
    
       {
    
  •           Patient patient = programInstance.getPatient();
    
  •        //taking patient present in selected orgunit
    
  •        if ( !patientListByOrgUnit.contains( patient ) || programInstance.getEndDate() != null )
    
  •        {
    
  •            continue;
    
  •        }
    
         if ( !programInstance.isCompleted() )

         {

             programInstances.add( programInstance );

Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Just a question Bahrath,

Once you have a program can’t you use Collection getProgramInstances( Program program, boolean completed );

Do you want to display status of programs per orgunit?

Yes.

If so I think you can still use the existing API and do some sort of mapping. Because I see you kind of hardcoding a bit … “get programInstances whose endData is null” - I think you can play around with the completed attribute of programInstance.

completed attribute is not setting some times where enddate is set, I am not sure exactly in which case it is happening (may be when we enroll ,unenroll again enroll program to a person). Actually the method name should be getActiveProgramInstances, but in store we are implementing GenericStore, thats y i have given getProgramInstances to the method.

May be in service i can use getActiveProgramInstances which will call getProgramInstances(program, orgunit) from store?

···

On Mon, Oct 25, 2010 at 5:00 PM, Abyot Gizaw abyota@gmail.com wrote:

Regards,
Bharath Kumar. Ch

Just a question Bahrath,

Once you have a program can’t you use Collection getProgramInstances( Program program, boolean completed );

Do you want to display status of programs per orgunit?

Yes.

If so I think you can still use the existing API and do some sort of mapping. Because I see you kind of hardcoding a bit … “get programInstances whose endData is null” - I think you can play around with the completed attribute of programInstance.

completed attribute is not setting some times where enddate is set, I am not sure exactly in which case it is happening (may be when we enroll ,unenroll again enroll program to a person). Actually the method name should be getActiveProgramInstances, but in store we are implementing GenericStore, thats y i have given getProgramInstances to the method.

Yes completed is set to true when we do program unenroll/enroll. I think, we should also provide a menu in program maintenance to cleanup programs - because it is very ideal that users follow a strict program enrollment and the un-enrollment (like successful completion or termination).

What was that you wanted to display exactly ? all those active programs or completed ones?

···

On Mon, Oct 25, 2010 at 1:44 PM, bharath kumar chbharathk@gmail.com wrote:

On Mon, Oct 25, 2010 at 5:00 PM, Abyot Gizaw abyota@gmail.com wrote:

May be in service i can use getActiveProgramInstances which will call getProgramInstances(program, orgunit) from store?

Regards,
Bharath Kumar. Ch

What was that you wanted to display exactly ? all those active programs or completed ones?

In Namebased entry we added option Multiple DataEntry where we are displaying all Active ProgramInstances for selected orgunit.

···

Regards,
Bharath Kumar. Ch