=== added directory 'local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry' === added directory 'local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action' === added directory 'local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient' === added file 'local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java' --- local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2012-08-10 10:44:21 +0000 @@ -0,0 +1,421 @@ +/* + * Copyright (c) 2004-2009, 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.caseentry.action.patient; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.caseentry.idgen.PatientIdentifierGenerator; +import org.hisp.dhis.caseentry.state.SelectedStateManager; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeOption; +import org.hisp.dhis.patient.PatientAttributeOptionService; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientIdentifier; +import org.hisp.dhis.patient.PatientIdentifierService; +import org.hisp.dhis.patient.PatientIdentifierType; +import org.hisp.dhis.patient.PatientIdentifierTypeService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.phieusanh.action.OrganisationUnitService; +import org.springframework.beans.factory.annotation.Autowired; + +import com.opensymphony.xwork2.Action; + +/** + * @author Abyot Asalefew Gizaw + * @version $Id$ + */ +public class AddPatientAction + implements Action +{ + public static final String PREFIX_ATTRIBUTE = "attr"; + + public static final String PREFIX_IDENTIFIER = "iden"; + + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private I18nFormat format; + + private PatientService patientService; + + private PatientIdentifierService patientIdentifierService; + + private PatientIdentifierTypeService patientIdentifierTypeService; + + private OrganisationUnitSelectionManager selectionManager; + + private SelectedStateManager selectedStateManager; + + private PatientAttributeService patientAttributeService; + + private PatientAttributeOptionService patientAttributeOptionService; + + @Autowired + private OrganisationUnitService organisationUnitService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String fullName; + + private String birthDate; + + private Integer age; + + private Boolean verified; + + private String gender; + + private String phoneNumber; + + private String registrationDate; + + private boolean underAge; + + private Integer representativeId; + + private Integer relationshipTypeId; + + private String message; + + private Integer registeredUnit; + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + // --------------------------------------------------------------------- + // Prepare values + // --------------------------------------------------------------------- + + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( registeredUnit ); + + Patient patient = new Patient(); + + verified = (verified == null) ? false : verified; + + // --------------------------------------------------------------------- + // 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.setIsDead( false ); + patient.setPhoneNumber( phoneNumber ); + patient.setUnderAge( underAge ); + patient.setOrganisationUnit( organisationUnit ); + + Character dobType = (verified) ? 'V' : 'D'; + + if ( !verified && age != null ) + { + dobType = 'A'; + } + + if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) + { + birthDate = birthDate.trim(); + patient.setBirthDate( format.parseDate( birthDate ) ); + } + else + { + patient.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR ); + } + + patient.setDobType( dobType ); + + patient.setRegistrationDate( format.parseDate( registrationDate ) ); + + // ----------------------------------------------------------------------------- + // Prepare Patient Identifiers + // ----------------------------------------------------------------------------- + + HttpServletRequest request = ServletActionContext.getRequest(); + + Collection identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + + String value = null; + + PatientIdentifier pIdentifier = null; + + if ( identifierTypes != null && identifierTypes.size() > 0 ) + { + for ( PatientIdentifierType identifierType : identifierTypes ) + { + + value = request.getParameter( PREFIX_IDENTIFIER + identifierType.getId() ); + + if ( StringUtils.isNotBlank( value ) ) + { + pIdentifier = new PatientIdentifier(); + pIdentifier.setIdentifierType( identifierType ); + pIdentifier.setPatient( patient ); + pIdentifier.setIdentifier( value.trim() ); + patient.getIdentifiers().add( pIdentifier ); + } + } + } + + // -------------------------------------------------------------------------------- + // Generate system id with this format : + // (BirthDate)(Gender)(XXXXXX)(checkdigit) + // PatientIdentifierType will be null + // -------------------------------------------------------------------------------- + + String identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() ); + + PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); + while ( systemGenerateIdentifier != null ) + { + identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() ); + systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); + } + + systemGenerateIdentifier = new PatientIdentifier(); + systemGenerateIdentifier.setIdentifier( identifier ); + systemGenerateIdentifier.setPatient( patient ); + + patient.getIdentifiers().add( systemGenerateIdentifier ); + + selectedStateManager.clearListAll(); + selectedStateManager.clearSearchingAttributeId(); + selectedStateManager.setSearchText( systemGenerateIdentifier.getIdentifier() ); + + // ----------------------------------------------------------------------------- + // Prepare Patient Attributes + // ----------------------------------------------------------------------------- + + Collection attributes = patientAttributeService.getAllPatientAttributes(); + + List patientAttributeValues = new ArrayList(); + + PatientAttributeValue attributeValue = null; + + if ( attributes != null && attributes.size() > 0 ) + { + for ( PatientAttribute attribute : attributes ) + { + value = request.getParameter( PREFIX_ATTRIBUTE + attribute.getId() ); + if ( StringUtils.isNotBlank( value ) ) + { + if ( !patient.getAttributes().contains( attribute ) ) + { + patient.getAttributes().add( attribute ); + } + + attributeValue = new PatientAttributeValue(); + attributeValue.setPatient( patient ); + attributeValue.setPatientAttribute( attribute ); + + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService + .get( NumberUtils.toInt( value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + else + { + // Someone deleted this option ... + } + } + else + { + attributeValue.setValue( value.trim() ); + } + + patientAttributeValues.add( attributeValue ); + } + } + } + + // ------------------------------------------------------------------------- + // Save patient + // ------------------------------------------------------------------------- + + Integer id = patientService.createPatient( patient, representativeId, relationshipTypeId, + patientAttributeValues ); + + message = id + "_" + systemGenerateIdentifier.getIdentifier(); + + return SUCCESS; + } + + // ----------------------------------------------------------------------------- + // Getter/Setter + // ----------------------------------------------------------------------------- + + public String getMessage() + { + return message; + } + + public void setVerified( Boolean verified ) + { + this.verified = verified; + } + + public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) + { + this.patientIdentifierTypeService = patientIdentifierTypeService; + } + + public void setBirthDate( String birthDate ) + { + this.birthDate = birthDate; + } + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) + { + this.patientIdentifierService = patientIdentifierService; + } + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + public void setFullName( String fullName ) + { + this.fullName = fullName; + } + + public void setAge( Integer age ) + { + this.age = age; + } + + public void setRegistrationDate( String registrationDate ) + { + this.registrationDate = registrationDate; + } + + public void setGender( String gender ) + { + this.gender = gender; + } + + public void setPhoneNumber( String phoneNumber ) + { + this.phoneNumber = phoneNumber; + } + + public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) + { + this.patientAttributeOptionService = patientAttributeOptionService; + } + + public void setRepresentativeId( Integer representativeId ) + { + this.representativeId = representativeId; + } + + public void setRelationshipTypeId( Integer relationshipTypeId ) + { + this.relationshipTypeId = relationshipTypeId; + } + + public void setUnderAge( boolean underAge ) + { + this.underAge = underAge; + } + + public void setRegisteredUnit( Integer registeredUnit ) + { + this.registeredUnit = registeredUnit; + } +} === added file 'local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java' --- local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2012-08-10 10:44:21 +0000 @@ -0,0 +1,446 @@ +/* + * Copyright (c) 2004-2009, 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.caseentry.action.patient; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.struts2.ServletActionContext; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.patient.Patient; +import org.hisp.dhis.patient.PatientAttribute; +import org.hisp.dhis.patient.PatientAttributeOption; +import org.hisp.dhis.patient.PatientAttributeOptionService; +import org.hisp.dhis.patient.PatientAttributeService; +import org.hisp.dhis.patient.PatientIdentifier; +import org.hisp.dhis.patient.PatientIdentifierService; +import org.hisp.dhis.patient.PatientIdentifierType; +import org.hisp.dhis.patient.PatientIdentifierTypeService; +import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patientattributevalue.PatientAttributeValue; +import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Abyot Asalefew Gizaw + * @version $Id$ + */ +public class UpdatePatientAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private I18nFormat format; + + private PatientService patientService; + + private PatientAttributeService patientAttributeService; + + private PatientAttributeValueService patientAttributeValueService; + + private PatientIdentifierService patientIdentifierService; + + private PatientIdentifierTypeService patientIdentifierTypeService; + + private OrganisationUnitSelectionManager selectionManager; + + private PatientAttributeOptionService patientAttributeOptionService; + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer id; + + private String fullName; + + private String birthDate; + + private boolean isDead; + + private String deathDate; + + private Integer age; + + private Boolean verified; + + private String gender; + + private String phoneNumber; + + private boolean underAge; + + private Integer representativeId; + + private Integer relationshipTypeId; + + private Character dobType; + + private Integer registeredUnit; + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Patient patient; + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( registeredUnit ); + + patient = patientService.getPatient( id ); + + verified = (verified == null) ? false : verified; + + // --------------------------------------------------------------------- + // Set FirstName, MiddleName, LastName by FullName + // --------------------------------------------------------------------- + + 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.setIsDead( isDead ); + patient.setPhoneNumber( phoneNumber ); + + if ( deathDate != null ) + { + deathDate = deathDate.trim(); + patient.setDeathDate( format.parseDate( deathDate ) ); + } + + patient.setUnderAge( underAge ); + patient.setOrganisationUnit( organisationUnit ); + + if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) + { + birthDate = birthDate.trim(); + patient.setBirthDate( format.parseDate( birthDate ) ); + } + else + { + patient.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR ); + } + + patient.setDobType( dobType ); + + // ------------------------------------------------------------------------------------- + // Save PatientIdentifier + // ------------------------------------------------------------------------------------- + + HttpServletRequest request = ServletActionContext.getRequest(); + + String value = null; + + Collection identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); + + PatientIdentifier identifier = null; + + if ( identifierTypes != null && identifierTypes.size() > 0 ) + { + for ( PatientIdentifierType identifierType : identifierTypes ) + { + value = request.getParameter( AddPatientAction.PREFIX_IDENTIFIER + identifierType.getId() ); + + identifier = patientIdentifierService.getPatientIdentifier( identifierType, patient ); + + if ( StringUtils.isNotBlank( value ) ) + { + value = value.trim(); + + if ( identifier == null ) + { + identifier = new PatientIdentifier(); + identifier.setIdentifierType( identifierType ); + identifier.setPatient( patient ); + identifier.setIdentifier( value ); + patient.getIdentifiers().add( identifier ); + } + else + { + identifier.setIdentifier( value ); + patient.getIdentifiers().add( identifier ); + } + } + else if ( identifier != null ) + { + patient.getIdentifiers().remove( identifier ); + // patientIdentifierService.deletePatientIdentifier( + // identifier ); + } + } + } + + // -------------------------------------------------------------------------------------------------------- + // Save Patient Attributes + // ----------------------------------------------------------------------------------------------------- + + Collection attributes = patientAttributeService.getAllPatientAttributes(); + + List valuesForSave = new ArrayList(); + List valuesForUpdate = new ArrayList(); + Collection valuesForDelete = null; + + PatientAttributeValue attributeValue = null; + + if ( attributes != null && attributes.size() > 0 ) + { + patient.getAttributes().clear(); + valuesForDelete = patientAttributeValueService.getPatientAttributeValues( patient ); + + for ( PatientAttribute attribute : attributes ) + { + value = request.getParameter( AddPatientAction.PREFIX_ATTRIBUTE + attribute.getId() ); + + if ( StringUtils.isNotBlank( value ) ) + { + attributeValue = patientAttributeValueService.getPatientAttributeValue( patient, attribute ); + + if ( !patient.getAttributes().contains( attribute ) ) + { + patient.getAttributes().add( attribute ); + } + + if ( attributeValue == null ) + { + attributeValue = new PatientAttributeValue(); + attributeValue.setPatient( patient ); + attributeValue.setPatientAttribute( attribute ); + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( + value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + else + { + // This option was deleted ??? + } + } + else + { + attributeValue.setValue( value.trim() ); + } + valuesForSave.add( attributeValue ); + } + else + { + if ( PatientAttribute.TYPE_COMBO.equalsIgnoreCase( attribute.getValueType() ) ) + { + PatientAttributeOption option = patientAttributeOptionService.get( NumberUtils.toInt( + value, 0 ) ); + if ( option != null ) + { + attributeValue.setPatientAttributeOption( option ); + attributeValue.setValue( option.getName() ); + } + else + { + // This option was deleted ??? + } + } + else + { + attributeValue.setValue( value.trim() ); + } + valuesForUpdate.add( attributeValue ); + valuesForDelete.remove( attributeValue ); + } + } + } + } + + patientService.updatePatient( patient, representativeId, relationshipTypeId, valuesForSave, valuesForUpdate, + valuesForDelete ); + + return SUCCESS; + } + + // ----------------------------------------------------------------------------- + // Getter/Setter + // ----------------------------------------------------------------------------- + + public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) + { + this.patientIdentifierTypeService = patientIdentifierTypeService; + } + + public void setDobType( Character dobType ) + { + this.dobType = dobType; + } + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + public void setPatientService( PatientService patientService ) + { + this.patientService = patientService; + } + + public void setPatientAttributeService( PatientAttributeService patientAttributeService ) + { + this.patientAttributeService = patientAttributeService; + } + + public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) + { + this.patientAttributeValueService = patientAttributeValueService; + } + + public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService ) + { + this.patientIdentifierService = patientIdentifierService; + } + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + public void setId( Integer id ) + { + this.id = id; + } + + public void setDead( boolean isDead ) + { + this.isDead = isDead; + } + + public void setDeathDate( String deathDate ) + { + this.deathDate = deathDate; + } + + public void setFullName( String fullName ) + { + this.fullName = fullName; + } + + public void setBirthDate( String birthDate ) + { + this.birthDate = birthDate; + } + + public void setGender( String gender ) + { + this.gender = gender; + } + + public void setPhoneNumber( String phoneNumber ) + { + this.phoneNumber = phoneNumber; + } + + public Patient getPatient() + { + return patient; + } + + public void setAge( Integer age ) + { + this.age = age; + } + + public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) + { + this.patientAttributeOptionService = patientAttributeOptionService; + } + + public void setUnderAge( boolean underAge ) + { + this.underAge = underAge; + } + + public void setRepresentativeId( Integer representativeId ) + { + this.representativeId = representativeId; + } + + public void setRelationshipTypeId( Integer relationshipTypeId ) + { + this.relationshipTypeId = relationshipTypeId; + } + + public void setVerified( Boolean verified ) + { + this.verified = verified; + } + + public void setRegisteredUnit( Integer registeredUnit ) + { + this.registeredUnit = registeredUnit; + } +} === removed file 'local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/phieusanh/action/ReregisterPatientLocationAction.java' --- local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/phieusanh/action/ReregisterPatientLocationAction.java 2012-06-28 08:17:52 +0000 +++ local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/phieusanh/action/ReregisterPatientLocationAction.java 1970-01-01 00:00:00 +0000 @@ -1,97 +0,0 @@ -package org.hisp.dhis.phieusanh.action; - -/* - * Copyright (c) 2004-2012, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -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 com.opensymphony.xwork2.Action; - -/** - * @author Dang Duy Hieu - * @version $Id$ - */ -public class ReregisterPatientLocationAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private PatientService patientService; - - public void setPatientService( PatientService patientService ) - { - this.patientService = patientService; - } - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - private Integer patientId; - - public void setPatientId( Integer patientId ) - { - this.patientId = patientId; - } - - private Integer newUnitId; - - public void setNewUnitId( Integer newUnitId ) - { - this.newUnitId = newUnitId; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - OrganisationUnit newUnit = organisationUnitService.getOrganisationUnit( newUnitId ); - - Patient patient = patientService.getPatient( patientId ); - - patient.setOrganisationUnit( newUnit ); - - patientService.savePatient( patient ); - - return SUCCESS; - } -} === added file 'local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/javascript/patient.js' --- local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/javascript/patient.js 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/javascript/patient.js 2012-08-10 10:44:21 +0000 @@ -0,0 +1,53 @@ +function addPatient() +{ + var registeredUnit = getFieldValue( 'wardLevel' ); + + if ( registeredUnit && registeredUnit != -1 ) + { + var args = getParamsForDiv('editPatientDiv'); + args += "registeredUnit=" + registeredUnit; + + $.ajax ({ + type: "POST", + url: 'addPatient.action', + data: args, + success: function(json) + { + var patientId = json.message.split('_')[0]; + var systemIdentifierId = json.message.split('_')[1]; + + jQuery('#advSearchBox0 [id="searchText"]').val( systemIdentifierId ); + statusSearching = 1; + + showProgramEnrollmentSelectForm( patientId ); + jQuery('#resultSearchDiv').dialog('close'); + } + }); + } else { + showWarningMessage( i18n_please_select_address ); + } + + return false; +} + +function updatePatient() +{ + var registeredUnit = getFieldValue( 'wardLevel' ); + + if ( registeredUnit && registeredUnit != -1 ) + { + var args = getParamsForDiv('editPatientDiv'); + args += "registeredUnit=" + registeredUnit; + + $.ajax( { + type: "POST", + url: 'updatePatient.action', + data: args, + success: function( json ) { + showProgramEnrollmentSelectForm( getFieldValue('id') ); + } + }); + } else { + showWarningMessage( i18n_please_select_address ); + } +} \ No newline at end of file === added file 'local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/patientForm.vm' --- local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/patientForm.vm 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/patientForm.vm 2012-08-10 10:44:21 +0000 @@ -0,0 +1,173 @@ +## Macro for generating the jQuery validation rules +#macro( validate $type $require ) + #if( $type == "NUMBER" ) + {validate:{ number:true #if($require), required:true #end }} + #elseif( $require ) + {validate:{required:true}} + #end +#end + + + + + + + + + + + $i18n.getString( "demographics" ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #parse ( "dhis-web-caseentry/secondUnitForPhieuSanh.vm" ) + + + + + + + + + + + + + $i18n.getString("has_guardian") + + + + + + + + + + + +#if( $identifierTypes.size() > 0) +   + $i18n.getString( "patient_identifiers" ) + #foreach ($identifierType in $identifierTypes) + #if( $identifierType && $identifierType.program ) + #else + + + + + + + #end + #end +#end + + +#foreach ($attributeGroup in $attributeGroups ) +   + $attributeGroup.name + #foreach($attribute in $attributeGroup.attributes ) + #if( $!attribute && $attribute.program ) + #elseif( $!attribute) + + + + #if( $attribute.valueType == "YES/NO" ) + + #elseif( $attribute.valueType == "DATE" ) + + + #elseif( $attribute.valueType == "COMBO" ) + + #else + + #end + + + #end + #end +#end + + + +  +#if ( $noGroupAttributes && $noGroupAttributes.size() > 0) + $i18n.getString( "other_details" ) + #foreach($attribute in $noGroupAttributes ) + #if( $!attribute && $attribute.program ) + #elseif( $!attribute) + + + + #if( $attribute.valueType == "YES/NO" ) + + #elseif( $attribute.valueType == "DATE" ) + + + #elseif( $attribute.valueType == "COMBO" ) + + #else + + #end + + + #end + #end +#end === modified file 'local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/secondUnitForPhieuSanh.vm' --- local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/secondUnitForPhieuSanh.vm 2012-07-05 07:43:01 +0000 +++ local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/secondUnitForPhieuSanh.vm 2012-08-10 10:44:21 +0000 @@ -49,40 +49,12 @@ } ); } - function addPatient( newUnitId ) - { - if ( newUnitId && newUnitId != -1 ) - { - jQuery.postUTF8( '../dhis-web-caseentry/addPatient.action', - { - fullName: getFieldValue( 'fullName' ), - age: getFieldValue( 'age' ) - }, function( json ) - { - if ( json.response == "success" ) - { - jQuery.get( '../dhis-web-phieusanh/registerPatientLocation.action', - { - patientId: json.message.split( "_" ), - newUnitId: newUnitId - }, function( json ) - { - if ( json.response == "success" ) { - showSuccessMessage( i18n_register_patient_successfully ); - } - } ); - } - } ); - } else { - showErrorMessage( i18n_please_select_unit ); - } - } - var i18n_label = '$encoder.jsEscape( $i18n.getString( "select_orgunit" ) , "'" )'; var i18n_please_select_unit = '$encoder.jsEscape( $i18n.getString( "please_select_unit" ) , "'" )'; var i18n_register_patient_successfully = '$encoder.jsEscape( $i18n.getString( "register_patient_successfully" ) , "'" )'; + var i18n_please_select_address = '$encoder.jsEscape( $i18n.getString( "please_select_address" ) , "'" )'; - - - \ No newline at end of file +
+
+ \ No newline at end of file