22
22
package com .iemr .ecd .service .associate ;
23
23
24
24
import java .sql .Timestamp ;
25
+ import java .text .SimpleDateFormat ;
25
26
import java .time .LocalDateTime ;
26
27
import java .time .format .DateTimeFormatter ;
27
28
import java .util .ArrayList ;
28
29
import java .util .Calendar ;
30
+ import java .util .Date ;
29
31
import java .util .HashMap ;
30
32
import java .util .List ;
31
33
import java .util .Map ;
@@ -401,8 +403,10 @@ private String createEcdCallRecordsInOutboundCalls(CallClosureDTO request,
401
403
continue ;
402
404
403
405
Timestamp callEndDate = null ;
404
- if (callStartDate == null )
405
- callStartDate = motherRecord .getLmpDate ();
406
+ if (callStartDate == null ) {
407
+ callStartDate = getCallDateStartFormat (motherRecord .getLmpDate ());
408
+ }
409
+ callStartDate = getCallDateStartFormat (callStartDate );
406
410
outboundCalls .setCallDateFrom (callStartDate );
407
411
408
412
if (callConfiguration .getConfigTerms () != null
@@ -411,17 +415,15 @@ private String createEcdCallRecordsInOutboundCalls(CallClosureDTO request,
411
415
Calendar cal = Calendar .getInstance ();
412
416
cal .setTime (motherRecord .getLmpDate ());
413
417
cal .add (Calendar .DAY_OF_WEEK , callConfiguration .getTermRange ());
414
-
415
- callEndDate = new Timestamp (cal .getTime ().getTime ());
418
+ callEndDate = getCallDateEndFormat (new Timestamp (cal .getTime ().getTime ()));
416
419
417
420
} else if (callConfiguration .getConfigTerms () != null
418
421
&& callConfiguration .getConfigTerms ().equalsIgnoreCase ("months" )) {
419
422
420
423
Calendar cal = Calendar .getInstance ();
421
424
cal .setTime (motherRecord .getLmpDate ());
422
425
cal .add (Calendar .DAY_OF_WEEK , callConfiguration .getTermRange () * 30 );
423
-
424
- callEndDate = new Timestamp (cal .getTime ().getTime ());
426
+ callEndDate = getCallDateEndFormat (new Timestamp (cal .getTime ().getTime ()));
425
427
}
426
428
427
429
if (callEndDate != null )
@@ -430,16 +432,18 @@ private String createEcdCallRecordsInOutboundCalls(CallClosureDTO request,
430
432
Calendar cal = Calendar .getInstance ();
431
433
cal .setTime (callEndDate );
432
434
cal .add (Calendar .DAY_OF_WEEK , 1 );
433
- callStartDate = new Timestamp (cal .getTime ().getTime ());
435
+ callStartDate = getCallDateStartFormat ( new Timestamp (cal .getTime ().getTime () ));
434
436
435
437
} else if (childRecord != null && childRecord .getDob () != null ) {
436
438
if (callConfiguration .getBaseLine ().equalsIgnoreCase ("LMP" ))
437
439
continue ;
438
440
439
441
Timestamp callEndDate = null ;
440
442
441
- if (callStartDate == null )
443
+ if (callStartDate == null ) {
442
444
callStartDate = childRecord .getDob ();
445
+ callStartDate = getCallDateStartFormat (callStartDate );
446
+ }
443
447
outboundCalls .setCallDateFrom (callStartDate );
444
448
445
449
if (callConfiguration .getConfigTerms () != null
@@ -448,17 +452,15 @@ private String createEcdCallRecordsInOutboundCalls(CallClosureDTO request,
448
452
Calendar cal = Calendar .getInstance ();
449
453
cal .setTime (childRecord .getDob ());
450
454
cal .add (Calendar .DAY_OF_WEEK , callConfiguration .getTermRange ());
451
-
452
- callEndDate = new Timestamp (cal .getTime ().getTime ());
455
+ callEndDate = getCallDateEndFormat (new Timestamp (cal .getTime ().getTime ()));
453
456
454
457
} else if (callConfiguration .getConfigTerms () != null
455
458
&& callConfiguration .getConfigTerms ().equalsIgnoreCase ("months" )) {
456
459
457
460
Calendar cal = Calendar .getInstance ();
458
461
cal .setTime (childRecord .getDob ());
459
462
cal .add (Calendar .DAY_OF_WEEK , callConfiguration .getTermRange () * 30 );
460
-
461
- callEndDate = new Timestamp (cal .getTime ().getTime ());
463
+ callEndDate = getCallDateEndFormat (new Timestamp (cal .getTime ().getTime ()));
462
464
}
463
465
464
466
if (callEndDate != null )
@@ -467,11 +469,9 @@ private String createEcdCallRecordsInOutboundCalls(CallClosureDTO request,
467
469
Calendar cal = Calendar .getInstance ();
468
470
cal .setTime (callEndDate );
469
471
cal .add (Calendar .DAY_OF_WEEK , 1 );
470
- callStartDate = new Timestamp (cal .getTime ().getTime ());
472
+ callStartDate = getCallDateStartFormat ( new Timestamp (cal .getTime ().getTime () ));
471
473
}
472
-
473
474
outboundCalls .setPhoneNumberType (phoneNoType );
474
-
475
475
// from request
476
476
if (request .getBeneficiaryRegId () != null )
477
477
outboundCalls .setBeneficiaryRegId (request .getBeneficiaryRegId ());
@@ -501,15 +501,24 @@ private String createEcdCallRecordsInOutboundCalls(CallClosureDTO request,
501
501
outboundCallsList .add (outboundCalls );
502
502
}
503
503
outboundCallsRepo .saveAll (outboundCallsList );
504
-
505
504
}
506
-
507
505
}
508
-
509
506
return "created" ;
510
507
} catch (Exception e ) {
511
508
throw new ECDException (e );
512
509
}
513
510
}
514
511
512
+ private Timestamp getCallDateEndFormat (Timestamp callEndDate ) {
513
+ SimpleDateFormat format = new SimpleDateFormat ("yyyy-MM-dd 23:59:59" );
514
+ String time = format .format (callEndDate );
515
+ return Timestamp .valueOf (time );
516
+ }
517
+
518
+ private Timestamp getCallDateStartFormat (Timestamp callStartDate ) {
519
+ SimpleDateFormat format = new SimpleDateFormat ("yyyy-MM-dd 00:00:00" );
520
+ String time = format .format (callStartDate );
521
+ return Timestamp .valueOf (time );
522
+ }
523
+
515
524
}
0 commit comments