dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18607
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7895: local vn - Implemented the two org-units form in patientForm.vm
------------------------------------------------------------
revno: 7895
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-08-10 17:44:21 +0700
message:
local vn - Implemented the two org-units form in patientForm.vm
removed:
local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/phieusanh/action/ReregisterPatientLocationAction.java
added:
local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/
local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/
local/vn/dhis-web-phieusanh/src/main/java/org/hisp/dhis/caseentry/action/patient/
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/UpdatePatientAction.java
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/patientForm.vm
modified:
local/vn/dhis-web-phieusanh/src/main/webapp/dhis-web-phieusanh/secondUnitForPhieuSanh.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<PatientIdentifierType> 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<PatientAttribute> attributes = patientAttributeService.getAllPatientAttributes();
+
+ List<PatientAttributeValue> patientAttributeValues = new ArrayList<PatientAttributeValue>();
+
+ 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<PatientIdentifierType> 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<PatientAttribute> attributes = patientAttributeService.getAllPatientAttributes();
+
+ List<PatientAttributeValue> valuesForSave = new ArrayList<PatientAttributeValue>();
+ List<PatientAttributeValue> valuesForUpdate = new ArrayList<PatientAttributeValue>();
+ Collection<PatientAttributeValue> 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
+
+<tr>
+ <td class='text-column'><label for="registration_date">$i18n.getString( "registration_date" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column" colspan='2'>
+ <input type="text" id="registrationDate" name="registrationDate" class="{validate:{required:true}}"/>
+ <script type="text/javascript">
+ datePickerValid( 'registrationDate', true );
+ </script>
+ </td>
+</tr>
+
+<tr>
+ <th colspan="2" class="heading-column">$i18n.getString( "demographics" )</th>
+</tr>
+<tr>
+ <td class='text-column'><label for="fullName">$i18n.getString( "full_name" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column">
+ <input type="text" id="fullName" name="fullName" class="{validate:{required:true, unicodechars:true, rangelength:[7,50]}}"/>
+ </td>
+</tr>
+
+<tr>
+ <td class='text-column'><label for="gender">$i18n.getString( "gender" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column">
+ <select id="gender" name="gender" class="{validate:{required:true}}">
+ <option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
+ <option value="M" >$i18n.getString( "male" )</option>
+ <option value="F">$i18n.getString( "female" )</option>
+ <option value="T">$i18n.getString( "transgender" )</option>
+ </select>
+ </td>
+</tr>
+
+<tr>
+ <td class='text-column'><label for="birthDate">$i18n.getString( "date_of_birth" )<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+ <td class="input-column">
+ <select id='dobType' name="dobType" style='width:120px' onchange='dobTypeOnChange("patientForm")' >
+ <option value="V" selected>$i18n.getString( "verified" )</option>
+ <option value="D" >$i18n.getString( "declared" )</option>
+ <option value="A" >$i18n.getString( "approximated" )</option>
+ </select>
+ <input type="text" id="age" name="age" placeholder="$i18n.getString('please_enter_age_in_year')" class="{validate:{number:true}}" style="width:136px;display:none;" />
+ <input type="text" id="birthDate" name="birthDate" style='width:136px;' />
+ <input id="memberValidator" class="hidden {validate:{required:true}}"/>
+ </td>
+</tr>
+
+<tr>
+ <td class='text-column'><label for="address">$i18n.getString( "address" )</label></td>
+ <td>
+ #parse ( "dhis-web-caseentry/secondUnitForPhieuSanh.vm" )
+ </td>
+</tr>
+
+<tr>
+ <td class='text-column'><label for="phoneNumber">$i18n.getString( "phone_number" )</label></td>
+ <td class="input-column">
+ <input type="text" id="phoneNumber" name="phoneNumber" />
+ </td>
+</tr>
+
+<!-- UNDERAGE -->
+<tr id='underAgeDiv'>
+ <td class='text-column'>$i18n.getString("has_guardian")</td>
+ <td>
+ <input type="checkbox" name="underAge" id="underAge" onclick="toggleUnderAge(this);" value="true"/>
+ </td>
+</tr>
+
+<tr>
+ <td></td>
+ <td><input type="button" class='button' id='checkDuplicateBtn' name='checkDuplicateBtn' value="$i18n.getString('check_duplicate')" /></td>
+</tr>
+
+<!--IDENTIFIERS -->
+#if( $identifierTypes.size() > 0)
+ <tr><td colspan="2"> </td></tr>
+ <tr><th colspan="2" class="heading-column">$i18n.getString( "patient_identifiers" )</th></tr>
+ #foreach ($identifierType in $identifierTypes)
+ #if( $identifierType && $identifierType.program )
+ #else
+ <tr>
+ <td class='text-column'><label>$identifierType.name #if($identifierType.mandatory == true )<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
+ <td class="input-column">
+ <input type="text" id="iden$identifierType.id" name="iden$identifierType.id" data="{related:$identifierType.related}" class="{validate:{required:$identifierType.mandatory, #if($!identifierType.noChars) maxlength:$identifierType.noChars, #end #if($identifierType.type=='number') number:true #elseif($!identifierType.type=='letter') lettersonly:true #end }}" />
+ </td>
+ </tr>
+ #end
+ #end
+#end
+
+<!-- ATTRIBUTES IN GROUPS -->
+#foreach ($attributeGroup in $attributeGroups )
+ <tr><td> </td></tr>
+ <tr><th colspan="2" class="heading-column">$attributeGroup.name</th></tr>
+ #foreach($attribute in $attributeGroup.attributes )
+ #if( $!attribute && $attribute.program )
+ #elseif( $!attribute)
+ <tr>
+ <td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
+ <td class="input-column">
+ #if( $attribute.valueType == "YES/NO" )
+ <select id="attr$attribute.id" name="attr$attribute.id">
+ <option value="" selected="selected">[$i18n.getString( "please_select" )]</option>
+ <option value="true">$i18n.getString( "yes" )</option>
+ <option value="false">$i18n.getString( "no" )</option>
+ </select>
+ #elseif( $attribute.valueType == "DATE" )
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class=' #validate( "default" $attribute.mandatory )'/>
+ <script type="text/javascript">
+ datePickerValid( 'attr$attribute.id' );
+ </script>
+ #elseif( $attribute.valueType == "COMBO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )'>
+ <option value="">[$i18n.getString( "please_select" )]</option>
+ #foreach ($option in $attribute.attributeOptions )
+ <option value="$option.id" >$option.name</option>
+ #end
+ </select>
+ #else
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$attribute.mandatory #if($attribute.valueType=='NUMBER'),number:true #end }}" />
+ #end
+ </td>
+ </tr>
+ #end
+ #end
+#end
+
+<!-- ATTRIBUTES NOT IN GROUPS -->
+
+<tr><td> </td></tr>
+#if ( $noGroupAttributes && $noGroupAttributes.size() > 0)
+ <tr><th colspan="2" class="heading-column">$i18n.getString( "other_details" )</th></tr>
+ #foreach($attribute in $noGroupAttributes )
+ #if( $!attribute && $attribute.program )
+ #elseif( $!attribute)
+ <tr>
+ <td class='text-column'><label>$attribute.name #if($attribute.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em> #end</label></td>
+ <td class="input-column" >
+ #if( $attribute.valueType == "YES/NO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" colspan='2' >
+ <option value="" >[$i18n.getString( "please_select" )]</option>
+ <option value="true">$i18n.getString( "yes" )</option>
+ <option value="false" >$i18n.getString( "no" )</option>
+ </select>
+ #elseif( $attribute.valueType == "DATE" )
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )' />
+ <script type="text/javascript">
+ datePickerValid( 'attr$attribute.id' );
+ </script>
+ #elseif( $attribute.valueType == "COMBO" )
+ <select id="attr$attribute.id" name="attr$attribute.id" class='#validate( "default" $attribute.mandatory )'>
+ <option value="">[$i18n.getString( "please_select" )]</option>
+ #foreach ($option in $attribute.attributeOptions )
+ <option value="$option.id" >$option.name</option>
+ #end
+ </select>
+ #else
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" class="{validate:{required:$attribute.mandatory #if($attribute.valueType=='NUMBER'),number:true #end }}" />
+ #end
+ </td>
+ </tr>
+ #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" ) , "'" )';
</script>
-<select id="provinceLevel" name="provinceLevel" onchange="loadPureChildrens( this.value, 'districtLevel' )"></select>
-<select id="districtLevel" name="districtLevel" onchange="loadPureChildrens( this.value, 'wardLevel' )"></select>
-<select id="wardLevel" name="wardLevel" onchange="addPatient( this.value )"></select>
\ No newline at end of file
+<select id="provinceLevel" name="provinceLevel" onchange="loadPureChildrens( this.value, 'districtLevel' )"></select><br/>
+<select id="districtLevel" name="districtLevel" onchange="loadPureChildrens( this.value, 'wardLevel' )"></select><br/>
+<select id="wardLevel" name="wardLevel"></select>
\ No newline at end of file