From d14525c71a04c715d3005d08ba3d2c705507564d Mon Sep 17 00:00:00 2001 From: Drizzentic Date: Thu, 9 Feb 2023 10:51:45 +0300 Subject: [PATCH] fix bug thrown when client submits time ahead of server (#1546) --- src/app/interfaces/program-enrollment.interface.ts | 2 +- .../hiv-referrals/hiv-referral.component.ts | 11 ++++++----- .../hiv-referrals/hiv-referral.service.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/app/interfaces/program-enrollment.interface.ts b/src/app/interfaces/program-enrollment.interface.ts index 1ff235a6b..fb5ea3322 100644 --- a/src/app/interfaces/program-enrollment.interface.ts +++ b/src/app/interfaces/program-enrollment.interface.ts @@ -18,6 +18,6 @@ export interface ProgramCompletionEnrollmentPayload { export interface ProgramEnrollmentPayload { location: string; patient: string; - dateEnrolled: Date; + dateEnrolled: any; program: string; } diff --git a/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.component.ts b/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.component.ts index d7b4bce8a..25b823e9a 100644 --- a/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.component.ts +++ b/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.component.ts @@ -22,6 +22,7 @@ import { import { Location } from './../../../../interfaces/location.interface'; import { ReferralStatus } from './../../../../interfaces/referral-status.interface'; import { Programs } from 'src/app/constants/program.constants'; +import * as moment from 'moment'; interface Provider { provider: string; @@ -32,7 +33,7 @@ interface AutoEnrollmentEncounterPayload { patient: string; encounterProviders: Provider[]; encounterType: string; - encounterDatetime: Date; + encounterDatetime: string; } @Component({ @@ -200,7 +201,7 @@ export class HivReferralComponent implements OnInit, OnChanges, OnDestroy { const enrollmentPayload: ProgramEnrollmentPayload = { location: this.referredHivProgram.locationUuid, patient: this.patient.uuid, - dateEnrolled: new Date(), + dateEnrolled: moment().subtract(1, 'minutes').format(), program: this.referredHivProgram.uuid }; let referredToStandard = false; @@ -219,7 +220,7 @@ export class HivReferralComponent implements OnInit, OnChanges, OnDestroy { return { location: this.referredHivProgram.locationUuid, patient: this.patient.uuid, - dateEnrolled: new Date(), + dateEnrolled: moment().subtract(1, 'minutes').format(), program: hivProgram.program.uuid }; } @@ -260,7 +261,7 @@ export class HivReferralComponent implements OnInit, OnChanges, OnDestroy { return { location: this.referredHivProgram.locationUuid, patient: this.patient.uuid, - dateEnrolled: Date.now().toLocaleString(), + dateEnrolled: moment().subtract(1, 'minutes').format(), program: hivProgram.program.uuid }; } @@ -301,7 +302,7 @@ export class HivReferralComponent implements OnInit, OnChanges, OnDestroy { } ], encounterType: '', - encounterDatetime: new Date() + encounterDatetime: moment().subtract(1, 'minutes').format() }; const programUuid = this.referredHivProgram.uuid; diff --git a/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.service.ts b/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.service.ts index ca0098a68..15684f514 100644 --- a/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.service.ts +++ b/src/app/patient-dashboard/common/patient-referrals/hiv-referrals/hiv-referral.service.ts @@ -28,7 +28,7 @@ interface EncounterPayload { location: string; patient: string; encounterProviders: Provider[]; - encounterDatetime: Date; + encounterDatetime: string; encounterType: string; obs?: Obs[]; }