File tree Expand file tree Collapse file tree
api/src/main/java/org/openmrs/module/ugandaemrsync/server
omod/src/main/java/org/openmrs/module/ugandaemrsync/web/resource Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ public class SyncConstant {
9292 public static final String VIRAL_LOAD_SYNC_TASK_TYPE_UUID = "3551ca84-06c0-432b-9064-fcfeefd6f4ec" ;
9393
9494 public static final String VIRAL_LOAD_SYNC_TYPE_UUID = "3551ca84-06c0-432b-9064-fcfeefd6f4ec" ;
95+ public static final String VIRAL_LOAD_RESULT_SYNC_TYPE_UUID = "3396dcf0-2106-4e73-9b90-c63978c3a8b4" ;
9596 public static final String VL_PROGRAM_DATA_SYNC_TYPE_UUID = "f9b2fa5d-5d37-4fd9-b20a-a0cab664f520" ;
9697 public static final String FHIRSERVER_SYNC_TASK_TYPE_UUID = "3c1ce940-8ade-11ea-bc55-0242ac130003" ;
9798 public static final String VIRAL_LOAD_RESULT_PULL_TYPE_UUID = "3396dcf0-2106-4e73-9b90-c63978c3a8b4" ;
Original file line number Diff line number Diff line change @@ -242,12 +242,27 @@ private SyncTask getSyncTaskByOrder(Order order) {
242242 if (order == null || order .getAccessionNumber () == null ) {
243243 return null ;
244244 }
245+
245246 UgandaEMRSyncService syncService = Context .getService (UgandaEMRSyncService .class );
246- SyncTaskType syncTaskType = syncService .getSyncTaskTypeByUUID (VIRAL_LOAD_SYNC_TYPE_UUID );
247- List <SyncTask > syncTaskLog = syncService .getSyncTasksBySyncTaskId (order .getAccessionNumber ()).stream ().filter (syncTask -> syncTask .getSyncTaskType ().equals (syncTaskType )).collect (Collectors .toList ());
248- if (!syncTaskLog .isEmpty ()) {
249- return syncTaskLog .get (0 );
247+ SyncTaskType requestType = syncService .getSyncTaskTypeByUUID (VIRAL_LOAD_SYNC_TYPE_UUID );
248+ SyncTaskType resultType = syncService .getSyncTaskTypeByUUID (VIRAL_LOAD_RESULT_SYNC_TYPE_UUID );
249+
250+ List <SyncTask > syncTasks = syncService .getSyncTasksBySyncTaskId (order .getAccessionNumber ());
251+
252+ // Prioritize result sync task
253+ for (SyncTask task : syncTasks ) {
254+ if (task .getSyncTaskType ().equals (resultType )) {
255+ return task ;
256+ }
250257 }
258+
259+ // Fallback to request sync task
260+ for (SyncTask task : syncTasks ) {
261+ if (task .getSyncTaskType ().equals (requestType )) {
262+ return task ;
263+ }
264+ }
265+
251266 return null ;
252267 }
253268
You can’t perform that action at this time.
0 commit comments