dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24943
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12275: Reverted r 12270
------------------------------------------------------------
revno: 12275
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-09-27 13:10:25 +0200
message:
Reverted r 12270
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientProperty.java
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/startup/TableAlteror.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java 2013-09-27 07:43:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientRegistrationFormService.java 2013-09-27 11:10:25 +0000
@@ -59,6 +59,10 @@
final Pattern TITLE_TAG_PATTERN = Pattern.compile( "title=\"(.*?)\"", Pattern.DOTALL );
+ final Pattern SUGGESTED_VALUE_PATTERN = Pattern.compile( "suggested=('|\")(\\w*)('|\")" );
+
+ final Pattern CLASS_PATTERN = Pattern.compile( "class='(\\w*)'" );
+
// --------------------------------------------------------------------------
// ProgramDataEntryService
// --------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientProperty.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientProperty.java 2013-09-27 07:43:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramPatientProperty.java 2013-09-27 11:10:25 +0000
@@ -54,7 +54,7 @@
private String defaultValue;
- private boolean hidden = false;
+ private boolean hidden;
private int sortOrder;
=== 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-09-27 07:43:07 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java 2013-09-27 11:10:25 +0000
@@ -39,8 +39,6 @@
import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramPatientProperty;
-import org.hisp.dhis.program.ProgramPatientPropertyService;
import org.hisp.dhis.user.User;
import org.springframework.transaction.annotation.Transactional;
@@ -100,13 +98,6 @@
this.attributeValueService = attributeValueService;
}
- private ProgramPatientPropertyService programPatientPropertyService;
-
- public void setProgramPatientPropertyService( ProgramPatientPropertyService programPatientPropertyService )
- {
- this.programPatientPropertyService = programPatientPropertyService;
- }
-
// -------------------------------------------------------------------------
// PatientRegistrationForm implementation
// -------------------------------------------------------------------------
@@ -174,6 +165,8 @@
Matcher identifierMatcher = IDENTIFIER_PATTERN.matcher( inputHtml );
Matcher dynamicAttrMatcher = DYNAMIC_ATTRIBUTE_PATTERN.matcher( inputHtml );
Matcher programMatcher = PROGRAM_PATTERN.matcher( inputHtml );
+ Matcher suggestedMarcher = SUGGESTED_VALUE_PATTERN.matcher( inputHtml );
+ Matcher classMarcher = CLASS_PATTERN.matcher( inputHtml );
index++;
@@ -184,14 +177,6 @@
// Get value
String value = "";
String hidden = "";
-
- ProgramPatientProperty programPatientProperty = programPatientPropertyService.getProgramPatientProperty( program, fixedAttr );
- if (programPatientProperty != null)
- {
- hidden = programPatientProperty.isHidden() ? "hidden" : "";
- value = programPatientProperty.getDefaultValue();
- }
-
if ( patient != null )
{
Object object = getValueFromPatient( fixedAttr, patient );
@@ -211,6 +196,15 @@
}
}
}
+ else if ( suggestedMarcher.find() )
+ {
+ value = suggestedMarcher.group( 2 );
+ }
+
+ if ( classMarcher.find() )
+ {
+ hidden = classMarcher.group( 1 );
+ }
inputHtml = getFixedAttributeField( inputHtml, fixedAttr, value.toString(), hidden, healthWorkers,
i18n, index );
@@ -229,15 +223,6 @@
int id = identifierType.getId();
// Get value
String value = "";
- String hidden = "";
-
- ProgramPatientProperty programPatientProperty = programPatientPropertyService.getProgramPatientProperty( program, identifierType );
- if (programPatientProperty != null)
- {
- hidden = programPatientProperty.isHidden() ? "hidden" : "";
- value = programPatientProperty.getDefaultValue();
- }
-
if ( patient != null )
{
PatientIdentifier patientIdentifier = identifierService.getPatientIdentifier( identifierType,
@@ -252,7 +237,7 @@
inputHtml = "<input id=\"iden" + id + "\" name=\"iden" + id + "\" tabindex=\"" + index
+ "\" value=\"" + value + "\" ";
- inputHtml += "class=\" " + hidden + " {validate:{required:" + identifierType.isMandatory() + ",";
+ inputHtml += "class=\"{validate:{required:" + identifierType.isMandatory() + ",";
if ( identifierType.getNoChars() != null )
{
inputHtml += "maxlength:" + identifierType.getNoChars() + ",";
@@ -273,16 +258,7 @@
{
String uid = dynamicAttrMatcher.group( 1 );
PatientAttribute attribute = attributeService.getPatientAttribute( uid );
- String value = "";
- String hidden = "";
-
- ProgramPatientProperty programPatientProperty = programPatientPropertyService.getProgramPatientProperty( program, attribute );
- if (programPatientProperty != null)
- {
- hidden = programPatientProperty.isHidden() ? "hidden" : "";
- value = programPatientProperty.getDefaultValue();
- }
-
+
if ( attribute == null )
{
inputHtml = "<input value='[" + i18n.getString( "missing_patient_attribute" ) + " " + uid
@@ -290,6 +266,8 @@
}
else
{
+ // Get value
+ String value = "";
if ( patient != null )
{
PatientAttributeValue attributeValue = attributeValueService.getPatientAttributeValue( patient,
@@ -300,7 +278,7 @@
}
}
- inputHtml = getAttributeField( inputHtml, attribute, value, i18n, index, hidden );
+ inputHtml = getAttributeField( inputHtml, attribute, value, i18n, index );
}
}
@@ -354,12 +332,12 @@
// Supportive methods
// -------------------------------------------------------------------------
- private String getAttributeField( String inputHtml, PatientAttribute attribute, String value, I18n i18n, int index, String hidden )
+ private String getAttributeField( String inputHtml, PatientAttribute attribute, String value, I18n i18n, int index )
{
inputHtml = TAG_OPEN + "input id=\"attr" + attribute.getId() + "\" name=\"attr" + attribute.getId()
+ "\" tabindex=\"" + index + "\" ";
- inputHtml += "\" class=\" " + hidden + " {validate:{required:" + attribute.isMandatory();
+ inputHtml += "\" class=\"{validate:{required:" + attribute.isMandatory();
if ( PatientAttribute.TYPE_INT.equals( attribute.getValueType() ) )
{
inputHtml += ",number:true";
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-27 07:43:07 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java 2013-09-27 11:10:25 +0000
@@ -248,11 +248,6 @@
executeSql( "update patientidentifiertype set orgunitScope=false where orgunitScope is null" );
executeSql( "update patientidentifiertype set programScope=false where programScope is null" );
-
- int index = updateProgramPatientAttribue();
- updateProgramPatientIdentifierType( index );
- executeSql( "DROP TABLE program_patientattributes" );
- executeSql( "DROP TABLE program_patientidentifiertypes" );
}
// -------------------------------------------------------------------------
@@ -387,73 +382,6 @@
executeSql( "ALTER TABLE programinstance DROP COLUMN completed" );
}
- private int updateProgramPatientAttribue()
- {
- StatementHolder holder = statementManager.getHolder();
-
- try
- {
- Statement statement = holder.getStatement();
-
- ResultSet resultSet = statement
- .executeQuery( "select programid, patientattributeid, sort_order from program_patientattributes" );
- int i = 1;
- while ( resultSet.next() )
- {
- executeSql( "insert into programpatientproperty( programpatientpropertyid, programid, patientattributeid, hidden, sortOrder) "
- + "values ("
- + i
- + ", "
- + resultSet.getInt( "programid" )
- + ","
- + resultSet.getInt( "patientattributeid" ) + ", false, " + resultSet.getInt( "sort_order" ) + ") " );
- i++;
- }
- return i;
- }
- catch ( Exception ex )
- {
- log.debug( ex );
- }
- finally
- {
- holder.close();
- }
- return 0;
- }
-
- private void updateProgramPatientIdentifierType( int index )
- {
- StatementHolder holder = statementManager.getHolder();
-
- try
- {
- Statement statement = holder.getStatement();
-
- ResultSet resultSet = statement
- .executeQuery( "select programid, patientidentifiertypeid, sort_order from program_patientidentifiertypes" );
- while ( resultSet.next() )
- {
- executeSql( "insert into programpatientproperty( programpatientpropertyid, programid, patientidentifiertypeid, hidden, sortOrder) "
- + "values ("
- + index
- + ", "
- + resultSet.getInt( "programid" )
- + ","
- + resultSet.getInt( "patientidentifiertypeid" ) + ", false, " + resultSet.getInt( "sort_order" ) + ") " );
- index++;
- }
- }
- catch ( Exception ex )
- {
- log.debug( ex );
- }
- finally
- {
- holder.close();
- }
- }
-
private int executeSql( String sql )
{
try
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-09-27 07:43:07 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-09-27 11:10:25 +0000
@@ -465,8 +465,6 @@
ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="attributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
- <property name="programPatientPropertyService"
- ref="org.hisp.dhis.program.ProgramPatientPropertyService" />
</bean>
<bean id="org.hisp.dhis.patient.PatientRegistrationFormStore"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java 2013-09-27 07:43:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ViewPatientRegistrationFormAction.java 2013-09-27 11:10:25 +0000
@@ -133,13 +133,6 @@
return identifierTypes;
}
- private Collection<String> fixedProperties;
-
- public Collection<String> getFixedProperties()
- {
- return fixedProperties;
- }
-
private PatientRegistrationForm registrationForm;
public PatientRegistrationForm getRegistrationForm()
@@ -194,15 +187,10 @@
else
{
program = programService.getProgram( programId );
-
+
identifierTypes.addAll( programPatientPropertyService.getPatientIdentifierTypes( program ) );
attributes.addAll( programPatientPropertyService.getPatientAttributes( program ) );
- fixedProperties = programPatientPropertyService.getPatientProperties( program );
- if ( fixedProperties == null )
- {
- fixedProperties = new HashSet<String>();
- }
-
+
registrationForm = patientRegistrationFormService.getPatientRegistrationForm( program );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2013-09-27 07:43:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/program/UpdateProgramAction.java 2013-09-27 11:10:25 +0000
@@ -483,6 +483,7 @@
}
else
{
+ programPatientProperty.setProgram( program );
programPatientProperty.setHidden( hiddens.get( index ) );
programPatientProperty.setDefaultValue( defaultValues.get( index ) );
programPatientProperty.setSortOrder( index );
@@ -508,6 +509,7 @@
}
else
{
+ programPatientProperty.setProgram( program );
programPatientProperty.setHidden( hiddens.get( index ) );
programPatientProperty.setDefaultValue( defaultValues.get( index ) );
programPatientProperty.setSortOrder( index );
@@ -529,11 +531,12 @@
}
else
{
+ programPatientProperty.setProgram( program );
programPatientProperty.setHidden( hiddens.get( index ) );
programPatientProperty.setDefaultValue( defaultValues.get( index ) );
programPatientProperty.setSortOrder( index );
programPatientPropertyService.updateProgramPatientProperty( programPatientProperty );
-
+
removeProgramProperties.remove( programPatientProperty );
}
}