dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18868
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8021: [mobile] fix PatientIdentifierType issue in dhis-web-light module
------------------------------------------------------------
revno: 8021
committer: Long <thanhlongngo1988@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-09-08 21:18:07 +0700
message:
[mobile] fix PatientIdentifierType issue in dhis-web-light module
modified:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java
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/resources/META-INF/dhis/beans.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java 2012-07-30 10:56:25 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/RegisterBeneficiaryAction.java 2012-09-08 14:18:07 +0000
@@ -33,6 +33,8 @@
import org.hisp.dhis.patient.PatientAttributeService;
import org.hisp.dhis.patient.PatientIdentifierType;
import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
import com.opensymphony.xwork2.Action;
@@ -56,6 +58,18 @@
{
this.patientAttributeService = patientAttributeService;
}
+
+ private ProgramService programService;
+
+ public ProgramService getProgramService()
+ {
+ return programService;
+ }
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
// -------------------------------------------------------------------------
// Input & Output
@@ -107,7 +121,13 @@
{
patientIdentifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
patientAttributes = patientAttributeService.getAllPatientAttributes();
+ Collection<Program> programs = programService.getAllPrograms();
+ for ( Program program : programs )
+ {
+ patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+ patientAttributes.removeAll( program.getPatientAttributes() );
+ }
return SUCCESS;
}
}
=== 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 2012-09-07 10:18:43 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/beneficiaryregistration/action/SaveBeneficiaryAction.java 2012-09-08 14:18:07 +0000
@@ -35,6 +35,8 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.*;
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;
@@ -122,6 +124,18 @@
this.patientAttributeOptionService = patientAttributeOptionService;
}
+ private ProgramService programService;
+
+ public ProgramService getProgramService()
+ {
+ return programService;
+ }
+
+ public void setProgramService( ProgramService programService )
+ {
+ this.programService = programService;
+ }
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -315,7 +329,8 @@
try
{
patient.setBirthDateFromAge( Integer.parseInt( dateOfBirth ), Patient.AGE_TYPE_YEAR );
- } catch ( NumberFormatException nfe )
+ }
+ catch ( NumberFormatException nfe )
{
validationMap.put( "dob", "is_invalid_number" );
}
@@ -327,7 +342,8 @@
DateTimeFormatter sdf = ISODateTimeFormat.yearMonthDay();
DateTime date = sdf.parseDateTime( dateOfBirth );
patient.setBirthDate( date.toDate() );
- } catch ( Exception e )
+ }
+ catch ( Exception e )
{
validationMap.put( "dob", "is_invalid_date" );
}
@@ -337,9 +353,20 @@
ServletActionContext.HTTP_REQUEST );
Map<String, String> parameterMap = ContextUtils.getParameterMap( request );
- for ( PatientIdentifierType patientIdentifierType : patientIdentifierTypeService.getAllPatientIdentifierTypes() )
- {
-// if ( patientIdentifierType.getProgram() == null )
+ // Add Identifier and Attributes
+ Collection<PatientIdentifierType> patientIdentifierTypes = patientIdentifierTypeService
+ .getAllPatientIdentifierTypes();
+ Collection<PatientAttribute> patientAttributes = patientAttributeService.getAllPatientAttributes();
+ Collection<Program> programs = programService.getAllPrograms();
+
+ for ( Program program : programs )
+ {
+ patientIdentifierTypes.removeAll( program.getPatientIdentifierTypes() );
+ patientAttributes.removeAll( program.getPatientAttributes() );
+ }
+
+ for ( PatientIdentifierType patientIdentifierType : patientIdentifierTypes )
+ {
{
String key = "IDT" + patientIdentifierType.getId();
String value = parameterMap.get( key );
@@ -379,10 +406,9 @@
}
}
- for ( PatientAttribute patientAttribute : patientAttributeService.getAllPatientAttributes() )
+ for ( PatientAttribute patientAttribute : patientAttributes )
{
patientAttributeSet.add( patientAttribute );
-// if ( patientAttribute.getProgram() == null )
{
String key = "AT" + patientAttribute.getId();
String value = parameterMap.get( key ).trim();
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-08-13 10:06:08 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2012-09-08 14:18:07 +0000
@@ -279,6 +279,7 @@
scope="prototype">
<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
<bean
@@ -292,6 +293,7 @@
<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientAttributeOptionService" ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
<!-- Beneficiary Enrollment -->