=== 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-12-18 06:05:41 +0000 +++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2013-12-19 06:41:31 +0000 @@ -640,18 +640,17 @@ } /** - * Return standard SQL of a dynamic patient-attribute expression. E.g [CA:1] + * Return standard SQL of a dynamic patient-attribute expression. E.g [CA:1] OR [CA:1.age] * */ private String getConditionForPatientAttribute( String attributeId, Collection orgunitIds, boolean isExist ) { - - String sql = " EXISTS ( SELECT * FROM patientattributevalue _pav " + " WHERE _pav.patientid=pi.patientid "; + 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 )"; + sql += " AND _pav.patientattributeid=" + attributeId.split( "." )[0] + " AND DATE(now) - DATE( _pav.value ) "; } if ( isExist ) { === 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-18 08:01:59 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-12-19 06:41:31 +0000 @@ -460,7 +460,7 @@ { Statement statement = holder.getStatement(); - ResultSet resultSet = statement.executeQuery( "SELECT gender1 FROM patient" ); + ResultSet resultSet = statement.executeQuery( "SELECT gender FROM patient" ); if ( resultSet.next() ) { @@ -471,13 +471,15 @@ // --------------------------------------------------------------------- max++; + String uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() - + "','Gender', 'Gender','" + PatientAttribute.TYPE_COMBO + "', false, false, false)" ); + + "','Gender', 'Gender','" + + PatientAttribute.TYPE_COMBO + "', false, false, false)" ); int maxOpt = jdbcTemplate .queryForInt( "select max(patientattributeoptionid) from patientattributeoption" ); @@ -505,30 +507,39 @@ + CaseAggregationCondition.SEPARATOR_OBJECT + max + "]"; updateFixedAttributeInCaseAggregate( source, target ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "gender", uid ); + // --------------------------------------------------------------------- // Death date // --------------------------------------------------------------------- - + max++; + uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() - + "','Death date', 'Death date','" + PatientAttribute.TYPE_DATE + "', false, false, false)" ); + + "','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" ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "deathDate", uid ); + // --------------------------------------------------------------------- // registrationDate // --------------------------------------------------------------------- - + max++; + uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() + "','Registration date', 'Registration date','" @@ -537,50 +548,63 @@ executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + ",registrationDate from patient where registrationDate is not null" ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "registrationDate", uid ); + // --------------------------------------------------------------------- // isDead // --------------------------------------------------------------------- - + max++; + uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() - + "','Is Dead', 'Is Dead','" + PatientAttribute.TYPE_TRACKER_ASSOCIATE + "', false, false, false)" ); + + "','Is Dead', 'Is Dead','" + + PatientAttribute.TYPE_TRACKER_ASSOCIATE + "', false, false, false)" ); executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + ",isDead from patient where isDead is not null" ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "isDead", uid ); + // --------------------------------------------------------------------- // underAge // --------------------------------------------------------------------- max++; + uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, description, name, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() + "','Is under age', 'Is under age','" - + PatientAttribute.TYPE_TRACKER_ASSOCIATE - + "', false, false, false)" ); + + PatientAttribute.TYPE_TRACKER_ASSOCIATE + "', false, false, false)" ); executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + ",isDead from patient where underAge=true" ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "underAge", uid ); + // --------------------------------------------------------------------- // DobType // --------------------------------------------------------------------- max++; + uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, description, name, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() - + "','DOB type', 'DOB type','" + PatientAttribute.TYPE_COMBO + "', false, false, false)" ); + + "','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" ); @@ -608,38 +632,69 @@ + CaseAggregationCondition.SEPARATOR_OBJECT + max + "]"; updateFixedAttributeInCaseAggregate( source, target ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "dobType", uid ); + // ------------------------------------------------------------- // 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" ); + uid = CodeGenerator.generateCode(); + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + uid + + "','" + + 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 and dobType in ('D','V') " ); + + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "birthDate", uid ); + + // ------------------------------------------------------------- + // Age + // ------------------------------------------------------------- + + max++; + uid = CodeGenerator.generateCode(); + executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + + max + + ",'" + + uid + + "','" + + DateUtils.getMediumDateString() + + "','Age', 'Age','" + + PatientAttribute.TYPE_AGE + "', false, false, false)" ); + executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + + max + ",birthdate from patient where birthdate is not null and dobType='A' " ); + + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "age", uid ); // ------------------------------------------------------------- // Phone number // ------------------------------------------------------------- max++; + uid = CodeGenerator.generateCode(); executeSql( "INSERT INTO patientattribute (patientattributeid, uid, lastUpdated, name, description, valueType, mandatory, inherit, displayOnVisitSchedule ) VALUES (" + max + ",'" - + CodeGenerator.generateCode() + + uid + "','" + DateUtils.getMediumDateString() + "','Phone number', 'Phone number','" - + PatientAttribute.TYPE_PHONE_NUMBER - + "', false, false, false)" ); + + PatientAttribute.TYPE_PHONE_NUMBER + "', false, false, false)" ); executeSql( "INSERT INTO patientattributevalue (patientid, patientattributeid, value ) SELECT patientid," + max + ",phoneNumber from patient where phoneNumber is not null" ); + // Update custom entry form + removeFixedAttributeInCustomRegistrationForm( "phoneNumber", uid ); + // ------------------------------------------------------------- // Update Case Aggregate Query Builder // ------------------------------------------------------------- @@ -649,14 +704,13 @@ + 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" ); - // executeSql( "ALTER TABLE patient DROP COLUMN phoneNumber" ); + 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" ); + executeSql( "ALTER TABLE patient DROP COLUMN phoneNumber" ); } } catch ( Exception ex ) @@ -695,6 +749,35 @@ } } + public void removeFixedAttributeInCustomRegistrationForm( String property, String uid ) + { + StatementHolder holder = statementManager.getHolder(); + try + { + Statement statement = holder.getStatement(); + + ResultSet resultSet = statement + .executeQuery( "SELECT df.dataentryformid, df.htmlcode FROM dataentryform df INNER JOIN patientregistrationform pf on df.dataentryformid=pf.dataentryform" ); + + while ( resultSet.next() ) + { + String htmlCode = resultSet.getString( "htmlcode" ); + htmlCode = htmlCode.replaceAll( "fixedattributeid=\"" + property + "\"", "attributeid=\"" + uid + "\"" ); + + executeSql( "UPDATE dataentryform SET htmlcode='" + htmlCode + "' WHERE dataentryformid=" + + resultSet.getInt( "dataentryformid" ) ); + } + } + catch ( Exception ex ) + { + log.debug( ex ); + } + finally + { + holder.close(); + } + } + private int executeSql( String sql ) { try === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm 2013-12-18 06:05:41 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addPatientForm.vm 2013-12-19 06:41:31 +0000 @@ -21,7 +21,6 @@ }); addRelationship = false; - hideById('patientForm [id=age]'); hideById('mainLinkLbl'); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm 2013-12-18 06:05:41 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm 2013-12-19 06:41:31 +0000 @@ -54,21 +54,6 @@ { validateData(); } - ,beforeValidateHandler: function(form) - { - var dobType = $('#singleEventForm [id=dobType]').val(); - - if( dobType=='V' || dobType=='D' ) - { - var birthDate = $('#singleEventForm [id=birthDate]').val(); - if( birthDate != '' ){ - $("#singleEventForm [id=memberValidator]").val(birthDate); - } - }else{ - var age = $('#singleEventForm [id=age]').val(); - $("#singleEventForm [id=memberValidator]").val(age); - } - } }); }); \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-12-18 08:01:59 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-12-19 06:41:31 +0000 @@ -26,31 +26,6 @@ }); } ); -function dobTypeOnChange( container ){ - - var type = $('#' + container + ' [id=dobType]').val(); - if(type == 'V' || type == 'D') - { - $('#' + container + ' [id=age]').rules("remove"); - $('#' + container + ' [id=age]').css("display","none"); - $('#' + container + ' [id=age]').val(""); - - $('#' + container + ' [id=birthDate]').rules("add",{required:true}); - datePickerValid( container + ' [id=birthDate]' ); - $('#' + container + ' [id=birthDate]').css("display",""); - } - else if(type == 'A') - { - $('#' + container + ' [id=age]').rules("add",{required:true, number: true}); - $('#' + container + ' [id=age]').css("display",""); - - $('#' + container + ' [id=birthDate]').val(""); - $('#' + container + ' [id=birthDate]').rules("remove","required"); - $('#' + container+ ' [id=birthDate]').datepicker("destroy"); - $('#' + container + ' [id=birthDate]').css("display","none"); - } -} - // ----------------------------------------------------------------------------- // Advanced search // ----------------------------------------------------------------------------- @@ -999,10 +974,6 @@ $("#" + divname + " [id=checkDuplicateBtn]").click(function() { checkDuplicate( divname ); }); - - $("#" + divname + " [id=dobType]").change(function() { - dobTypeOnChange( divname ); - }); } function showRepresentativeInfo( patientId) === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js 2013-12-18 06:05:41 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js 2013-12-19 06:41:31 +0000 @@ -72,10 +72,6 @@ jQuery("#" + divname + " [id=checkDuplicateBtn]").click(function() { checkDuplicate( divname ); }); - - jQuery("#" + divname + " [id=dobType]").change(function() { - dobTypeOnChange( divname ); - }); } function validateData() === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm 2013-12-17 03:31:30 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregationForm.vm 2013-12-19 06:41:31 +0000 @@ -79,7 +79,11 @@