← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1143: Patient-record : save save uncode string.

 

------------------------------------------------------------
revno: 1143
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2009-12-01 10:21:36 +0700
message:
  Patient-record : save save uncode string.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java


--
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-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java	2009-10-27 09:52:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/AddPatientAction.java	2009-12-01 03:21:36 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.patient.PatientIdentifier;
 import org.hisp.dhis.patient.PatientIdentifierService;
 import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.system.util.CodecUtils;
 import org.hisp.dhis.i18n.I18nFormat;
 
 import com.opensymphony.xwork2.Action;
@@ -43,178 +44,157 @@
  * @author Abyot Asalefew Gizaw
  * @version $Id$
  */
-public class AddPatientAction
-    implements Action
-{
-    // -------------------------------------------------------------------------
-    // Dependencies
-    // -------------------------------------------------------------------------
-
-    private I18nFormat format;
-
-    public void setFormat( I18nFormat format )
-    {
-        this.format = format;
-    }
-
-    private PatientService patientService;
-
-    public void setPatientService( PatientService patientService )
-    {
-        this.patientService = patientService;
-    }
-
-    private PatientIdentifierService patientIdentifierService;
-
-    public void setPatientIdentifierService( PatientIdentifierService patientIdentifierService )
-    {
-        this.patientIdentifierService = patientIdentifierService;
-    }
-
-    private OrganisationUnitSelectionManager selectionManager;
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input - identifier
-    // -------------------------------------------------------------------------
-
-    private String identifier;
-
-    public void setIdentifier( String identifier )
-    {
-        this.identifier = identifier;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input - name
-    // -------------------------------------------------------------------------
-
-    private String firstName;
-
-    public void setFirstName( String firstName )
-    {
-        this.firstName = firstName;
-    }
-
-    private String middleName;
-
-    public void setMiddleName( String middleName )
-    {
-        this.middleName = middleName;
-    }
-
-    private String lastName;
-
-    public void setLastName( String lastName )
-    {
-        this.lastName = lastName;
-    }
-
-    // -------------------------------------------------------------------------
-    // Input - demographics
-    // -------------------------------------------------------------------------
-
-    private String birthDate;
-
-    public void setBirthDate( String birthDate )
-    {
-        this.birthDate = birthDate;
-    }
-
-    private Integer age;
-
-    public void setAge( Integer age )
-    {
-        this.age = age;
-    }
-
-    private boolean birthDateEstimated;
-
-    public void setBirthDateEstimated( boolean birthDateEstimated )
-    {
-        this.birthDateEstimated = birthDateEstimated;
-    }
-
-    private String gender;
-
-    public void setGender( String gender )
-    {
-        this.gender = gender;
-    }
-
-    // -------------------------------------------------------------------------
-    // Output - making the patient available so that its attributes can be
-    // edited
-    // -------------------------------------------------------------------------
-
-    private Patient patient;
-
-    public Patient getPatient()
-    {
-        return patient;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    public String execute()
-    {
-        // ---------------------------------------------------------------------
-        // Prepare values
-        // ---------------------------------------------------------------------
-
-        OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
-
-        patient = new Patient();
-
-        patient.setFirstName( firstName );
-        patient.setMiddleName( middleName );
-        patient.setLastName( lastName );
-        patient.setGender( gender );
-
-        if ( birthDate != null )
-        {
-
-            birthDate = birthDate.trim();
-
-            if ( birthDate.length() != 0 )
-            {
-                patient.setBirthDate( format.parseDate( birthDate ) );
-                patient.setBirthDateEstimated( birthDateEstimated );
-            }
-            else
-            {
-                if ( age != null )
-                {
-                    patient.setBirthDateFromAge( age.intValue() );
-                }
-            }
-        }
-        else
-        {
-            if ( age != null )
-            {
-                patient.setBirthDateFromAge( age.intValue() );                
-            }
-        }
-        
-        patient.setRegistrationDate( new Date() );
-
-        patientService.savePatient( patient );
-
-        PatientIdentifier patientIdentifier = new PatientIdentifier();
-        patientIdentifier.setIdentifier( identifier );
-        patientIdentifier.setOrganisationUnit( organisationUnit );
-        patientIdentifier.setPatient( patient );
-        patientIdentifier.setPreferred( true );
-
-        patientIdentifierService.savePatientIdentifier( patientIdentifier );
-
-        return SUCCESS;
-    }
+public class AddPatientAction implements Action {
+	// -------------------------------------------------------------------------
+	// Dependencies
+	// -------------------------------------------------------------------------
+
+	private I18nFormat format;
+
+	public void setFormat(I18nFormat format) {
+		this.format = format;
+	}
+
+	private PatientService patientService;
+
+	public void setPatientService(PatientService patientService) {
+		this.patientService = patientService;
+	}
+
+	private PatientIdentifierService patientIdentifierService;
+
+	public void setPatientIdentifierService(
+			PatientIdentifierService patientIdentifierService) {
+		this.patientIdentifierService = patientIdentifierService;
+	}
+
+	private OrganisationUnitSelectionManager selectionManager;
+
+	public void setSelectionManager(
+			OrganisationUnitSelectionManager selectionManager) {
+		this.selectionManager = selectionManager;
+	}
+
+	// -------------------------------------------------------------------------
+	// Input - identifier
+	// -------------------------------------------------------------------------
+
+	private String identifier;
+
+	public void setIdentifier(String identifier) {
+		this.identifier = identifier;
+	}
+
+	// -------------------------------------------------------------------------
+	// Input - name
+	// -------------------------------------------------------------------------
+
+	private String firstName;
+
+	public void setFirstName(String firstName) {
+		this.firstName = firstName;
+	}
+
+	private String middleName;
+
+	public void setMiddleName(String middleName) {
+		this.middleName = middleName;
+	}
+
+	private String lastName;
+
+	public void setLastName(String lastName) {
+		this.lastName = lastName;
+	}
+
+	// -------------------------------------------------------------------------
+	// Input - demographics
+	// -------------------------------------------------------------------------
+
+	private String birthDate;
+
+	public void setBirthDate(String birthDate) {
+		this.birthDate = birthDate;
+	}
+
+	private Integer age;
+
+	public void setAge(Integer age) {
+		this.age = age;
+	}
+
+	private boolean birthDateEstimated;
+
+	public void setBirthDateEstimated(boolean birthDateEstimated) {
+		this.birthDateEstimated = birthDateEstimated;
+	}
+
+	private String gender;
+
+	public void setGender(String gender) {
+		this.gender = gender;
+	}
+
+	// -------------------------------------------------------------------------
+	// Output - making the patient available so that its attributes can be
+	// edited
+	// -------------------------------------------------------------------------
+
+	private Patient patient;
+
+	public Patient getPatient() {
+		return patient;
+	}
+
+	// -------------------------------------------------------------------------
+	// Action implementation
+	// -------------------------------------------------------------------------
+
+	public String execute() {
+		// ---------------------------------------------------------------------
+		// Prepare values
+		// ---------------------------------------------------------------------
+
+		OrganisationUnit organisationUnit = selectionManager
+				.getSelectedOrganisationUnit();
+
+		patient = new Patient();
+
+		patient.setFirstName(CodecUtils.unescape(firstName));
+		patient.setMiddleName(CodecUtils.unescape(middleName));
+		patient.setLastName(CodecUtils.unescape(lastName));
+		patient.setGender(gender);
+
+		if (birthDate != null) {
+
+			birthDate = birthDate.trim();
+
+			if (birthDate.length() != 0) {
+				patient.setBirthDate(format.parseDate(birthDate));
+				patient.setBirthDateEstimated(birthDateEstimated);
+			} else {
+				if (age != null) {
+					patient.setBirthDateFromAge(age.intValue());
+				}
+			}
+		} else {
+			if (age != null) {
+				patient.setBirthDateFromAge(age.intValue());
+			}
+		}
+
+		patient.setRegistrationDate(new Date());
+
+		patientService.savePatient(patient);
+
+		PatientIdentifier patientIdentifier = new PatientIdentifier();
+		patientIdentifier.setIdentifier(identifier);
+		patientIdentifier.setOrganisationUnit(organisationUnit);
+		patientIdentifier.setPatient(patient);
+		patientIdentifier.setPreferred(true);
+
+		patientIdentifierService.savePatientIdentifier(patientIdentifier);
+
+		return SUCCESS;
+	}
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java	2009-10-27 09:52:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patient/UpdatePatientAction.java	2009-12-01 03:21:36 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
+import org.hisp.dhis.system.util.CodecUtils;
 import org.hisp.dhis.i18n.I18nFormat;
 
 import com.opensymphony.xwork2.Action;
@@ -146,9 +147,9 @@
         // ---------------------------------------------------------------------
 
         patient = patientService.getPatient( id );
-        patient.setFirstName( firstName );
-        patient.setMiddleName( middleName );
-        patient.setLastName( lastName );
+        patient.setFirstName(CodecUtils.unescape(firstName));
+		patient.setMiddleName(CodecUtils.unescape(middleName));
+		patient.setLastName(CodecUtils.unescape(lastName));
         patient.setGender( gender );
         patient.setBirthDate( format.parseDate( birthDate ) );        
         patient.setBirthDateEstimated( birthDateEstimated );        


Follow ups