dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16717
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6426: (patient) Improve function for saving identifiers and attribute value in Enrollment form.
------------------------------------------------------------
revno: 6426
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-29 11:15:07 +0700
message:
(patient) Improve function for saving identifiers and attribute value in Enrollment form.
removed:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeService.java 2012-03-29 04:15:07 +0000
@@ -62,5 +62,6 @@
Collection<PatientAttribute> getPatientAttributes( Program program, PatientAttributeGroup group );
+ Collection<PatientAttribute> getPatientAttributes( Program program );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttributeStore.java 2012-03-29 04:15:07 +0000
@@ -52,4 +52,6 @@
Collection<PatientAttribute> getWithoutGroup();
PatientAttribute getByGroupBy( boolean groupBy );
+
+ Collection<PatientAttribute> get( Program program );
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientAttributeService.java 2012-03-29 04:15:07 +0000
@@ -113,5 +113,10 @@
{
return patientAttributeStore.getWithoutGroup();
}
+
+ public Collection<PatientAttribute> getPatientAttributes( Program program )
+ {
+ return patientAttributeStore.get( program );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientAttributeStore.java 2012-03-29 04:15:07 +0000
@@ -70,7 +70,6 @@
}
@SuppressWarnings("unchecked")
- @Override
public Collection<PatientAttribute> get( Program program, PatientAttributeGroup group )
{
Criteria criteria = getCriteria();
@@ -101,5 +100,12 @@
{
return getCriteria( Restrictions.isNull( "patientAttributeGroup" ) ).list();
}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Collection<PatientAttribute> get( Program program )
+ {
+ return getCriteria( Restrictions.eq( "program", program ) ).list();
+ }
}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientAttributeValueAction.java 1970-01-01 00:00:00 +0000
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.caseentry.action.patient;
-
-import org.apache.commons.lang.math.NumberUtils;
-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.PatientService;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- *
- * @version $SavePatientAttributeValueAction.java Mar 26, 2012 4:06:46 PM$
- */
-public class SavePatientAttributeValueAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private PatientService patientService;
-
- private PatientAttributeValueService patientAttributeValueService;
-
- private PatientAttributeService patientAttributeService;
-
- private PatientAttributeOptionService patientAttributeOptionService;
-
- // -------------------------------------------------------------------------
- // Input/Output
- // -------------------------------------------------------------------------
-
- private Integer patientId;
-
- private Integer attributeId;
-
- private String value;
-
- private Integer statusCode;
-
- // -------------------------------------------------------------------------
- // Getters && Setters
- // -------------------------------------------------------------------------
-
-
- public Integer getStatusCode()
- {
- return statusCode;
- }
-
- public void setPatientService( PatientService patientService )
- {
- this.patientService = patientService;
- }
-
- public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
- {
- this.patientAttributeValueService = patientAttributeValueService;
- }
-
- public void setPatientAttributeService( PatientAttributeService patientAttributeService )
- {
- this.patientAttributeService = patientAttributeService;
- }
-
- public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService )
- {
- this.patientAttributeOptionService = patientAttributeOptionService;
- }
-
- public void setPatientId( Integer patientId )
- {
- this.patientId = patientId;
- }
-
- public void setAttributeId( Integer attributeId )
- {
- this.attributeId = attributeId;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- public String execute()
- throws Exception
- {
- Patient patient = patientService.getPatient( patientId );
-
- PatientAttribute attribute = patientAttributeService.getPatientAttribute( attributeId );
-
- if ( value != null && value.trim().length() == 0 )
- {
- value = null;
- }
-
- PatientAttributeValue attributeValue = patientAttributeValueService.getPatientAttributeValue( patient,
- attribute );
-
- if ( value != null )
- {
- 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() );
- }
- patientAttributeValueService.savePatientAttributeValue( 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() );
- }
- patientAttributeValueService.updatePatientAttributeValue( attributeValue );
- }
- }
- else if ( attributeValue != null )
- {
- patientAttributeValueService.deletePatientAttributeValue( attributeValue );
- patient.getAttributes().remove( attribute );
- patientService.updatePatient( patient );
- }
-
- statusCode = 0;
-
- return SUCCESS;
- }
-
-}
=== removed file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java 2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SavePatientIdentifierAction.java 1970-01-01 00:00:00 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.hisp.dhis.caseentry.action.patient;
-
-import org.hisp.dhis.patient.Patient;
-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 com.opensymphony.xwork2.Action;
-
-/**
- * @author Chau Thu Tran
- *
- * @version $SavePatientIdentifierAction.java Mar 26, 2012 11:50:50 AM$
- */
-public class SavePatientIdentifierAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private PatientService patientService;
-
- private PatientIdentifierTypeService identifierTypeService;
-
- private PatientIdentifierService patientIdentifierService;
-
- // -------------------------------------------------------------------------
- // Input/Output
- // -------------------------------------------------------------------------
-
- private Integer patientId;
-
- private Integer identifierTypeId;
-
- private String value;
-
- private Integer statusCode;
-
- // -------------------------------------------------------------------------
- // Input/Output
- // -------------------------------------------------------------------------
-
- public void setPatientService( PatientService patientService )
- {
- this.patientService = patientService;
- }
-
- public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
- {
- this.patientIdentifierService = patientIdentifierService;
- }
-
- public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
- {
- this.identifierTypeService = identifierTypeService;
- }
-
- public void setPatientId( Integer patientId )
- {
- this.patientId = patientId;
- }
-
- public Integer getStatusCode()
- {
- return statusCode;
- }
-
- public void setIdentifierTypeId( Integer identifierTypeId )
- {
- this.identifierTypeId = identifierTypeId;
- }
-
- public void setValue( String value )
- {
- this.value = value;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- public String execute()
- throws Exception
- {
- Patient patient = patientService.getPatient( patientId );
- PatientIdentifierType identifierType = identifierTypeService.getPatientIdentifierType( identifierTypeId );
-
- if ( value != null && value.trim().length() == 0 )
- {
- value = null;
- }
-
- PatientIdentifier patientIdentifier = patientIdentifierService.getPatientIdentifier( identifierType, patient );
-
- if ( value != null )
- {
- if ( patientIdentifier == null )
- {
- patientIdentifier = new PatientIdentifier();
- patientIdentifier.setIdentifierType( identifierType );
- patientIdentifier.setPatient( patient );
- }
-
- patientIdentifier.setIdentifier( value.trim() );
- patient.getIdentifiers().add( patientIdentifier );
- patientService.updatePatient( patient );
- }
- else if ( patientIdentifier != null )
- {
- patientIdentifierService.deletePatientIdentifier( patientIdentifier );
- }
-
- statusCode = 0;
-
- return SUCCESS;
- }
-
-}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-03-28 07:10:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-03-29 04:15:07 +0000
@@ -688,22 +688,16 @@
</bean>
<bean
- id="org.hisp.dhis.caseentry.action.patient.SavePatientIdentifierAction"
- class="org.hisp.dhis.caseentry.action.patient.SavePatientIdentifierAction"
+ id="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction"
+ class="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction"
scope="prototype">
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
- </bean>
-
- <bean
- id="org.hisp.dhis.caseentry.action.patient.SavePatientAttributeValueAction"
- class="org.hisp.dhis.caseentry.action.patient.SavePatientAttributeValueAction"
- scope="prototype">
- <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientAttributeOptionService" ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
<!-- Relationship -->
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-03-28 07:10:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2012-03-29 04:15:07 +0000
@@ -567,14 +567,8 @@
<param name="requiredAuthorities">F_PROGRAM_ENROLLMENT</param>
</action>
- <action name="savePatientIdentifier"
- class="org.hisp.dhis.caseentry.action.patient.SavePatientIdentifierAction">
- <result name="success" type="velocity-xml">status.vm</result>
- <param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
- </action>
-
- <action name="savePatientAttribueValue"
- class="org.hisp.dhis.caseentry.action.patient.SavePatientAttributeValueAction">
+ <action name="savePatientIdentifierAndAttribute"
+ class="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction">
<result name="success" type="velocity-xml">status.vm</result>
<param name="requiredAuthorities">F_PATIENT_UPDATE, F_PROGRAM_ENROLLMENT</param>
</action>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-03-28 07:10:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js 2012-03-29 04:15:07 +0000
@@ -794,176 +794,17 @@
showById('enrollBtn');
}
-function savePatientIdentifier( identifierTypeId, field )
-{
- field.style.backgroundColor = COLOR_WHITE;
- field.blur();
- if( validateValue( "iden" + identifierTypeId ) )
- {
- var patientId = getFieldValue("patientId");
- field.style.backgroundColor = COLOR_YELLOW;
-
- var valueSaver = new PatientIdentifierSaver( patientId, identifierTypeId, field.value, COLOR_GREEN );
- valueSaver.save();
- }
- else
- {
- field.style.backgroundColor = COLOR_ORANGE;
- }
-}
-
-function savePatientAttrValue( patientAttributeId, field )
-{
- field.style.backgroundColor = COLOR_WHITE;
- field.blur();
- if( validateValue( "attr" + patientAttributeId ) )
- {
- var patientId = getFieldValue("patientId");
- field.style.backgroundColor = COLOR_YELLOW;
-
- var valueSaver = new PatientAttributeValueSaver( patientId, patientAttributeId, field.value, COLOR_GREEN );
- valueSaver.save();
- }
- else
- {
- field.style.backgroundColor = COLOR_ORANGE;
- }
-}
-
-//--------------------------------------------------------------------------------------------
-// For saving patient-identifier and patient-attribute-value
-//--------------------------------------------------------------------------------------------
-
-function validateValue( spanErrorId )
-{
- var classes = jQuery( 'span[for=' + spanErrorId + ']' ).attr('class');
- return ( classes == "error") ? false : true;
-}
-
-function PatientIdentifierSaver( patientId_, identifierTypeId_, value_, resultColor_ )
-{
- var patientId = patientId_;
- var identifierTypeId = identifierTypeId_;
- var value = value_;
- var resultColor = resultColor_;
-
- this.save = function()
- {
- var params = 'patientId=' + patientId;
- params += '&identifierTypeId=' + identifierTypeId;
- params += '&value=' + value;
-
- $.ajax({
- url: "savePatientIdentifier.action",
- data: params,
- type: "POST",
- dataType: "xml",
- success: function(result){
- handleResponse (result);
- },
- error: function(request,status,errorThrown) {
- handleHttpError (request);
- }
- });
- };
-
- function handleResponse( rootElement )
- {
- var codeElement = rootElement.getElementsByTagName( 'code' )[0];
- var code = parseInt( codeElement.firstChild.nodeValue );
- if ( code == 0 )
- {
- markValue( resultColor );
- }
- else
- {
- if(value!="")
- {
- markValue( COLOR_GREY );
- window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
- }
- else
- {
- markValue( resultColor );
- }
- }
- }
-
- function handleHttpError( errorCode )
- {
- markValue( COLOR_GREY );
- window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
- }
-
- function markValue( color )
- {
- var programStageId = getFieldValue('programStageId');
- var element = byId( 'iden' + identifierTypeId );
- element.style.backgroundColor = color;
- }
-}
-
-function PatientAttributeValueSaver( patientId_, attributeId_, value_, resultColor_ )
-{
- var patientId = patientId_;
- var attributeId = attributeId_;
- var value = value_;
- var resultColor = resultColor_;
-
- this.save = function()
- {
- var params = 'patientId=' + patientId;
- params += '&attributeId=' + attributeId;
- params += '&value=' + value;
-
- $.ajax({
- url: "savePatientAttribueValue.action",
- data: params,
- type: "POST",
- dataType: "xml",
- success: function(result){
- handleResponse (result);
- },
- error: function(request,status,errorThrown) {
- handleHttpError (request);
- }
- });
- };
-
- function handleResponse( rootElement )
- {
- var codeElement = rootElement.getElementsByTagName( 'code' )[0];
- var code = parseInt( codeElement.firstChild.nodeValue );
- if ( code == 0 )
- {
- markValue( resultColor );
- }
- else
- {
- if(value!="")
- {
- markValue( COLOR_GREY );
- window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
- }
- else
- {
- markValue( resultColor );
- }
- }
- }
-
- function handleHttpError( errorCode )
- {
- markValue( COLOR_GREY );
- window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
- }
-
- function markValue( color )
- {
- var programStageId = getFieldValue('programStageId');
- var element = byId( 'attr' + attributeId );
- element.style.backgroundColor = color;
- }
+function saveIdentifierAndAttribute()
+{
+ $.ajax({
+ type: "POST",
+ url: 'savePatientIdentifierAndAttribute.action',
+ data: getParamsForDiv('programEnrollmentInforForm'),
+ success: function(json)
+ {
+ showSuccessMessage( i18n_save_success );
+ }
+ });
}
//--------------------------------------------------------------------------------------------
@@ -1057,4 +898,4 @@
{
showSuccessMessage( i18n_save_success );
} );
-}
\ No newline at end of file
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-03-28 07:10:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm 2012-03-29 04:15:07 +0000
@@ -13,6 +13,8 @@
<!-- Enroll program TAB -->
<div id="tab-1">
<form id='programEnrollmentInforForm' name='programEnrollmentInforForm' action='#' method="POST" >
+ <input type='hidden' id='programId' name='programId' value='$programInstance.program.id'>
+ <input type='hidden' id='patientId' name='patientId' value='$programInstance.patient.id'>
<!-- IDENTIFIERS -->
#if( $identifierTypes || $noGroupAttributes || $attributeGroups )
<table class='mainPageTable' id='enrollmentInforDiv' name='enrollmentInforDiv' >
@@ -25,12 +27,13 @@
#end
#set( $mark = false )
- #foreach ($identifierType in $identifierTypes)
+ #foreach ($identifierType in $identifierTypes)
+ #set( $identifier = '')
#set( $identifier = $identiferMap.get( $identifierType.id ) )
<tr #alternate( $mark )>
<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" value='$!identifier' 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 }}" onchange='savePatientIdentifier( $identifierType.id, this);' />
+ <input type="text" id="iden$identifierType.id" objectId='$identifierType.id' objectType='iden' name="iden$identifierType.id" value='$!identifier' 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>
#set( $mark = !$mark )
@@ -43,30 +46,31 @@
#set( $mark = false )
#foreach($attribute in $attributeGroup.attributes)
#if( $!attribute.program )
+ #set( $attributeValue = '')
#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
<tr #alternate( $mark )>
<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" onchange='savePatientAttrValue( $attribute.id, this);' >
+ <select id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' >
<option value="">[$i18n.getString( "please_select" )]</option>
<option value="true" #if( $attributeValue=='true') selected="selected" #end>$i18n.getString( "yes" )</option>
<option value="false" #if( $attributeValue=='false') selected="selected" #end>$i18n.getString( "no" )</option>
</select>
#elseif( $attribute.valueType == "DATE" )
- <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default" $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' >
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" objectId='$attribute.id' objectType='attr' 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 )' onchange='savePatientAttrValue( $attribute.id, this);' >
+ <select id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' class=' #validate( "default" $attribute.mandatory )' >
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach ($option in $attribute.attributeOptions )
<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
#end
</select>
#else
- <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" onchange='savePatientAttrValue( $attribute.id, this);' >
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
#end
</td>
</tr>
@@ -83,30 +87,31 @@
#set( $mark = false )
#foreach($attribute in $noGroupAttributes )
#if( $attribute.program )
+ #set( $attributeValue = '')
#set( $attributeValue = $!patientAttributeValueMap.get( $attribute.id ) )
<tr #alternate( $mark )>
<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" onchange='savePatientAttrValue( $attribute.id, this);' >
+ <select id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' >
<option value="">[$i18n.getString( "please_select" )]</option>
<option value="true" #if( $attributeValue ) selected="selected" #end>$i18n.getString( "yes" )</option>
<option value="false" #if( !$attributeValue ) selected="selected" #end>$i18n.getString( "no" )</option>
</select>
#elseif( $attribute.valueType == "DATE" )
- <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class=' #validate( "default" $attribute.mandatory )' onchange='savePatientAttrValue( $attribute.id, this);' >
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' value="$!attributeValue" 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 )' onchange='savePatientAttrValue( $attribute.id, this);' >
+ <select id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' class=' #validate( "default" $attribute.mandatory )' >
<option value="">[$i18n.getString( "please_select" )]</option>
#foreach ($option in $attribute.attributeOptions )
<option value="$option.id" #if($attributeValue == $option.name) selected="selected" #end>$option.name</option>
#end
</select>
#else
- <input type="text" id="attr$attribute.id" name="attr$attribute.id" value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" onchange='savePatientAttrValue( $attribute.id, this);' >
+ <input type="text" id="attr$attribute.id" name="attr$attribute.id" objectId='$attribute.id' objectType='attr' value="$!attributeValue" class="{validate:{required:$attribute.mandatory #if($!attribute.noChars),maxlength:$attribute.noChars #end #if($attribute.valueType=='NUMBER'),number:true #end }}" >
#end
</td>
</tr>
@@ -114,9 +119,12 @@
#end
#end
#end
+ <tr>
+ <td></td>
+ <td><input type='submit' value='$i18n.getString("save")' /></td>
+ </tr>
</table>
#end
- <input type='submit' class='hidden'>
</form>
</div>
@@ -220,15 +228,15 @@
<script type="text/javascript">
- jQuery("#programEnrollmentInforForm").ready( function(){
+ jQuery("#programEnrollmentInforForm").ready( function(){
validation( 'programEnrollmentInforForm', function(form){
- return false;
+ saveIdentifierAndAttribute();
});
});
#if( $programInstance || $hasDataEntry == 'true')
$('#tabs').tabs();
-
+
#if( $identifierTypes || $noGroupAttributes || $attributeGroups )
$( "#tabs" ).tabs( "option", "selected", 1 );
$( "#tabs" ).tabs( "option", "disabled", [0] );