dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #27543
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13713: event: use eventDate as due/execution date if provided (if not, use current date as before), pars...
------------------------------------------------------------
revno: 13713
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-01-14 17:15:25 +0700
message:
event: use eventDate as due/execution date if provided (if not, use current date as before), parsed as medium date string: YYYY-MM-DD
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-01-02 14:34:54 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2014-01-14 10:15:25 +0000
@@ -29,15 +29,8 @@
*/
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
@@ -71,8 +64,13 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -110,7 +108,7 @@
@Autowired
private PatientService patientService;
-
+
@Autowired
private PatientCommentService patientCommentService;
@@ -414,7 +412,7 @@
public Event getEvent( String uid )
{
ProgramStageInstance psi = programStageInstanceService.getProgramStageInstance( uid );
-
+
return psi != null ? convertProgramStageInstance( psi ) : null;
}
@@ -449,20 +447,25 @@
{
organisationUnit = programStageInstance.getOrganisationUnit();
}
-
+
Date date = new Date();
+ if ( event.getEventDate() != null )
+ {
+ date = DateUtils.getMediumDate( event.getEventDate() );
+ }
+
String storedBy = getStoredBy( event, null );
programStageInstance.setDueDate( date );
programStageInstance.setExecutionDate( date );
programStageInstance.setOrganisationUnit( organisationUnit );
- programStageInstance.setCompletedUser( storedBy );
-
+ programStageInstance.setCompletedUser( storedBy );
+
programStageInstanceService.updateProgramStageInstance( programStageInstance );
-
+
ProgramInstance programInstance = programStageInstance.getProgramInstance();
-
+
savePatientCommentFromEvent( programInstance, event, storedBy );
Set<PatientDataValue> patientDataValues = new HashSet<PatientDataValue>(
@@ -532,10 +535,10 @@
event.setOrgUnit( programStageInstance.getOrganisationUnit().getUid() );
event.setProgram( programStageInstance.getProgramInstance().getProgram().getUid() );
event.setProgramStage( programStageInstance.getProgramStage().getUid() );
-
+
if ( programStageInstance.getProgramInstance().getPatient() != null )
{
- event.setPerson( programStageInstance.getProgramInstance().getPatient().getUid());
+ event.setPerson( programStageInstance.getProgramInstance().getPatient().getUid() );
}
if ( programStageInstance.getProgramStage().getCaptureCoordinates() )
@@ -578,20 +581,20 @@
value.setStoredBy( patientDataValue.getStoredBy() );
event.getDataValues().add( value );
- }
-
+ }
+
ProgramInstance programInstance = programStageInstance.getProgramInstance();
-
+
Collection<PatientComment> patientComments = programInstance.getPatientComments();
-
+
for ( PatientComment patientComment : patientComments )
- {
+ {
Note note = new Note();
note.setValue( patientComment.getCommentText() );
note.setStoredBy( patientComment.getCreator() );
note.setStoredDate( patientComment.getCreatedDate().toString() );
event.getNotes().add( note );
- }
+ }
return event;
}
@@ -759,14 +762,14 @@
}
String storedBy = getStoredBy( event, importSummary );
-
+
if ( !dryRun )
{
if ( programStageInstance == null )
{
programStageInstance = createProgramStageInstance( programStage, programInstance, organisationUnit,
- eventDate, EventStatus.COMPLETED.equals( event.getStatus() ), event.getCoordinate(), storedBy );
-
+ eventDate, EventStatus.COMPLETED.equals( event.getStatus() ), event.getCoordinate(), storedBy );
+
}
else
{
@@ -774,7 +777,7 @@
EventStatus.COMPLETED.equals( event.getStatus() ), event.getCoordinate(), storedBy,
programStageInstance );
}
-
+
savePatientCommentFromEvent( programInstance, event, storedBy );
importSummary.setReference( programStageInstance.getUid() );
@@ -809,21 +812,21 @@
return importSummary;
}
-
- private void savePatientCommentFromEvent(ProgramInstance programInstance, Event event, String storedBy)
+
+ private void savePatientCommentFromEvent( ProgramInstance programInstance, Event event, String storedBy )
{
- for ( Note note : event.getNotes() )
+ for ( Note note : event.getNotes() )
{
- PatientComment patientComment = new PatientComment();
- patientComment.setCreator( storedBy );
- patientComment.setCreatedDate( new Date() );
- patientComment.setCommentText( note.getValue() );
-
- patientCommentService.addPatientComment( patientComment );
-
- programInstance.getPatientComments().add( patientComment );
-
- programInstanceService.updateProgramInstance( programInstance );
- }
+ PatientComment patientComment = new PatientComment();
+ patientComment.setCreator( storedBy );
+ patientComment.setCreatedDate( new Date() );
+ patientComment.setCommentText( note.getValue() );
+
+ patientCommentService.addPatientComment( patientComment );
+
+ programInstance.getPatientComments().add( patientComment );
+
+ programInstanceService.updateProgramInstance( programInstance );
+ }
}
}