=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-09-11 15:26:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-09-12 07:19:15 +0000 @@ -85,12 +85,6 @@ public static String FIXED_ATTR_FULL_NAME = "fullName"; - private String firstName; - - private String middleName; - - private String lastName; - private String gender; private Date birthDate; @@ -128,107 +122,6 @@ } // ------------------------------------------------------------------------- - // hashCode and equals - // ------------------------------------------------------------------------- - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - - result = prime * result + ((uid == null) ? 0 : uid.hashCode()); - result = prime * result + ((birthDate == null) ? 0 : birthDate.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((gender == null) ? 0 : gender.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); - - return result; - } - - @Override - public boolean equals( Object object ) - { - if ( this == object ) - { - return true; - } - - if ( object == null ) - { - return false; - } - - if ( !getClass().isAssignableFrom( object.getClass() ) ) - { - return false; - } - - final Patient other = (Patient) object; - - if ( birthDate == null ) - { - if ( other.birthDate != null ) - { - return false; - } - } - else if ( !birthDate.equals( other.birthDate ) ) - { - return false; - } - - if ( firstName == null ) - { - if ( other.firstName != null ) - { - return false; - } - } - else if ( !firstName.equals( other.firstName ) ) - { - return false; - } - - if ( gender == null ) - { - if ( other.gender != null ) - return false; - } - else if ( !gender.equals( other.gender ) ) - { - return false; - } - - if ( lastName == null ) - { - if ( other.lastName != null ) - { - return false; - } - } - else if ( !lastName.equals( other.lastName ) ) - { - return false; - } - - if ( middleName == null ) - { - if ( other.middleName != null ) - { - return false; - } - } - else if ( !middleName.equals( other.middleName ) ) - { - return false; - } - - return true; - } - - // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -259,45 +152,6 @@ @JsonProperty @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public String getFirstName() - { - return firstName; - } - - public void setFirstName( String firstName ) - { - this.firstName = firstName; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public String getMiddleName() - { - return middleName; - } - - public void setMiddleName( String middleName ) - { - this.middleName = middleName; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public String getLastName() - { - return lastName; - } - - public void setLastName( String lastName ) - { - this.lastName = lastName; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getGender() { return gender; @@ -534,80 +388,6 @@ // Getter && Setter // ------------------------------------------------------------------------- - public void setFullName( String fullName ) - { - name = fullName; - - if ( fullName == null ) - { - return; - } - - fullName = fullName.trim(); - - int startIndex = fullName.indexOf( ' ' ); - int endIndex = fullName.lastIndexOf( ' ' ); - - String firstName = fullName; - 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() ); - } - } - - this.firstName = firstName; - this.middleName = middleName; - this.lastName = lastName; - } - - public String getFullName() - { - boolean space = false; - String name = ""; - - if ( firstName != null && firstName.length() != 0 ) - { - name = firstName; - space = true; - } - - if ( middleName != null && middleName.length() != 0 ) - { - if ( space ) - { - name += " "; - } - - name += middleName; - space = true; - } - - if ( lastName != null && lastName.length() != 0 ) - { - if ( space ) - { - name += " "; - } - - name += lastName; - } - - return name; - } - public String getPhoneNumber() { return phoneNumber; === removed directory 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/patient' === removed file 'dhis-2/dhis-api/src/test/java/org/hisp/dhis/patient/PatientTest.java' --- dhis-2/dhis-api/src/test/java/org/hisp/dhis/patient/PatientTest.java 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/test/java/org/hisp/dhis/patient/PatientTest.java 1970-01-01 00:00:00 +0000 @@ -1,61 +0,0 @@ -package org.hisp.dhis.patient; - -/* - * Copyright (c) 2004-2013, 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 static org.junit.Assert.*; - -import org.junit.Test; - -public class PatientTest -{ - @Test - public void testFullname() { - - Patient patient = new Patient(); - - assertEquals( "", patient.getFullName() ); - - patient.setFirstName( "firstName" ); - assertEquals( "firstName", patient.getFullName() ); - - patient.setLastName( "lastName" ); - assertEquals( "firstName lastName", patient.getFullName() ); - - patient.setMiddleName( "middleName" ); - assertEquals( "firstName middleName lastName", patient.getFullName() ); - - patient.setFirstName( "" ); - assertEquals( "middleName lastName", patient.getFullName() ); - - patient.setFirstName( "firstName middleName lastName" ); - patient.setMiddleName( null ); - patient.setLastName( null ); - assertEquals( "firstName middleName lastName", patient.getFullName() ); - } -} === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-11 12:12:22 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/event/person/AbstractPersonService.java 2013-09-12 07:19:15 +0000 @@ -148,7 +148,7 @@ person.setPerson( patient.getUid() ); person.setOrgUnit( patient.getOrganisationUnit().getUid() ); - person.setName( patient.getFullName() ); + person.setName( patient.getName() ); person.setGender( Gender.fromString( patient.getGender() ) ); person.setDeceased( patient.getIsDead() ); === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/Beneficiary.java 2013-09-12 07:19:15 +0000 @@ -28,6 +28,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -35,15 +41,8 @@ import java.util.Date; import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - @XmlRootElement -@XmlAccessorType( XmlAccessType.FIELD ) +@XmlAccessorType(XmlAccessType.FIELD) public class Beneficiary implements DataStreamSerializable { @@ -53,25 +52,19 @@ private int id; @XmlAttribute - private String firstName; - - @XmlAttribute - private String middleName; - - @XmlAttribute - private String lastName; + private String name; @XmlAttribute private int age; - @XmlElementWrapper( name = "attributes" ) - @XmlElement( name = "attribute" ) + @XmlElementWrapper(name = "attributes") + @XmlElement(name = "attribute") private List patientAttValues; private PatientAttribute groupAttribute; - @XmlElementWrapper( name = "identifiers" ) - @XmlElement( name = "identifier" ) + @XmlElementWrapper(name = "identifiers") + @XmlElement(name = "identifier") private List identifiers; private String gender; @@ -92,32 +85,6 @@ this.identifiers = identifiers; } - public String getFullName() - { - boolean space = false; - String name = ""; - - if ( firstName != null && firstName.length() != 0 ) - { - name = firstName; - space = true; - } - if ( middleName != null && middleName.length() != 0 ) - { - if ( space ) - name += " "; - name += middleName; - space = true; - } - if ( lastName != null && lastName.length() != 0 ) - { - if ( space ) - name += " "; - name += lastName; - } - return name; - } - public int getAge() { return age; @@ -198,34 +165,14 @@ this.id = id; } - public String getFirstName() - { - return firstName; - } - - public void setFirstName( String firstName ) - { - this.firstName = firstName; - } - - public String getMiddleName() - { - return middleName; - } - - public void setMiddleName( String middleName ) - { - this.middleName = middleName; - } - - public String getLastName() - { - return lastName; - } - - public void setLastName( String lastName ) - { - this.lastName = lastName; + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; } public String getClientVersion() @@ -246,9 +193,7 @@ DataOutputStream dout = new DataOutputStream( bout ); dout.writeInt( this.getId() ); - dout.writeUTF( this.getFirstName() ); - dout.writeUTF( this.getMiddleName() ); - dout.writeUTF( this.getLastName() ); + dout.writeUTF( this.getName() ); dout.writeInt( this.getAge() ); if ( gender != null ) @@ -349,9 +294,9 @@ { return false; } - + final Beneficiary otherBeneficiary = (Beneficiary) otherObject; - + if ( birthDate == null ) { if ( otherBeneficiary.birthDate != null ) @@ -363,15 +308,15 @@ { return false; } - - if ( firstName == null ) + + if ( name == null ) { - if ( otherBeneficiary.firstName != null ) + if ( otherBeneficiary.name != null ) { return false; } } - else if ( !firstName.equals( otherBeneficiary.firstName ) ) + else if ( !name.equals( otherBeneficiary.name ) ) { return false; } @@ -386,30 +331,6 @@ return false; } - if ( lastName == null ) - { - if ( otherBeneficiary.lastName != null ) - { - return false; - } - } - else if ( !lastName.equals( otherBeneficiary.lastName ) ) - { - return false; - } - - if ( middleName == null ) - { - if ( otherBeneficiary.middleName != null ) - { - return false; - } - } - else if ( !middleName.equals( otherBeneficiary.middleName ) ) - { - return false; - } - return true; } @@ -418,12 +339,10 @@ { final int prime = 31; int result = 1; - + result = prime * result + ((birthDate == null) ? 0 : birthDate.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((gender == null) ? 0 : gender.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); return result; } @@ -436,9 +355,7 @@ DataOutputStream dout = new DataOutputStream( bout ); dout.writeInt( this.getId() ); - dout.writeUTF( this.getFirstName() ); - dout.writeUTF( this.getMiddleName() ); - dout.writeUTF( this.getLastName() ); + dout.writeUTF( this.getName() ); dout.writeInt( this.getAge() ); if ( gender != null ) @@ -520,9 +437,7 @@ throws IOException { dout.writeInt( this.getId() ); - dout.writeUTF( this.getFirstName() ); - dout.writeUTF( this.getMiddleName() ); - dout.writeUTF( this.getLastName() ); + dout.writeUTF( this.getName() ); dout.writeInt( this.getAge() ); if ( gender != null ) === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-09-11 14:28:23 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-09-12 07:19:15 +0000 @@ -28,6 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.api.mobile.model.DataStreamSerializable; +import org.hisp.dhis.api.mobile.model.PatientAttribute; +import org.hisp.dhis.api.mobile.model.PatientIdentifier; + import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -37,10 +41,6 @@ import java.util.Date; import java.util.List; -import org.hisp.dhis.api.mobile.model.DataStreamSerializable; -import org.hisp.dhis.api.mobile.model.PatientAttribute; -import org.hisp.dhis.api.mobile.model.PatientIdentifier; - /** * @author Nguyen Kim Lai */ @@ -51,11 +51,7 @@ private int id; - private String firstName; - - private String middleName; - - private String lastName; + private String name; private int age; @@ -72,9 +68,9 @@ private Character dobType; private List programs; - + //private List programsID; - + //private Map patientDataValues; private List enrollmentPrograms; @@ -86,13 +82,13 @@ private String phoneNumber; private String organisationUnitName; - + private List completedPrograms; // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- - + public List getIdentifiers() { return identifiers; @@ -153,32 +149,6 @@ this.enrollmentPrograms = enrollmentPrograms; } - public String getFullName() - { - boolean space = false; - String name = ""; - - if ( firstName != null && firstName.length() != 0 ) - { - name = firstName; - space = true; - } - if ( middleName != null && middleName.length() != 0 ) - { - if ( space ) - name += " "; - name += middleName; - space = true; - } - if ( lastName != null && lastName.length() != 0 ) - { - if ( space ) - name += " "; - name += lastName; - } - return name; - } - public int getAge() { return age; @@ -249,34 +219,14 @@ this.id = id; } - public String getFirstName() - { - return firstName; - } - - public void setFirstName( String firstName ) - { - this.firstName = firstName; - } - - public String getMiddleName() - { - return middleName; - } - - public void setMiddleName( String middleName ) - { - this.middleName = middleName; - } - - public String getLastName() - { - return lastName; - } - - public void setLastName( String lastName ) - { - this.lastName = lastName; + public String getName() + { + return name; + } + + public void setName( String name ) + { + this.name = name; } public String getClientVersion() @@ -328,7 +278,7 @@ { this.completedPrograms = completedPrograms; } - + // ------------------------------------------------------------------------- // Override Methods // ------------------------------------------------------------------------- @@ -341,10 +291,8 @@ DataOutputStream dout = new DataOutputStream( bout ); dout.writeInt( this.getId() ); - dout.writeUTF( this.getFirstName() ); - dout.writeUTF( this.getMiddleName() ); - dout.writeUTF( this.getLastName() ); - + dout.writeUTF( this.getName() ); + if ( organisationUnitName != null ) { dout.writeBoolean( true ); @@ -420,7 +368,7 @@ { dout.writeInt( 0 ); } - + // Write PatientIdentifier if ( identifiers != null ) { @@ -455,7 +403,7 @@ dout.writeInt( key ); dout.writeUTF( patientDataValues.get( key ) ); }*/ - + // Write Relationships dout.writeInt( relationships.size() ); for ( Relationship each : relationships ) @@ -478,7 +426,7 @@ { each.serialize( dout ); } - + // Write completed Programs dout.writeInt( completedPrograms.size() ); for ( Program each : completedPrograms ) @@ -495,10 +443,8 @@ throws IOException, EOFException { this.setId( din.readInt() ); - this.setFirstName( din.readUTF() ); - this.setMiddleName( din.readUTF() ); - this.setLastName( din.readUTF() ); - + this.setName( din.readUTF() ); + // Org Name if ( din.readBoolean() ) { @@ -508,7 +454,7 @@ { this.setOrganisationUnitName( null ); } - + // Gender if ( din.readBoolean() ) { @@ -518,7 +464,7 @@ { this.setGender( null ); } - + // DOB Type if ( din.readBoolean() ) { @@ -529,7 +475,7 @@ { this.setDobType( null ); } - + // DOB if ( din.readBoolean() ) { @@ -542,7 +488,7 @@ // doesn't transfer blood group to client din.readBoolean(); - + // Registration Date if ( din.readBoolean() ) { @@ -562,10 +508,10 @@ { this.setPhoneNumber( null ); } - + // Patient Attribute & Identifiers int attsNumb = din.readInt(); - if( attsNumb > 0 ) + if ( attsNumb > 0 ) { this.patientAttValues = new ArrayList(); for ( int j = 0; j < attsNumb; j++ ) @@ -589,10 +535,10 @@ PatientIdentifier identifier = new PatientIdentifier(); identifier.deSerialize( din ); this.identifiers.add( identifier ); - + } } - + // Program & Relationship int numbPrograms = din.readInt(); if ( numbPrograms > 0 ) @@ -609,7 +555,7 @@ { this.programs = null; } - + int numbRelationships = din.readInt(); if ( numbRelationships > 0 ) { @@ -625,7 +571,7 @@ { this.relationships = null; } - + int numbEnrollmentPrograms = din.readInt(); if ( numbEnrollmentPrograms > 0 ) { @@ -641,7 +587,7 @@ { this.enrollmentPrograms = null; } - + int numbEnrollmentRelationships = din.readInt(); if ( numbEnrollmentRelationships > 0 ) { @@ -657,7 +603,7 @@ { this.enrollmentRelationships = null; } - + int numbCompletedPrograms = din.readInt(); if ( numbCompletedPrograms > 0 ) { @@ -707,14 +653,14 @@ return false; } - if ( firstName == null ) + if ( name == null ) { - if ( otherPatient.firstName != null ) + if ( otherPatient.name != null ) { return false; } } - else if ( !firstName.equals( otherPatient.firstName ) ) + else if ( !name.equals( otherPatient.name ) ) { return false; } @@ -729,30 +675,6 @@ return false; } - if ( lastName == null ) - { - if ( otherPatient.lastName != null ) - { - return false; - } - } - else if ( !lastName.equals( otherPatient.lastName ) ) - { - return false; - } - - if ( middleName == null ) - { - if ( otherPatient.middleName != null ) - { - return false; - } - } - else if ( !middleName.equals( otherPatient.middleName ) ) - { - return false; - } - return true; } @@ -763,10 +685,8 @@ int result = 1; result = prime * result + ((birthDate == null) ? 0 : birthDate.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); result = prime * result + ((gender == null) ? 0 : gender.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); return result; } === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/comparator/ActivityComparator.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/comparator/ActivityComparator.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/comparator/ActivityComparator.java 2013-09-12 07:19:15 +0000 @@ -42,6 +42,6 @@ @Override public int compare( Activity act1, Activity act2 ) { - return act2.getBeneficiary().getFullName().compareToIgnoreCase( act1.getBeneficiary().getFullName() ); + return act2.getBeneficiary().getName().compareToIgnoreCase( act1.getBeneficiary().getName() ); } } === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-11 16:13:49 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-09-12 07:19:15 +0000 @@ -28,21 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.hisp.dhis.api.mobile.ActivityReportingService; import org.hisp.dhis.api.mobile.NotAllowedException; import org.hisp.dhis.api.mobile.PatientMobileSettingService; @@ -51,9 +36,9 @@ import org.hisp.dhis.api.mobile.model.ActivityValue; import org.hisp.dhis.api.mobile.model.Beneficiary; import org.hisp.dhis.api.mobile.model.DataValue; +import org.hisp.dhis.api.mobile.model.LWUITmodel.Section; import org.hisp.dhis.api.mobile.model.PatientAttribute; import org.hisp.dhis.api.mobile.model.Task; -import org.hisp.dhis.api.mobile.model.LWUITmodel.Section; import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; @@ -95,6 +80,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Required; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + public class ActivityReportingServiceImpl implements ActivityReportingService { @@ -461,7 +461,7 @@ for ( Patient each : patients ) { - patientsInfo += each.getId() + "/" + each.getFullName() + "/" + patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) + "$"; } @@ -771,9 +771,7 @@ List atts; beneficiary.setId( patient.getId() ); - beneficiary.setFirstName( patient.getFirstName() ); - beneficiary.setLastName( patient.getLastName() ); - beneficiary.setMiddleName( patient.getMiddleName() ); + beneficiary.setName( patient.getName() ); Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() ); beneficiary.setAge( period.getYears() ); @@ -869,29 +867,7 @@ List atts; patientModel.setId( patient.getId() ); - - String firstName = ""; - String lastName = ""; - String middleName = ""; - - if ( patient.getFirstName() != null ) - { - firstName = patient.getFirstName(); - } - - if ( patient.getLastName() != null ) - { - lastName = patient.getLastName(); - } - - if ( patient.getMiddleName() != null ) - { - middleName = patient.getMiddleName(); - } - - patientModel.setFirstName( firstName ); - patientModel.setLastName( lastName ); - patientModel.setMiddleName( middleName ); + patientModel.setName( patient.getName() ); Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() ); patientModel.setAge( period.getYears() ); @@ -1027,20 +1003,20 @@ if ( eachRelationship.getPatientA().getId() == patient.getId() ) { relationshipMobile.setName( eachRelationship.getRelationshipType().getaIsToB() ); - relationshipMobile.setPersonBName( eachRelationship.getPatientB().getFullName() ); + relationshipMobile.setPersonBName( eachRelationship.getPatientB().getName() ); relationshipMobile.setPersonBId( eachRelationship.getPatientB().getId() ); // relationshipMobile.setPersonAName( - // eachRelationship.getPatientA().getFullName() ); + // eachRelationship.getPatientA().getName() ); // relationshipMobile.setPersonAId( // eachRelationship.getPatientA().getId() ); } else { relationshipMobile.setName( eachRelationship.getRelationshipType().getbIsToA() ); - relationshipMobile.setPersonBName( eachRelationship.getPatientA().getFullName() ); + relationshipMobile.setPersonBName( eachRelationship.getPatientA().getName() ); relationshipMobile.setPersonBId( eachRelationship.getPatientA().getId() ); // relationshipMobile.setPersonAName( - // eachRelationship.getPatientB().getFullName() ); + // eachRelationship.getPatientB().getName() ); // relationshipMobile.setPersonAId( // eachRelationship.getPatientB().getId() ); } @@ -1360,7 +1336,7 @@ for ( Patient each : patients ) { - patientsInfo += each.getId() + "/" + each.getFullName() + "/" + patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) + "$"; } @@ -1845,31 +1821,7 @@ { org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient(); - int startIndex = patient.getFirstName().indexOf( ' ' ); - int endIndex = patient.getFirstName().lastIndexOf( ' ' ); - - String firstName = patient.getFirstName().toString(); - String middleName = ""; - String lastName = ""; - - if ( patient.getFirstName().indexOf( ' ' ) != -1 ) - { - firstName = patient.getFirstName().substring( 0, startIndex ); - if ( startIndex == endIndex ) - { - middleName = ""; - lastName = patient.getFirstName().substring( startIndex + 1, patient.getFirstName().length() ); - } - else - { - middleName = patient.getFirstName().substring( startIndex + 1, endIndex ); - lastName = patient.getFirstName().substring( endIndex + 1, patient.getFirstName().length() ); - } - } - - patientWeb.setFirstName( firstName ); - patientWeb.setMiddleName( middleName ); - patientWeb.setLastName( lastName ); + patientWeb.setName( patient.getName() ); patientWeb.setGender( patient.getGender() ); patientWeb.setDobType( patient.getDobType() ); patientWeb.setPhoneNumber( patient.getPhoneNumber() ); @@ -2015,12 +1967,12 @@ } if ( each.getBirthDate() != null ) { - patientsInfo += each.getId() + "/" + each.getFullName() + "/" + patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) + "$"; } else { - patientsInfo += each.getId() + "/" + each.getFullName() + "/DOB$"; + patientsInfo += each.getId() + "/" + each.getName() + "/DOB$"; } i++; } === modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java' --- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java 2013-09-11 14:28:23 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java 2013-09-12 07:19:15 +0000 @@ -28,20 +28,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.junit.Assert.*; - -import java.util.ArrayList; -import java.util.Date; - import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.api.mobile.ActivityReportingService; import org.hisp.dhis.api.mobile.NotAllowedException; +import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient; import org.hisp.dhis.api.mobile.model.PatientAttribute; import org.hisp.dhis.api.mobile.model.PatientIdentifier; -import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.ArrayList; +import java.util.Date; + +import static org.junit.Assert.assertEquals; + public class ActivityReportingServiceTest extends DhisSpringTest { @@ -60,11 +60,11 @@ patientA = activityReportingService.findPatient( patientAId ); assertEquals( patientAId, patientA.getId() ); - assertEquals( "FirstnameA", patientA.getFirstName() ); + assertEquals( "FirstnameA", patientA.getName() ); patientB = activityReportingService.findPatient( patientBId ); assertEquals( patientBId, patientB.getId() ); - assertEquals( "FirstnameB", patientB.getFirstName() ); + assertEquals( "FirstnameB", patientB.getName() ); } private Patient createLWUITPatient( char uniqueCharacter ) @@ -72,9 +72,7 @@ Patient patient = new Patient(); patient.setAge( 1 ); patient.setBirthDate( "25-09-1990" ); - patient.setFirstName( "Firstname" + uniqueCharacter ); - patient.setMiddleName( "Middlename" + uniqueCharacter ); - patient.setLastName( "Lastname" + uniqueCharacter ); + patient.setName( "Firstname" + uniqueCharacter ); patient.setGender( "male" ); patient.setOrganisationUnitName( "OrgUnitName" ); patient.setPhoneNumber( "095678943" ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java 2013-09-10 15:46:44 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientReminderService.java 2013-09-12 07:19:15 +0000 @@ -55,7 +55,7 @@ Patient patient = programInstance.getPatient(); String templateMessage = patientReminder.getTemplateMessage(); - String patientName = patient.getFirstName(); + String patientName = patient.getName(); String organisationunitName = patient.getOrganisationUnit().getName(); String programName = programInstance.getProgram().getName(); String daysSinceEnrollementDate = DateUtils.daysBetween( new Date(), programInstance.getEnrollmentDate() ) + ""; @@ -88,7 +88,7 @@ Patient patient = programStageInstance.getProgramInstance().getPatient(); String templateMessage = patientReminder.getTemplateMessage(); - String patientName = patient.getFirstName(); + String patientName = patient.getName(); String organisationunitName = patient.getOrganisationUnit().getName(); String programName = programStageInstance.getProgramInstance().getProgram().getName(); String programStageName = programStageInstance.getProgramStage().getName(); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-12 05:49:31 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-12 07:19:15 +0000 @@ -235,7 +235,11 @@ executeSql( "UPDATE programstage_dataelements SET displayAsRadioButton=false WHERE displayAsRadioButton is null" ); executeSql( "UPDATE patientreminder SET messageType=1 WHERE messageType is null" ); executeSql( "UPDATE programstage SET allowGenerateNextVisit=false WHERE allowGenerateNextVisit is null" ); - + + executeSql( "update patient set name=concat_ws(' ', trim(firstname), trim(middlename), trim(lastname))" ); + executeSql( "alter table patient drop column firstname" ); + executeSql( "alter table patient drop column middlename" ); + executeSql( "alter table patient drop column lastname" ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2013-09-10 04:51:49 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2013-09-12 07:19:15 +0000 @@ -28,14 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - import org.hisp.dhis.common.Grid; import org.hisp.dhis.common.GridHeader; import org.hisp.dhis.dataelement.DataElement; @@ -62,6 +54,14 @@ import org.hisp.dhis.user.CurrentUserService; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + /** * @author Abyot Asalefew * @version $Id$ @@ -247,13 +247,13 @@ Grid attrGrid = new ListGrid(); - if ( patient.getFirstName() == null && patient.getMiddleName() == null && patient.getLastName() == null ) + if ( patient.getName() == null ) { attrGrid.setTitle( "" ); } else { - attrGrid.setTitle( patient.getFullName() ); + attrGrid.setTitle( patient.getName() ); } attrGrid.setSubtitle( "" ); @@ -486,7 +486,7 @@ + format.formatDateTime( messasge.getDate() ) ); grid.addValue( messasge.getMessage() ); } - + // Get message conversations of the program-instance List conversations = programInstance.getMessageConversations(); @@ -495,7 +495,7 @@ { grid.addRow(); grid.addValue( i18n.getString( "message" ) + " " + i18n.getString( "on" ) + " " - + format.formatDateTime( conversation.getLastUpdated()) ); + + format.formatDateTime( conversation.getLastUpdated() ) ); grid.addValue( conversation.getMessages().get( 0 ) ); } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-09-06 08:24:36 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-09-12 07:19:15 +0000 @@ -12,6 +12,8 @@ &identifiableProperties; + + === modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java' --- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java 2013-09-12 07:19:15 +0000 @@ -73,8 +73,8 @@ int idA = patientStore.save( patientA ); int idB = patientStore.save( patientB ); - assertEquals( patientA.getFirstName(), patientStore.get( idA ).getFirstName() ); - assertEquals( patientB.getFirstName(), patientStore.get( idB ).getFirstName() ); + assertEquals( patientA.getName(), patientStore.get( idA ).getName() ); + assertEquals( patientB.getName(), patientStore.get( idB ).getName() ); } @Test @@ -83,8 +83,8 @@ int idA = patientStore.save( patientA ); int idB = patientStore.save( patientB ); - assertEquals( patientA.getFirstName(), patientStore.get( idA ).getFirstName() ); - assertEquals( patientB.getFirstName(), patientStore.get( idB ).getFirstName() ); + assertEquals( patientA.getName(), patientStore.get( idA ).getName() ); + assertEquals( patientB.getName(), patientStore.get( idB ).getName() ); } @Test === modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java' --- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2013-09-12 07:19:15 +0000 @@ -928,9 +928,7 @@ { Patient patient = new Patient(); - patient.setFirstName( "FirstName" + uniqueChar ); - patient.setMiddleName( "MiddleName" + uniqueChar ); - patient.setLastName( "LastName" + uniqueChar ); + patient.setName( "FirstName" + uniqueChar ); patient.setGender( Patient.MALE ); patient.setBirthDate( getDate( 1970, 1, 1 ) ); patient.setRegistrationDate( new Date() ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-09-11 12:12:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-09-12 07:19:15 +0000 @@ -154,7 +154,7 @@ // Set FirstName, MiddleName, LastName by FullName // --------------------------------------------------------------------- - patient.setFullName( fullName ); + patient.setName( fullName ); // --------------------------------------------------------------------- // Set Other information for patient === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRelationshipPatientAction.java 2013-09-12 07:19:15 +0000 @@ -178,32 +178,7 @@ if ( fullName != null ) { 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 ); + patient.setName( fullName ); } // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java 2013-09-12 07:19:15 +0000 @@ -111,32 +111,7 @@ // --------------------------------------------------------------------- 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 ); + patient.setName( fullName ); // --------------------------------------------------------------------- // Get Other information for patient === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-09-11 12:12:22 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-09-12 07:19:15 +0000 @@ -144,7 +144,7 @@ // Set FirstName, MiddleName, LastName by FullName // --------------------------------------------------------------------- - patient.setFullName( fullName ); + patient.setName( fullName ); // --------------------------------------------------------------------- // Set Other information for patient === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm 2013-08-30 02:54:18 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm 2013-09-12 07:19:15 +0000 @@ -169,7 +169,7 @@ #if( $auth.hasAccess( "dhis-web-caseentry", "getPatientLocation" ) ) $i18n.getString( "change_patient_location" ) #end - $i18n.getString( "remove" ) + $i18n.getString( "remove" ) $i18n.getString( "patient_details_and_history" ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm 2013-07-31 06:51:17 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/relationshipList.vm 2013-09-12 07:19:15 +0000 @@ -95,7 +95,7 @@ $i18n.getString( 'manage_representative' ) - $i18n.getString( 'remove' ) + $i18n.getString( 'remove' ) #set( $mark = !$mark) === modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java' --- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2013-09-12 07:19:15 +0000 @@ -28,15 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import javax.servlet.http.HttpServletRequest; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionContext; import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.StrutsStatics; import org.hisp.dhis.light.utils.FormUtils; @@ -51,16 +44,24 @@ import org.hisp.dhis.patient.PatientIdentifierType; import org.hisp.dhis.patient.PatientIdentifierTypeService; import org.hisp.dhis.patient.PatientService; +import org.hisp.dhis.patient.util.PatientIdentifierGenerator; import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.util.ContextUtils; -import org.hisp.dhis.patient.util.PatientIdentifierGenerator; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.ISODateTimeFormat; -import com.opensymphony.xwork2.Action; -import com.opensymphony.xwork2.ActionContext; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public class SaveBeneficiaryAction implements Action @@ -339,13 +340,13 @@ patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes(); patientAttributes = patientAttributeService.getAllPatientAttributes(); Collection programs = programService.getAllPrograms(); - + for ( Program program : programs ) { patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() ); patientAttributes.removeAll( program.getPatientAttributes() ); } - + patient.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) ); if ( this.patientFullName.trim().length() < 7 ) @@ -354,33 +355,7 @@ } else { - patientFullName = patientFullName.trim(); - - int startIndex = patientFullName.indexOf( ' ' ); - int endIndex = patientFullName.lastIndexOf( ' ' ); - - String firstName = patientFullName.toString(); - String middleName = ""; - String lastName = ""; - - if ( patientFullName.indexOf( ' ' ) != -1 ) - { - firstName = patientFullName.substring( 0, startIndex ); - if ( startIndex == endIndex ) - { - middleName = ""; - lastName = patientFullName.substring( startIndex + 1, patientFullName.length() ); - } - else - { - middleName = patientFullName.substring( startIndex + 1, endIndex ); - lastName = patientFullName.substring( endIndex + 1, patientFullName.length() ); - } - } - - patient.setFirstName( firstName ); - patient.setMiddleName( middleName ); - patient.setLastName( lastName ); + patient.setName( patientFullName.trim() ); } patient.setGender( gender ); @@ -429,7 +404,7 @@ Collection patientIdentifierTypes = patientIdentifierTypeService .getAllPatientIdentifierTypes(); Collection patientAttributes = patientAttributeService.getAllPatientAttributes(); - + for ( Program program : programs ) { @@ -477,15 +452,15 @@ } } } - + String identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), gender ); PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); systemGenerateIdentifier = new PatientIdentifier(); systemGenerateIdentifier.setIdentifier( identifier ); systemGenerateIdentifier.setPatient( patient ); - patientIdentifierSet.add(systemGenerateIdentifier); - + patientIdentifierSet.add( systemGenerateIdentifier ); + for ( PatientAttribute patientAttribute : patientAttributes ) { patientAttributeSet.add( patientAttribute );