=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2011-11-04 11:27:33 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2012-04-10 06:49:47 +0000 @@ -39,7 +39,10 @@ public ActivityPlan getCurrentActivityPlan( OrganisationUnit unit, String localeString ); - public ActivityPlan getActivitiesByIdentifier( String keyword ) throws NotAllowedException; + public ActivityPlan getAllActivityPlan( OrganisationUnit unit, String localeString ); + + public ActivityPlan getActivitiesByIdentifier( String keyword ) + throws NotAllowedException; public void saveActivityReport( OrganisationUnit unit, ActivityValue activityValue ) throws NotAllowedException; === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2012-03-22 14:17:16 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2012-04-10 06:49:47 +0000 @@ -109,6 +109,7 @@ private org.hisp.dhis.patient.PatientAttribute groupByAttribute; + @Override public ActivityPlan getCurrentActivityPlan( OrganisationUnit unit, String localeString ) { long time = System.currentTimeMillis(); @@ -140,6 +141,32 @@ } @Override + public ActivityPlan getAllActivityPlan( OrganisationUnit unit, String localeString ) + { + long time = System.currentTimeMillis(); + + List items = new ArrayList(); + + this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( true ) ); + + Collection activities = activityPlanService.getActivitiesByProvider( unit ); + + for ( org.hisp.dhis.activityplan.Activity activity : activities ) + { + items.add( getActivity( activity.getTask(), activity.getDueDate().getTime() < time ) ); + } + + if ( items.isEmpty() ) + { + return null; + } + + Collections.sort( items, activityComparator ); + + return new ActivityPlan( items ); + } + + @Override public ActivityPlan getActivitiesByIdentifier( String keyword ) throws NotAllowedException { === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java 2012-02-16 12:58:37 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java 2012-04-10 06:49:47 +0000 @@ -37,7 +37,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.api.mobile.FacilityReportingService; === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration' === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action' === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/GetBeneficiaryRegistrationOrganisationUnitAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.beneficiaryregistration.action; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; + +import com.opensymphony.xwork2.Action; + +public class GetBeneficiaryRegistrationOrganisationUnitAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List organisationUnits = new ArrayList(); + + public List getOrganisationUnits() + { + return organisationUnits; + } + + @Override + public String execute() + throws Exception + { + User user = currentUserService.getCurrentUser(); + + if ( user != null ) + { + organisationUnits = new ArrayList( user.getOrganisationUnits() ); + Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE ); + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.beneficiaryregistration.action; + +import com.opensymphony.xwork2.Action; + +public class RegisterBeneficiaryAction implements Action +{ + + private String orgUnitId; + + public String getOrgUnitId() + { + return orgUnitId; + } + + + public void setOrgUnitId( String orgUnitId ) + { + this.orgUnitId = orgUnitId; + } + + @Override + public String execute() + throws Exception + { + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.beneficiaryregistration.action; + +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientService; +import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.ISODateTimeFormat; + +import com.opensymphony.xwork2.Action; + +public class SaveBeneficiaryAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private PatientService patientService; + + public PatientService getPatientService() + { + return patientService; + } + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private OrganisationUnitService organisationUnitService; + + public OrganisationUnitService getOrganisationUnitService() + { + return organisationUnitService; + } + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String orgUnitId; + + public String getOrgUnitId() + { + return orgUnitId; + } + + public void setOrgUnitId( String orgUnitId ) + { + this.orgUnitId = orgUnitId; + } + + private String patientFullName; + + public String getPatientFullName() + { + return patientFullName; + } + + public void setPatientFullName( String patientFullName ) + { + this.patientFullName = patientFullName; + } + + private String bloodGroup; + + public String getBloodGroup() + { + return bloodGroup; + } + + public void setBloodGroup( String bloodGroup ) + { + this.bloodGroup = bloodGroup; + } + + private String gender; + + public String getGender() + { + return gender; + } + + public void setGender( String gender ) + { + this.gender = gender; + } + + private String dateOfBirth; + + public String getDateOfBirth() + { + return dateOfBirth; + } + + public void setDateOfBirth( String dateOfBirth ) + { + this.dateOfBirth = dateOfBirth; + } + + public boolean validated; + + public boolean isValidated() + { + return validated; + } + + public void setValidated( boolean validated ) + { + this.validated = validated; + } + + @Override + public String execute() + throws Exception + { + Patient patient = new Patient(); + + patient.setOrganisationUnit( organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitId ) ) ); + + String[] tokens = this.patientFullName.split( " " ); + + patient.setFirstName( tokens[0] ); + + if ( tokens.length == 2 ) + { + patient.setLastName( tokens[1] ); + } + else if ( tokens.length > 2 ) + { + patient.setMiddleName( tokens[1] ); + patient.setLastName( tokens[2] ); + } + + patient.setGender( gender ); + patient.setBloodGroup( bloodGroup ); + + DateTimeFormatter sdf = ISODateTimeFormat.yearMonthDay(); + DateTime date = sdf.parseDateTime( dateOfBirth ); + try + { + patient.setBirthDate( date.toDate() ); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + + patientService.savePatient( patient ); + validated = true; + + return SUCCESS; + } + +} === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry' === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action' === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetActivityListAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetActivityListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetActivityListAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.namebaseddataentry.action; + +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.api.mobile.model.Activity; +import org.hisp.dhis.api.mobile.ActivityReportingService; +import org.hisp.dhis.api.mobile.model.ActivityPlan; +import org.hisp.dhis.light.utils.NamebasedUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import com.opensymphony.xwork2.Action; + +public class GetActivityListAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ActivityReportingService activityReportingService; + + public void setActivityReportingService( ActivityReportingService activityReportingService ) + { + this.activityReportingService = activityReportingService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private NamebasedUtils util; + + public void setUtil( NamebasedUtils util ) + { + this.util = util; + } + + public NamebasedUtils getUtil() + { + return util; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String beneficiaryId; + + public void setBeneficiaryId( String beneficiaryId ) + { + this.beneficiaryId = beneficiaryId; + } + + public String getBeneficiaryId() + { + return this.beneficiaryId; + } + + private boolean current; + + public boolean isCurrent() + { + return current; + } + + public void setCurrent( boolean current ) + { + this.current = current; + } + + private OrganisationUnit organisationUnit; + + public String getOrganisationUnitId() + { + return this.organisationUnitId; + } + + private String organisationUnitId; + + public void setOrganisationUnitId( String organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + private List activities; + + public List getActivities() + { + return activities; + } + + public void setActivities( List activities ) + { + this.activities = activities; + } + + @Override + public String execute() + throws Exception + { + activities = new ArrayList(); + organisationUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( organisationUnitId ) ); + ActivityPlan activityPlan; + if ( current ) + { + activityPlan = activityReportingService.getCurrentActivityPlan( organisationUnit, "" ); + } + else + { + activityPlan = activityReportingService.getAllActivityPlan( organisationUnit, "" ); + } + List allActivities = activityPlan.getActivitiesList(); + for ( Activity activity : allActivities ) + { + if ( activity.getBeneficiary().getId() == Integer.parseInt( beneficiaryId ) ) + { + activities.add( activity ); + } + } + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetBeneficiaryDetailAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetBeneficiaryDetailAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetBeneficiaryDetailAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,92 @@ +package org.hisp.dhis.light.namebaseddataentry.action; + +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientService; + +import com.opensymphony.xwork2.Action; + +public class GetBeneficiaryDetailAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private PatientService patientService; + + public PatientService getPatientService() + { + return patientService; + } + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String organisationUnitId; + + public String getOrganisationUnitId() + { + return organisationUnitId; + } + + public void setOrganisationUnitId( String organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + private String beneficiaryId; + + public void setBeneficiaryId( String beneficiaryId ) + { + this.beneficiaryId = beneficiaryId; + } + + public String getBeneficiaryId() + { + return this.beneficiaryId; + } + + private Patient patient; + + public Patient getPatient() + { + return patient; + } + + public void setPatient( Patient patient ) + { + this.patient = patient; + } + + private boolean current; + + public void setCurrent( boolean current ) + { + this.current = current; + } + + public boolean getCurrent() + { + return current; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + this.patient = patientService.getPatient( Integer.parseInt( beneficiaryId ) ); + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetBeneficiaryListAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetBeneficiaryListAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetBeneficiaryListAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.namebaseddataentry.action; + +import java.util.ArrayList; +import java.util.List; +import org.hisp.dhis.api.mobile.ActivityReportingService; +import org.hisp.dhis.api.mobile.model.Activity; +import org.hisp.dhis.api.mobile.model.ActivityPlan; +import org.hisp.dhis.api.mobile.model.Beneficiary; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import com.opensymphony.xwork2.Action; + +public class GetBeneficiaryListAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ActivityReportingService activityReportingService; + + public void setActivityReportingService( ActivityReportingService activityReportingService ) + { + this.activityReportingService = activityReportingService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private boolean current; + + public boolean isCurrent() + { + return current; + } + + public void setCurrent( boolean current ) + { + this.current = current; + } + + private boolean validated = false; + + public boolean isValidated() + { + return validated; + } + + public void setValidated( boolean validated ) + { + this.validated = validated; + } + + private List beneficiaries; + + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() + { + return this.organisationUnit; + } + + private String organisationUnitId; + + public void setOrganisationUnitId( String organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public String getOrganisationUnitId( String organisationUnitId ) + { + return this.organisationUnitId; + } + + private ActivityPlan activityPlan; + + public ActivityPlan getActivityPlan() + { + return this.activityPlan; + } + + private List activities; + + public List getActivities() + { + return this.activities; + } + + public List getBeneficiaries() + { + return this.beneficiaries; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + beneficiaries = new ArrayList(); + + organisationUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( organisationUnitId ) ); + + if ( current ) + { + activityPlan = activityReportingService.getCurrentActivityPlan( organisationUnit, "" ); + } + else + { + activityPlan = activityReportingService.getAllActivityPlan(organisationUnit, ""); + } + + if ( activityPlan == null ) + return SUCCESS; + + activities = activityPlan.getActivitiesList(); + + if ( activities == null ) + return SUCCESS; + + for ( Activity activity : activities ) + { + beneficiaries.add( activity.getBeneficiary() ); + } + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetNamebasedOrganisationUnitsAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2011, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.namebaseddataentry.action; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; +import com.opensymphony.xwork2.Action; + +public class GetNamebasedOrganisationUnitsAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List organisationUnits = new ArrayList(); + + public List getOrganisationUnits() + { + return organisationUnits; + } + + @Override + public String execute() + throws Exception + { + User user = currentUserService.getCurrentUser(); + + if ( user != null ) + { + organisationUnits = new ArrayList( user.getOrganisationUnits() ); + Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE ); + } + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetProgramStageFormAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,208 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.namebaseddataentry.action; + +import java.util.List; +import org.hisp.dhis.api.mobile.model.Activity; +import org.hisp.dhis.api.mobile.model.ActivityPlan; +import org.hisp.dhis.api.mobile.model.DataElement; +import org.hisp.dhis.api.mobile.model.Program; +import org.hisp.dhis.api.mobile.model.ProgramStage; +import org.hisp.dhis.light.utils.NamebasedUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; + +import com.opensymphony.xwork2.Action; + +public class GetProgramStageFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private NamebasedUtils util; + + public void setUtil( NamebasedUtils util ) + { + this.util = util; + } + + public NamebasedUtils getUtil() + { + return util; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String programStageInstanceId; + + public String getProgramStageInstanceId() + { + return programStageInstanceId; + } + + public void setProgramStageInstanceId( String programStageInstanceId ) + { + this.programStageInstanceId = programStageInstanceId; + } + + private String beneficiaryId; + + public void setBeneficiaryId( String beneficiaryId ) + { + this.beneficiaryId = beneficiaryId; + } + + public String getBeneficiaryId() + { + return this.beneficiaryId; + } + + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() + { + return this.organisationUnit; + } + + + public void setOrganisationUnit( OrganisationUnit organisationUnit ) + { + this.organisationUnit = organisationUnit; + } + + private List dataElements; + + public List getDataElements() + { + return this.dataElements; + } + + private ProgramStage programStage; + + public ProgramStage getProgramStage() + { + return this.programStage; + } + + private String programId; + + public void setProgramId( String programId ) + { + this.programId = programId; + } + + public String getProgramId() + { + return programId; + } + + private String programStageId; + + public void setProgramStageId( String programStageId ) + { + this.programStageId = programStageId; + } + + public String getProgramStageId() + { + return programStageId; + } + + private String orgUnitId; + + public void setOrgUnitId( String orgUnitId ) + { + this.orgUnitId = orgUnitId; + } + + public String getOrgUnitId() + { + return this.orgUnitId; + } + + private ActivityPlan activityPlan; + + public ActivityPlan getActivityPlan() + { + return this.activityPlan; + } + + private List activities; + + public List getActivities() + { + return this.activities; + } + + private Program program; + + public Program getProgram() + { + return this.program; + } + + private boolean current; + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + public boolean isCurrent() + { + return current; + } + + public void setCurrent( boolean current ) + { + this.current = current; + } + + @Override + public String execute() + throws Exception + { + organisationUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitId ) ); + + programStage = util.getProgramStage( Integer.parseInt( programId ), Integer.parseInt( programStageId ) ); + + dataElements = programStage.getDataElements(); + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/SaveProgramStageFormAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.namebaseddataentry.action; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.api.mobile.ActivityReportingService; +import org.hisp.dhis.api.mobile.NotAllowedException; +import org.hisp.dhis.api.mobile.model.ActivityValue; +import org.hisp.dhis.api.mobile.model.DataElement; +import org.hisp.dhis.api.mobile.model.DataValue; +import org.hisp.dhis.api.mobile.model.ProgramStage; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.light.utils.NamebasedUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.util.ContextUtils; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; + +public class SaveProgramStageFormAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private NamebasedUtils util; + + public NamebasedUtils getUtil() + { + return util; + } + + public void setUtil( NamebasedUtils util ) + { + this.util = util; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private ActivityReportingService activityReportingService; + + public void setActivityReportingService( ActivityReportingService activityReportingService ) + { + this.activityReportingService = activityReportingService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String orgUnitId; + + public void setOrgUnitId( String orgUnitId ) + { + this.orgUnitId = orgUnitId; + } + + public String getOrgUnitId() + { + return orgUnitId; + } + + private OrganisationUnit organisationUnit; + + private String programStageInstanceId; + + public String getProgramStageInstanceId() + { + return programStageInstanceId; + } + + public void setProgramStageInstanceId( String programStageInstanceId ) + { + this.programStageInstanceId = programStageInstanceId; + } + + private String beneficiaryId; + + public void setBeneficiaryId( String beneficiaryId ) + { + this.beneficiaryId = beneficiaryId; + } + + public String getBeneficiaryId() + { + return beneficiaryId; + } + + private String programId; + + public void setProgramId( String programId ) + { + this.programId = programId; + } + + public String getProgramId() + { + return programId; + } + + private String programStageId; + + public void setProgramStageId( String programStageId ) + { + this.programStageId = programStageId; + } + + public String getProgramStageId() + { + return programStageId; + } + + private ProgramStage programStage; + + public ProgramStage getProgramStage() + + { + return programStage; + } + + private boolean current; + + public void setCurrent( boolean current ) + { + this.current = current; + } + + public boolean getCurrent() + { + return current; + } + + private List dataElements; + + public List getDataElements() + { + return dataElements; + } + + private Map typeViolations = new HashMap(); + + public Map getTypeViolations() + { + return typeViolations; + } + + private Map prevDataValues = new HashMap(); + + public Map getPrevDataValues() + { + return prevDataValues; + } + + @Override + public String execute() + throws Exception + { + organisationUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( orgUnitId ) ); + + programStage = util.getProgramStage( Integer.parseInt( programId ), Integer.parseInt( programStageId ) ); + + dataElements = programStage.getDataElements(); + + System.out.println( "Current: " + current ); + + HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get( + ServletActionContext.HTTP_REQUEST ); + Map parameterMap = ContextUtils.getParameterMap( request ); + + List dataValues = new ArrayList(); + + typeViolations.clear(); + prevDataValues.clear(); + + for ( String key : parameterMap.keySet() ) + { + if ( key.startsWith( "DE" ) && key.indexOf( "OC" ) != -1 ) + { + String[] splitKey = key.split( "OC" ); + Integer dataElementId = Integer.parseInt( splitKey[0].substring( 2 ) ); + Integer categoryOptComboId = Integer.parseInt( splitKey[1] ); + String value = parameterMap.get( key ); + + // validate types + org.hisp.dhis.dataelement.DataElement dataElement = dataElementService.getDataElement( dataElementId ); + value = value.trim(); + Boolean valueIsEmpty = (value == null || value.length() == 0); + + if ( !valueIsEmpty ) + { + String typeViolation = util.getTypeViolation( dataElement, value ); + + if ( typeViolation != null ) + { + typeViolations.put( key, typeViolation ); + } + prevDataValues.put( key, value ); + } + + // build dataValue for activity value + DataValue dataValue = new DataValue(); + dataValue.setId( dataElementId ); + dataValue.setValue( value ); + dataValue.setCategoryOptComboID( categoryOptComboId ); + + dataValues.add( dataValue ); + } + } + + if ( !typeViolations.isEmpty() ) + { + return ERROR; + } + + ActivityValue activityValue = new ActivityValue(); + activityValue.setDataValues( dataValues ); + activityValue.setProgramInstanceId( Integer.parseInt( programStageInstanceId ) ); + + try + { + activityReportingService.saveActivityReport( organisationUnit, activityValue ); + } + catch ( NotAllowedException e ) + { + e.printStackTrace(); + + return ERROR; + } + + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/ShowActivityTypeAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/ShowActivityTypeAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/ShowActivityTypeAction.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,45 @@ +package org.hisp.dhis.light.namebaseddataentry.action; + +import com.opensymphony.xwork2.Action; + +public class ShowActivityTypeAction + implements Action +{ + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String orgUnitId; + + public void setOrgUnitId( String orgUnitId ) + { + this.orgUnitId = orgUnitId; + } + + public String getOrgUnitId( String orgUnitId ) + { + return this.orgUnitId; + } + + private String organisationUnitId; + + public String getOrganisationUnitId() + { + return organisationUnitId; + } + + public void setOrganisationUnitId( String organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + @Override + public String execute() + throws Exception + { + this.organisationUnitId = orgUnitId; + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/NamebasedUtils.java 2012-04-10 06:49:47 +0000 @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.hisp.dhis.light.utils; + +import java.util.Collection; +import org.hisp.dhis.api.mobile.IProgramService; +import org.hisp.dhis.api.mobile.model.Program; +import org.hisp.dhis.api.mobile.model.ProgramStage; +import org.hisp.dhis.dataelement.DataElement; + +public class NamebasedUtils +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private IProgramService programService; + + public void setProgramService( IProgramService programService ) + { + this.programService = programService; + } + + public ProgramStage getProgramStage( int programId, int programStageId ) + { + Program program = programService.getProgram( programId, "" ); + + Collection stages = program.getProgramStages(); + + for ( ProgramStage programStage : stages ) + { + if ( programStage.getId() == programStageId ) + { + return programStage; + } + } + return null; + } + + public String getTypeViolation( DataElement dataElement, String value ) + { + String type = dataElement.getType(); + String numberType = dataElement.getNumberType(); + + if ( type.equals( DataElement.VALUE_TYPE_STRING ) ) + { + } + else if ( type.equals( DataElement.VALUE_TYPE_BOOL ) ) + { + if ( !FormUtils.isBoolean( value ) ) + { + return "is_invalid_boolean"; + } + } + else if ( type.equals( DataElement.VALUE_TYPE_DATE ) ) + { + if ( !FormUtils.isDate( value ) ) + { + return "is_invalid_date"; + } + } + else if ( type.equals( DataElement.VALUE_TYPE_INT ) && numberType.equals( DataElement.VALUE_TYPE_NUMBER ) ) + { + if ( !FormUtils.isNumber( value ) ) + { + return "is_invalid_number"; + } + } + else if ( type.equals( DataElement.VALUE_TYPE_INT ) && numberType.equals( DataElement.VALUE_TYPE_INT ) ) + { + if ( !FormUtils.isInteger( value ) ) + { + return "is_invalid_integer"; + } + } + else if ( type.equals( DataElement.VALUE_TYPE_INT ) && numberType.equals( DataElement.VALUE_TYPE_POSITIVE_INT ) ) + { + if ( !FormUtils.isPositiveInteger( value ) ) + { + return "is_invalid_positive_integer"; + } + } + else if ( type.equals( DataElement.VALUE_TYPE_INT ) && numberType.equals( DataElement.VALUE_TYPE_NEGATIVE_INT ) ) + { + if ( !FormUtils.isNegativeInteger( value ) ) + { + return "is_invalid_negative_integer"; + } + } + return null; + } +} === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-02-16 14:00:33 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-04-10 06:49:47 +0000 @@ -92,7 +92,72 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /dhis-web-light/main.vm /dhis-web-light/selectOrganisationUnit.vm - /mobile/selectDataSet.action?organisationUnitId=${organisationUnitId} /mobile/selectPeriod.action?organisationUnitId=${organisationUnitId}&dataSetId=${dataSetId} @@ -25,7 +24,6 @@ /dhis-web-light/main.vm /dhis-web-light/selectDataSet.vm - /mobile/selectPeriod.action?organisationUnitId=${organisationUnitId}&dataSetId=${dataSetId} @@ -54,7 +52,62 @@ /mobile/index.action?organisationUnitId=${organisationUnitId}&dataSetId=${dataSetId}&periodId=${periodId}&complete=true - + + + + + /dhis-web-light/main.vm + /dhis-web-light/selectNamebasedOrganisationUnits.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/selectActivityType.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/beneficiaryList.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/selectActivity.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/programStageForm.vm + + + + /mobile/selectBeneficiary.action?organisationUnitId=${orgUnitId}&current=${current}&validated=true + /dhis-web-light/main.vm + /dhis-web-light/programStageForm.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/beneficiaryDetail.vm + + + + + + /dhis-web-light/main.vm + /dhis-web-light/selectRegistrationOrganisationUnits.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/beneficiaryRegistrationForm.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/beneficiaryRegistrationForm.vm + + === added file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/beneficiaryDetail.vm' --- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/beneficiaryDetail.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/beneficiaryDetail.vm 2012-04-10 06:49:47 +0000 @@ -0,0 +1,20 @@ +

$i18n.getString("details_for") $patient.firstName $patient.middleName $patient.lastName

+

+ +

    +
  • $i18n.getString("id"): $patient.id
  • +
  • $i18n.getString("gender"): #if ($patient.gender == "F") Female #else Male #end
  • + #set($day = $patient.birthDate.date) + #set($month = $patient.birthDate.month+1) + #set($year = $patient.birthDate.year + 1900) +
  • $i18n.getString("date_of_birth"): $year - $month - $day
  • +
  • $i18n.getString("blood_group"): $patient.bloodGroup
  • +
+ +

+