=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-11-29 09:24:58 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-12-16 04:27:26 +0000 @@ -66,8 +66,6 @@ public static String OBJECT_PATIENT_ATTRIBUTE = "CA"; - public static String OBJECT_PATIENT_PROPERTY = "CP"; - public static String OBJECT_PROGRAM_PROPERTY = "PP"; public static String OBJECT_PROGRAM = "PG"; @@ -97,8 +95,8 @@ public static final String regExp = "\\[(" + OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE + "|" + OBJECT_PATIENT + "|" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE + "|" + OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" - + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" - + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+[" + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]"; + + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9@#\\- ]+[" + + SEPARATOR_ID + "[a-zA-Z0-9]*]*)" + "\\]"; public static final String dataelementRegExp = MINUS_OPERATOR + "{1}\\s*\\(\\s*(\\[" + OBJECT_PROGRAM_STAGE_DATAELEMENT + SEPARATOR_OBJECT + "([0-9]+" + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID === 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-11-25 07:31:02 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-12-16 04:27:26 +0000 @@ -28,8 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Calendar; -import java.util.Date; import java.util.HashSet; import java.util.Set; @@ -60,30 +58,10 @@ */ private static final long serialVersionUID = 884114994005945275L; - public static final String MALE = "M"; - - public static final String FEMALE = "F"; - - public static final String TRANSGENDER = "T"; - - public static final char DOB_TYPE_VERIFIED = 'V'; - - public static final char DOB_TYPE_DECLARED = 'D'; - - public static final char DOB_TYPE_APPROXIMATED = 'A'; - - public static final char AGE_TYPE_YEAR = 'Y'; - - public static final char AGE_TYPE_MONTH = 'M'; - - public static final char AGE_TYPE_DAY = 'D'; - public static String SEARCH_SAPERATE = "_"; public static String PREFIX_IDENTIFIER_TYPE = "iden"; - public static String PREFIX_FIXED_ATTRIBUTE = "fixedAttr"; - public static String PREFIX_PATIENT_ATTRIBUTE = "attr"; public static String PREFIX_PROGRAM = "prg"; @@ -94,28 +72,6 @@ public static String PREFIX_PROGRAM_STAGE = "prgst"; - public static String FIXED_ATTR_BIRTH_DATE = "birthDate"; - - public static String FIXED_ATTR_AGE = "age"; - - public static String FIXED_ATTR_INTEGER_AGE = "integerValueOfAge"; - - public static String FIXED_ATTR_REGISTRATION_DATE = "registrationDate"; - - public static String FIXED_ATTR_FULL_NAME = "fullName"; - - private String gender; - - private Date birthDate; - - private String phoneNumber; - - private Date deathDate; - - private Date registrationDate; - - private boolean isDead; - private Set identifiers = new HashSet(); private Set attributeValues = new HashSet(); @@ -124,12 +80,10 @@ private OrganisationUnit organisationUnit; + private String phoneNumber; + private Patient representative; - private boolean underAge; - - private Character dobType; - private User associate; // ------------------------------------------------------------------------- @@ -144,11 +98,6 @@ // Getters and setters // ------------------------------------------------------------------------- - public String getFullName() - { - return name; - } - @JsonProperty @JsonSerialize( as = BaseIdentifiableObject.class ) @JsonView( { DetailedView.class, ExportView.class } ) @@ -163,58 +112,6 @@ this.organisationUnit = organisationUnit; } - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public String getGender() - { - return gender; - } - - public void setGender( String gender ) - { - this.gender = gender; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getBirthDate() - { - return birthDate; - } - - public void setBirthDate( Date birthDate ) - { - this.birthDate = birthDate; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getDeathDate() - { - return deathDate; - } - - public void setDeathDate( Date deathDate ) - { - this.deathDate = deathDate; - } - - @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Boolean getIsDead() - { - return isDead; - } - - public void setIsDead( Boolean isDead ) - { - this.isDead = isDead; - } - public Set getIdentifiers() { return identifiers; @@ -260,19 +157,6 @@ } @JsonProperty - @JsonView( { DetailedView.class, ExportView.class } ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getRegistrationDate() - { - return registrationDate; - } - - public void setRegistrationDate( Date registrationDate ) - { - this.registrationDate = registrationDate; - } - - @JsonProperty @JsonSerialize( as = BaseIdentifiableObject.class ) @JsonView( { DetailedView.class, ExportView.class } ) @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) @@ -290,131 +174,6 @@ // Convenience method // ------------------------------------------------------------------------- - public String getAge() - { - if ( birthDate == null ) - { - return "0"; - } - - Calendar birthCalendar = Calendar.getInstance(); - birthCalendar.setTime( birthDate ); - - Calendar todayCalendar = Calendar.getInstance(); - - int age = todayCalendar.get( Calendar.YEAR ) - birthCalendar.get( Calendar.YEAR ); - - if ( todayCalendar.get( Calendar.MONTH ) < birthCalendar.get( Calendar.MONTH ) ) - { - age--; - } - else if ( todayCalendar.get( Calendar.MONTH ) == birthCalendar.get( Calendar.MONTH ) - && todayCalendar.get( Calendar.DAY_OF_MONTH ) < birthCalendar.get( Calendar.DAY_OF_MONTH ) ) - { - age--; - } - - if ( age < 1 ) - { - return "< 1 yr"; - } - - return age + " yr"; - } - - public int getIntegerValueOfAge() - { - return getIntegerValueOfAge( birthDate ); - } - - public static int getIntegerValueOfAge( Date birthDate ) - { - if ( birthDate == null ) - { - return 0; - } - - Calendar birthCalendar = Calendar.getInstance(); - birthCalendar.setTime( birthDate ); - - Calendar todayCalendar = Calendar.getInstance(); - - int age = todayCalendar.get( Calendar.YEAR ) - birthCalendar.get( Calendar.YEAR ); - - if ( todayCalendar.get( Calendar.MONTH ) < birthCalendar.get( Calendar.MONTH ) ) - { - age--; - } - else if ( todayCalendar.get( Calendar.MONTH ) == birthCalendar.get( Calendar.MONTH ) - && todayCalendar.get( Calendar.DAY_OF_MONTH ) < birthCalendar.get( Calendar.DAY_OF_MONTH ) ) - { - age--; - } - - return age; - } - - public static Date getBirthFromAge( int age, char ageType ) - { - Calendar todayCalendar = Calendar.getInstance(); - todayCalendar.clear( Calendar.MILLISECOND ); - todayCalendar.clear( Calendar.SECOND ); - todayCalendar.clear( Calendar.MINUTE ); - todayCalendar.set( Calendar.HOUR_OF_DAY, 0 ); - - // Assumed relative to the 1st of January - // todayCalendar.set( Calendar.DATE, 1 ); - // todayCalendar.set( Calendar.MONTH, Calendar.JANUARY ); - - if ( ageType == AGE_TYPE_YEAR ) - { - todayCalendar.add( Calendar.YEAR, -1 * age ); - } - else if ( ageType == AGE_TYPE_MONTH ) - { - todayCalendar.add( Calendar.MONTH, -1 * age ); - } - else if ( ageType == AGE_TYPE_DAY ) - { - todayCalendar.add( Calendar.DATE, -1 * age ); - } - - return todayCalendar.getTime(); - } - - public void setBirthDateFromAge( int age, char ageType ) - { - Date fromAge = getBirthFromAge( age, ageType ); - setBirthDate( fromAge ); - } - - public char getAgeType() - { - Calendar todayCalendar = Calendar.getInstance(); - todayCalendar.clear( Calendar.MILLISECOND ); - todayCalendar.clear( Calendar.SECOND ); - todayCalendar.clear( Calendar.MINUTE ); - todayCalendar.set( Calendar.HOUR_OF_DAY, 0 ); - - Calendar birthCalendar = Calendar.getInstance(); - birthCalendar.setTime( birthDate ); - - int age = todayCalendar.get( Calendar.YEAR ) - birthCalendar.get( Calendar.YEAR ); - - if ( age > 0 ) - { - return AGE_TYPE_YEAR; - } - - age = todayCalendar.get( Calendar.MONTH ) - birthCalendar.get( Calendar.MONTH ); - if ( age > 0 ) - { - return AGE_TYPE_MONTH; - } - - return AGE_TYPE_DAY; - } - public void addIdentifier( PatientIdentifier identifier ) { identifiers.add( identifier ); @@ -453,41 +212,4 @@ this.phoneNumber = phoneNumber; } - public boolean isUnderAge() - { - return underAge; - } - - public void setUnderAge( boolean underAge ) - { - this.underAge = underAge; - } - - public String getTextGender() - { - return gender.equalsIgnoreCase( MALE ) ? "male" : "female"; - } - - public Character getDobType() - { - return dobType; - } - - public void setDobType( Character dobType ) - { - this.dobType = dobType; - } - - public String getTextDoBType() - { - switch ( dobType ) - { - case DOB_TYPE_VERIFIED: - return "Verified"; - case DOB_TYPE_DECLARED: - return "Declared"; - default: - return "Approxiated"; - } - } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-12-03 17:53:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java 2013-12-16 04:27:26 +0000 @@ -34,6 +34,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.view.DetailedView; @@ -44,7 +45,7 @@ /** * @author Abyot Asalefew */ -@JacksonXmlRootElement(localName = "personAttribute", namespace = DxfNamespaces.DXF_2_0) +@JacksonXmlRootElement( localName = "personAttribute", namespace = DxfNamespaces.DXF_2_0 ) public class PatientAttribute extends BaseIdentifiableObject { @@ -54,10 +55,15 @@ private static final long serialVersionUID = 3026922158464592390L; public static final String TYPE_DATE = "date"; + public static final String TYPE_STRING = "string"; + public static final String TYPE_INT = "number"; + public static final String TYPE_BOOL = "bool"; + public static final String TYPE_TRUE_ONLY = "trueOnly"; + public static final String TYPE_COMBO = "combo"; private String description; @@ -89,6 +95,19 @@ setAutoFields(); } + public PatientAttribute( String name, String description, String valueType, boolean mandatory, Boolean inherit, + Boolean displayOnVisitSchedule ) + { + this.name = name; + this.description = description; + this.valueType = valueType; + this.mandatory = mandatory; + this.inherit = inherit; + this.displayOnVisitSchedule = displayOnVisitSchedule; + + setAutoFields(); + } + // ------------------------------------------------------------------------- // Logic // ------------------------------------------------------------------------- @@ -143,8 +162,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public Boolean getGroupBy() { return groupBy; @@ -156,8 +175,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isMandatory() { return mandatory; @@ -169,8 +188,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getDescription() { return description; @@ -182,8 +201,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getValueType() { return valueType; @@ -209,8 +228,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getExpression() { return expression; @@ -222,8 +241,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public Boolean getDisplayOnVisitSchedule() { return displayOnVisitSchedule; @@ -235,8 +254,8 @@ } @JsonProperty - @JsonView({ DetailedView.class }) - @JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) + @JsonView( { DetailedView.class } ) + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public Integer getSortOrderInVisitSchedule() { return sortOrderInVisitSchedule; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java 2013-11-25 07:31:02 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationForm.java 2013-12-16 04:27:26 +0000 @@ -40,24 +40,6 @@ { private static final long serialVersionUID = -6000530171659755186L; - public static String FIXED_ATTRIBUTE_FULLNAME = "fullName"; - - public static String FIXED_ATTRIBUTE_GENDER = "gender"; - - public static String FIXED_ATTRIBUTE_BIRTHDATE = "birthDate"; - - public static String FIXED_ATTRIBUTE_AGE = "age"; - - public static String FIXED_ATTRIBUTE_PHONE_NUMBER = "phoneNumber"; - - public static String FIXED_ATTRIBUTE_DEATH_DATE = "deathDate"; - - public static String FIXED_ATTRIBUTE_REGISTRATION_DATE = "registrationDate"; - - public static String FIXED_ATTRIBUTE_IS_DEAD = "isDead"; - - public static String FIXED_ATTRIBUTE_DOB_TYPE = "dobType"; - public static String FIXED_ATTRIBUTE_ASSOCIATE = "associate"; private Program program; === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-11-18 11:50:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2013-12-16 04:27:26 +0000 @@ -28,6 +28,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Collection; +import java.util.List; +import java.util.Set; + import org.hisp.dhis.common.Grid; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; @@ -35,11 +39,6 @@ import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.program.Program; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Set; - /** * @author Abyot Asalefew Gizaw * @version $Id$ @@ -104,16 +103,6 @@ Collection getAllPatients(); /** - * Retrieve patients who is the same name, birthdate and gender - * - * @param name - * @param birthDate - * @param gender - * @return Patient List - * **/ - Collection getPatients( String name, Date birthdate, String gender ); - - /** * Retrieve patients by full name (performs partial search ) * * @param name fullName @@ -171,7 +160,7 @@ * @return */ Collection getPatients( OrganisationUnit organisationUnit, Program program ); - + /** * Retrieve patients base on organisationUnit and identifier value name * @@ -428,16 +417,6 @@ Collection getPatientByFullname( String fullName, OrganisationUnit organisationUnit ); /** - * Get ids of orgunits where patient registered in a certain period - * - * @param startDate Start date - * @param endDate End date - * - * @return List of patient - */ - Collection getRegistrationOrgunitIds( Date startDate, Date endDate ); - - /** * Get events of patients who meet the criteria for searching * * @param program Program. It's is used for getting identifier-types of this === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-12-06 16:26:51 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-12-16 04:27:26 +0000 @@ -60,16 +60,6 @@ Collection getByNames( String name, Integer min, Integer max ); /** - * Search patients by full name, date of birth and gender - * - * @param name Full name - * @param birthdate Date of birth - * - * @return List of patients - */ - Collection get( String name, Date birthdate, String gender ); - - /** * Search patients who registered in a certain organisation unit * * @param organisationUnit Organisation unit where patients registered @@ -110,7 +100,7 @@ Integer max ); List query( TrackedEntityQueryParams params ); - + /** * Search patient who has the same representative * @@ -192,16 +182,6 @@ Collection getByFullName( String name, OrganisationUnit organisationUnit ); /** - * Retrieve ids of orgunits where patient registered in a certain period - * - * @param startDate Start date - * @param endDate End date - * - * @return List of patient - */ - Collection getRegistrationOrgunitIds( Date startDate, Date endDate ); - - /** * Search events of patients who meet the criteria for searching * * @param searchKeys The key for searching patients by attribute values, === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaServiceTest.java 2013-12-16 04:27:26 +0000 @@ -34,7 +34,6 @@ import static org.junit.Assert.assertTrue; import java.util.Collection; -import java.util.Date; import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.patient.Patient; @@ -71,11 +70,11 @@ { validationCriteriaService = (ValidationCriteriaService) getBean( ValidationCriteriaService.ID ); - propertyA = Patient.class.getDeclaredField( "birthDate" ).getName(); - propertyB = Patient.class.getDeclaredField( "dobType" ).getName(); + propertyA = "name"; + propertyB = "name"; - valueA = new Date(); - valueB = (char)'A'; + valueA = "A"; + valueB = "B"; validationCriteriaA = createValidationCriteria( 'A', propertyA, ValidationCriteria.OPERATOR_EQUAL_TO, valueA ); validationCriteriaB = createValidationCriteria( 'B', propertyB, ValidationCriteria.OPERATOR_EQUAL_TO, valueB ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/validation/ValidationCriteriaStoreTest.java 2013-12-16 04:27:26 +0000 @@ -34,11 +34,9 @@ import static org.junit.Assert.assertTrue; import java.util.Collection; -import java.util.Date; import org.hisp.dhis.DhisSpringTest; import org.hisp.dhis.common.GenericIdentifiableObjectStore; -import org.hisp.dhis.patient.Patient; import org.junit.Test; /** @@ -69,13 +67,11 @@ { validationCriteriaStore = (GenericIdentifiableObjectStore) getBean( "org.hisp.dhis.validation.ValidationCriteriaStore" ); - propertyA = Patient.class.getDeclaredField( "birthDate" ).getName(); - - propertyB = Patient.class.getDeclaredField( "dobType" ).getName(); - - valueA = new Date(); - - valueB = (char) 'A'; + propertyA = "name"; + propertyB = "name"; + + valueA = "A"; + valueB = "B"; } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-11-05 08:07:19 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/AbstractPersonService.java 2013-12-16 04:27:26 +0000 @@ -124,7 +124,7 @@ // ------------------------------------------------------------------------- // READ - // ------------------------------------------------------------------------- + // --------------------T----------------------------------------------------- @Override public Persons getPersons() @@ -136,7 +136,8 @@ @Override public Person getPerson( Identifier identifier ) { - PatientIdentifierType patientIdentifierType = patientIdentifierTypeService.getPatientIdentifierTypeByUid( identifier.getType() ); + PatientIdentifierType patientIdentifierType = patientIdentifierTypeService + .getPatientIdentifierTypeByUid( identifier.getType() ); Patient patient = patientIdentifierService.getPatient( patientIdentifierType, identifier.getValue() ); return getPerson( patient ); } @@ -151,7 +152,8 @@ @Override public Persons getPersons( OrganisationUnit organisationUnit, String nameLike ) { - List patients = new ArrayList( patientService.getPatientsLikeName( organisationUnit, nameLike, 0, Integer.MAX_VALUE ) ); + List patients = new ArrayList( patientService.getPatientsLikeName( organisationUnit, + nameLike, 0, Integer.MAX_VALUE ) ); return getPersons( patients ); } @@ -201,10 +203,6 @@ person.setOrgUnit( patient.getOrganisationUnit().getUid() ); person.setName( patient.getName() ); - person.setGender( Gender.fromString( patient.getGender() ) ); - - person.setDeceased( patient.getIsDead() ); - person.setDateOfDeath( patient.getDeathDate() ); Contact contact = new Contact(); contact.setPhoneNumber( nullIfEmpty( patient.getPhoneNumber() ) ); @@ -214,28 +212,6 @@ person.setContact( contact ); } - DateOfBirth dateOfBirth; - - Character dobType = patient.getDobType(); - - if ( dobType != null && patient.getBirthDate() != null ) - { - if ( dobType.equals( Patient.DOB_TYPE_VERIFIED ) || dobType.equals( Patient.DOB_TYPE_DECLARED ) ) - { - dateOfBirth = new DateOfBirth( patient.getBirthDate(), - DateOfBirthType.fromString( String.valueOf( dobType ) ) ); - } - else - { - // assume APPROXIMATE - dateOfBirth = new DateOfBirth( patient.getIntegerValueOfAge() ); - } - - person.setDateOfBirth( dateOfBirth ); - } - - person.setDateOfRegistration( patient.getRegistrationDate() ); - Collection relationshipsForPatient = relationshipService.getRelationshipsForPatient( patient ); for ( Relationship relationshipPatient : relationshipsForPatient ) @@ -250,15 +226,18 @@ for ( PatientIdentifier patientIdentifier : patient.getIdentifiers() ) { - String identifierType = patientIdentifier.getIdentifierType() == null ? null : patientIdentifier.getIdentifierType().getUid(); - String displayName = patientIdentifier.getIdentifierType() != null ? patientIdentifier.getIdentifierType().getDisplayName() : null; + String identifierType = patientIdentifier.getIdentifierType() == null ? null : patientIdentifier + .getIdentifierType().getUid(); + String displayName = patientIdentifier.getIdentifierType() != null ? patientIdentifier.getIdentifierType() + .getDisplayName() : null; Identifier identifier = new Identifier( identifierType, patientIdentifier.getIdentifier() ); identifier.setDisplayName( displayName ); person.getIdentifiers().add( identifier ); } - Collection patientAttributeValues = patientAttributeValueService.getPatientAttributeValues( patient ); + Collection patientAttributeValues = patientAttributeValueService + .getPatientAttributeValues( patient ); for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) { @@ -279,45 +258,17 @@ Patient patient = new Patient(); patient.setName( person.getName() ); - patient.setGender( person.getGender().getValue() ); OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, person.getOrgUnit() ); Assert.notNull( organisationUnit ); patient.setOrganisationUnit( organisationUnit ); - DateOfBirth dateOfBirth = person.getDateOfBirth(); - - if ( dateOfBirth != null ) - { - if ( dateOfBirth.getDate() != null && (dateOfBirth.getType().equals( DateOfBirthType.DECLARED ) || - dateOfBirth.getType().equals( DateOfBirthType.VERIFIED )) ) - { - char dobType = dateOfBirth.getType().getValue().charAt( 0 ); - patient.setDobType( dobType ); - patient.setBirthDate( dateOfBirth.getDate() ); - } - else if ( dateOfBirth.getAge() != null && dateOfBirth.getType().equals( DateOfBirthType.APPROXIMATE ) ) - { - char dobType = dateOfBirth.getType().getValue().charAt( 0 ); - patient.setDobType( dobType ); - patient.setBirthDateFromAge( dateOfBirth.getAge(), dobType ); - } - } - if ( person.getContact() != null && person.getContact().getPhoneNumber() != null ) { patient.setPhoneNumber( person.getContact().getPhoneNumber() ); } - patient.setIsDead( person.isDeceased() ); - - if ( person.isDeceased() && person.getDateOfDeath() != null ) - { - patient.setDeathDate( person.getDateOfDeath() ); - } - - patient.setRegistrationDate( person.getDateOfRegistration() ); updateIdentifiers( person, patient ); return patient; @@ -380,24 +331,16 @@ if ( patient == null ) { - importConflicts.add( - new ImportConflict( "Person", "person " + person.getPerson() + " does not point to valid person" ) ); + importConflicts.add( new ImportConflict( "Person", "person " + person.getPerson() + + " does not point to valid person" ) ); } OrganisationUnit organisationUnit = manager.get( OrganisationUnit.class, person.getOrgUnit() ); if ( organisationUnit == null ) { - importConflicts.add( - new ImportConflict( "OrganisationUnit", "orgUnit " + person.getOrgUnit() + " does not point to valid organisation unit" ) ); - } - - DateOfBirth dateOfBirth = person.getDateOfBirth(); - - if ( dateOfBirth == null ) - { - importConflicts.add( - new ImportConflict( "DateOfBirth", "dateOfBirth is not present" ) ); + importConflicts.add( new ImportConflict( "OrganisationUnit", "orgUnit " + person.getOrgUnit() + + " does not point to valid organisation unit" ) ); } importSummary.setConflicts( importConflicts ); @@ -410,23 +353,9 @@ } patient.setName( person.getName() ); - patient.setGender( person.getGender().getValue() ); - patient.setIsDead( person.isDeceased() ); - patient.setDeathDate( person.getDateOfDeath() ); - // TODO should we allow update of this property? - patient.setRegistrationDate( person.getDateOfRegistration() ); - String phoneNumber = person.getContact() != null ? person.getContact().getPhoneNumber() : null; patient.setPhoneNumber( phoneNumber ); - if ( DateOfBirthType.APPROXIMATE.equals( dateOfBirth.getType() ) ) - { - dateOfBirth = new DateOfBirth( dateOfBirth.getAge() ); - } - - patient.setDobType( dateOfBirth.getType().getValue().charAt( 0 ) ); - patient.setBirthDate( dateOfBirth.getDate() ); - updateSystemIdentifier( person ); removeRelationships( patient ); removeIdentifiers( patient ); @@ -489,23 +418,24 @@ { if ( !cacheMap.keySet().contains( patientIdentifierType.getUid() ) ) { - importConflicts.add( - new ImportConflict( "Identifier.type", "Missing required identifier type " + patientIdentifierType.getUid() ) ); + importConflicts.add( new ImportConflict( "Identifier.type", "Missing required identifier type " + + patientIdentifierType.getUid() ) ); } } - List patientIdentifiers = new ArrayList( patientIdentifierService.getAll( - patientIdentifierType, cacheMap.get( patientIdentifierType.getUid() ) ) ); + List patientIdentifiers = new ArrayList( + patientIdentifierService.getAll( patientIdentifierType, cacheMap.get( patientIdentifierType.getUid() ) ) ); if ( !patientIdentifiers.isEmpty() ) { - // if .size() > 1, there is something wrong with the db.. but we for-loop for now + // if .size() > 1, there is something wrong with the db.. but we + // for-loop for now for ( PatientIdentifier patientIdentifier : patientIdentifiers ) { if ( !patientIdentifier.getPatient().equals( patient ) ) { - importConflicts.add( - new ImportConflict( "Identifier.value", "Value already exists for patient " + patientIdentifier.getPatient().getUid() + importConflicts.add( new ImportConflict( "Identifier.value", + "Value already exists for patient " + patientIdentifier.getPatient().getUid() + " with identifier type " + patientIdentifierType.getUid() ) ); } } @@ -514,12 +444,12 @@ for ( Identifier identifier : person.getIdentifiers() ) { - PatientIdentifierType patientIdentifierType = manager.get( PatientIdentifierType.class, identifier.getType() ); + PatientIdentifierType patientIdentifierType = manager.get( PatientIdentifierType.class, + identifier.getType() ); if ( patientIdentifierType == null ) { - importConflicts.add( - new ImportConflict( "Identifier.type", "Invalid type " + identifier.getType() ) ); + importConflicts.add( new ImportConflict( "Identifier.type", "Invalid type " + identifier.getType() ) ); } } @@ -546,8 +476,8 @@ { if ( !cache.contains( patientAttribute.getUid() ) ) { - importConflicts.add( - new ImportConflict( "Attribute.type", "Missing required attribute type " + patientAttribute.getUid() ) ); + importConflicts.add( new ImportConflict( "Attribute.type", "Missing required attribute type " + + patientAttribute.getUid() ) ); } } } @@ -558,8 +488,7 @@ if ( patientAttribute == null ) { - importConflicts.add( - new ImportConflict( "Attribute.type", "Invalid type " + attribute.getType() ) ); + importConflicts.add( new ImportConflict( "Attribute.type", "Invalid type " + attribute.getType() ) ); } } @@ -576,23 +505,22 @@ if ( relationshipType == null ) { - importConflicts.add( - new ImportConflict( "Relationship.type", "Invalid type " + relationship.getType() ) ); + importConflicts + .add( new ImportConflict( "Relationship.type", "Invalid type " + relationship.getType() ) ); } Patient patient = manager.get( Patient.class, relationship.getPerson() ); if ( patient == null ) { - importConflicts.add( - new ImportConflict( "Relationship.person", "Invalid person " + relationship.getPerson() ) ); + importConflicts.add( new ImportConflict( "Relationship.person", "Invalid person " + + relationship.getPerson() ) ); } } return importConflicts; } - private void updateAttributeValues( Person person, Patient patient ) { for ( Attribute attribute : person.getAttributes() ) @@ -613,15 +541,6 @@ private void updateSystemIdentifier( Person person ) { - Date birthDate = person.getDateOfBirth() != null ? person.getDateOfBirth().getDate() : null; - String gender = person.getGender() != null ? person.getGender().getValue() : null; - - if ( birthDate == null || gender == null ) - { - birthDate = new Date(); - gender = "F"; - } - Iterator iterator = person.getIdentifiers().iterator(); // remove any old system identifiers @@ -634,12 +553,9 @@ iterator.remove(); } } - - Identifier identifier = generateSystemIdentifier( birthDate, gender ); - + Identifier identifier = null; if ( person.getPerson() != null ) { - identifier = generateSystemIdentifier( birthDate, gender ); Patient patient = manager.get( Patient.class, person.getPerson() ); for ( PatientIdentifier patientIdentifier : patient.getIdentifiers() ) @@ -652,25 +568,10 @@ } } - person.getIdentifiers().add( identifier ); - } - - private Identifier generateSystemIdentifier( Date birthDate, String gender ) - { - String systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender ); - - PatientIdentifier patientIdentifier = patientIdentifierService.get( null, systemId ); - - while ( patientIdentifier != null ) + if ( identifier != null ) { - systemId = PatientIdentifierGenerator.getNewIdentifier( birthDate, gender ); - patientIdentifier = patientIdentifierService.get( null, systemId ); + person.getIdentifiers().add( identifier ); } - - Identifier identifier = new Identifier(); - identifier.setValue( systemId ); - - return identifier; } // add identifiers from person => patient === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/DateOfBirth.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/DateOfBirth.java 2013-10-15 07:40:07 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/DateOfBirth.java 1970-01-01 00:00:00 +0000 @@ -1,133 +0,0 @@ -package org.hisp.dhis.dxf2.events.person; - -/* - * 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 com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import org.hisp.dhis.common.DxfNamespaces; -import org.hisp.dhis.patient.Patient; - -import java.util.Date; - -/** - * @author Morten Olav Hansen - */ -@JacksonXmlRootElement( localName = "dateOfBirth", namespace = DxfNamespaces.DXF_2_0 ) -public class DateOfBirth -{ - private final Date date; - - private final DateOfBirthType type; - - private final Integer age; - - public DateOfBirth() - { - this.type = DateOfBirthType.APPROXIMATE; - this.age = 0; - this.date = Patient.getBirthFromAge( age, Patient.AGE_TYPE_YEAR ); - } - - public DateOfBirth( Date date ) - { - this.type = DateOfBirthType.VERIFIED; - this.age = Patient.getIntegerValueOfAge( date ); - this.date = date; - } - - public DateOfBirth( Date date, DateOfBirthType type ) - { - this.type = type; - this.age = Patient.getIntegerValueOfAge( date ); - this.date = date; - } - - public DateOfBirth( Integer age ) - { - this.type = DateOfBirthType.APPROXIMATE; - this.age = age; - this.date = Patient.getBirthFromAge( age, Patient.AGE_TYPE_YEAR ); - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( isAttribute = true ) - public Date getDate() - { - return date; - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public DateOfBirthType getType() - { - return type; - } - - @JsonProperty( required = true ) - @JacksonXmlProperty( isAttribute = true ) - public Integer getAge() - { - return age; - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) return true; - if ( o == null || getClass() != o.getClass() ) return false; - - DateOfBirth that = (DateOfBirth) o; - - if ( age != null ? !age.equals( that.age ) : that.age != null ) return false; - if ( date != null ? !date.equals( that.date ) : that.date != null ) return false; - if ( type != that.type ) return false; - - return true; - } - - @Override - public int hashCode() - { - int result = date != null ? date.hashCode() : 0; - result = 31 * result + (type != null ? type.hashCode() : 0); - result = 31 * result + (age != null ? age.hashCode() : 0); - return result; - } - - @Override - public String toString() - { - return "DateOfBirth{" + - "date=" + date + - ", type=" + type + - ", age=" + age + - '}'; - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/DateOfBirthType.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/DateOfBirthType.java 2013-09-17 12:15:39 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/DateOfBirthType.java 1970-01-01 00:00:00 +0000 @@ -1,64 +0,0 @@ -package org.hisp.dhis.dxf2.events.person; - -/* - * 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. - */ - -/** - * @author Morten Olav Hansen - */ -public enum DateOfBirthType -{ - VERIFIED( "V" ), - DECLARED( "D" ), - APPROXIMATE( "A" ); - - private final String value; - - private DateOfBirthType( String value ) - { - this.value = value; - } - - public String getValue() - { - return value; - } - - public static DateOfBirthType fromString( String text ) - { - for ( DateOfBirthType dateOfBirthType : DateOfBirthType.values() ) - { - if ( text.equals( dateOfBirthType.getValue() ) ) - { - return dateOfBirthType; - } - } - - throw new IllegalArgumentException(); - } -} === removed file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Gender.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Gender.java 2013-09-17 12:15:39 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Gender.java 1970-01-01 00:00:00 +0000 @@ -1,66 +0,0 @@ -package org.hisp.dhis.dxf2.events.person; - -/* - * 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 com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import org.hisp.dhis.common.DxfNamespaces; - -/** - * @author Morten Olav Hansen - */ -@JacksonXmlRootElement( localName = "gender", namespace = DxfNamespaces.DXF_2_0 ) -public enum Gender -{ - MALE( "M" ), FEMALE( "F" ), TRANSGENDER( "T" ); - - private final String value; - - private Gender( String value ) - { - this.value = value; - } - - public String getValue() - { - return value; - } - - public static Gender fromString( String text ) - { - for ( Gender gender : Gender.values() ) - { - if ( text.equals( gender.getValue() ) ) - { - return gender; - } - } - - throw new IllegalArgumentException(); - } -} === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java 2013-09-19 08:51:41 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/person/Person.java 2013-12-16 04:27:26 +0000 @@ -28,14 +28,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.common.DxfNamespaces; + import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; -import org.hisp.dhis.common.DxfNamespaces; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; /** * @author Morten Olav Hansen @@ -49,16 +49,6 @@ private String name; - private Gender gender; - - private DateOfBirth dateOfBirth; - - private boolean deceased; - - private Date dateOfDeath; - - private Date dateOfRegistration = new Date(); - private Contact contact; private List relationships = new ArrayList(); @@ -109,66 +99,6 @@ @JsonProperty @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Gender getGender() - { - return gender; - } - - public void setGender( Gender gender ) - { - this.gender = gender; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public DateOfBirth getDateOfBirth() - { - return dateOfBirth; - } - - public void setDateOfBirth( DateOfBirth dateOfBirth ) - { - this.dateOfBirth = dateOfBirth; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public boolean isDeceased() - { - return deceased; - } - - public void setDeceased( boolean deceased ) - { - this.deceased = deceased; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getDateOfDeath() - { - return dateOfDeath; - } - - public void setDateOfDeath( Date dateOfDeath ) - { - this.dateOfDeath = dateOfDeath; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) - public Date getDateOfRegistration() - { - return dateOfRegistration; - } - - public void setDateOfRegistration( Date dateOfRegistration ) - { - this.dateOfRegistration = dateOfRegistration; - } - - @JsonProperty - @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public Contact getContact() { return contact; @@ -218,24 +148,26 @@ @Override public boolean equals( Object o ) { - if ( this == o ) return true; - if ( o == null || getClass() != o.getClass() ) return false; + if ( this == o ) + return true; + if ( o == null || getClass() != o.getClass() ) + return false; Person person1 = (Person) o; - - if ( deceased != person1.deceased ) return false; - if ( attributes != null ? !attributes.equals( person1.attributes ) : person1.attributes != null ) return false; - if ( contact != null ? !contact.equals( person1.contact ) : person1.contact != null ) return false; - if ( dateOfBirth != null ? !dateOfBirth.equals( person1.dateOfBirth ) : person1.dateOfBirth != null ) return false; - if ( dateOfDeath != null ? !dateOfDeath.equals( person1.dateOfDeath ) : person1.dateOfDeath != null ) return false; - if ( dateOfRegistration != null ? !dateOfRegistration.equals( person1.dateOfRegistration ) : person1.dateOfRegistration != null ) - return false; - if ( gender != person1.gender ) return false; - if ( identifiers != null ? !identifiers.equals( person1.identifiers ) : person1.identifiers != null ) return false; - if ( name != null ? !name.equals( person1.name ) : person1.name != null ) return false; - if ( orgUnit != null ? !orgUnit.equals( person1.orgUnit ) : person1.orgUnit != null ) return false; - if ( person != null ? !person.equals( person1.person ) : person1.person != null ) return false; - if ( relationships != null ? !relationships.equals( person1.relationships ) : person1.relationships != null ) return false; + if ( attributes != null ? !attributes.equals( person1.attributes ) : person1.attributes != null ) + return false; + if ( contact != null ? !contact.equals( person1.contact ) : person1.contact != null ) + return false; + if ( identifiers != null ? !identifiers.equals( person1.identifiers ) : person1.identifiers != null ) + return false; + if ( name != null ? !name.equals( person1.name ) : person1.name != null ) + return false; + if ( orgUnit != null ? !orgUnit.equals( person1.orgUnit ) : person1.orgUnit != null ) + return false; + if ( person != null ? !person.equals( person1.person ) : person1.person != null ) + return false; + if ( relationships != null ? !relationships.equals( person1.relationships ) : person1.relationships != null ) + return false; return true; } @@ -246,11 +178,6 @@ int result = person != null ? person.hashCode() : 0; result = 31 * result + (orgUnit != null ? orgUnit.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (gender != null ? gender.hashCode() : 0); - result = 31 * result + (dateOfBirth != null ? dateOfBirth.hashCode() : 0); - result = 31 * result + (deceased ? 1 : 0); - result = 31 * result + (dateOfDeath != null ? dateOfDeath.hashCode() : 0); - result = 31 * result + (dateOfRegistration != null ? dateOfRegistration.hashCode() : 0); result = 31 * result + (contact != null ? contact.hashCode() : 0); result = 31 * result + (relationships != null ? relationships.hashCode() : 0); result = 31 * result + (identifiers != null ? identifiers.hashCode() : 0); @@ -258,21 +185,11 @@ return result; } - @Override public String toString() + @Override + public String toString() { - return "Person{" + - "person='" + person + '\'' + - ", orgUnit='" + orgUnit + '\'' + - ", name='" + name + '\'' + - ", gender=" + gender + - ", dateOfBirth=" + dateOfBirth + - ", deceased=" + deceased + - ", dateOfDeath=" + dateOfDeath + - ", dateOfRegistration=" + dateOfRegistration + - ", contact=" + contact + - ", relationships=" + relationships + - ", identifiers=" + identifiers + - ", attributes=" + attributes + - '}'; + return "Person{" + "person='" + person + '\'' + ", orgUnit='" + orgUnit + '\'' + ", name='" + name + '\'' + + ", contact=" + contact + ", relationships=" + relationships + ", identifiers=" + identifiers + + ", attributes=" + attributes + '}'; } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2013-12-01 22:32:50 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2013-12-16 04:27:26 +0000 @@ -96,10 +96,10 @@ manager.save( organisationUnitA ); manager.save( organisationUnitB ); - maleA = createPatient( 'A', Patient.MALE, organisationUnitA ); - maleB = createPatient( 'B', Patient.MALE, organisationUnitB ); - femaleA = createPatient( 'C', Patient.FEMALE, organisationUnitA ); - femaleB = createPatient( 'D', Patient.FEMALE, organisationUnitB ); + maleA = createPatient( 'A', organisationUnitA ); + maleB = createPatient( 'B', organisationUnitB ); + femaleA = createPatient( 'C', organisationUnitA ); + femaleB = createPatient( 'D', organisationUnitB ); manager.save( maleA ); manager.save( maleB ); @@ -152,6 +152,7 @@ @Test public void testGetEnrollmentsByPerson() { + programInstanceService.enrollPatient( maleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) ); programInstanceService.enrollPatient( femaleA, programA, null, null, organisationUnitA, mock( I18nFormat.class ) ); @@ -191,6 +192,8 @@ Enrollment enrollment = new Enrollment(); enrollment.setPerson( maleA.getUid() ); enrollment.setProgram( programA.getUid() ); + enrollment.setDateOfIncident( new Date() ); + enrollment.setDateOfEnrollment( new Date() ); ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); @@ -238,6 +241,8 @@ Enrollment enrollment = new Enrollment(); enrollment.setPerson( maleA.getUid() ); enrollment.setProgram( programA.getUid() ); + enrollment.setDateOfIncident( new Date() ); + enrollment.setDateOfEnrollment( new Date() ); ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); @@ -260,6 +265,8 @@ Enrollment enrollment = new Enrollment(); enrollment.setPerson( maleA.getUid() ); enrollment.setProgram( programA.getUid() ); + enrollment.setDateOfIncident( new Date() ); + enrollment.setDateOfEnrollment( new Date() ); ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); @@ -282,6 +289,8 @@ Enrollment enrollment = new Enrollment(); enrollment.setPerson( maleA.getUid() ); enrollment.setProgram( programA.getUid() ); + enrollment.setDateOfIncident( new Date() ); + enrollment.setDateOfEnrollment( new Date() ); ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); @@ -310,6 +319,8 @@ Enrollment enrollment = new Enrollment(); enrollment.setPerson( maleA.getUid() ); enrollment.setProgram( programA.getUid() ); + enrollment.setDateOfIncident( new Date() ); + enrollment.setDateOfEnrollment( new Date() ); ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/PersonServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/PersonServiceTest.java 2013-10-14 10:24:31 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/PersonServiceTest.java 2013-12-16 04:27:26 +0000 @@ -30,9 +30,6 @@ import org.hisp.dhis.DhisTest; import org.hisp.dhis.common.IdentifiableObjectManager; -import org.hisp.dhis.dxf2.events.person.DateOfBirth; -import org.hisp.dhis.dxf2.events.person.DateOfBirthType; -import org.hisp.dhis.dxf2.events.person.Gender; import org.hisp.dhis.dxf2.events.person.Person; import org.hisp.dhis.dxf2.events.person.PersonService; import org.hisp.dhis.dxf2.importsummary.ImportStatus; @@ -85,10 +82,10 @@ organisationUnitB.setParent( organisationUnitA ); - maleA = createPatient( 'A', Patient.MALE, organisationUnitA ); - maleB = createPatient( 'B', Patient.MALE, organisationUnitB ); - femaleA = createPatient( 'C', Patient.FEMALE, organisationUnitA ); - femaleB = createPatient( 'D', Patient.FEMALE, organisationUnitB ); + maleA = createPatient( 'A', organisationUnitA ); + maleB = createPatient( 'B', organisationUnitB ); + femaleA = createPatient( 'C', organisationUnitA ); + femaleB = createPatient( 'D', organisationUnitB ); programA = createProgram( 'A', new HashSet(), organisationUnitA ); programA.setUseBirthDateAsEnrollmentDate( true ); @@ -161,13 +158,11 @@ { Person person = personService.getPerson( maleA.getUid() ); person.setName( "UPDATED_NAME" ); - person.setGender( Gender.TRANSGENDER ); ImportSummary importSummary = personService.updatePerson( person ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); assertEquals( "UPDATED_NAME", personService.getPerson( maleA.getUid() ).getName() ); - assertEquals( Gender.TRANSGENDER, personService.getPerson( maleA.getUid() ).getGender() ); } @Test @@ -175,18 +170,12 @@ { Person person = new Person(); person.setName( "NAME" ); - person.setGender( Gender.MALE ); person.setOrgUnit( organisationUnitA.getUid() ); - DateOfBirth dateOfBirth = new DateOfBirth( new Date(), DateOfBirthType.VERIFIED ); - person.setDateOfBirth( dateOfBirth ); - ImportSummary importSummary = personService.savePerson( person ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); assertEquals( "NAME", personService.getPerson( importSummary.getReference() ).getName() ); - assertEquals( Gender.MALE, personService.getPerson( importSummary.getReference() ).getGender() ); - assertEquals( DateOfBirthType.VERIFIED, personService.getPerson( importSummary.getReference() ).getDateOfBirth().getType() ); } @Test === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2013-10-14 09:59:01 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2013-12-16 04:27:26 +0000 @@ -82,35 +82,48 @@ private IdentifiableObjectManager manager; private Patient maleA; + private Patient maleB; + private Patient femaleA; + private Patient femaleB; private Person personMaleA; + private Person personMaleB; + private Person personFemaleA; + private Person personFemaleB; private OrganisationUnit organisationUnitA; + private OrganisationUnit organisationUnitB; + private Program programA; + private DataElement dataElementA; + private DataElement dataElementB; + private ProgramStage programStageA; + private ProgramStage programStageB; @Override - protected void setUpTest() throws Exception + protected void setUpTest() + throws Exception { organisationUnitA = createOrganisationUnit( 'A' ); organisationUnitB = createOrganisationUnit( 'B' ); manager.save( organisationUnitA ); manager.save( organisationUnitB ); - maleA = createPatient( 'A', Patient.MALE, organisationUnitA ); - maleB = createPatient( 'B', Patient.MALE, organisationUnitB ); - femaleA = createPatient( 'C', Patient.FEMALE, organisationUnitA ); - femaleB = createPatient( 'D', Patient.FEMALE, organisationUnitB ); + maleA = createPatient( 'A', organisationUnitA ); + maleB = createPatient( 'B', organisationUnitB ); + femaleA = createPatient( 'C', organisationUnitA ); + femaleB = createPatient( 'D', organisationUnitB ); manager.save( maleA ); manager.save( maleB ); @@ -182,16 +195,19 @@ @Test public void testSaveWithoutProgramStageShouldFail() { - Event event = createEvent( programA.getUid(), null, organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); + Event event = createEvent( programA.getUid(), null, organisationUnitA.getUid(), personMaleA.getPerson(), + dataElementA.getUid() ); ImportSummary importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.ERROR, importSummary.getStatus() ); - assertThat( importSummary.getDescription(), CoreMatchers.containsString( "Event.programStage does not point to a valid programStage" ) ); + assertThat( importSummary.getDescription(), + CoreMatchers.containsString( "Event.programStage does not point to a valid programStage" ) ); } @Test public void testSaveWithoutEnrollmentShouldFail() { - Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); + Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); ImportSummary importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.ERROR, importSummary.getStatus() ); assertThat( importSummary.getDescription(), CoreMatchers.containsString( "is not enrolled in program" ) ); @@ -204,15 +220,18 @@ ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); - importSummary = eventService.saveEvent( event ); - assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - - event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); - importSummary = eventService.saveEvent( event ); - assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - - event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); + Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); + importSummary = eventService.saveEvent( event ); + assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); + + event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); + importSummary = eventService.saveEvent( event ); + assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); + + event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); @@ -226,17 +245,20 @@ ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); + Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementB.getUid() ); + event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementB.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() ); - event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementB.getUid() ); + event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementB.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); @@ -250,24 +272,28 @@ ImportSummary importSummary = enrollmentService.saveEnrollment( enrollment ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); + Event event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); - event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementB.getUid() ); + event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementB.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() ); - event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementB.getUid() ); + event = createEvent( programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementB.getUid() ); event.setEvent( importSummary.getReference() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); assertEquals( 2, eventService.getEvents( programA, organisationUnitA ).getEvents().size() ); - event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), personMaleA.getPerson(), dataElementA.getUid() ); + event = createEvent( programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), + personMaleA.getPerson(), dataElementA.getUid() ); importSummary = eventService.saveEvent( event ); assertEquals( ImportStatus.SUCCESS, importSummary.getStatus() ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2013-10-07 18:38:10 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2013-12-16 04:27:26 +0000 @@ -107,10 +107,10 @@ manager.save( organisationUnitA ); manager.save( organisationUnitB ); - maleA = createPatient( 'A', Patient.MALE, organisationUnitA ); - maleB = createPatient( 'B', Patient.MALE, organisationUnitB ); - femaleA = createPatient( 'C', Patient.FEMALE, organisationUnitA ); - femaleB = createPatient( 'D', Patient.FEMALE, organisationUnitB ); + maleA = createPatient( 'A', organisationUnitA ); + maleB = createPatient( 'B', organisationUnitB ); + femaleA = createPatient( 'C', organisationUnitA ); + femaleB = createPatient( 'D', organisationUnitB ); manager.save( maleA ); manager.save( maleB ); === modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java' --- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2013-11-29 09:24:58 +0000 +++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2013-12-16 04:27:26 +0000 @@ -32,7 +32,6 @@ import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROGRAM_STAGE_PROPERTY; -import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROPERTY; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE; @@ -92,8 +91,6 @@ { private final String IS_NULL = "is null"; - private final String PROPERTY_AGE = "age"; - private final String IN_CONDITION_GET_ALL = "*"; private final String IN_CONDITION_START_SIGN = "@"; @@ -505,14 +502,9 @@ { condition = getConditionForPatient( orgunitIds, operator, startDate, endDate ); } - else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_PROPERTY ) ) - { - String propertyName = info[1]; - condition = getConditionForPatientProperty( propertyName, operator, startDate, endDate ); - } else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) ) { - int attributeId = Integer.parseInt( info[1] ); + String attributeId = info[1]; String compareValue = expression[index].replace( "[" + match + "]", "" ).trim(); @@ -651,14 +643,19 @@ * Return standard SQL of a dynamic patient-attribute expression. E.g [CA:1] * */ - private String getConditionForPatientAttribute( int attributeId, Collection orgunitIds, boolean isExist ) + private String getConditionForPatientAttribute( String attributeId, Collection orgunitIds, + boolean isExist ) { - String sql = " EXISTS ( SELECT * FROM patientattributevalue _pav " - + " WHERE _pav.patientid=pi.patientid AND _pav.patientattributeid=" + attributeId; - + + String sql = " EXISTS ( SELECT * FROM patientattributevalue _pav " + " WHERE _pav.patientid=pi.patientid "; + + if ( attributeId.split( SEPARATOR_ID ).length==2) + { + sql += " AND _pav.patientattributeid=" + attributeId.split( "." )[0] + " AND DATE(now) - DATE( _pav.value )"; + } if ( isExist ) { - sql += " AND _pav.value "; + sql += " AND _pav.patientattributeid=" + attributeId + " AND _pav.value "; } else { @@ -676,31 +673,9 @@ private String getConditionForPatient( Collection orgunitIds, String operator, String startDate, String endDate ) { - String sql = " EXISTS ( SELECT * " + "FROM patient _p " + "WHERE _p.patientid = pi.patientid " + String sql = " EXISTS ( SELECT * FROM patient _p WHERE _p.patientid = pi.patientid " + "AND _p.registrationdate>='" + startDate + "' AND _p.registrationdate<='" + endDate + "' " - + "AND p.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds ) + ") "; - - return sql; - } - - /** - * Return standard SQL of the patient-fixed-attribute expression. E.g - * [CP:gender] - * - */ - private String getConditionForPatientProperty( String propertyName, String operator, String startDate, - String endDate ) - { - String sql = " EXISTS (SELECT _p.patientid FROM patient _p WHERE _p.patientid = pi.patientid AND "; - - if ( propertyName.equals( PROPERTY_AGE ) ) - { - sql += "DATE(registrationdate) - DATE(birthdate) "; - } - else - { - sql += propertyName + " "; - } + + "AND _p.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds ) + ") "; return sql; } @@ -1101,7 +1076,6 @@ String[] info = match.split( SEPARATOR_OBJECT ); if ( info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PATIENT ) - || info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PATIENT_PROPERTY ) || info[0].equalsIgnoreCase( CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE ) ) { return true; === 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-11-18 11:50:20 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-12-16 04:27:26 +0000 @@ -100,8 +100,6 @@ import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.user.CurrentUserService; import org.hisp.dhis.user.User; -import org.joda.time.DateTime; -import org.joda.time.Period; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Required; @@ -153,24 +151,24 @@ private org.hisp.dhis.mobile.service.ModelMapping modelMapping; private PatientIdentifierTypeService patientIdentifierTypeService; - + private CurrentUserService currentUserService; - + private MessageService messageService; - + private SmsSender smsSender; - + private PatientAttributeService patientAttributeService; - + private Collection patientIdentifierTypes; private Collection patientAttributes; - + private Integer patientId; - + @Autowired private OrganisationUnitService organisationUnitService; - + // ------------------------------------------------------------------------- // Setters // ------------------------------------------------------------------------- @@ -330,7 +328,7 @@ } } - this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( ) ); + this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy() ); if ( items.isEmpty() ) { @@ -358,7 +356,7 @@ } } - this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy( ) ); + this.setGroupByAttribute( patientAttService.getPatientAttributeByGroupBy() ); if ( items.isEmpty() ) { @@ -510,12 +508,9 @@ { String patientsInfo = new String(); - DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" ); - for ( Patient each : patients ) { - patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) - + "$"; + patientsInfo += each.getId() + "/" + each.getName() + "$"; } throw new NotAllowedException( patientsInfo ); @@ -709,13 +704,14 @@ } if ( mobileProgramStage.isRepeatable() ) { - Date nextDate = DateUtils.getDateAfterAddition( new Date(), mobileProgramStage.getStandardInterval() ); - - return PROGRAM_STAGE_UPLOADED+"$"+PeriodUtil.dateToString( nextDate ); + Date nextDate = DateUtils.getDateAfterAddition( new Date(), + mobileProgramStage.getStandardInterval() ); + + return PROGRAM_STAGE_UPLOADED + "$" + PeriodUtil.dateToString( nextDate ); } else { - return PROGRAM_STAGE_UPLOADED; + return PROGRAM_STAGE_UPLOADED; } } } @@ -788,9 +784,9 @@ programInstanceService.updateProgramInstance( programInstance ); patient.getProgramInstances().add( programInstance ); patientService.updatePatient( patient ); - + patient = patientService.getPatient( patientId ); - + return getPatientModel( patient ); } @@ -835,30 +831,10 @@ beneficiary.setId( patient.getId() ); beneficiary.setName( patient.getName() ); - Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() ); - beneficiary.setAge( period.getYears() ); - this.setSetting( getSettings() ); if ( setting != null ) { - if ( setting.getGender() ) - { - beneficiary.setGender( patient.getGender() ); - } - if ( setting.getDobtype() ) - { - beneficiary.setDobType( patient.getDobType() ); - } - if ( setting.getBirthdate() ) - { - beneficiary.setBirthDate( patient.getBirthDate() ); - } - if ( setting.getRegistrationdate() ) - { - beneficiary.setRegistrationDate( patient.getRegistrationDate() ); - } - atts = setting.getPatientAttributes(); for ( org.hisp.dhis.patient.PatientAttribute each : atts ) { @@ -934,8 +910,7 @@ { patientModel.setName( patient.getName() ); } - Period period = new Period( new DateTime( patient.getBirthDate() ), new DateTime() ); - patientModel.setAge( period.getYears() ); + /* * DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" ); * patientModel.setAge( dateFormat.format( patient.getBirthDate() ) ); @@ -953,24 +928,6 @@ if ( setting != null ) { - if ( setting.getGender() ) - { - patientModel.setGender( patient.getGender() ); - } - if ( setting.getDobtype() ) - { - patientModel.setDobType( patient.getDobType() ); - } - if ( setting.getBirthdate() && patient.getBirthDate() != null ) - { - DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" ); - patientModel.setBirthDate( dateFormat.format( patient.getBirthDate() ) ); - } - if ( setting.getRegistrationdate() ) - { - patientModel.setRegistrationDate( patient.getRegistrationDate() ); - } - atts = setting.getPatientAttributes(); for ( org.hisp.dhis.patient.PatientAttribute each : atts ) { @@ -1169,7 +1126,7 @@ // is repeatable mobileProgramStage.setRepeatable( programStage.getIrregular() ); - + if ( programStage.getStandardInterval() == null ) { mobileProgramStage.setStandardInterval( 0 ); @@ -1327,11 +1284,11 @@ } else { - System.out.println("program name: "+program.getName()); + System.out.println( "program name: " + program.getName() ); } } } - System.out.println("final size: "+programs.size()); + System.out.println( "final size: " + programs.size() ); return programs; } @@ -1372,12 +1329,9 @@ { String patientsInfo = new String(); - DateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" ); - for ( Patient each : patients ) { - patientsInfo += each.getId() + "/" + each.getName() + "/" + dateFormat.format( each.getBirthDate() ) - + "$"; + patientsInfo += each.getId() + "/" + each.getName() + "$"; } throw new NotAllowedException( patientsInfo ); @@ -1789,12 +1743,8 @@ org.hisp.dhis.patient.Patient patientWeb = new org.hisp.dhis.patient.Patient(); patientWeb.setName( patient.getName() ); - patientWeb.setGender( patient.getGender() ); - patientWeb.setDobType( patient.getDobType() ); patientWeb.setPhoneNumber( patient.getPhoneNumber() ); - patientWeb.setBirthDate( PeriodUtil.stringToDate( patient.getBirthDate() ) ); patientWeb.setOrganisationUnit( organisationUnitService.getOrganisationUnit( orgUnitId ) ); - patientWeb.setRegistrationDate( new Date() ); Set patientIdentifierSet = new HashSet(); Set patientAttributeSet = new HashSet(); @@ -1925,11 +1875,8 @@ { String patientsInfo = new String(); - DateFormat dateFormat = new SimpleDateFormat( "dd-MM-yyyy" ); - int i = 1; String name = ""; - String DOB = ""; for ( Patient each : patients ) { if ( i > 10 ) @@ -1946,15 +1893,7 @@ name = "unknown"; } - if ( each.getBirthDate() != null ) - { - DOB = dateFormat.format( each.getBirthDate() ); - } - else - { - DOB = "unknown"; - } - patientsInfo += each.getId() + "/" + name + ", DOB: " + DOB + "$"; + patientsInfo += each.getId() + "/" + name + "$"; i++; } @@ -1981,20 +1920,20 @@ throws NotAllowedException { String[] searchEventInfosArray = searchEventInfos.split( "-" ); - + int programStageStatus = 0; - - if ( searchEventInfosArray[1].equalsIgnoreCase("Scheduled in future") ) + + if ( searchEventInfosArray[1].equalsIgnoreCase( "Scheduled in future" ) ) { programStageStatus = ProgramStageInstance.FUTURE_VISIT_STATUS; } - else if ( searchEventInfosArray[1].equalsIgnoreCase("Overdue") ) + else if ( searchEventInfosArray[1].equalsIgnoreCase( "Overdue" ) ) { programStageStatus = ProgramStageInstance.LATE_VISIT_STATUS; } - + boolean followUp; - + if ( searchEventInfosArray[2].equalsIgnoreCase( "true" ) ) { followUp = true; @@ -2003,9 +1942,9 @@ { followUp = false; } - + String eventsInfo = ""; - + DateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd" ); List searchTextList = new ArrayList(); @@ -2114,43 +2053,46 @@ return notification; } } - - + @Override public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient generateRepeatableEvent( int orgUnitId, String eventInfo ) throws NotAllowedException { - OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId ); - + OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId ); + String mobileProgramStageId = eventInfo.substring( 0, eventInfo.indexOf( "$" ) ); - - String nextDueDate = eventInfo.substring( eventInfo.indexOf( "$" )+1, eventInfo.length() ); - - ProgramStageInstance oldProgramStageIntance = programStageInstanceService.getProgramStageInstance( Integer.valueOf( mobileProgramStageId ) ); - + + String nextDueDate = eventInfo.substring( eventInfo.indexOf( "$" ) + 1, eventInfo.length() ); + + ProgramStageInstance oldProgramStageIntance = programStageInstanceService.getProgramStageInstance( Integer + .valueOf( mobileProgramStageId ) ); + ProgramInstance programInstance = oldProgramStageIntance.getProgramInstance(); - - ProgramStageInstance newProgramStageInstance = new ProgramStageInstance( programInstance, oldProgramStageIntance.getProgramStage() ); - + + ProgramStageInstance newProgramStageInstance = new ProgramStageInstance( programInstance, + oldProgramStageIntance.getProgramStage() ); + newProgramStageInstance.setDueDate( PeriodUtil.stringToDate( nextDueDate ) ); - + newProgramStageInstance.setOrganisationUnit( orgUnit ); - + programInstance.getProgramStageInstances().add( newProgramStageInstance ); - - List proStageInstanceList = new ArrayList( programInstance.getProgramStageInstances() ); - + + List proStageInstanceList = new ArrayList( + programInstance.getProgramStageInstances() ); + Collections.sort( proStageInstanceList, new ProgramStageInstanceVisitDateComparator() ); - + programInstance.getProgramStageInstances().removeAll( proStageInstanceList ); programInstance.getProgramStageInstances().addAll( proStageInstanceList ); - + programStageInstanceService.addProgramStageInstance( newProgramStageInstance ); - + programInstanceService.updateProgramInstance( programInstance ); - - org.hisp.dhis.api.mobile.model.LWUITmodel.Patient mobilePatient = getPatientModel( patientService.getPatient( programInstance.getPatient().getId() )); - + + org.hisp.dhis.api.mobile.model.LWUITmodel.Patient mobilePatient = getPatientModel( patientService + .getPatient( programInstance.getPatient().getId() ) ); + return mobilePatient; } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java 2013-11-25 07:31:02 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java 2013-12-16 04:27:26 +0000 @@ -218,20 +218,8 @@ value = suggestedMarcher.group( 2 ); } - String dobType = ""; - if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_BIRTHDATE ) ) - { - hasBirthdate = true; - dobType = DOB_FIELD; - } - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_AGE ) ) - { - hasAge = true; - dobType = DOB_FIELD; - } - - inputHtml = dobType + getFixedAttributeField( inputHtml, fixedAttr, value.toString(), healthWorkers, i18n, - index, hidden, style ); + inputHtml = getFixedAttributeField( inputHtml, fixedAttr, value.toString(), healthWorkers, i18n, index, + hidden, style ); } else if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 ) { @@ -367,7 +355,7 @@ { dobType = ""; } - + entryForm = entryForm.replaceFirst( DOB_FIELD, dobType ); entryForm = entryForm.replaceAll( DOB_FIELD, "" ); @@ -455,101 +443,11 @@ private String getFixedAttributeField( String inputHtml, String fixedAttr, String value, Collection healthWorkers, I18n i18n, int index, String hidden, String style ) { - inputHtml = TAG_OPEN + "input id=\"" + fixedAttr + "\" name=\"" + fixedAttr + "\" tabindex=\"" + index + "\" value=\"" + value + "\" style=\"" + style + "\""; - // Fullname fields - if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_FULLNAME ) ) - { - inputHtml += " class=\"{validate:{required:true, rangelength:[3,50]}}\" " + hidden + " " + TAG_CLOSE; - } - - // Phone number fields - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_PHONE_NUMBER ) ) - { - inputHtml += " class=\"{validate:{phone:true}}\" " + hidden + " " + TAG_CLOSE; - inputHtml += " "; - } - - // Age fields - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_AGE ) ) - { - inputHtml += " class=\"{validate:{number:true}}\" " + hidden + " " + TAG_CLOSE; - } - - // Gender selector - if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_GENDER ) ) - { - inputHtml = inputHtml.replaceFirst( "input", "select" ) + " class='" + hidden + "' >"; - - if ( value.equals( "" ) || value.equals( Patient.FEMALE ) ) - { - inputHtml += ""; - inputHtml += ""; - inputHtml += ""; - } - else if ( value.equals( Patient.MALE ) ) - { - inputHtml += ""; - inputHtml += ""; - inputHtml += ""; - } - else if ( value.equals( Patient.TRANSGENDER ) ) - { - inputHtml += ""; - inputHtml += ""; - inputHtml += ""; - } - inputHtml += ""; - } - - // Date field - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_BIRTHDATE ) - || fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_DEATH_DATE ) - || fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_REGISTRATION_DATE ) ) - { - inputHtml += " class='" + hidden + "' " + TAG_CLOSE; - if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_BIRTHDATE ) - || fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_REGISTRATION_DATE ) ) - { - inputHtml += ""; - } - else - { - inputHtml += ""; - } - } - - // DobType field - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_DOB_TYPE ) ) - { - inputHtml = inputHtml.replaceFirst( "input", "select" ) + " class='" + hidden + "' >"; - - if ( value.equals( "" ) || value.equals( Patient.DOB_TYPE_VERIFIED + "" ) ) - { - inputHtml += ""; - inputHtml += ""; - inputHtml += ""; - } - else if ( value.equals( Patient.DOB_TYPE_DECLARED + "" ) ) - { - inputHtml += ""; - inputHtml += ""; - inputHtml += ""; - } - else if ( value.equals( Patient.DOB_TYPE_APPROXIMATED + "" ) ) - { - inputHtml += ""; - inputHtml += ""; - inputHtml += ""; - } - - inputHtml += ""; - } - // Health-worker field - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_ASSOCIATE ) ) + if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_ASSOCIATE ) ) { inputHtml = inputHtml.replaceFirst( "input", "select" ) + " class='" + hidden + "' >"; inputHtml += ""; @@ -566,28 +464,11 @@ inputHtml += ""; } - // IsDead field - else if ( fixedAttr.equals( PatientRegistrationForm.FIXED_ATTRIBUTE_IS_DEAD ) ) - { - inputHtml += " type='checkbox' class='" + hidden + "' "; - - if ( value.equals( "true" ) ) - { - inputHtml += " checked "; - } - - inputHtml += TAG_CLOSE; - } - return inputHtml; } private Object getValueFromPatient( String property, Patient patient ) { - if ( property.equals( Patient.FIXED_ATTR_AGE ) ) - { - property = Patient.FIXED_ATTR_INTEGER_AGE; - } property = StringUtils.capitalize( property ); try === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-11-18 11:50:20 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-12-16 04:27:26 +0000 @@ -134,37 +134,34 @@ patientAttributeValueService.savePatientAttributeValue( pav ); patient.getAttributeValues().add( pav ); } - + // --------------------------------------------------------------------- // If under age, save representative information // --------------------------------------------------------------------- - if ( patient.isUnderAge() ) + if ( representativeId != null ) { - if ( representativeId != null ) + Patient representative = patientStore.get( representativeId ); + if ( representative != null ) { - Patient representative = patientStore.get( representativeId ); - if ( representative != null ) + patient.setRepresentative( representative ); + + Relationship rel = new Relationship(); + rel.setPatientA( representative ); + rel.setPatientB( patient ); + + if ( relationshipTypeId != null ) { - patient.setRepresentative( representative ); - - Relationship rel = new Relationship(); - rel.setPatientA( representative ); - rel.setPatientB( patient ); - - if ( relationshipTypeId != null ) + RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId ); + if ( relType != null ) { - RelationshipType relType = relationshipTypeService.getRelationshipType( relationshipTypeId ); - if ( relType != null ) - { - rel.setRelationshipType( relType ); - relationshipService.saveRelationship( rel ); - } + rel.setRelationshipType( relType ); + relationshipService.saveRelationship( rel ); } } } } - + updatePatient( patient ); // Save patient to update associations return id; @@ -201,12 +198,6 @@ } @Override - public Collection getPatients( String name, Date birthdate, String gender ) - { - return patientStore.get( name, birthdate, gender ); - } - - @Override public Collection getPatients( String searchText, Integer min, Integer max ) { int countPatientName = patientStore.countGetPatientsByName( searchText ); @@ -276,30 +267,35 @@ } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatients( OrganisationUnit organisationUnit, Integer min, Integer max ) { return patientStore.getByOrgUnit( organisationUnit, min, max ); } - + @Override + @SuppressWarnings( "unchecked" ) public Collection getPatients( Program program ) { return patientStore.getByProgram( program, 0, Integer.MAX_VALUE ); } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatients( OrganisationUnit organisationUnit, Program program ) { return patientStore.getByOrgUnitProgram( organisationUnit, program, 0, Integer.MAX_VALUE ); } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatientsLikeName( OrganisationUnit organisationUnit, String name, Integer min, Integer max ) { return patientStore.getByOrgUnitAndNameLike( organisationUnit, name, min, max ); } + @SuppressWarnings( "unchecked" ) @Override public Collection getPatient( Integer identifierTypeId, Integer attributeId, String value ) { @@ -327,12 +323,9 @@ } } } - else - { - return patientStore.getByNames( value, null, null ); - } + + return patientStore.getByNames( value, null, null ); - return null; } @Override @@ -371,6 +364,7 @@ } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatientsByNames( String name, Integer min, Integer max ) { return patientStore.getByNames( name.toLowerCase(), min, max ); @@ -444,16 +438,16 @@ private boolean shouldSaveRepresentativeInformation( Patient patient, Integer representativeId ) { - if ( !patient.isUnderAge() ) - return false; - if ( representativeId == null ) + { return false; + } return patient.getRepresentative() == null || !(patient.getRepresentative().getId() == representativeId); } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatients( OrganisationUnit organisationUnit, Program program, Integer min, Integer max ) { return patientStore.getByOrgUnitProgram( organisationUnit, program, min, max ); @@ -499,11 +493,15 @@ return null; } + @Override + @SuppressWarnings( "unchecked" ) public Collection getRepresentatives( Patient patient ) { return patientStore.getRepresentatives( patient ); } + @Override + @SuppressWarnings( "unchecked" ) public Collection searchPatients( List searchKeys, Collection orgunits, Boolean followup, Collection patientAttributes, Collection identifierTypes, Integer statusEnrollment, Integer min, Integer max ) @@ -512,12 +510,15 @@ statusEnrollment, min, max ); } + @Override public int countSearchPatients( List searchKeys, Collection orgunits, Boolean followup, Integer statusEnrollment ) { return patientStore.countSearch( searchKeys, orgunits, followup, statusEnrollment ); } + @Override + @SuppressWarnings( "unchecked" ) public Collection getPatientPhoneNumbers( List searchKeys, Collection orgunits, Boolean followup, Integer statusEnrollment, Integer min, Integer max ) { @@ -537,6 +538,8 @@ return phoneNumbers; } + @Override + @SuppressWarnings( "unchecked" ) public List getProgramStageInstances( List searchKeys, Collection orgunits, Boolean followup, Integer statusEnrollment, Integer min, Integer max ) { @@ -545,6 +548,7 @@ } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatientsByPhone( String phoneNumber, Integer min, Integer max ) { return patientStore.getByPhoneNumber( phoneNumber, min, max ); @@ -640,20 +644,16 @@ } @Override + @SuppressWarnings( "unchecked" ) public Collection getPatientByFullname( String fullName, OrganisationUnit organisationUnit ) { return patientStore.getByFullName( fullName, organisationUnit ); } @Override - public Collection getRegistrationOrgunitIds( Date startDate, Date endDate ) - { - return patientStore.getRegistrationOrgunitIds( startDate, endDate ); - } - - @Override public int validatePatient( Patient patient, Program program ) { return patientStore.validate( patient, program ); } + } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2013-09-19 05:24:04 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2013-12-16 04:27:26 +0000 @@ -65,7 +65,6 @@ for ( Patient representative : representatives ) { representative.setRepresentative( null ); - representative.setUnderAge( false ); patientService.updatePatient( representative ); } } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-12-10 08:51:03 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-12-16 04:27:26 +0000 @@ -28,13 +28,27 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.patient.Patient.PREFIX_IDENTIFIER_TYPE; +import static org.hisp.dhis.patient.Patient.PREFIX_PATIENT_ATTRIBUTE; +import static org.hisp.dhis.patient.Patient.PREFIX_PROGRAM; +import static org.hisp.dhis.patient.Patient.PREFIX_PROGRAM_EVENT_BY_STATUS; +import static org.hisp.dhis.patient.Patient.PREFIX_PROGRAM_INSTANCE; +import static org.hisp.dhis.patient.Patient.PREFIX_PROGRAM_STAGE; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Conjunction; import org.hibernate.criterion.Disjunction; -import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.Grid; @@ -56,21 +70,10 @@ import org.hisp.dhis.system.grid.GridUtils; import org.hisp.dhis.system.util.SqlHelper; import org.hisp.dhis.system.util.TextUtils; -import org.hisp.dhis.validation.ValidationCriteria; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.transaction.annotation.Transactional; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; - -import static org.hisp.dhis.patient.Patient.*; - /** * @author Abyot Asalefew Gizaw */ @@ -109,22 +112,6 @@ @Override @SuppressWarnings( "unchecked" ) - public Collection get( String name, Date birthdate, String gender ) - { - Criteria criteria = getCriteria(); - Conjunction con = Restrictions.conjunction(); - con.add( Restrictions.ilike( "name", name ) ); - con.add( Restrictions.eq( "gender", gender ) ); - con.add( Restrictions.eq( "birthDate", birthdate ) ); - criteria.add( con ); - - criteria.addOrder( Order.asc( "name" ) ); - - return criteria.list(); - } - - @Override - @SuppressWarnings( "unchecked" ) public Collection getByOrgUnit( OrganisationUnit organisationUnit, Integer min, Integer max ) { String hql = "select p from Patient p where p.organisationUnit = :organisationUnit order by p.id DESC"; @@ -433,15 +420,15 @@ } } - if ( program != null ) - { - ValidationCriteria validationCriteria = program.isValid( patient ); - - if ( validationCriteria != null ) - { - return PatientService.ERROR_ENROLLMENT; - } - } +// if ( program != null ) +// { +// ValidationCriteria validationCriteria = program.isValid( patient ); +// +// if ( validationCriteria != null ) +// { +// return PatientService.ERROR_ENROLLMENT; +// } +// } return PatientService.ERROR_NONE; } @@ -455,7 +442,7 @@ Collection identifierTypes, Integer statusEnrollment, Integer min, Integer max ) { String selector = count ? "count(*) " : "* "; - String sql = "select " + selector + " from ( select distinct p.patientid, p.name, p.gender, p.phonenumber,"; + String sql = "select " + selector + " from ( select distinct p.patientid, p.name, p.phonenumber,"; if ( identifierTypes != null ) { @@ -478,7 +465,7 @@ String patientWhere = ""; String patientOperator = " where "; - String patientGroupBy = " GROUP BY p.patientid, p.name, p.gender, p.phonenumber "; + String patientGroupBy = " GROUP BY p.patientid, p.name, p.phonenumber "; String otherWhere = ""; String operator = " where "; String orderBy = ""; @@ -509,29 +496,7 @@ value = keys[2]; } - if ( keys[0].equals( PREFIX_FIXED_ATTRIBUTE ) ) - { - patientWhere += patientOperator; - - if ( id.equals( FIXED_ATTR_BIRTH_DATE ) ) - { - patientWhere += " p." + id + value; - } - else if ( id.equals( FIXED_ATTR_AGE ) ) - { - patientWhere += " ((DATE(now()) - DATE(birthdate))/365) " + value; - } - else if ( id.equals( FIXED_ATTR_REGISTRATION_DATE ) ) - { - patientWhere += "p." + id + value; - } - else - { - patientWhere += " lower(p." + id + ")='" + value + "'"; - } - patientOperator = " and "; - } - else if ( keys[0].equals( PREFIX_IDENTIFIER_TYPE ) ) + if ( keys[0].equals( PREFIX_IDENTIFIER_TYPE ) ) { String[] keyValues = id.split( " " ); @@ -852,7 +817,8 @@ { for ( OrganisationUnit orgunit : orgunits ) { - orgUnitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) ); + orgUnitIds + .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) ); orgUnitIds.remove( orgunit.getId() ); } } @@ -881,4 +847,4 @@ return orgUnitIds; } -} +} \ No newline at end of file === 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-12-05 10:41:52 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-12-16 04:27:26 +0000 @@ -38,15 +38,20 @@ import org.amplecode.quick.StatementManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hisp.dhis.caseaggregation.CaseAggregationCondition; import org.hisp.dhis.common.CodeGenerator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.dataentryform.DataEntryFormService; +import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageService; import org.hisp.dhis.system.startup.AbstractStartupRoutine; +import org.hisp.dhis.system.util.DateUtils; import org.hisp.dhis.system.util.ValidationUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.annotation.Transactional; /** @@ -95,6 +100,9 @@ this.dataEntryFormService = dataEntryFormService; } + @Autowired + private JdbcTemplate jdbcTemplate; + // ------------------------------------------------------------------------- // Action Implementation // ------------------------------------------------------------------------- @@ -276,6 +284,8 @@ executeSql( "ALTER TABLE programstageinstance ALTER COLUMN executiondate TYPE timestamp" ); updateCoordinatesProgramStageInstance(); + + addPatientAttributes(); } // ------------------------------------------------------------------------- @@ -442,6 +452,204 @@ } } + private void addPatientAttributes() + { + int max = jdbcTemplate.queryForInt( "select max(patientattributeid) from patientattribute" ); + + // --------------------------------------------------------------------- + // Gender + // --------------------------------------------------------------------- + + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','Gender', 'Gender','" + PatientAttribute.TYPE_COMBO + "', false, false, false)" ); + + int maxOpt = jdbcTemplate.queryForInt( "select max(patientattributeoptionid) from patientattributeoption" ); + maxOpt++; + executeSql( "INSERT INTO patientattributeoption (patientattributeoptionid, name, patientattributeid ) VALUES ('" + + maxOpt + "', 'F'," + max + ")" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value, patientattributeoptionid ) SELECT patientid," + + max + ",'F'," + maxOpt + " from patient where gender='F'" ); + + maxOpt++; + executeSql( "INSERT INTO patientattributeoption (patientattributeoptionid, name, patientattributeid ) VALUES ('" + + maxOpt + "', 'M'," + max + ")" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value, patientattributeoptionid ) SELECT patientid," + + max + ",'M'," + maxOpt + " from patient where gender='M'" ); + + maxOpt++; + executeSql( "INSERT INTO patientattributeoption (patientattributeoptionid, name, patientattributeid ) VALUES ('" + + maxOpt + "', 'T'," + max + ")" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value, patientattributeoptionid ) SELECT patientid," + + max + ",'T'," + maxOpt + " from patient where gender='T'" ); + + // Update Case Aggregate Query Builder + String source = "[CP" + CaseAggregationCondition.SEPARATOR_OBJECT + "gender]"; + String target = "[" + CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE + + CaseAggregationCondition.SEPARATOR_OBJECT + max + "]"; + updateFixedAttributeInCaseAggregate( source, target ); + + // --------------------------------------------------------------------- + // Death date + // --------------------------------------------------------------------- + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','Death date', 'Death date','" + PatientAttribute.TYPE_DATE + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + + ",deathDate from patient where deathDate is not null" ); + + // --------------------------------------------------------------------- + // registrationDate + // --------------------------------------------------------------------- + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','Registration date', 'Registration date','" + PatientAttribute.TYPE_DATE + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + + ",registrationDate from patient where registrationDate is not null" ); + + // --------------------------------------------------------------------- + // isDead + // --------------------------------------------------------------------- + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','Is Dead', 'Is Dead','" + PatientAttribute.TYPE_TRUE_ONLY + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + + ",isDead from patient where isDead is not null" ); + + // --------------------------------------------------------------------- + // underAge + // --------------------------------------------------------------------- + + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, description, name, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','Is under age', 'Is under age','" + PatientAttribute.TYPE_TRUE_ONLY + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + + ",isDead from patient where underAge=true" ); + + // --------------------------------------------------------------------- + // DobType + // --------------------------------------------------------------------- + + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, description, name, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','DOB type', 'DOB type','" + PatientAttribute.TYPE_COMBO + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + + ",dobType from patient where dobType is not null" ); + + maxOpt++; + executeSql( "INSERT INTO patientattributeoption (patientattributeoptionid, name, patientattributeid ) VALUES ('" + + maxOpt + "', 'A'," + max + ")" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value, patientattributeoptionid ) SELECT patientid," + + max + ",'A'," + maxOpt + " from patient where dobType='A'" ); + + maxOpt++; + executeSql( "INSERT INTO patientattributeoption (patientattributeoptionid, name, patientattributeid ) VALUES ('" + + maxOpt + "', 'D'," + max + ")" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value, patientattributeoptionid ) SELECT patientid," + + max + ",'D'," + maxOpt + " from patient where dobType='D'" ); + + maxOpt++; + executeSql( "INSERT INTO patientattributeoption (patientattributeoptionid, name, patientattributeid ) VALUES ('" + + maxOpt + "', 'V'," + max + ")" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value, patientattributeoptionid ) SELECT patientid," + + max + ",'V'," + maxOpt + " from patient where dobType='V'" ); + + // Update Case Aggregate Query Builder + source = "[CP" + CaseAggregationCondition.SEPARATOR_OBJECT + "dobType]"; + target = "[" + CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE + CaseAggregationCondition.SEPARATOR_OBJECT + + max + "]"; + updateFixedAttributeInCaseAggregate( source, target ); + + // --------------------------------------------------------------------- + // Birthdate + // --------------------------------------------------------------------- + + max++; + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + CodeGenerator.generateCode() + + "','" + + DateUtils.getMediumDateString() + + "','Birth date', 'Birth date','" + PatientAttribute.TYPE_DATE + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + + ",birthdate from patient where birthdate is not null" ); + + // Update Case Aggregate Query Builder + source = "[CP" + CaseAggregationCondition.SEPARATOR_OBJECT + "age]"; + target = "[" + CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE + CaseAggregationCondition.SEPARATOR_OBJECT + + max + ".age]"; + updateFixedAttributeInCaseAggregate( source, target ); + + // executeSql( "ALTER TABLE patient DROP COLUMN deathDate" ); + // executeSql( "ALTER TABLE patient DROP COLUMN registrationDate" ); + // executeSql( "ALTER TABLE patient DROP COLUMN isDead" ); + // executeSql( "ALTER TABLE patient DROP COLUMN underAge" ); + // executeSql( "ALTER TABLE patient DROP COLUMN dobType" ); + // executeSql( "ALTER TABLE patient DROP COLUMN birthdate" ); + } + + private void updateFixedAttributeInCaseAggregate( String source, String target ) + { + StatementHolder holder = statementManager.getHolder(); + try + { + Statement statement = holder.getStatement(); + + ResultSet resultSet = statement + .executeQuery( "SELECT caseaggregationconditionid, aggregationExpression FROM caseaggregationcondition where aggregationExpression like '%" + + source + "%'" ); + + while ( resultSet.next() ) + { + String id = resultSet.getString( "caseaggregationconditionid" ); + String expression = resultSet.getString( "aggregationExpression" ); + + expression = expression.replaceAll( source, target ); + executeSql( "UPDATE caseaggregationcondition SET aggregationExpression='" + expression + + "' WHERE caseaggregationconditionid=" + id ); + } + } + catch ( Exception ex ) + { + log.debug( ex ); + } + finally + { + holder.close(); + } + } + private int executeSql( String sql ) { try @@ -451,7 +659,6 @@ catch ( Exception ex ) { log.debug( ex ); - return -1; } } === 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-11-14 08:17:57 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2013-12-16 04:27:26 +0000 @@ -282,31 +282,6 @@ // Add fixed attribues // --------------------------------------------------------------------- - if ( patient.getGender() != null ) - { - attrGrid.addRow(); - attrGrid.addValue( i18n.getString( "gender" ) ); - attrGrid.addValue( i18n.getString( patient.getGender() ) ); - } - - if ( patient.getBirthDate() != null ) - { - attrGrid.addRow(); - attrGrid.addValue( i18n.getString( "date_of_birth" ) ); - attrGrid.addValue( format.formatDate( patient.getBirthDate() ) ); - - attrGrid.addRow(); - attrGrid.addValue( i18n.getString( "age" ) ); - attrGrid.addValue( patient.getAge() ); - } - - if ( patient.getDobType() != null ) - { - attrGrid.addRow(); - attrGrid.addValue( i18n.getString( "dob_type" ) ); - attrGrid.addValue( i18n.getString( patient.getDobType() + "" ) ); - } - attrGrid.addRow(); attrGrid.addValue( i18n.getString( "phoneNumber" ) ); attrGrid @@ -542,7 +517,7 @@ { return programInstanceStore.getByStatus( status, program, orgunitIds, startDate, endDate ); } - + public Collection getScheduleMesssages() { Collection result = programInstanceStore @@ -607,16 +582,6 @@ public ProgramInstance enrollPatient( Patient patient, Program program, Date enrollmentDate, Date dateOfIncident, OrganisationUnit organisationUnit, I18nFormat format ) { - if ( enrollmentDate == null ) - { - enrollmentDate = program.getUseBirthDateAsIncidentDate() ? patient.getBirthDate() : new Date(); - } - - if ( dateOfIncident == null ) - { - dateOfIncident = program.getUseBirthDateAsIncidentDate() ? patient.getBirthDate() : enrollmentDate; - } - // --------------------------------------------------------------------- // Add program instance // --------------------------------------------------------------------- @@ -624,10 +589,26 @@ ProgramInstance programInstance = new ProgramInstance(); programInstance.enrollPatient( patient, program ); - programInstance.setEnrollmentDate( enrollmentDate ); - programInstance.setDateOfIncident( dateOfIncident ); + + if ( enrollmentDate != null ) + { + programInstance.setEnrollmentDate( enrollmentDate ); + } + else + { + programInstance.setEnrollmentDate( new Date() ); + } + + if ( dateOfIncident != null ) + { + programInstance.setDateOfIncident( dateOfIncident ); + } + else + { + programInstance.setDateOfIncident( new Date() ); + } + programInstance.setStatus( ProgramInstance.STATUS_ACTIVE ); - addProgramInstance( programInstance ); // --------------------------------------------------------------------- @@ -637,10 +618,10 @@ for ( ProgramStage programStage : program.getProgramStages() ) { if ( programStage.getAutoGenerateEvent() ) - { + { ProgramStageInstance programStageInstance = generateEvent( programInstance, programStage, - enrollmentDate, dateOfIncident, organisationUnit ); - + programInstance.getEnrollmentDate(), programInstance.getDateOfIncident(), organisationUnit ); + if ( programStageInstance != null ) { programStageInstanceService.addProgramStageInstance( programStageInstance ); === 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-11-25 07:31:02 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-12-16 04:27:26 +0000 @@ -13,23 +13,9 @@ &identifiableProperties; - - - - - - - - - - - + - - - - - + === modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientServiceTest.java' --- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientServiceTest.java 2013-11-18 11:50:20 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientServiceTest.java 2013-12-16 04:27:26 +0000 @@ -33,7 +33,6 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.HashSet; @@ -52,7 +51,6 @@ import org.hisp.dhis.program.ProgramStageInstance; import org.hisp.dhis.relationship.RelationshipType; import org.hisp.dhis.relationship.RelationshipTypeService; -import org.hisp.dhis.validation.ValidationCriteria; import org.hisp.dhis.validation.ValidationCriteriaService; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -119,7 +117,7 @@ { organisationUnit = createOrganisationUnit( 'A' ); organisationUnitService.addOrganisationUnit( organisationUnit ); - + OrganisationUnit organisationUnitB = createOrganisationUnit( 'B' ); organisationUnitService.addOrganisationUnit( organisationUnitB ); @@ -129,10 +127,10 @@ patientAttribute = createPatientAttribute( 'A' ); attributeId = patientAttributeService.savePatientAttribute( patientAttribute ); - patientA1 = createPatient( 'A', "F", organisationUnit ); - patientA2 = createPatient( 'A', "F", organisationUnitB ); + patientA1 = createPatient( 'A', organisationUnit ); + patientA2 = createPatient( 'A', organisationUnitB ); patientA3 = createPatient( 'A', organisationUnit, patientIdentifierType ); - patientB1 = createPatient( 'B', "M", organisationUnit ); + patientB1 = createPatient( 'B', organisationUnit ); patientB2 = createPatient( 'B', organisationUnit ); programA = createProgram( 'A', new HashSet(), organisationUnit ); @@ -215,20 +213,6 @@ } @Test - public void testGetByNameGenderBirthdate() - { - patientService.savePatient( patientA1 ); - patientService.savePatient( patientA2 ); - - Collection patients = patientService.getPatients( "NameA", patientA1.getBirthDate(), - patientA1.getGender() ); - - assertEquals( 2, patients.size() ); - assertTrue( patients.contains( patientA1 ) ); - assertTrue( patients.contains( patientA2 ) ); - } - - @Test public void testGetPatientsByNames() { patientService.savePatient( patientA1 ); @@ -292,7 +276,7 @@ public void testGetPatientsbyOuProgram() { programService.addProgram( programA ); - + patientService.savePatient( patientA1 ); patientService.savePatient( patientA2 ); patientService.savePatient( patientA3 ); @@ -333,12 +317,12 @@ patientAttributeValues.add( attributeValue ); patientService.createPatient( patientA3, null, null, patientAttributeValues ); - + Collection patients = patientService.getPatient( null, attributeId, "AttributeA" ); assertEquals( 1, patients.size() ); assertTrue( patients.contains( patientA3 ) ); - + Patient patient = patients.iterator().next(); assertEquals( 1, patient.getAttributeValues().size() ); assertTrue( patient.getAttributeValues().contains( attributeValue ) ); @@ -416,7 +400,6 @@ RelationshipType relationshipType = createRelationshipType( 'A' ); int relationshipTypeId = relationshipTypeService.saveRelationshipType( relationshipType ); - patientA1.setUnderAge( true ); PatientAttributeValue attributeValue = createPatientAttributeValue( 'A', patientA1, patientAttribute ); Set patientAttributeValues = new HashSet(); patientAttributeValues.add( attributeValue ); @@ -433,7 +416,6 @@ RelationshipType relationshipType = createRelationshipType( 'A' ); int relationshipTypeId = relationshipTypeService.saveRelationshipType( relationshipType ); - patientA3.setUnderAge( true ); patientA3.setName( "B" ); PatientAttributeValue attributeValue = createPatientAttributeValue( 'A', patientA3, patientAttribute ); Set patientAttributeValues = new HashSet(); @@ -442,10 +424,11 @@ assertNotNull( patientService.getPatient( idA ) ); attributeValue.setValue( "AttributeB" ); - List attributeValues = new ArrayList(); //TODO use set + List attributeValues = new ArrayList(); attributeValues.add( attributeValue ); - patientService.updatePatient( patientA3, idB, relationshipTypeId, attributeValues, new ArrayList(), new ArrayList() ); + patientService.updatePatient( patientA3, idB, relationshipTypeId, attributeValues, + new ArrayList(), new ArrayList() ); assertEquals( "B", patientService.getPatient( idA ).getName() ); } @@ -614,43 +597,4 @@ assertTrue( patients.contains( patientB2 ) ); } - @Test - public void testGetRegistrationOrgunitIds() - { - patientService.savePatient( patientA1 ); - patientService.savePatient( patientB1 ); - patientService.savePatient( patientB2 ); - - Calendar yesterday = Calendar.getInstance(); - yesterday.add( Calendar.DATE, -1 ); - Calendar tomorrow = Calendar.getInstance(); - tomorrow.add( Calendar.DATE, 1 ); - - Collection orgunitIds = patientService.getRegistrationOrgunitIds( yesterday.getTime(), - tomorrow.getTime() ); - - assertEquals( 1, orgunitIds.size() ); - assertEquals( organisationUnit.getId(), orgunitIds.iterator().next().intValue() ); - } - - @Test - public void testValidatePatient() - { - programService.addProgram( programA ); - - ValidationCriteria validationCriteria = createValidationCriteria( 'A', "gender", 0, "F" ); - validationCriteriaService.saveValidationCriteria( validationCriteria ); - - programA.getPatientValidationCriteria().add( validationCriteria ); - programService.updateProgram( programA ); - - patientService.savePatient( patientA1 ); - patientService.savePatient( patientB1 ); - - int validatePatientA1 = patientService.validatePatient( patientA1, programA ); - int validatePatientB1 = patientService.validatePatient( patientB1, programA ); - - assertEquals( 0, validatePatientA1 ); - assertEquals( 2, validatePatientB1 ); - } } === 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-12-06 16:26:51 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/patient/PatientStoreTest.java 2013-12-16 04:27:26 +0000 @@ -49,7 +49,6 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.program.ProgramStage; import org.hisp.dhis.program.ProgramStageInstance; -import org.hisp.dhis.validation.ValidationCriteria; import org.hisp.dhis.validation.ValidationCriteriaService; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -121,10 +120,10 @@ patientAttribute = createPatientAttribute( 'A' ); attributeId = patientAttributeService.savePatientAttribute( patientAttribute ); - patientA1 = createPatient( 'A', "F", organisationUnit ); - patientA2 = createPatient( 'A', "F", organisationUnitB ); + patientA1 = createPatient( 'A', organisationUnit ); + patientA2 = createPatient( 'A', organisationUnitB ); patientA3 = createPatient( 'A', organisationUnit, patientIdentifierType ); - patientB1 = createPatient( 'B', "M", organisationUnit ); + patientB1 = createPatient( 'B', organisationUnit ); patientB2 = createPatient( 'B', organisationUnit ); programA = createProgram( 'A', new HashSet(), organisationUnit ); @@ -271,19 +270,6 @@ } @Test - public void testGetByNameGenderBirthdate() - { - patientStore.save( patientA1 ); - patientStore.save( patientA2 ); - - Collection patients = patientStore.get( "NameA", patientA1.getBirthDate(), patientA1.getGender() ); - - assertEquals( 2, patients.size() ); - assertTrue( patients.contains( patientA1 ) ); - assertTrue( patients.contains( patientA2 ) ); - } - - @Test public void testGetByOrgUnitAndNameLike() { patientStore.save( patientA1 ); @@ -354,27 +340,6 @@ } @Test - public void testValidate() - { - programService.addProgram( programA ); - - ValidationCriteria validationCriteria = createValidationCriteria( 'A', "gender", 0, "F" ); - validationCriteriaService.saveValidationCriteria( validationCriteria ); - - programA.getPatientValidationCriteria().add( validationCriteria ); - programService.updateProgram( programA ); - - patientStore.save( patientA1 ); - patientStore.save( patientB1 ); - - int validatePatientA1 = patientStore.validate( patientA1, programA ); - int validatePatientB1 = patientStore.validate( patientB1, programA ); - - assertEquals( 0, validatePatientA1 ); - assertEquals( 2, validatePatientB1 ); - } - - @Test public void testQuery() { patientStore.save( patientA1 ); @@ -382,11 +347,11 @@ patientStore.save( patientA3 ); patientStore.save( patientB1 ); patientStore.save( patientB2 ); - + TrackedEntityQueryParams params = new TrackedEntityQueryParams(); - + List list = patientStore.query( params ); - + assertEquals( 5, list.size() ); } } === 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-11-14 08:17:57 +0000 +++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2013-12-16 04:27:26 +0000 @@ -1005,27 +1005,7 @@ patient.setAutoFields(); patient.setName( "Name" + uniqueChar ); - patient.setGender( Patient.MALE ); - patient.setDobType( Patient.DOB_TYPE_VERIFIED ); - patient.setBirthDate( getDate( 1970, 1, 1 ) ); - patient.setPhoneNumber( "123456789" ); - patient.setRegistrationDate( new Date() ); - patient.setOrganisationUnit( organisationUnit ); - - return patient; - } - - public static Patient createPatient( char uniqueChar, String gender, OrganisationUnit organisationUnit ) - { - Patient patient = new Patient(); - patient.setAutoFields(); - - patient.setName( "Name" + uniqueChar ); - patient.setGender( gender ); - patient.setDobType( Patient.DOB_TYPE_VERIFIED ); - patient.setBirthDate( getDate( 1970, 1, 1 ) ); - patient.setPhoneNumber( "123456789" ); - patient.setRegistrationDate( new Date() ); + patient.setPhoneNumber( "123456789" ); patient.setOrganisationUnit( organisationUnit ); return patient; @@ -1038,10 +1018,6 @@ patient.setAutoFields(); patient.setName( "Name" + uniqueChar ); - patient.setGender( Patient.MALE ); - patient.setDobType( Patient.DOB_TYPE_VERIFIED ); - patient.setBirthDate( getDate( 1970, 1, 1 ) ); - patient.setRegistrationDate( new Date() ); patient.setOrganisationUnit( organisationUnit ); PatientIdentifier pIdentifier = new PatientIdentifier(); === 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-11-25 07:31:02 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddPatientAction.java 2013-12-16 04:27:26 +0000 @@ -38,9 +38,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeOption; @@ -77,16 +74,12 @@ // Dependencies // ------------------------------------------------------------------------- - private I18nFormat format; - private PatientService patientService; private PatientIdentifierService patientIdentifierService; private PatientIdentifierTypeService patientIdentifierTypeService; - private OrganisationUnitSelectionManager selectionManager; - private PatientAttributeService patientAttributeService; private PatientAttributeOptionService patientAttributeOptionService; @@ -105,18 +98,8 @@ private String fullName; - private String birthDate; - - private Integer age; - - private Boolean verified; - - private String gender; - private String[] phoneNumber; - private String registrationDate; - private boolean underAge; private Integer representativeId; @@ -125,10 +108,6 @@ private Integer healthWorker; - private boolean isDead; - - private String deathDate; - private Integer relationshipId; private boolean relationshipFromA; @@ -141,12 +120,6 @@ public String execute() { - // --------------------------------------------------------------------- - // Prepare values - // --------------------------------------------------------------------- - - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); - Patient patient = new Patient(); // --------------------------------------------------------------------- @@ -178,62 +151,11 @@ patient.setPhoneNumber( phone ); } - patient.setGender( gender ); - patient.setIsDead( false ); - patient.setUnderAge( underAge ); - patient.setOrganisationUnit( organisationUnit ); - patient.setIsDead( isDead ); - - if ( deathDate != null ) - { - deathDate = deathDate.trim(); - patient.setDeathDate( format.parseDate( deathDate ) ); - } - if ( healthWorker != null ) { patient.setAssociate( userService.getUser( healthWorker ) ); } - Date _birthDate = new Date(); - if ( birthDate != null || age != null ) - { - verified = (verified == null) ? false : verified; - - Character dobType = (verified) ? Patient.DOB_TYPE_VERIFIED : Patient.DOB_TYPE_DECLARED; - - if ( !verified && age != null ) - { - dobType = 'A'; - } - - if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) - { - birthDate = birthDate.trim(); - patient.setBirthDate( format.parseDate( birthDate ) ); - } - else - { - patient.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR ); - } - - _birthDate = patient.getBirthDate(); - patient.setDobType( dobType ); - } - - // ----------------------------------------------------------------------------- - // Registration Date - // ----------------------------------------------------------------------------- - - if ( registrationDate == null ) - { - patient.setRegistrationDate( new Date() ); - } - else - { - patient.setRegistrationDate( format.parseDate( registrationDate ) ); - } - // ----------------------------------------------------------------------------- // Prepare Patient Identifiers // ----------------------------------------------------------------------------- @@ -269,17 +191,12 @@ // PatientIdentifierType will be null // -------------------------------------------------------------------------------- - if ( gender == null ) - { - gender = Patient.FEMALE; - } - - String identifier = PatientIdentifierGenerator.getNewIdentifier( _birthDate, gender ); + String identifier = PatientIdentifierGenerator.getNewIdentifier( new Date(), "F" ); PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); while ( systemGenerateIdentifier != null ) { - identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() ); + identifier = PatientIdentifierGenerator.getNewIdentifier( new Date(), "F" ); systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); } @@ -416,16 +333,6 @@ this.systemSettingManager = systemSettingManager; } - public void setDead( boolean isDead ) - { - this.isDead = isDead; - } - - public void setDeathDate( String deathDate ) - { - this.deathDate = deathDate; - } - public String getMessage() { return message; @@ -436,26 +343,11 @@ this.healthWorker = healthWorker; } - public void setVerified( Boolean verified ) - { - this.verified = verified; - } - public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService ) { this.patientIdentifierTypeService = patientIdentifierTypeService; } - public void setBirthDate( String birthDate ) - { - this.birthDate = birthDate; - } - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - public void setPatientService( PatientService patientService ) { this.patientService = patientService; @@ -466,11 +358,6 @@ this.patientIdentifierService = patientIdentifierService; } - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - public void setPatientAttributeService( PatientAttributeService patientAttributeService ) { this.patientAttributeService = patientAttributeService; @@ -481,21 +368,6 @@ this.fullName = fullName; } - public void setAge( Integer age ) - { - this.age = age; - } - - public void setRegistrationDate( String registrationDate ) - { - this.registrationDate = registrationDate; - } - - public void setGender( String gender ) - { - this.gender = gender; - } - public void setPhoneNumber( String[] phoneNumber ) { this.phoneNumber = phoneNumber; === 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-09-16 17:07:25 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/AddRepresentativeAction.java 2013-12-16 04:27:26 +0000 @@ -29,6 +29,7 @@ */ import java.util.Collection; +import java.util.Date; import javax.servlet.http.HttpServletRequest; @@ -55,8 +56,6 @@ // Dependencies // ------------------------------------------------------------------------- - private I18nFormat format; - private PatientService patientService; private PatientIdentifierService patientIdentifierService; @@ -71,18 +70,6 @@ private String fullName; - private String birthDate; - - private char ageType; - - private Integer age; - - private Character dobType; - - private String gender; - - private String registrationDate; - private Integer relationshipTypeId; // ------------------------------------------------------------------------- @@ -112,29 +99,8 @@ fullName = fullName.trim(); patient.setName( fullName ); - - // --------------------------------------------------------------------- - // Get Other information for patient - // --------------------------------------------------------------------- - - patient.setGender( gender ); - patient.setIsDead( false ); patient.setOrganisationUnit( organisationUnit ); - if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) - { - birthDate = birthDate.trim(); - patient.setBirthDate( format.parseDate( birthDate ) ); - } - else - { - patient.setBirthDateFromAge( age.intValue(), ageType ); - } - - patient.setDobType( dobType ); - - patient.setRegistrationDate( format.parseDate( registrationDate ) ); - patientService.savePatient( patient ); // -------------------------------------------------------------------------------- @@ -143,12 +109,12 @@ // PatientIdentifierType will be null // -------------------------------------------------------------------------------- - String identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() ); + String identifier = PatientIdentifierGenerator.getNewIdentifier( new Date(), "F" ); PatientIdentifier systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); while ( systemGenerateIdentifier != null ) { - identifier = PatientIdentifierGenerator.getNewIdentifier( patient.getBirthDate(), patient.getGender() ); + identifier = PatientIdentifierGenerator.getNewIdentifier( new Date(), "F" ); systemGenerateIdentifier = patientIdentifierService.get( null, identifier ); } @@ -204,16 +170,6 @@ this.patientIdentifierTypeService = patientIdentifierTypeService; } - public void setBirthDate( String birthDate ) - { - this.birthDate = birthDate; - } - - public void setFormat( I18nFormat format ) - { - this.format = format; - } - public void setPatientService( PatientService patientService ) { this.patientService = patientService; @@ -234,21 +190,6 @@ this.fullName = fullName; } - public void setRegistrationDate( String registrationDate ) - { - this.registrationDate = registrationDate; - } - - public void setAge( Integer age ) - { - this.age = age; - } - - public void setGender( String gender ) - { - this.gender = gender; - } - public Integer getRelationshipTypeId() { return relationshipTypeId; @@ -264,13 +205,4 @@ return patient; } - public void setDobType( Character dobType ) - { - this.dobType = dobType; - } - - public void setAgeType( char ageType ) - { - this.ageType = ageType; - } } === 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 2013-10-11 13:49:41 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/GetPatientAction.java 2013-12-16 04:27:26 +0000 @@ -283,16 +283,13 @@ Patient representative = patient.getRepresentative(); relationship = relationshipService.getRelationship( representative, patient ); - if ( patient.isUnderAge() && representative != null ) + for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() ) { - for ( PatientIdentifier representativeIdentifier : representative.getIdentifiers() ) + if ( representativeIdentifier.getIdentifierType() != null + && representativeIdentifier.getIdentifierType().isRelated() ) { - if ( representativeIdentifier.getIdentifierType() != null - && representativeIdentifier.getIdentifierType().isRelated() ) - { - identiferMap.put( representativeIdentifier.getIdentifierType().getId(), - representativeIdentifier.getIdentifier() ); - } + identiferMap.put( representativeIdentifier.getIdentifierType().getId(), + representativeIdentifier.getIdentifier() ); } } @@ -315,8 +312,8 @@ for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) { - patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), - patientAttributeValue.getValue() ); + patientAttributeValueMap.put( patientAttributeValue.getPatientAttribute().getId(), + patientAttributeValue.getValue() ); } } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-11-25 08:18:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java 2013-12-16 04:27:26 +0000 @@ -236,7 +236,7 @@ } } } - + // --------------------------------------------------------------------- // Get patient-identifiers // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2013-10-24 08:31:35 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java 2013-12-16 04:27:26 +0000 @@ -67,8 +67,6 @@ private PatientIdentifierService patientIdentifierService; - private PatientAttributeValueService patientAttributeValueService; - private OrganisationUnitSelectionManager selectionManager; // ------------------------------------------------------------------------- @@ -117,12 +115,7 @@ { return patientAttributeValueMap; } - - public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService ) - { - this.patientAttributeValueService = patientAttributeValueService; - } - + public Map getIdentiferMap() { return identiferMap; @@ -231,8 +224,8 @@ if ( patientAttributes != null ) { - Collection patientAttributeValues = patientAttributeValueService - .getPatientAttributeValues( programInstance.getPatient() ); + Collection patientAttributeValues = programInstance.getPatient() + .getAttributeValues(); for ( PatientAttributeValue patientAttributeValue : patientAttributeValues ) { === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveRepresentativeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveRepresentativeAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/RemoveRepresentativeAction.java 2013-12-16 04:27:26 +0000 @@ -71,7 +71,6 @@ { Patient patient = patientService.getPatient( patientId ); patient.setRepresentative( null ); - patient.setUnderAge( false ); patientService.updatePatient( patient ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java 2013-09-27 11:13:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveIdentifierAndAttributeAction.java 2013-12-16 04:27:26 +0000 @@ -219,7 +219,8 @@ String value = null; Collection attributes = patientAttributeService.getAllPatientAttributes(); - + patient.getAttributeValues().clear(); + PatientAttributeValue attributeValue = null; if ( attributes != null && attributes.size() > 0 ) @@ -258,6 +259,7 @@ attributeValue.setValue( value.trim() ); } patientAttributeValueService.savePatientAttributeValue( attributeValue ); + patient.getAttributeValues().add( attributeValue ); } else { @@ -280,6 +282,7 @@ attributeValue.setValue( value.trim() ); } patientAttributeValueService.updatePatientAttributeValue( attributeValue ); + patient.getAttributeValues().add( attributeValue ); } } else if ( attributeValue != null ) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveRepresentativeAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveRepresentativeAction.java 2013-09-19 06:06:15 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SaveRepresentativeAction.java 2013-12-16 04:27:26 +0000 @@ -102,7 +102,6 @@ patient = patientService.getPatient( patientId ); patient.setRepresentative( representative ); - patient.setUnderAge( true ); patientService.updatePatient( 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-11-25 07:31:02 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/UpdatePatientAction.java 2013-12-16 04:27:26 +0000 @@ -28,13 +28,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.opensymphony.xwork2.Action; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patient.PatientAttribute; import org.hisp.dhis.patient.PatientAttributeOption; @@ -50,10 +52,7 @@ import org.hisp.dhis.setting.SystemSettingManager; import org.hisp.dhis.user.UserService; -import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import com.opensymphony.xwork2.Action; /** * @author Abyot Asalefew Gizaw @@ -66,8 +65,6 @@ // Dependencies // ------------------------------------------------------------------------- - private I18nFormat format; - private PatientService patientService; private PatientAttributeService patientAttributeService; @@ -78,8 +75,6 @@ private PatientIdentifierTypeService patientIdentifierTypeService; - private OrganisationUnitSelectionManager selectionManager; - private PatientAttributeOptionService patientAttributeOptionService; private UserService userService; @@ -99,22 +94,8 @@ private String fullName; - private String birthDate; - - private boolean isDead; - - private String deathDate; - - private Integer age; - - private Boolean verified; - - private String gender; - private String[] phoneNumber; - private boolean underAge; - private Integer representativeId; private Integer relationshipTypeId; @@ -134,12 +115,9 @@ public String execute() throws Exception { - OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit(); patient = patientService.getPatient( id ); - verified = (verified == null) ? false : verified; - // --------------------------------------------------------------------- // Set FullName // --------------------------------------------------------------------- @@ -167,46 +145,10 @@ phone = (phone.isEmpty()) ? null : phone.substring( 0, phone.length() - 1 ); patient.setPhoneNumber( phone ); } - - patient.setGender( gender ); - patient.setIsDead( false ); - patient.setUnderAge( underAge ); - patient.setOrganisationUnit( organisationUnit ); - patient.setIsDead( isDead ); - - if ( deathDate != null ) - { - deathDate = deathDate.trim(); - patient.setDeathDate( format.parseDate( deathDate ) ); - } if ( healthWorker != null ) { - patient.setAssociate( userService.getUser( healthWorker ) ); - } - - if ( birthDate != null || age != null ) - { - verified = (verified == null) ? false : verified; - - Character dobType = (verified) ? Patient.DOB_TYPE_VERIFIED : Patient.DOB_TYPE_DECLARED; - - if ( !verified && age != null ) - { - dobType = 'A'; - } - - if ( dobType == Patient.DOB_TYPE_VERIFIED || dobType == Patient.DOB_TYPE_DECLARED ) - { - birthDate = birthDate.trim(); - patient.setBirthDate( format.parseDate( birthDate ) ); - } - else - { - patient.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR ); - } - - patient.setDobType( dobType ); + patient.setAssociate( userService.getUser( healthWorker ) ); } // ------------------------------------------------------------------------------------- @@ -351,11 +293,6 @@ this.patientIdentifierTypeService = patientIdentifierTypeService; } - public void setFormat( I18nFormat format ) - { - this.format = format; - } - public void setPatientService( PatientService patientService ) { this.patientService = patientService; @@ -376,41 +313,16 @@ this.patientIdentifierService = patientIdentifierService; } - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - public void setId( Integer id ) { this.id = id; } - public void setIsDead( boolean isDead ) - { - this.isDead = isDead; - } - - public void setDeathDate( String deathDate ) - { - this.deathDate = deathDate; - } - public void setFullName( String fullName ) { this.fullName = fullName; } - public void setBirthDate( String birthDate ) - { - this.birthDate = birthDate; - } - - public void setGender( String gender ) - { - this.gender = gender; - } - public void setPhoneNumber( String[] phoneNumber ) { this.phoneNumber = phoneNumber; @@ -421,21 +333,11 @@ return patient; } - public void setAge( Integer age ) - { - this.age = age; - } - public void setPatientAttributeOptionService( PatientAttributeOptionService patientAttributeOptionService ) { this.patientAttributeOptionService = patientAttributeOptionService; } - public void setUnderAge( boolean underAge ) - { - this.underAge = underAge; - } - public void setRepresentativeId( Integer representativeId ) { this.representativeId = representativeId; @@ -446,9 +348,4 @@ this.relationshipTypeId = relationshipTypeId; } - public void setVerified( Boolean verified ) - { - this.verified = verified; - } - } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-10-25 05:00:41 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-12-16 04:27:26 +0000 @@ -38,7 +38,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.struts2.ServletActionContext; -import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.patient.Patient; @@ -63,8 +62,6 @@ // Dependencies // ------------------------------------------------------------------------- - private I18nFormat format; - private PatientService patientService; private PatientIdentifierTypeService identifierTypeService; @@ -79,12 +76,6 @@ private String fullName; - private String birthDate; - - private Integer age; - - private String gender; - private Integer id; private boolean underAge; @@ -126,21 +117,6 @@ patient = new Patient(); } - if ( gender != null ) - { - patient.setGender( gender ); - } - - if ( birthDate != null && !birthDate.isEmpty() ) - { - birthDate = birthDate.trim(); - patient.setBirthDate( format.parseDate( birthDate ) ); - - } - else if ( age != null ) - { - patient.setBirthDateFromAge( age, Patient.AGE_TYPE_YEAR ); - } patient.setName( fullName ); patient.setOrganisationUnit( orgunit ); @@ -209,11 +185,6 @@ this.identifierTypeService = identifierTypeService; } - public void setFormat( I18nFormat format ) - { - this.format = format; - } - public void setPatientService( PatientService patientService ) { this.patientService = patientService; @@ -229,16 +200,6 @@ this.fullName = fullName; } - public void setBirthDate( String birthDate ) - { - this.birthDate = birthDate; - } - - public void setAge( Integer age ) - { - this.age = age; - } - public String getMessage() { return message; @@ -259,11 +220,6 @@ this.id = id; } - public void setGender( String gender ) - { - this.gender = gender; - } - public void setUnderAge( boolean underAge ) { this.underAge = underAge; === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java 2013-09-25 07:00:33 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java 2013-12-16 04:27:26 +0000 @@ -83,7 +83,7 @@ throws Exception { ProgramStage programStage = programStageService.getProgramStage( programStageId ); - + if ( programStage.getProgramStageSections() != null ) { sections = new ArrayList( programStage.getProgramStageSections() ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java 2013-11-04 22:45:00 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java 2013-12-16 04:27:26 +0000 @@ -122,8 +122,6 @@ ProgramStage programStage = programStageService.getProgramStage( programStageId ); psDataElements = new ArrayList( programStage.getProgramStageDataElements() ); program = programStage.getProgram(); - - System.out.println("psd " + psDataElements.size()); } else if ( sectionId != null ) { === 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 2013-12-01 22:32:50 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-12-16 04:27:26 +0000 @@ -455,8 +455,6 @@ - @@ -494,8 +492,6 @@ - @@ -627,8 +623,6 @@ - === 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-12-01 22:32:50 +0000 +++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2013-12-16 04:27:26 +0000 @@ -29,7 +29,6 @@ */ import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -51,14 +50,10 @@ 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.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; @@ -358,35 +353,6 @@ patient.setName( patientFullName.trim() ); } - patient.setGender( gender ); - patient.setRegistrationDate( new Date() ); - patient.setDobType( dobType.charAt( 0 ) ); - - if ( dobType.equals( "A" ) ) - { - try - { - patient.setBirthDateFromAge( Integer.parseInt( dateOfBirth ), Patient.AGE_TYPE_YEAR ); - } - catch ( NumberFormatException nfe ) - { - validationMap.put( "dob", "is_invalid_number" ); - } - } - else - { - try - { - DateTimeFormatter sdf = ISODateTimeFormat.yearMonthDay(); - DateTime date = sdf.parseDateTime( dateOfBirth ); - patient.setBirthDate( date.toDate() ); - } - catch ( Exception e ) - { - validationMap.put( "dob", "is_invalid_date" ); - } - } - if ( phoneNumber.matches( "^(\\+)?\\d+$" ) ) { patient.setPhoneNumber( phoneNumber ); @@ -453,14 +419,6 @@ } } - 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 ); - for ( PatientAttribute patientAttribute : patientAttributes ) { patientAttributeSet.add( patientAttribute );