dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25699
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12789: add incident date when enroll program [j2me]
------------------------------------------------------------
revno: 12789
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-10-22 11:01:39 +0700
message:
add incident date when enroll program [j2me]
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java
dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.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-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java 2013-09-04 10:01:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java 2013-10-22 04:01:39 +0000
@@ -123,6 +123,7 @@
}
SMSCommand smsCommand = smsCommandService.getSMSCommand( commandString, ParserType.KEY_VALUE_PARSER );
Map<String, String> parsedMessage = this.parse( message, smsCommand );
+
Date date = lookForDate( message );
String senderPhoneNumber = StringUtils.replace( sms.getOriginator(), "+", "" );
Collection<OrganisationUnit> orgUnits = getOrganisationUnitsByPhoneNumber( senderPhoneNumber );
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-10-09 03:02:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/ActivityReportingService.java 2013-10-22 04:01:39 +0000
@@ -29,6 +29,7 @@
*/
import java.util.Collection;
+import java.util.Date;
import org.hisp.dhis.api.mobile.model.ActivityPlan;
import org.hisp.dhis.api.mobile.model.ActivityValue;
@@ -69,7 +70,7 @@
public String saveProgramStage( ProgramStage programStage, int patientId, int orgUnitId )
throws NotAllowedException;
- public Patient enrollProgram( String enrollInfo )
+ public Patient enrollProgram( String enrollInfo, Date incidentDate )
throws NotAllowedException;
public Collection<PatientIdentifierType> getIdentifierTypes();
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-10-08 17:16:47 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/api/mobile/model/LWUITmodel/Patient.java 2013-10-22 04:01:39 +0000
@@ -55,7 +55,7 @@
private int age;
- private List<PatientAttribute> patientAttValues;
+ private List<PatientAttribute> attributes;
private List<PatientIdentifier> identifiers;
@@ -80,6 +80,8 @@
private String organisationUnitName;
private List<Program> completedPrograms;
+
+ private String incidentDate;
// -------------------------------------------------------------------------
// Getters and setters
@@ -175,14 +177,14 @@
this.age = age;
}
- public List<PatientAttribute> getPatientAttValues()
+ public List<PatientAttribute> getAttributes()
{
- return patientAttValues;
+ return attributes;
}
- public void setPatientAttValues( List<PatientAttribute> patientAttValues )
+ public void setAttributes( List<PatientAttribute> attributes )
{
- this.patientAttValues = patientAttValues;
+ this.attributes = attributes;
}
public int getId()
@@ -254,7 +256,17 @@
{
this.completedPrograms = completedPrograms;
}
+
+ public String getIncidentDate()
+ {
+ return incidentDate;
+ }
+ public void setIncidentDate( String incidentDate )
+ {
+ this.incidentDate = incidentDate;
+ }
+
// -------------------------------------------------------------------------
// Override Methods
// -------------------------------------------------------------------------
@@ -326,6 +338,16 @@
{
dout.writeBoolean( false );
}
+
+ if ( incidentDate != null )
+ {
+ dout.writeBoolean( true );
+ dout.writeUTF( incidentDate );
+ }
+ else
+ {
+ dout.writeBoolean( false );
+ }
if ( phoneNumber != null )
{
@@ -338,10 +360,10 @@
}
// Write Patient Attribute
- if ( patientAttValues != null )
+ if ( attributes != null )
{
- dout.writeInt( patientAttValues.size() );
- for ( PatientAttribute patientAtt : patientAttValues )
+ dout.writeInt( attributes.size() );
+ for ( PatientAttribute patientAtt : attributes )
{
patientAtt.serialize( dout );
}
@@ -472,6 +494,16 @@
this.setRegistrationDate( null );
}
+ // Incident Date
+ if ( din.readBoolean() )
+ {
+ this.setIncidentDate( din.readUTF() );
+ }
+ else
+ {
+ this.setIncidentDate( null );
+ }
+
// Phone Number
if ( din.readBoolean() )
{
@@ -486,17 +518,17 @@
int attsNumb = din.readInt();
if ( attsNumb > 0 )
{
- this.patientAttValues = new ArrayList<PatientAttribute>();
+ attributes = new ArrayList<PatientAttribute>();
for ( int j = 0; j < attsNumb; j++ )
{
PatientAttribute pa = new PatientAttribute();
pa.deSerialize( din );
- this.patientAttValues.add( pa );
+ attributes.add( pa );
}
}
else
{
- this.patientAttValues = null;
+ attributes = null;
}
int numbIdentifiers = din.readInt();
=== 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-10-14 11:13:33 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2013-10-22 04:01:39 +0000
@@ -173,9 +173,9 @@
{
this.currentUserService = currentUserService;
}
-
+
private MessageService messageService;
-
+
@Required
public void setMessageService( MessageService messageService )
{
@@ -188,7 +188,7 @@
{
this.smsSender = smsSender;
}
-
+
public PatientIdentifierTypeService getPatientIdentifierTypeService()
{
return patientIdentifierTypeService;
@@ -563,8 +563,9 @@
if ( isNumber( keyword ) == false )
{
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-
- List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( keyword, organisationUnit );
+
+ List<Patient> patients = (List<Patient>) patientService.getPatientByFullname( keyword,
+ organisationUnit );
if ( patients.size() > 1 )
{
@@ -793,7 +794,7 @@
}
@Override
- public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient enrollProgram( String enrollInfo )
+ public org.hisp.dhis.api.mobile.model.LWUITmodel.Patient enrollProgram( String enrollInfo, Date incidentDate )
throws NotAllowedException
{
String[] enrollProgramInfo = enrollInfo.split( "-" );
@@ -805,7 +806,7 @@
ProgramInstance programInstance = new ProgramInstance();
programInstance.setEnrollmentDate( new Date() );
- programInstance.setDateOfIncident( new Date() );
+ programInstance.setDateOfIncident( incidentDate );
programInstance.setProgram( program );
programInstance.setPatient( patient );
programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
@@ -1054,7 +1055,7 @@
}
patientModel.setIdentifiers( identifiers );
- patientModel.setPatientAttValues( patientAtts );
+ patientModel.setAttributes( patientAtts );
// Set current programs
List<ProgramInstance> listOfProgramInstance = new ArrayList<ProgramInstance>(
@@ -1399,9 +1400,10 @@
{
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-
+
String fullName = enrollmentRelationship.getPersonBName();
- List<Patient> patients = (List<Patient>) this.patientService.getPatientByFullname( fullName, organisationUnit );
+ List<Patient> patients = (List<Patient>) patientService.getPatientByFullname( fullName,
+ organisationUnit );
// remove the own searcher
patients = removeIfDuplicated( patients, enrollmentRelationship.getPersonAId() );
@@ -1551,7 +1553,7 @@
anonymousProgramMobile.setName( program.getName() );
- //if ( program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
+ // if ( program.getType() == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
{
anonymousProgramMobile.setVersion( program.getVersion() );
@@ -1837,16 +1839,15 @@
Set<org.hisp.dhis.patient.PatientAttribute> patientAttributeSet = new HashSet<org.hisp.dhis.patient.PatientAttribute>();
List<PatientAttributeValue> patientAttributeValues = new ArrayList<PatientAttributeValue>();
- Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> identifiers = patient.getIdentifiers();
+ Collection<org.hisp.dhis.api.mobile.model.PatientIdentifier> identifiersMobile = patient.getIdentifiers();
Collection<PatientIdentifierType> identifierTypes = patientIdentifierTypeService.getAllPatientIdentifierTypes();
- Collection<org.hisp.dhis.api.mobile.model.PatientAttribute> patientAttributesMobile = patient
- .getPatientAttValues();
+ Collection<org.hisp.dhis.api.mobile.model.PatientAttribute> attributesMobile = patient.getAttributes();
if ( identifierTypes.size() > 0 )
{
- for ( org.hisp.dhis.api.mobile.model.PatientIdentifier identifier : identifiers )
+ for ( org.hisp.dhis.api.mobile.model.PatientIdentifier identifier : identifiersMobile )
{
PatientIdentifierType patientIdentifierType = patientIdentifierTypeService
.getPatientIdentifierType( identifier.getIdentifierType() );
@@ -1876,9 +1877,9 @@
patientIdentifierSet.add( systemGenerateIdentifier );
}
- if ( patientAttributesMobile != null )
+ if ( attributesMobile != null )
{
- for ( org.hisp.dhis.api.mobile.model.PatientAttribute paAtt : patientAttributesMobile )
+ for ( org.hisp.dhis.api.mobile.model.PatientAttribute paAtt : attributesMobile )
{
org.hisp.dhis.patient.PatientAttribute patientAttribute = patientAttributeService
@@ -1903,7 +1904,8 @@
try
{
int programId = Integer.parseInt( programIdText );
- this.enrollProgram( patientId + "-" + programId );
+ Date incidentDate = PeriodUtil.stringToDate( patient.getIncidentDate() );
+ enrollProgram( patientId + "-" + programId, incidentDate );
}
catch ( Exception e )
{
@@ -2073,43 +2075,49 @@
Notification notification = new Notification();
try
{
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( lostEvent.getId() );
+ ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance( lostEvent
+ .getId() );
programStageInstance.setDueDate( PeriodUtil.stringToDate( lostEvent.getDueDate() ) );
programStageInstance.setStatus( lostEvent.getStatus() );
-
+
if ( lostEvent.getComment() != null )
{
List<MessageConversation> conversationList = new ArrayList<MessageConversation>();
-
- MessageConversation conversation = new MessageConversation( lostEvent.getName(), currentUserService.getCurrentUser() );
-
- conversation.addMessage( new Message( lostEvent.getComment(), null, currentUserService.getCurrentUser() ) );
-
+
+ MessageConversation conversation = new MessageConversation( lostEvent.getName(),
+ currentUserService.getCurrentUser() );
+
+ conversation
+ .addMessage( new Message( lostEvent.getComment(), null, currentUserService.getCurrentUser() ) );
+
conversation.setRead( true );
-
+
conversationList.add( conversation );
-
+
programStageInstance.setMessageConversations( conversationList );
-
+
messageService.saveMessageConversation( conversation );
}
-
+
programStageInstanceService.updateProgramStageInstance( programStageInstance );
-
- //send SMS
- if ( programStageInstance.getProgramInstance().getPatient().getPhoneNumber() != null && lostEvent.getSMS() != null )
+
+ // send SMS
+ if ( programStageInstance.getProgramInstance().getPatient().getPhoneNumber() != null
+ && lostEvent.getSMS() != null )
{
User user = new User();
user.setPhoneNumber( programStageInstance.getProgramInstance().getPatient().getPhoneNumber() );
List<User> recipientsList = new ArrayList<User>();
recipientsList.add( user );
-
- smsSender.sendMessage( lostEvent.getName(), lostEvent.getSMS(), currentUserService.getCurrentUser(), recipientsList, false );
+
+ smsSender.sendMessage( lostEvent.getName(), lostEvent.getSMS(), currentUserService.getCurrentUser(),
+ recipientsList, false );
}
-
+
notification.setMessage( "Success" );
}
- catch (Exception e) {
+ catch ( Exception e )
+ {
e.printStackTrace();
notification.setMessage( "Fail" );
}
=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java 2013-09-16 17:07:25 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/test/java/org/hisp/dhis/mobile/service/ActivityReportingServiceTest.java 2013-10-22 04:01:39 +0000
@@ -77,8 +77,9 @@
patient.setOrganisationUnitName( "OrgUnitName" );
patient.setPhoneNumber( "095678943" );
patient.setRegistrationDate( new Date() );
+ patient.setIncidentDate( "Incident Date" );
patient.setIdentifiers( new ArrayList<PatientIdentifier>() );
- patient.setPatientAttValues( new ArrayList<PatientAttribute>() );
+ patient.setAttributes( new ArrayList<PatientAttribute>() );
return patient;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-10-10 05:42:48 +0000
+++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2013-10-22 04:01:39 +0000
@@ -369,7 +369,7 @@
public Patient enrollProgram( @PathVariable int id, @RequestHeader( "enrollInfo" ) String enrollInfo )
throws NotAllowedException
{
- return activityReportingService.enrollProgram( enrollInfo );
+ return activityReportingService.enrollProgram( enrollInfo, new Date() );
}
@RequestMapping( method = RequestMethod.POST, value = "{clientVersion}/LWUIT/orgUnits/{id}/addRelationship" )