← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13647: Fixed bug - Edit person form doen't work properly.

 

------------------------------------------------------------
revno: 13647
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-01-08 15:01:29 +0700
message:
  Fixed bug - Edit person form doen't work properly.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2014-01-07 18:18:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java	2014-01-08 08:01:29 +0000
@@ -54,7 +54,6 @@
 import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
 import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramPatientAttributeService;
 import org.hisp.dhis.program.ProgramPatientIdentifierTypeService;
@@ -101,6 +100,7 @@
 
     @Autowired
     private ProgramPatientAttributeService programPatientAttributeService;
+
     @Autowired
     private ProgramPatientIdentifierTypeService programPatientIdentifierTypeService;
 
@@ -146,6 +146,8 @@
 
     private Map<String, List<PatientAttribute>> attributesMap = new HashMap<String, List<PatientAttribute>>();
 
+    private PatientRegistrationForm patientRegistrationForm;
+
     public void setProgramId( Integer programId )
     {
         this.programId = programId;
@@ -180,6 +182,11 @@
         return attributesMap;
     }
 
+    public PatientRegistrationForm getPatientRegistrationForm()
+    {
+        return patientRegistrationForm;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -206,37 +213,25 @@
 
         if ( programId == null )
         {
-            PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
-                .getCommonPatientRegistrationForm();
+            patientRegistrationForm = patientRegistrationFormService.getCommonPatientRegistrationForm();
 
-            if ( patientRegistrationForm != null )
+            if ( patientRegistrationForm != null && patientRegistrationForm.getDataEntryForm() != null )
             {
                 customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
                     patientRegistrationForm.getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(),
-                    healthWorkers, patient, null, i18n, format );
+                    healthWorkers, null, null, i18n, format );
             }
         }
         else
         {
             program = programService.getProgram( programId );
-            Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient,
-                program, ProgramInstance.STATUS_ACTIVE );
-
-            ProgramInstance programInstance = null;
-
-            if ( programInstances.iterator().hasNext() )
-            {
-                programInstance = programInstances.iterator().next();
-            }
-
-            PatientRegistrationForm patientRegistrationForm = patientRegistrationFormService
-                .getPatientRegistrationForm( program );
-
-            if ( patientRegistrationForm != null )
+            patientRegistrationForm = patientRegistrationFormService.getPatientRegistrationForm( program );
+
+            if ( patientRegistrationForm != null && patientRegistrationForm.getDataEntryForm() != null )
             {
                 customRegistrationForm = patientRegistrationFormService.prepareDataEntryFormForAdd(
                     patientRegistrationForm.getDataEntryForm().getHtmlCode(), patientRegistrationForm.getProgram(),
-                    healthWorkers, patient, programInstance, i18n, format );
+                    healthWorkers, null, null, i18n, format );
             }
         }
 
@@ -262,7 +257,8 @@
             else
             {
                 identifierTypes = programPatientIdentifierTypeService.getListPatientIdentifierType( program );
-                attributes.removeAll( programPatientAttributeService.getListPatientAttribute( program ) );
+                attributes = new ArrayList<PatientAttribute>(
+                    programPatientAttributeService.getListPatientAttribute( program ) );
             }
 
             for ( PatientAttribute attribute : attributes )
@@ -282,58 +278,60 @@
                 }
             }
 
-            // -------------------------------------------------------------------------
-            // Get data
-            // -------------------------------------------------------------------------
-
-            identiferMap = new HashMap<Integer, String>();
-
-            PatientIdentifierType idType = null;
-            Patient representative = patient.getRepresentative();
-            if ( representative != null )
-            {
-                relationship = relationshipService.getRelationship( representative, patient );
-
-                for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() )
-                {
-                    if ( representativeIdentifier.getIdentifierType() != null
-                        && representativeIdentifier.getIdentifierType().isRelated() )
-                    {
-                        identiferMap.put( representativeIdentifier.getIdentifierType().getId(),
-                            representativeIdentifier.getIdentifier() );
-                    }
-                }
-            }
-
-            for ( PatientIdentifier identifier : patient.getIdentifiers() )
-            {
-                idType = identifier.getIdentifierType();
-
-                if ( idType != null )
-                {
-                    identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
-                }
-            }
-
-            // -------------------------------------------------------------------------
-            // Get patient-attribute values
-            // -------------------------------------------------------------------------
-
-            Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
-                .getPatientAttributeValues( patient );
-
-            for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
-            {
-                String value = patientAttributeValue.getValue();
-                
-                if ( patientAttributeValue.getPatientAttribute().getValueType().equals( PatientAttribute.TYPE_AGE ) && value != null )
-                {
-                    Date date = format.parseDate( value );
-                    value = PatientAttribute.getAgeFromDate( date ) + "";
-                }
-
-                patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), value );
-            }
+        }
+
+        // -------------------------------------------------------------------------
+        // Get data
+        // -------------------------------------------------------------------------
+
+        identiferMap = new HashMap<Integer, String>();
+
+        PatientIdentifierType idType = null;
+        Patient representative = patient.getRepresentative();
+        if ( representative != null )
+        {
+            relationship = relationshipService.getRelationship( representative, patient );
+
+            for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() )
+            {
+                if ( representativeIdentifier.getIdentifierType() != null
+                    && representativeIdentifier.getIdentifierType().isRelated() )
+                {
+                    identiferMap.put( representativeIdentifier.getIdentifierType().getId(),
+                        representativeIdentifier.getIdentifier() );
+                }
+            }
+        }
+
+        for ( PatientIdentifier identifier : patient.getIdentifiers() )
+        {
+            idType = identifier.getIdentifierType();
+
+            if ( idType != null )
+            {
+                identiferMap.put( identifier.getIdentifierType().getId(), identifier.getIdentifier() );
+            }
+        }
+
+        // -------------------------------------------------------------------------
+        // Get patient-attribute values
+        // -------------------------------------------------------------------------
+
+        Collection<PatientAttributeValue> patientAttributeValues = patientAttributeValueService
+            .getPatientAttributeValues( patient );
+
+        for ( PatientAttributeValue patientAttributeValue : patientAttributeValues )
+        {
+            String value = patientAttributeValue.getValue();
+
+            if ( patientAttributeValue.getPatientAttribute().getValueType().equals( PatientAttribute.TYPE_AGE )
+                && value != null )
+            {
+                Date date = format.parseDate( value );
+                value = PatientAttribute.getAgeFromDate( date ) + "";
+            }
+
+            patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), value );
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2014-01-08 07:49:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientForm.vm	2014-01-08 08:01:29 +0000
@@ -1,5 +1,4 @@
-$attributeGroups.size()
-$identifierTypes.size()
+
 #if($!customRegistrationForm)
 	$customRegistrationForm
 #elseif($!patientRegistrationForm)