Skip to content

Commit

Permalink
date format issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ancy Riju authored and Ancy Riju committed Jul 9, 2024
1 parent 8d475f1 commit a7fa360
Show file tree
Hide file tree
Showing 23 changed files with 344 additions and 29 deletions.
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@angular/core": "^16.2.0",
"@angular/forms": "^16.2.0",
"@angular/material": "^16.2.12",
"@angular/material-moment-adapter": "^18.0.6",
"@angular/platform-browser": "^16.2.12",
"@angular/platform-browser-dynamic": "^16.2.0",
"@angular/router": "^16.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
ng-readonly="true"
(dateChange)="checkupLMP(lmpDate)"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="lmpPicker"
Expand Down Expand Up @@ -77,7 +76,6 @@
required
disbaled
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="eddPicker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,45 @@ import { ConfirmationService } from '../../../core/services/confirmation.service
import { SetLanguageComponent } from 'src/app/app-modules/core/components/set-language.component';
import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service';
import { NurseService } from '../../shared/services';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
} from '@angular/material/core';
import {
MomentDateAdapter,
MAT_MOMENT_DATE_ADAPTER_OPTIONS,
} from '@angular/material-moment-adapter';

@Component({
selector: 'app-nurse-anc-details',
templateUrl: './anc-details.component.html',
styleUrls: ['./anc-details.component.css'],
providers: [
{
provide: MAT_DATE_LOCALE,
useValue: 'en-US', // Set the desired locale (e.g., 'en-GB' for dd/MM/yyyy)
},
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS],
},
{
provide: MAT_DATE_FORMATS,
useValue: {
parse: {
dateInput: 'LL',
},
display: {
dateInput: 'DD/MM/YYYY', // Set the desired display format
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
},
},
],
})
export class AncDetailsComponent implements OnInit, DoCheck, OnDestroy {
@Input()
Expand Down Expand Up @@ -85,14 +119,18 @@ export class AncDetailsComponent implements OnInit, DoCheck, OnDestroy {
const today = new Date();
const checkdate = new Date();

checkdate.setMonth(today.getMonth() - 10);
checkdate.setMonth(today.getMonth() - 9);

if (lmpDate > checkdate && lmpDate < today) {
this.patientANCDetailsForm.patchValue({ duration: null });
this.calculateEDD(lmpDate);
this.calculateGestationalAge(lmpDate);
this.calculatePeriodOfPregnancy(lmpDate);
this.nurseService.setLMPForFetosenseTest(lmpDate);
const lmpDateJS = lmpDate.toDate();

if (lmpDateJS > checkdate && lmpDateJS < today) {
this.patientANCDetailsForm.patchValue({
lmpDate: lmpDateJS,
duration: null,
});
this.calculateEDD(lmpDateJS);
this.calculateGestationalAge(lmpDateJS);
this.calculatePeriodOfPregnancy(lmpDateJS);
} else {
lmpDate = null;
this.patientANCDetailsForm.patchValue({ lmpDate: lmpDate });
Expand All @@ -102,17 +140,16 @@ export class AncDetailsComponent implements OnInit, DoCheck, OnDestroy {
this.calculateEDD(lmpDate);
this.calculateGestationalAge(lmpDate);
this.calculatePeriodOfPregnancy(lmpDate);
this.nurseService.clearLMPForFetosenseTest();
}
}

calculatePeriodOfPregnancy(lmpDate: any) {
this.patientANCDetailsForm.patchValue({ duration: null });
}

calculateGestationalAge(lastMP: any) {
calculateGestationalAge(lastMP: Date) {
let gestationalAge: any;
if (lastMP !== null) {
if (lastMP instanceof Date) {
const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
gestationalAge = Math.round(
Math.abs(
Expand All @@ -134,8 +171,8 @@ export class AncDetailsComponent implements OnInit, DoCheck, OnDestroy {
}
}

calculateEDD(lastMP: any) {
if (lastMP !== null) {
calculateEDD(lastMP: Date) {
if (lastMP instanceof Date) {
const edd = new Date(lastMP);
edd.setDate(lastMP.getDate() + 280);
this.patientANCDetailsForm.patchValue({ expDelDt: edd });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
[matDatepicker]="dateReceivedForTT_1Picker"
(dateChange)="checkTT_1Date(dateReceivedForTT_1)"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="dateReceivedForTT_1Picker"
Expand Down Expand Up @@ -130,7 +129,6 @@
[matDatepicker]="dateReceivedForTT_2Picker"
(dateChange)="checkTT_2Date(dateReceivedForTT_2)"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="dateReceivedForTT_2Picker"
Expand Down Expand Up @@ -224,7 +222,6 @@
[max]="today"
[matDatepicker]="dateReceivedForTT_3Picker"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="dateReceivedForTT_3Picker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,45 @@ import { FormGroup } from '@angular/forms';
import { BeneficiaryDetailsService } from '../../../core/services/beneficiary-details.service';
import { SetLanguageComponent } from 'src/app/app-modules/core/components/set-language.component';
import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
} from '@angular/material/core';
import {
MomentDateAdapter,
MAT_MOMENT_DATE_ADAPTER_OPTIONS,
} from '@angular/material-moment-adapter';

@Component({
selector: 'app-nurse-anc-immunization',
templateUrl: './anc-immunization.component.html',
styleUrls: ['./anc-immunization.component.css'],
providers: [
{
provide: MAT_DATE_LOCALE,
useValue: 'en-US', // Set the desired locale (e.g., 'en-GB' for dd/MM/yyyy)
},
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS],
},
{
provide: MAT_DATE_FORMATS,
useValue: {
parse: {
dateInput: 'LL',
},
display: {
dateInput: 'DD/MM/YYYY', // Set the desired display format
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
},
},
],
})
export class AncImmunizationComponent
implements OnInit, OnChanges, OnDestroy, DoCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ <h4>
formControlName="dateOfDeath"
[min]="minimumDeathDate"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="picker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,45 @@ import { MasterdataService, DoctorService } from '../../../../shared/services';
import { SetLanguageComponent } from 'src/app/app-modules/core/components/set-language.component';
import { BeneficiaryDetailsService } from 'src/app/app-modules/core/services';
import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
} from '@angular/material/core';
import {
MomentDateAdapter,
MAT_MOMENT_DATE_ADAPTER_OPTIONS,
} from '@angular/material-moment-adapter';

@Component({
selector: 'app-anc-diagnosis',
templateUrl: './anc-diagnosis.component.html',
styleUrls: ['./anc-diagnosis.component.css'],
providers: [
{
provide: MAT_DATE_LOCALE,
useValue: 'en-US', // Set the desired locale (e.g., 'en-GB' for dd/MM/yyyy)
},
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS],
},
{
provide: MAT_DATE_FORMATS,
useValue: {
parse: {
dateInput: 'LL',
},
display: {
dateInput: 'DD/MM/YYYY', // Set the desired display format
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
},
},
],
})
export class AncDiagnosisComponent implements OnInit, DoCheck, OnDestroy {
masterData: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ <h4>
formControlName="dateOfDeath"
[min]="minimumDeathDate"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="picker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,45 @@ import { GeneralUtils } from '../../../../shared/utility';
import { ConfirmationService } from './../../../../../core/services/confirmation.service';
import { HttpServiceService } from 'src/app/app-modules/core/services/http-service.service';
import { SetLanguageComponent } from 'src/app/app-modules/core/components/set-language.component';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
} from '@angular/material/core';
import {
MomentDateAdapter,
MAT_MOMENT_DATE_ADAPTER_OPTIONS,
} from '@angular/material-moment-adapter';

@Component({
selector: 'app-pnc-diagnosis',
templateUrl: './pnc-diagnosis.component.html',
styleUrls: ['./pnc-diagnosis.component.css'],
providers: [
{
provide: MAT_DATE_LOCALE,
useValue: 'en-US', // Set the desired locale (e.g., 'en-GB' for dd/MM/yyyy)
},
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS],
},
{
provide: MAT_DATE_FORMATS,
useValue: {
parse: {
dateInput: 'LL',
},
display: {
dateInput: 'DD/MM/YYYY', // Set the desired display format
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
},
},
],
})
export class PncDiagnosisComponent
implements OnInit, OnChanges, OnDestroy, DoCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
[matDatepicker]="lmpPicker"
[disabled]="visitType === 'ANC'"
/>
<mat-hint>MM/DD/YYYY</mat-hint>
<mat-datepicker-toggle
matSuffix
[for]="lmpPicker"
Expand Down
Loading

0 comments on commit a7fa360

Please sign in to comment.