=== modified file 'dhis-2/dhis-web/dhis-web-light/pom.xml' --- dhis-2/dhis-web/dhis-web-light/pom.xml 2011-11-14 12:19:36 +0000 +++ dhis-2/dhis-web/dhis-web-light/pom.xml 2011-11-21 12:44:20 +0000 @@ -42,6 +42,10 @@ org.hisp.dhis dhis-service-core + + org.hisp.dhis + dhis-service-mobile + === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents' === added directory 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action' === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/AddBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/AddBeneficiaryAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/AddBeneficiaryAction.java 2011-12-02 22:49:31 +0000 @@ -0,0 +1,671 @@ +/* + * 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.singleevents.action; + +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang.math.NumberUtils; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.light.dataentry.utils.FormUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeGroup; +import org.hisp.dhis.patient.PatientAttributeGroupService; +import org.hisp.dhis.patient.PatientAttributeOption; +import org.hisp.dhis.patient.PatientAttributeOptionService; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.program.ProgramService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class AddBeneficiaryAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private PatientAttributeGroupService patientAttributeGroupService; + + public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) + { + this.patientAttributeGroupService = patientAttributeGroupService; + } + + private PatientAttributeOptionService patientAttributeOptionService; + + public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) + { + this.patientAttributeOptionService = patientAttributeOptionService; + } + + // ------------------------------------------------------------------------- + // Input Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Patient patient; + + public Patient getPatient() + { + return patient; + } + + private String fullName; + + public void setFullName( String fullName ) + { + this.fullName = fullName; + } + + public String getFullName(){ + return fullName; + } + + private String birthDate; + + public void setBirthDate( String birthDate ) + { + this.birthDate = birthDate; + } + + public String getBirthDate() + { + return birthDate; + } + + private Character dobType; + + public void setDobType( Character dobType ) + { + this.dobType = dobType; + } + // + public char getDobType(){ + return dobType; + } + + private String gender; + + public void setGender( String gender ) + { + this.gender = gender; + } + // + public String getGender(){ + return gender; + } + + private String bloodGroup; + + public void setBloodGroup( String bloodGroup ){ + this.bloodGroup = bloodGroup; + } + // + public String getBloodGroup(){ + return bloodGroup; + } + + private String registrationDate; + + public void setRegistrationDate( String registrationDate ){ + this.registrationDate = registrationDate; + } + + public String getRegistrationDate() + { + return registrationDate; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + private Integer patientId; + + public Integer getPatientId(){ + return this.patientId; + } + + private List attributeGroups; + + public List getAttributeGroups() + { + return attributeGroups; + } + + private Collection noGroupAttributes; + + public Collection getNoGroupAttributes() + { + return noGroupAttributes; + } + + private String dynForm[]; + + public void setDynForm(String[] dynForm) { + this.dynForm = dynForm; + } + + public String[] getDynForm() + { + return dynForm; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Validation + // ------------------------------------------------------------------------- + + private Date rD,bD; + + private boolean fullNameIsToLong; + private boolean invalidFullName; + private boolean invalidRegistrationDate; + private boolean invalidBirthDate; + private boolean noGender; + private boolean noDobType; + private boolean invalidDobType; + private boolean invalidBloodGroup; + private boolean invalidGender; + + private ArrayList validList = new ArrayList(); + + public ArrayList getValidList() + { + return this.validList; + } + + public boolean getFullNameIsToLong() + { + return fullNameIsToLong; + } + + public boolean getInvalidFullName() + { + return invalidFullName; + } + + public boolean getInvalidRegistrationDate() + { + return invalidRegistrationDate; + } + + public boolean getInvalidBirthDate() + { + return invalidBirthDate; + } + + public boolean getNoGender() + { + return noGender; + } + + public boolean getNoDobType() + { + return noDobType; + } + + public boolean getInvalidDobType() + { + return invalidDobType; + } + + public boolean getInvalidGender() + { + return invalidGender; + } + + public boolean getInvalidBloodGroup() + { + return invalidBloodGroup; + } + + private boolean validate() + { + boolean valid = true; + + if(validateStringLength(fullName,7,50) == false){ + fullNameIsToLong = true; + valid = false; + } + + if(validName(fullName) == false){ + invalidFullName = true; + valid = false; + } + + if(validateDateNotNull(rD) == false){ + invalidRegistrationDate = true; + valid = false; + } + + if(validateDateNotNull(bD) == false){ + invalidBirthDate = true; + valid = false; + } + + if(validateDropDown(gender) == false){ + noGender = true; + valid = false; + } + + if(validateDropDown(dobType) == false){ + noDobType = true; + valid = false; + } + + if(validateDobType(dobType) == false){ + invalidDobType = true; + valid = false; + } + + if(validateGender(gender) == false){ + invalidGender = true; + valid = false; + } + + if(validateBloodGroup(bloodGroup) == false){ + invalidBloodGroup = true; + valid = false; + } + + return valid; + } + + private boolean validateStringLength(String s, int min, int max) + { + return ((s.length() >= min) && (s.length() <= max)); + } + + private boolean validName(String s) + { + return (s.matches("^[\\p{L}|\\s]*$")); + } + + private boolean validateDateNotNull(Date d){ + if(d == null){ + return false; + }else{ + return true; + } + } + + private boolean validateDropDown(String s){ + if(s.equalsIgnoreCase("please_select")){ + return false; + }else{ + return true; + } + } + + private boolean validateDropDown(Character c){ + if(c.equals('p')){ + return false; + }else{ + return true; + } + } + + private boolean validateDobType(Character c) + { + if(c == 'D' || c == 'V'){ + return true; + }else{ + return false; + } + } + + private boolean validateGender(String s) + { + if(s.equals("M") || s.equals("F") || s.equals("T")){ + return true; + }else{ + return false; + } + } + + private boolean validateBloodGroup(String s) + { + if(s.matches("^\\w{1,2}\\-?\\+?$") || s.equalsIgnoreCase("please_select")){ + return true; + }else{ + return false; + } + } + + + private boolean validateDynForm(String value, PatientAttribute patientAttribute){ + + boolean valid = true; + + String type = patientAttribute.getValueType(); + Integer id = patientAttribute.getId(); + + if(value.isEmpty()){ + if(patientAttribute.isMandatory()){ + validList.add(new Validate(id, i18n.getString( "is_required" ))); + valid = false; + } + }else if(type.equals("DATE")){ + if(!FormUtils.isDate( value )) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_date" ))); + valid = false; + } + }else if(type.equals("TEXT")){ + if(!value.matches("^[\\p{L}|\\s|0-9]*$")) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_string" ))); + valid = false; + } + }else if(type.equals("NUMBER")){ + if(!FormUtils.isNumber( value )) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_number" ))); + valid = false; + } + }else if(type.equals("YES/NO")){ + if(!FormUtils.isBoolean( value )) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_boolean" ))); + valid = false; + } + }else if(type.equals("COMBO")){ + Set attributeOptions = patientAttribute.getAttributeOptions(); + boolean contains = false; + for(PatientAttributeOption attributeOption : attributeOptions){ + if(attributeOption.getId() == NumberUtils.toInt( value, 0 ) ){ + contains = true; + } + } + if(!contains){ + validList.add(new Validate(id, value)); + } + valid = contains; + } + + return valid; + } + + public class Validate { + private Integer _id; + private String _errormessage; + + public String getErrorMessage(){ + return this._errormessage; + } + public Integer getId(){ + return this._id; + } + + public Validate(Integer id, String errormessage) + { + this._id = id; + this._errormessage = errormessage; + } + + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + // + eventName = programService.getProgram(singleEventId).getName(); + + fullNameIsToLong = false; + invalidFullName = false; + invalidRegistrationDate = false; + invalidBirthDate = false; + noGender = false; + noDobType = false; + invalidDobType = false; + invalidBloodGroup = false; + invalidGender = false; + + Patient patient = new Patient(); + // --------------------------------------------------------------------- + // Set FirstName, MiddleName, LastName by FullName + // --------------------------------------------------------------------- + + fullName = fullName.trim(); + + int startIndex = fullName.indexOf( ' ' ); + int endIndex = fullName.lastIndexOf( ' ' ); + + String firstName = fullName.toString(); + String middleName = ""; + String lastName = ""; + + if ( fullName.indexOf( ' ' ) != -1 ) + { + firstName = fullName.substring( 0, startIndex ); + if ( startIndex == endIndex ) + { + middleName = ""; + lastName = fullName.substring( startIndex + 1, fullName.length() ); + } + else + { + middleName = fullName.substring( startIndex + 1, endIndex ); + lastName = fullName.substring( endIndex + 1, fullName.length() ); + } + } + patient.setFirstName( firstName ); + patient.setMiddleName( middleName ); + patient.setLastName( lastName ); + + // --------------------------------------------------------------------- + // Set Other information for patient + // --------------------------------------------------------------------- + + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( getOrganisationUnitId() ); + + patient.setOrganisationUnit( organisationUnit ); + patient.setGender( gender ); + patient.setDobType( dobType ); + patient.setIsDead( false ); + if(!bloodGroup.equalsIgnoreCase("please_select")){ + patient.setBloodGroup( bloodGroup ); + } + birthDate = birthDate.trim(); + bD = format.parseDate( birthDate ); + patient.setBirthDate( bD ); + + registrationDate = registrationDate.trim(); + rD = format.parseDate( registrationDate ); + patient.setRegistrationDate( rD ); + + // --------------------------------------------------------------------- + // Dynamic form + // --------------------------------------------------------------------- + + noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); + + attributeGroups = new ArrayList( patientAttributeGroupService + .getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); + + boolean validInGroup = true; + List patientAttributeValues = new ArrayList(); + PatientAttributeValue attributeValue = null; + validList.clear(); + int i = 0; + + //Attributes in groups + + for (PatientAttributeGroup patientAttributeGroup : attributeGroups) { + List patientAttributeList = patientAttributeGroup.getAttributes(); + for(PatientAttribute patientAttribute : patientAttributeList){ + + String value = dynForm[i]; + + if(!validateDynForm(value, patientAttribute)){ + validInGroup = false; + } + + if(validInGroup){ + attributeValue = new PatientAttributeValue(); + attributeValue.setPatient( patient ); + attributeValue.setPatientAttribute( patientAttribute ); + + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + } + else + { + attributeValue.setValue( value.trim() ); + } + patientAttributeValues.add( attributeValue ); + } + + i++; + } + } + + //Attributes not in groups + + boolean validNoGroup = true; + + for (PatientAttribute patientAttribute : noGroupAttributes) { + String value = dynForm[i]; + + if(!validateDynForm(value, patientAttribute)){ + validNoGroup = false; + } + + if(validNoGroup){ + attributeValue = new PatientAttributeValue(); + attributeValue.setPatient( patient ); + attributeValue.setPatientAttribute( patientAttribute ); + + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ){ + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ){ + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + }else{ + attributeValue.setValue( value.trim() ); + } + patientAttributeValues.add( attributeValue ); + } + + i++; + } + + if((validate() == false)||(!validNoGroup)||(!validInGroup)) { + return ERROR; + }else{ + patientId = patientService.createPatient( patient, 0, 0,patientAttributeValues ); + return SUCCESS; + } + + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/AddSingleEventAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/AddSingleEventAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/AddSingleEventAction.java 2011-12-02 22:49:31 +0000 @@ -0,0 +1,407 @@ +/* + * 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.singleevents.action; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.light.dataentry.utils.FormUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patientdatavalue.PatientDataValue; +import org.hisp.dhis.patientdatavalue.PatientDataValueService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class AddSingleEventAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramInstanceService programInstanceService; + + public void setProgramInstanceService( ProgramInstanceService programInstanceService ) + { + this.programInstanceService = programInstanceService; + } + + private ProgramStageInstanceService programStageInstanceService; + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private PatientDataValueService patientDataValueService; + + public void setPatientDataValueService( PatientDataValueService patientDataValueService ) + { + this.patientDataValueService = patientDataValueService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private FormUtils formUtils; + + public void setFormUtils( FormUtils formUtils ) + { + this.formUtils = formUtils; + } + + public FormUtils getFormUtils() + { + return formUtils; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Input Output + // ------------------------------------------------------------------------- + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId ){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return singleEventId; + } + + private Integer patientId; + + public void setPatientId( Integer patientId ){ + this.patientId = patientId; + } + + public Integer getPatientId(){ + return this.patientId; + } + + private Patient patient; + public Patient getPatient() + { + return patient; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private boolean update; + + public void setUpdate( boolean update ) + { + this.update = update; + } + + public boolean getUpdate() + { + return this.update; + } + + private Integer instId; + + public void setInstId( Integer instId ) + { + this.instId = instId; + } + + public Integer getInstId() + { + return this.instId; + } + + private List dynForm = new ArrayList() ; + + public void setDynForm(List dynForm) { + this.dynForm = dynForm; + } + + public List getDynForm() + { + return dynForm; + } + + private String resultString; + + public void setResultString(String resultString){ + this.resultString = resultString; + } + + public String getResultString(){ + return this.resultString; + } + + private ArrayList programStageDataElements = new ArrayList(); + + public ArrayList getProgramStageDataElements(){ + return this.programStageDataElements; + } + + static final Comparator OrderBySortOrder = + new Comparator() { + public int compare(ProgramStageDataElement i1, ProgramStageDataElement i2) { + return i1.getSortOrder().compareTo(i2.getSortOrder()); + } + }; + + // ------------------------------------------------------------------------- + // Validation + // ------------------------------------------------------------------------- + + public class Validate { + private Integer _id; + private String _errormessage; + + public String getErrorMessage(){ + return this._errormessage; + } + public Integer getId(){ + return this._id; + } + + public Validate(Integer id, String errormessage) + { + this._id = id; + this._errormessage = errormessage; + } + + } + + private ArrayList validList = new ArrayList(); + + public ArrayList getValidList() + { + return this.validList; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + + Program program = programService.getProgram(singleEventId); + eventName = program.getName(); + + Patient patient = patientService.getPatient(patientId); + ProgramStage programStage = program.getProgramStages().iterator().next(); + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId); + + programStageDataElements = new ArrayList(programStage.getProgramStageDataElements()); + Collections.sort(programStageDataElements, OrderBySortOrder); + + // ------------------------------------------------------------------------- + // Validation + // ------------------------------------------------------------------------- + + boolean valid = true; + validList.clear(); + int i = 0; + for (ProgramStageDataElement programStageDataElement : programStageDataElements) { + + DataElement dataElement = programStageDataElement.getDataElement(); + String value = dynForm.get(i).trim(); + String type = dataElement.getType(); + String numbertype = dataElement.getNumberType(); + + if(value.isEmpty()) { + validList.add(new Validate(dataElement.getId(),i18n.getString( "is_required" ))); + valid = false; + + } else if(type.equals( DataElement.VALUE_TYPE_DATE)) { + if(!FormUtils.isDate( value )) { + validList.add(new Validate(dataElement.getId(), value+ " " +i18n.getString( "is_invalid_date" ))); + valid = false; + } + + } else if(type.equals( DataElement.VALUE_TYPE_STRING)) { + if(!value.matches("^[\\p{L}|\\s|0-9]*$")) { + validList.add(new Validate(dataElement.getId(), value+" "+i18n.getString( "is_invalid_string" ))); + valid = false; + } + + } else if(type.equals( DataElement.VALUE_TYPE_INT)) { + + if(numbertype.equals(DataElement.VALUE_TYPE_POSITIVE_INT)) + { + if(!FormUtils.isPositiveInteger( value )) { + validList.add(new Validate(dataElement.getId(), value+" "+i18n.getString( "is_invalid_positive_integer" ))); + valid = false; + } + } + + if(numbertype.equals(DataElement.VALUE_TYPE_NEGATIVE_INT)) + { + if(!FormUtils.isNegativeInteger( value )) { + validList.add(new Validate(dataElement.getId(), value+" "+i18n.getString( "is_invalid_negative_integer" ))); + valid = false; + } + } + + if(numbertype.equals(DataElement.VALUE_TYPE_INT)) + { + if(!FormUtils.isInteger( value )) { + validList.add(new Validate(dataElement.getId(), value+" "+i18n.getString( "is_invalid_integer" ))); + valid = false; + } + } + + if(numbertype.equals(DataElement.VALUE_TYPE_NUMBER)) + { + if(!FormUtils.isNumber( value )) { + validList.add(new Validate(dataElement.getId(), value+" "+i18n.getString( "is_invalid_number" ))); + valid = false; + } + } + + } else if(type.equals( DataElement.VALUE_TYPE_BOOL)) { + if(!FormUtils.isBoolean( value )) { + validList.add(new Validate(dataElement.getId(), value+" "+i18n.getString( "is_invalid_boolean" ))); + valid = false; + } + } + i++; + } + + if(valid) { + + if(!update) + { + ProgramInstance programInstance = new ProgramInstance(); + programInstance.setEnrollmentDate( new Date() ); + programInstance.setDateOfIncident( new Date() ); + programInstance.setProgram( program ); + programInstance.setPatient( patient ); + programInstance.setCompleted( false ); + programInstanceService.addProgramInstance( programInstance ); + + ProgramStageInstance programStageInstance = new ProgramStageInstance(); + programStageInstance.setProgramInstance(programInstance); + programStageInstance.setProgramStage(programStage); + programStageInstance.setDueDate(new Date()); + programStageInstance.setExecutionDate(new Date()); + programStageInstance.setCompleted(false); + programStageInstanceService.addProgramStageInstance(programStageInstance); + + i = 0; + for (ProgramStageDataElement programStageDataElement : programStageDataElements) { + DataElement dataElement = programStageDataElement.getDataElement(); + + PatientDataValue patientDataValue = new PatientDataValue(); + patientDataValue.setDataElement(dataElement); + patientDataValue.setProgramStageInstance(programStageInstance); + patientDataValue.setOrganisationUnit(organisationUnit); + patientDataValue.setValue(dynForm.get(i).trim()); + patientDataValueService.savePatientDataValue(patientDataValue); + i++; + } + } + else + { + ProgramInstance programInstance = programInstanceService.getProgramInstance(instId); + programStage = program.getProgramStages().iterator().next(); // Fetch first, There exists only 1! + ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(programInstance, programStage); + + i = 0; + for (ProgramStageDataElement programStageDataElement : programStageDataElements) { + PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue(programStageInstance, programStageDataElement.getDataElement(), organisationUnit); + patientDataValue.setValue(dynForm.get(i).trim()); + patientDataValueService.updatePatientDataValue(patientDataValue); + i++; + } + } + + if(update){ + setResultString("updateSingleEvent"); + }else{ + setResultString("newSingleEvent"); + } + return SUCCESS; + } else { + return ERROR; + } + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/EditBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/EditBeneficiaryAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/EditBeneficiaryAction.java 2011-12-02 17:39:56 +0000 @@ -0,0 +1,252 @@ +/* + * 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.singleevents.action; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeGroup; +import org.hisp.dhis.patient.PatientAttributeGroupService; +import org.hisp.dhis.patient.PatientAttributeOption; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class EditBeneficiaryAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private PatientAttributeGroupService patientAttributeGroupService; + + public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) + { + this.patientAttributeGroupService = patientAttributeGroupService; + } + + private PatientAttributeValueService patientAttributeValueService; + + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) + { + this.patientAttributeValueService = patientAttributeValueService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer patientId; + + public void setPatientId( Integer patientId ) + { + this.patientId = patientId; + } + + public Integer getPatientId() + { + return patientId; + } + + private Patient patient; + + public Patient getPatient(){ + return patient; + } + + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + private Integer organisationUnitId; + + public Integer getOrganisationUnitId(){ + return organisationUnitId; + } + + private String birthDate; + + public String getBirthDate() + { + return birthDate; + } + + private String registrationDate; + + public String getRegistrationDate(){ + return registrationDate; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private List attributeGroups; + + public List getAttributeGroups() + { + return attributeGroups; + } + + private Collection noGroupAttributes; + + public Collection getNoGroupAttributes() + { + return noGroupAttributes; + } + + private String dynForm[]; + + public void setDynForm(String[] dynForm) { + this.dynForm = dynForm; + } + + public String[] getDynForm() + { + return dynForm; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + + patient = patientService.getPatient(patientId); + + organisationUnit = patient.getOrganisationUnit(); + + organisationUnitId = organisationUnit.getId(); + + Date date = patient.getBirthDate(); + SimpleDateFormat DFyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); + + birthDate = DFyyyyMMdd.format(date); + + date = patient.getRegistrationDate(); + registrationDate = DFyyyyMMdd.format(date); + + noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); + + attributeGroups = new ArrayList( patientAttributeGroupService + .getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); + + int size = noGroupAttributes.size(); + + for (PatientAttributeGroup patientAttributeGroup : attributeGroups) { + size += patientAttributeGroup.getAttributes().size(); + } + + dynForm = new String[size]; + + int i = 0; + + for (PatientAttributeGroup patientAttributeGroup : attributeGroups) { + List patientAttributeList = patientAttributeGroup.getAttributes(); + for(PatientAttribute patientAttribute : patientAttributeList){ + PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ); + + try{ + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ){ + PatientAttributeOption option = attributeValue.getPatientAttributeOption(); + Integer id = option.getId(); + dynForm[i] = id.toString(); + }else if (attributeValue.getValue().equals("")){ + dynForm[i] = ""; + }else{ + dynForm[i] = attributeValue.getValue(); + } + }catch (NullPointerException e){ + dynForm[i] = ""; + } + i++; + } + } + + for (PatientAttribute patientAttribute : noGroupAttributes){ + PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ); + + try{ + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ){ + PatientAttributeOption option = attributeValue.getPatientAttributeOption(); + Integer id = option.getId(); + dynForm[i] = id.toString(); + }else if (attributeValue.getValue().equals("")){ + dynForm[i] = ""; + }else{ + dynForm[i] = attributeValue.getValue(); + } + }catch (NullPointerException e){ + dynForm[i] = ""; + } + i++; + } + + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetBeneficiaryChoicesAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetBeneficiaryChoicesAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetBeneficiaryChoicesAction.java 2011-11-03 11:59:25 +0000 @@ -0,0 +1,89 @@ +/* + * 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.singleevents.action; + +import org.hisp.dhis.program.ProgramService; +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class GetBeneficiaryChoicesAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + eventName = programService.getProgram(singleEventId).getName(); + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetRecentlyEditChoicesAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetRecentlyEditChoicesAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetRecentlyEditChoicesAction.java 2011-12-02 15:22:44 +0000 @@ -0,0 +1,109 @@ +/* + * 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.singleevents.action; +import org.hisp.dhis.program.ProgramService; + +import com.opensymphony.xwork2.Action; + +public class GetRecentlyEditChoicesAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return singleEventId; + } + + private String eventName; + + public String getEventName(){ + return eventName; + } + + private Integer patientId; + + public void setPatientId( Integer patientId ) + { + this.patientId = patientId; + } + + public Integer getPatientId(){ + return patientId; + } + + private Integer instId; + + public void setInstId( Integer instId ) + { + this.instId = instId; + } + + public Integer getInstId(){ + return instId; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + eventName = programService.getProgram(singleEventId).getName(); + return SUCCESS; + } + +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetRecentlyRegisteredSingleEventsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetRecentlyRegisteredSingleEventsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetRecentlyRegisteredSingleEventsAction.java 2011-12-02 15:22:44 +0000 @@ -0,0 +1,141 @@ +/* + * 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.singleevents.action; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class GetRecentlyRegisteredSingleEventsAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private ProgramInstanceService programInstanceService; + + public void setProgramInstanceService( ProgramInstanceService programInstanceService ) + { + this.programInstanceService = programInstanceService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + private List proInst = new ArrayList(); + + public List getProInst() { + return this.proInst; + } + + static final Comparator OrderByDate = + new Comparator() { + public int compare(ProgramInstance i1, ProgramInstance i2) { + return i2.getDateOfIncident().compareTo(i1.getDateOfIncident()); + } + }; + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + + OrganisationUnit org = organisationUnitService.getOrganisationUnit(organisationUnitId); + Program pro = programService.getProgram(singleEventId); + eventName = pro.getName(); + + proInst.clear(); + proInst = (List) programInstanceService.getProgramInstances(pro, org); + + if(!proInst.isEmpty()) + { + Collections.sort(proInst, OrderByDate); + if(proInst.size() > 6) + { + proInst = proInst.subList(0, 6); + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSelectOrgUnitSingleEventsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSelectOrgUnitSingleEventsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSelectOrgUnitSingleEventsAction.java 2011-11-26 21:31:43 +0000 @@ -0,0 +1,94 @@ +/* + * 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.singleevents.action; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.light.dataentry.utils.FormUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class GetSelectOrgUnitSingleEventsAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService(CurrentUserService currentUserService) { + this.currentUserService = currentUserService; + } + + private FormUtils formUtils; + + public void setFormUtils( FormUtils formUtils ) + { + this.formUtils = formUtils; + } + + public FormUtils getFormUtils() + { + return formUtils; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List organisationUnits = new ArrayList(); + + public List getOrganisationUnits() { + return organisationUnits; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + User user = currentUserService.getCurrentUser(); + + if ( user != null ) + { + organisationUnits = new ArrayList( user.getOrganisationUnits() ); + Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSingleEventChoicesAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSingleEventChoicesAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSingleEventChoicesAction.java 2011-11-01 18:33:48 +0000 @@ -0,0 +1,89 @@ +/* + * 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.singleevents.action; + +import org.hisp.dhis.program.ProgramService; +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class GetSingleEventChoicesAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + eventName = programService.getProgram(singleEventId).getName(); + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSingleEventsAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSingleEventsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/GetSingleEventsAction.java 2011-10-30 21:07:19 +0000 @@ -0,0 +1,83 @@ +/* + * 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.singleevents.action; + +import java.util.Collection; +import java.util.HashSet; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramService; +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class GetSingleEventsAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Collection singleEvents = new HashSet(); + + public Collection getSingleEvents() { + return singleEvents; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + boolean singleEvent = true; + singleEvents = programService.getPrograms(singleEvent); + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RegisterNewBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RegisterNewBeneficiaryAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RegisterNewBeneficiaryAction.java 2011-12-02 17:30:16 +0000 @@ -0,0 +1,146 @@ +/* + * 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.singleevents.action; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeGroup; +import org.hisp.dhis.patient.PatientAttributeGroupService; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; +import org.hisp.dhis.program.ProgramService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class RegisterNewBeneficiaryAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private PatientAttributeGroupService patientAttributeGroupService; + + public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) + { + this.patientAttributeGroupService = patientAttributeGroupService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + private List attributeGroups; + + public List getAttributeGroups() + { + return attributeGroups; + } + + private Collection noGroupAttributes; + + public Collection getNoGroupAttributes() + { + return noGroupAttributes; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + private String todayDate; + + public String getTodayDate(){ + SimpleDateFormat dateFormatYYYYMMDD = new SimpleDateFormat("yyyy-MM-dd"); + Date d = new Date(); + todayDate = dateFormatYYYYMMDD.format(d); + return todayDate; + } + + @Override + public String execute() { + + noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); + + attributeGroups = new ArrayList( patientAttributeGroupService + .getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); + + eventName = programService.getProgram(singleEventId).getName(); + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RegisterNewSingleEventAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RegisterNewSingleEventAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RegisterNewSingleEventAction.java 2011-12-02 15:22:44 +0000 @@ -0,0 +1,210 @@ +/* + * 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.singleevents.action; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.patientdatavalue.PatientDataValueService; +import org.hisp.dhis.program.Program; +import org.hisp.dhis.program.ProgramInstance; +import org.hisp.dhis.program.ProgramInstanceService; +import org.hisp.dhis.program.ProgramService; +import org.hisp.dhis.program.ProgramStage; +import org.hisp.dhis.program.ProgramStageDataElement; +import org.hisp.dhis.program.ProgramStageInstance; +import org.hisp.dhis.program.ProgramStageInstanceService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class RegisterNewSingleEventAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientDataValueService patientDataValueService; + + public void setPatientDataValueService( PatientDataValueService patientDataValueService ) + { + this.patientDataValueService = patientDataValueService; + } + + private ProgramStageInstanceService programStageInstanceService; + + public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService ) + { + this.programStageInstanceService = programStageInstanceService; + } + + private ProgramInstanceService programInstanceService; + + public void setProgramInstanceService( ProgramInstanceService programInstanceService ) + { + this.programInstanceService = programInstanceService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ){ + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + private Integer patientId; + + public Integer getPatientId(){ + return this.patientId; + } + + public void setPatientId(Integer patientId){ + this.patientId = patientId; + } + + private Integer instId; + + public void setInstId( Integer instId ) + { + this.instId = instId; + } + + public Integer getInstId() + { + return this.instId; + } + + private boolean update; + + public void setUpdate( boolean update ) + { + this.update = update; + } + + public boolean getUpdate() + { + return this.update; + } + + private List dynForm = new ArrayList(100); + + public List getDynForm() + { + return dynForm; + } + + private ArrayList programStageDataElements = new ArrayList(); + + public ArrayList getProgramStageDataElements(){ + return this.programStageDataElements; + } + + static final Comparator OrderBySortOrder = + new Comparator() { + public int compare(ProgramStageDataElement i1, ProgramStageDataElement i2) { + return i1.getSortOrder().compareTo(i2.getSortOrder()); + } + }; + + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + + // --------------------------------------------------------------------- + // Set Data for SingleEventForm + // --------------------------------------------------------------------- + + Program program = programService.getProgram(singleEventId); + eventName = program.getName(); + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(organisationUnitId); + ProgramStage programStage = program.getProgramStages().iterator().next(); // Fetch first, There exists only 1! + programStageDataElements = new ArrayList(programStage.getProgramStageDataElements()); + Collections.sort(programStageDataElements, OrderBySortOrder); + + dynForm.clear(); + + if(update) + { + ProgramInstance programInstance = programInstanceService.getProgramInstance(instId); + ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(programInstance, programStage); + + int i = 0; + for (ProgramStageDataElement programStageDataElement : programStageDataElements) { + dynForm.add(i,patientDataValueService.getPatientDataValue(programStageInstance, programStageDataElement.getDataElement(), organisationUnit).getValue()); + i++; + } + } + + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RenderResultPageAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RenderResultPageAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/RenderResultPageAction.java 2011-12-02 20:27:58 +0000 @@ -0,0 +1,120 @@ +/* + * 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.singleevents.action; + +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.program.ProgramService; +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class RenderResultPageAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private ProgramService programService; + + public void setProgramService( ProgramService programService ) + { + this.programService = programService; + } + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId(){ + return this.organisationUnitId; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + private Integer patientId; + + public void setPatientId( Integer patientId ){ + this.patientId = patientId; + } + + private String eventName; + + public String getEventName(){ + return this.eventName; + } + + private String patientName; + + public String getPatientName(){ + return this.patientName; + } + + private String resultString; + + public void setResultString(String resultString){ + this.resultString = resultString; + } + + public String getResultString(){ + return this.resultString; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + eventName = programService.getProgram(singleEventId).getName(); + patientName = patientService.getPatient(patientId).getFullName(); + return SUCCESS; + } +} === added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/UpdateBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/UpdateBeneficiaryAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/singleevents/action/UpdateBeneficiaryAction.java 2011-12-02 22:49:31 +0000 @@ -0,0 +1,725 @@ +/* + * 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.singleevents.action; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang.math.NumberUtils; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.light.dataentry.utils.FormUtils; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeGroup; +import org.hisp.dhis.patient.PatientAttributeGroupService; +import org.hisp.dhis.patient.PatientAttributeOption; +import org.hisp.dhis.patient.PatientAttributeOptionService; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Group1 Fall 2011 + */ +public class UpdateBeneficiaryAction implements Action { + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + private PatientService patientService; + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private PatientAttributeService patientAttributeService; + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + private PatientAttributeGroupService patientAttributeGroupService; + + public void setPatientAttributeGroupService( PatientAttributeGroupService patientAttributeGroupService ) + { + this.patientAttributeGroupService = patientAttributeGroupService; + } + + private PatientAttributeOptionService patientAttributeOptionService; + + public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) + { + this.patientAttributeOptionService = patientAttributeOptionService; + } + + private PatientAttributeValueService patientAttributeValueService; + + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) + { + this.patientAttributeValueService = patientAttributeValueService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer organisationUnitId; + + public void setOrganisationUnitId( Integer organisationUnitId ) + { + this.organisationUnitId = organisationUnitId; + } + + public Integer getOrganisationUnitId() + { + return this.organisationUnitId; + } + + private Integer patientId; + + public void setPatientId( Integer patientId ) + { + this.patientId = patientId; + } + + private Patient patient; + + public Patient getPatient() + { + return patient; + } + + private String fullName; + + public void setFullName( String fullName ) + { + this.fullName = fullName; + } + + private String birthDate; + + public void setBirthDate( String birthDate ) + { + this.birthDate = birthDate; + } + + public String getBirthDate() + { + return birthDate; + } + + private Character dobType; + + public void setDobType( Character dobType ) + { + this.dobType = dobType; + } + + private String gender; + + public void setGender( String gender ) + { + this.gender = gender; + } + + private String bloodGroup; + + public void setBloodGroup( String bloodGroup ){ + this.bloodGroup = bloodGroup; + } + + private String registrationDate; + + public void setRegistrationDate( String registrationDate ){ + this.registrationDate = registrationDate; + } + + public String getRegistrationDate() + { + return registrationDate; + } + + private List attributeGroups; + + public List getAttributeGroups() + { + return attributeGroups; + } + + private Collection noGroupAttributes; + + public Collection getNoGroupAttributes() + { + return noGroupAttributes; + } + + private String dynForm[]; + + public void setDynForm(String[] dynForm) { + this.dynForm = dynForm; + } + + public String[] getDynForm() + { + return dynForm; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + private Integer singleEventId; + + public void setSingleEventId( Integer singleEventId){ + this.singleEventId = singleEventId; + } + + public Integer getSingleEventId(){ + return this.singleEventId; + } + + // ------------------------------------------------------------------------- + // Validation + // ------------------------------------------------------------------------- + + private Date rD,bD; + + private boolean fullNameIsToLong; + private boolean invalidFullName; + private boolean invalidRegistrationDate; + private boolean invalidBirthDate; + private boolean noGender; + private boolean noDobType; + private boolean invalidDobType; + private boolean invalidBloodGroup; + private boolean invalidGender; + + private ArrayList validList = new ArrayList(); + + public ArrayList getValidList() + { + return this.validList; + } + + public boolean getFullNameIsToLong() + { + return fullNameIsToLong; + } + + public boolean getInvalidFullName() + { + return invalidFullName; + } + + public boolean getInvalidRegistrationDate() + { + return invalidRegistrationDate; + } + + public boolean getInvalidBirthDate() + { + return invalidBirthDate; + } + + public boolean getNoGender() + { + return noGender; + } + + public boolean getNoDobType() + { + return noDobType; + } + + public boolean getInvalidDobType() + { + return invalidDobType; + } + + public boolean getInvalidGender() + { + return invalidGender; + } + + public boolean getInvalidBloodGroup() + { + return invalidBloodGroup; + } + + private boolean validate() + { + boolean valid = true; + + if(validateStringLength(fullName,7,50) == false){ + fullNameIsToLong = true; + valid = false; + } + + if(validName(fullName) == false){ + invalidFullName = true; + valid = false; + } + + if(validateDateNotNull(rD) == false){ + invalidRegistrationDate = true; + valid = false; + } + + if(validateDateNotNull(bD) == false){ + invalidBirthDate = true; + valid = false; + } + + if(validateDropDown(gender) == false){ + noGender = true; + valid = false; + } + + if(validateDropDown(dobType) == false){ + noDobType = true; + valid = false; + } + + if(validateDobType(dobType) == false){ + invalidDobType = true; + valid = false; + } + + if(validateGender(gender) == false){ + invalidGender = true; + valid = false; + } + + if(validateBloodGroup(bloodGroup) == false){ + invalidBloodGroup = true; + valid = false; + } + + return valid; + } + + private boolean validateStringLength(String s, int min, int max) + { + return ((s.length() >= min) && (s.length() <= max)); + } + + private boolean validName(String s) + { + return (s.matches("^[\\p{L}|\\s]*$")); + } + + private boolean validateDateNotNull(Date d){ + if(d == null){ + return false; + }else{ + return true; + } + } + + private boolean validateDropDown(String s){ + if(s.equalsIgnoreCase("please_select")){ + return false; + }else{ + return true; + } + } + + private boolean validateDropDown(Character c){ + if(c.equals('p')){ + return false; + }else{ + return true; + } + } + + private boolean validateDobType(Character c) + { + if(c == 'D' || c == 'V'){ + return true; + }else{ + return false; + } + } + + private boolean validateGender(String s) + { + if(s.equals("M") || s.equals("F") || s.equals("T")){ + return true; + }else{ + return false; + } + } + + private boolean validateBloodGroup(String s) + { + if(s.matches("^\\w{1,2}\\-?\\+?$") || s.equalsIgnoreCase("please_select")){ + return true; + }else{ + return false; + } + } + + private boolean validateDynForm(String value, PatientAttribute patientAttribute){ + + boolean valid = true; + + String type = patientAttribute.getValueType(); + Integer id = patientAttribute.getId(); + + if(value.isEmpty()){ + if(patientAttribute.isMandatory()){ + validList.add(new Validate(id, i18n.getString( "is_required" ))); + valid = false; + } + }else if(type.equals("DATE")){ + if(!FormUtils.isDate( value )) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_date" ))); + valid = false; + } + }else if(type.equals("TEXT")){ + if(!value.matches("^[\\p{L}|\\s|0-9]*$")) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_string" ))); + valid = false; + } + }else if(type.equals("NUMBER")){ + if(!FormUtils.isNumber( value )) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_number" ))); + valid = false; + } + }else if(type.equals("YES/NO")){ + if(!FormUtils.isBoolean( value )) { + validList.add(new Validate(id, value+" "+i18n.getString( "is_invalid_boolean" ))); + valid = false; + } + }else if(type.equals("COMBO")){ + Set attributeOptions = patientAttribute.getAttributeOptions(); + boolean contains = false; + for(PatientAttributeOption attributeOption : attributeOptions){ + if(attributeOption.getId() == NumberUtils.toInt( value, 0 ) ){ + contains = true; + } + } + if(!contains){ + validList.add(new Validate(id, value)); + } + valid = contains; + } + + return valid; + } + + public class Validate { + private Integer _id; + private String _errormessage; + + public String getErrorMessage(){ + return this._errormessage; + } + public Integer getId(){ + return this._id; + } + + public Validate(Integer id, String errormessage) + { + this._id = id; + this._errormessage = errormessage; + } + + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() { + + fullNameIsToLong = false; + invalidFullName = false; + invalidRegistrationDate = false; + invalidBirthDate = false; + noGender = false; + noDobType = false; + invalidDobType = false; + invalidBloodGroup = false; + invalidGender = false; + + patient = patientService.getPatient(patientId); + + // --------------------------------------------------------------------- + // Dynamic form + // --------------------------------------------------------------------- + + List valuesForSave = new ArrayList(); + List valuesForUpdate = new ArrayList(); + Collection valuesForDelete = null; + + noGroupAttributes = patientAttributeService.getPatientAttributesNotGroup(); + + attributeGroups = new ArrayList( patientAttributeGroupService + .getAllPatientAttributeGroups() ); + Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() ); + + patient.getAttributes().clear(); + valuesForDelete = patientAttributeValueService.getPatientAttributeValues( patient ); + + boolean validInGroup = true; + PatientAttributeValue attributeValue = null; + validList.clear(); + int i = 0; + + //Attributes in groups + + for (PatientAttributeGroup patientAttributeGroup : attributeGroups) { + List patientAttributeList = patientAttributeGroup.getAttributes(); + for(PatientAttribute patientAttribute : patientAttributeList){ + + String value = dynForm[i]; + + if(!validateDynForm(value, patientAttribute)){ + validInGroup = false; + } + + if(validInGroup){ + + attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ); + + if ( !patient.getAttributes().contains( patientAttribute ) ) + { + patient.getAttributes().add( patientAttribute ); + } + + if ( attributeValue == null ) + { + attributeValue = new PatientAttributeValue(); + attributeValue.setPatient( patient ); + attributeValue.setPatientAttribute( patientAttribute ); + + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + } + else + { + attributeValue.setValue( value.trim() ); + } + valuesForSave.add( attributeValue ); + }else + { + boolean resetCombo = false; + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + }else{ + resetCombo = true; + } + } + else + { + attributeValue.setValue( value.trim() ); + } + valuesForUpdate.add( attributeValue ); + if(!resetCombo){ + valuesForDelete.remove( attributeValue ); + } + } + } + i++; + } + } + + //Attributes not in groups + + boolean validNoGroup = true; + + for (PatientAttribute patientAttribute : noGroupAttributes) { + String value = dynForm[i]; + + if(!validateDynForm(value, patientAttribute)){ + validNoGroup = false; + } + + if(validNoGroup){ + attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, patientAttribute ); + + if ( !patient.getAttributes().contains( patientAttribute ) ) + { + patient.getAttributes().add( patientAttribute ); + } + + if ( attributeValue == null ) + { + attributeValue = new PatientAttributeValue(); + attributeValue.setPatient( patient ); + attributeValue.setPatientAttribute( patientAttribute ); + + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + } + else + { + attributeValue.setValue( value.trim() ); + } + valuesForSave.add( attributeValue ); + }else + { + boolean resetCombo = false; + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( patientAttribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + }else{ + resetCombo = true; + } + } + else + { + attributeValue.setValue( value.trim() ); + } + valuesForUpdate.add( attributeValue ); + if(!resetCombo){ + valuesForDelete.remove( attributeValue ); + } + } + } + + i++; + } + + // --------------------------------------------------------------------- + // Set FirstName, MiddleName, LastName by FullName + // --------------------------------------------------------------------- + + fullName = fullName.trim(); + + int startIndex = fullName.indexOf( ' ' ); + int endIndex = fullName.lastIndexOf( ' ' ); + + String firstName = fullName.toString(); + String middleName = ""; + String lastName = ""; + + if ( fullName.indexOf( ' ' ) != -1 ) + { + firstName = fullName.substring( 0, startIndex ); + if ( startIndex == endIndex ) + { + middleName = ""; + lastName = fullName.substring( startIndex + 1, fullName.length() ); + } + else + { + middleName = fullName.substring( startIndex + 1, endIndex ); + lastName = fullName.substring( endIndex + 1, fullName.length() ); + } + } + + patient.setFirstName( firstName ); + patient.setMiddleName( middleName ); + patient.setLastName( lastName ); + + // --------------------------------------------------------------------- + // Set Other information for patient + // --------------------------------------------------------------------- + + patient.setGender( gender ); + patient.setDobType( dobType ); + patient.setIsDead( false ); + if(!bloodGroup.equalsIgnoreCase("please_select")){ + patient.setBloodGroup( bloodGroup ); + } + + birthDate = birthDate.trim(); + bD = format.parseDate( birthDate ); + patient.setBirthDate( bD ); + + registrationDate = registrationDate.trim(); + rD = format.parseDate( registrationDate ); + patient.setRegistrationDate( rD ); + + if((validate() == false)||(!validNoGroup)||(!validInGroup)){ + return ERROR; + }else{ + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId ); + patient.setOrganisationUnit( organisationUnit ); + //patientService.updatePatient(patient); + patientService.updatePatient( patient, 0, 0, valuesForSave, valuesForUpdate,valuesForDelete ); + return SUCCESS; + } + + } +} === 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 2011-11-01 18:28:36 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2011-12-02 16:45:53 +0000 @@ -97,5 +97,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2011-10-27 17:40:17 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties 2011-12-06 22:23:13 +0000 @@ -36,3 +36,62 @@ validation_rule_violation_warnings = Validation Rule Violation Warnings minmax_violation_warnings = Min/Max Violation Warnings type_violation_errors = Type Violation Errors + +# Single events + +edit_beneficiary = Edit Beneficiary +find_benecifiary = Find beneficiary +new_beneficiary= New beneficiary +single_events = Single Events +single_event = Single Event +back = Back +date_of_registration = Date of Registration (yyyy-MM-dd) +date_of_birth = Date of Birth (yyyy-MM-dd) +full_name = Full Name +gender = Gender +select_gender = please select a gender +select_dob = please select a DOB type +please_select = [Please Select] +male = Male +female = Female +transgender = Transgender +dob_type = DOB type +verified = Verified +declared = Declared +blood_group = Blood Group +bg_a_pluss = A+ +bg_a_minus = A- +bg_b_pluss = B+ +bg_b_minus = B- +bg_o_pluss = O+ +bg_o_minus = O- +bg_ab_pluss = AB+ +bg_ab_minus = AB- +recently_registered = Recently Registered +recently_registered_options = Recently Registered options +edit_person_details = Edit Person Details +edit_single_event_details = Edit Single Event Details +register = Register +register_new_single_event = Register a new single event +available_single_events = Available single events +result = Result +submit = Submit +single_event_options = Single Event options +beneficiary_options = Beneficiary options +yes = Yes +no = No +registered_to_beneficiary = registered to beneficiary +beneficiary = Beneficiary +was_updated = was updated +was_added_to_beneficiary = was added to beneficiary + +# validation messages + +is_invalid_string = is not a valid string +is_required = is a required field + +is_invalid_name_length = the name must be between 7 and 50 characters +is_invalid_name = is not a valid name +is_invalid_gender = is not a valid gender +is_invalid_dob_type = is not a valid dob type +is_invalid_blood_group = is not a valid blood group === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2011-11-01 15:01:22 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml 2011-12-06 22:23:13 +0000 @@ -90,6 +90,76 @@ /mobile/index.action + + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/selectOrgUnitSingleEvents.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/singleEvents.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/singleEventChoices.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/beneficiaryChoices.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/newBeneficiary.vm + + + + /mobile/newSingleEvent.action?organisationUnitId=${organisationUnitId}&patientId=${patientId}&singleEventId=${singleEventId}&update=false&resultString=newSingleEvent + /dhis-web-light/main.vm + /dhis-web-light/singleevents/newBeneficiary.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/newSingleEvent.vm + + + + /mobile/resultPage.action?organisationUnitId=${organisationUnitId}&patientId=${patientId}&singleEventId=${singleEventId}&resultString=${resultString} + /dhis-web-light/main.vm + /dhis-web-light/singleevents/newSingleEvent.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/singleEventResultPage.vm + + + + /mobile/resultPage.action?organisationUnitId=${organisationUnitId}&patientId=${patient.getId()}&singleEventId=${singleEventId}&resultString=updateBeneficiary + /dhis-web-light/main.vm + /dhis-web-light/singleevents/editBeneficiary.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/editBeneficiary.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/recentlyRegisteredSingleEvents.vm + + + + /dhis-web-light/main.vm + /dhis-web-light/singleevents/recentlyEditChoices.vm + - \ No newline at end of file + === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm' --- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm 2011-10-14 11:42:11 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm 2011-12-06 22:23:13 +0000 @@ -8,6 +8,13 @@

+

Experimental

+

+

+

+