Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/app/app-modules/nurse-doctor/anc/anc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,46 @@ export class AncComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
visitCode: this.sessionstorage.getItem('visitCode'),
};

const immunizationForm = patientANCForm.get('patientANCImmunizationForm');

if (immunizationForm) {
const ttDateFields = [
'dateReceivedForTT_1',
'dateReceivedForTT_2',
'dateReceivedForTT_3',
];

ttDateFields.forEach((field) => {
const value = immunizationForm.get(field)?.value;

if (value) {
immunizationForm.patchValue({
[field]: this.normalizeToUTCMidnight(new Date(value)),
});
}
});
}

const ancDetailsForm = patientANCForm.get('patientANCDetailsForm');

if (ancDetailsForm) {
const lmpDateValue = ancDetailsForm.get('lmpDate')?.value;

if (lmpDateValue) {
ancDetailsForm.patchValue({
lmpDate: this.normalizeToUTCMidnight(new Date(lmpDateValue)),
});
}

const expDelDtValue = ancDetailsForm.get('expDelDt')?.value;

if (expDelDtValue) {
ancDetailsForm.patchValue({
expDelDt: this.normalizeToUTCMidnight(new Date(expDelDtValue)),
});
}
}

this.updateANCDetailsSubs = this.doctorService
.updateANCDetails(patientANCForm, temp)
.subscribe(
Expand All @@ -152,6 +192,16 @@ export class AncComponent implements OnInit, OnChanges, OnDestroy, DoCheck {
);
}

private normalizeToUTCMidnight(date: Date | null | undefined): string | null {
if (!date) return null;

const d = new Date(date);
const utcDate = new Date(
Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0)
);
return utcDate.toISOString();
}

getHRPDetails() {
const beneficiaryRegID = this.sessionstorage.getItem('beneficiaryRegID');
const visitCode = this.sessionstorage.getItem('visitCode');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ export class GeneralPersonalHistoryComponent
history.data.PersonalHistory
) {
this.personalHistoryData = history.data.PersonalHistory;
if (
this.personalHistoryData &&
this.personalHistoryData.riskySexualPracticesStatus !== null
) {
this.personalHistoryData.riskySexualPracticesStatus =
this.personalHistoryData.riskySexualPracticesStatus == '1'
? true
: false;
}
this.generalPersonalHistoryForm.patchValue(this.personalHistoryData);
this.handlePersonalTobaccoHistoryData();
this.handlePersonalAlcoholHistoryData();
Expand Down Expand Up @@ -420,44 +429,63 @@ export class GeneralPersonalHistoryComponent
const formArray = this.generalPersonalHistoryForm.controls[
'allergicList'
] as FormArray;

if (this.personalHistoryData && this.personalHistoryData.allergicList) {
const temp = this.personalHistoryData.allergicList.slice();

while (formArray.length > 0) {
formArray.removeAt(0);
}

for (let i = 0; i < temp.length; i++) {
formArray.push(this.initAllergyList());
}

this.allerySelectList = [];
this.previousSelectedAlleryList = [];

for (let i = 0; i < temp.length; i++) {
const allergyType = this.allergyMasterData.filter((item) => {
return item.allergyType === temp[i].allergyType;
});

if (allergyType.length > 0) temp[i].allergyType = allergyType[0];

if (this.masterData.AllergicReactionTypes !== undefined) {
temp[i].typeOfAllergicReactions =
this.masterData.AllergicReactionTypes.filter((item: any) => {
let flag = false;
temp[i].typeOfAllergicReactions.forEach((element: any) => {
if (element.name === item.name) flag = true;
});
return flag;
temp[i].typeOfAllergicReactions =
this.masterData.AllergicReactionTypes.filter((item: any) => {
let flag = false;
temp[i].typeOfAllergicReactions.forEach((element: any) => {
if (element.name === item.name) flag = true;
});
}
return flag;
});

if (temp[i].otherAllergicReaction) temp[i].enableOtherAllergy = true;

const selectedAllergies = temp
.filter((t: any, idx: any) => idx !== i && t.allergyType)
.map((t: any) => t.allergyType.allergyType);

const availableAllergies = this.allergyMasterData.filter(
(item) => !selectedAllergies.includes(item.allergyType),
);

this.allerySelectList.push(availableAllergies.slice());

if (temp[i].allergyType) {
const k: any = formArray.get('' + i);
this.previousSelectedAlleryList[i] = temp[i].allergyType;
}

const k: any = formArray.get('' + i);
if (k) {
k.patchValue(temp[i]);
k.markAsTouched();
k.markAsDirty();
this.filterAlleryList(temp[i].allergyType, i);
if (
k?.get('snomedTerm')?.value !== null &&
k?.get('typeOfAllergicReactions')?.value !== null
) {
k?.get('snomedTerm')?.enable();
k?.get('typeOfAllergicReactions')?.enable();

if (temp[i].allergyType) {
k.get('snomedTerm')?.enable();
k.get('typeOfAllergicReactions')?.enable();
}
}

if (i + 1 < temp.length) this.addAllergy();
}
}
}
Expand Down
22 changes: 21 additions & 1 deletion src/app/app-modules/nurse-doctor/pnc/pnc.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,25 @@ export class PncComponent implements OnInit, DoCheck, OnChanges, OnDestroy {
})[0];
}

tempPNCData.dDate = new Date(tempPNCData.dateOfDelivery);
tempPNCData.dDate = this.normalizeToUTCMidnight(
new Date(tempPNCData.dateOfDelivery),
);

const patchPNCdata = Object.assign({}, tempPNCData);
this.patientPNCForm.patchValue(tempPNCData);
});
}

private normalizeToUTCMidnight(date: Date | null | undefined): string | null {
if (!date) return null;

const d = new Date(date);
const utcDate = new Date(
Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0)
);
return utcDate.toISOString();
}

updatePatientPNC(patientPNCForm: any) {
const temp = {
beneficiaryRegID: this.sessionstorage.getItem('beneficiaryRegID'),
Expand All @@ -174,6 +186,14 @@ export class PncComponent implements OnInit, DoCheck, OnChanges, OnDestroy {
visitCode: this.sessionstorage.getItem('visitCode'),
};

const dDate = patientPNCForm.get('dDate')?.value;
if (dDate) {
patientPNCForm.patchValue({
dateOfDelivery: this.normalizeToUTCMidnight(new Date(dDate)),
dDate: this.normalizeToUTCMidnight(new Date(dDate)),
});
}

this.doctorService.updatePNCDetails(patientPNCForm, temp).subscribe(
(res: any) => {
if (res.statusCode === 200 && res.data !== null) {
Expand Down
58 changes: 48 additions & 10 deletions src/app/app-modules/nurse-doctor/shared/services/nurse.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,17 @@ export class NurseService {
};
}

private normalizeToUTCMidnight(date: Date | null | undefined): string | null {
if (!date) return null;

const d = new Date(date);

const utcDate = new Date(
Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0)
);
return utcDate.toISOString();
}

postANCDetailForm(patientANCForm: any, benVisitID: any) {
const detailedANC = JSON.parse(
JSON.stringify(patientANCForm.controls.patientANCDetailsForm.value),
Expand All @@ -702,11 +713,15 @@ export class NurseService {
JSON.stringify(patientANCForm.controls.obstetricFormulaForm.value),
);
if (detailedANC.lmpDate) {
const lmpDate = new Date(detailedANC.lmpDate);
const adjustedDate = new Date(
lmpDate.getTime() - lmpDate.getTimezoneOffset() * 60000,
detailedANC.lmpDate = this.normalizeToUTCMidnight(
new Date(detailedANC.lmpDate)
);
}

if (detailedANC.expDelDt) {
detailedANC.expDelDt = this.normalizeToUTCMidnight(
new Date(detailedANC.expDelDt)
);
detailedANC.lmpDate = adjustedDate.toISOString();
}

const combinedANCForm = Object.assign({}, detailedANC, {
Expand All @@ -726,7 +741,29 @@ export class NurseService {
}

postANCImmunizationForm(patientANCImmunizationForm: any, benVisitID: any) {
const immunizationForm = Object.assign({}, patientANCImmunizationForm, {
const immunizationFormValue = JSON.parse(
JSON.stringify(patientANCImmunizationForm)
);

if (immunizationFormValue.dateReceivedForTT_1) {
immunizationFormValue.dateReceivedForTT_1 = this.normalizeToUTCMidnight(
new Date(immunizationFormValue.dateReceivedForTT_1)
);
}

if (immunizationFormValue.dateReceivedForTT_2) {
immunizationFormValue.dateReceivedForTT_2 = this.normalizeToUTCMidnight(
new Date(immunizationFormValue.dateReceivedForTT_2)
);
}

if (immunizationFormValue.dateReceivedForTT_3) {
immunizationFormValue.dateReceivedForTT_3 = this.normalizeToUTCMidnight(
new Date(immunizationFormValue.dateReceivedForTT_3)
);
}

const immunizationForm = Object.assign({}, immunizationFormValue, {
beneficiaryRegID: this.sessionstorage.getItem('beneficiaryRegID'),
benVisitID: benVisitID,
providerServiceMapID: this.sessionstorage.getItem('providerServiceID'),
Expand Down Expand Up @@ -1264,11 +1301,7 @@ export class NurseService {
if (!temp.lMPDate) {
temp.lMPDate = undefined;
} else {
const lmpDate = new Date(temp.lMPDate);
const adjustedDate = new Date(
lmpDate.getTime() - lmpDate.getTimezoneOffset() * 60000,
);
temp.lMPDate = adjustedDate.toISOString();
temp.lMPDate = this.normalizeToUTCMidnight(new Date(temp.lMPDate));
}

const menstrualHistoryData = Object.assign({}, temp, otherDetails);
Expand Down Expand Up @@ -1894,6 +1927,11 @@ export class NurseService {
temp.newBornHealthStatus = temp.newBornHealthStatus.newBornHealthStatus;
}

if (temp.dDate) {
temp.dateOfDelivery = this.normalizeToUTCMidnight(new Date(temp.dDate));
temp.dDate = temp.dateOfDelivery;
}

const patientPNCDetails = Object.assign({}, temp, {
beneficiaryRegID: this.sessionstorage.getItem('beneficiaryRegID'),
benVisitID: benVisitID,
Expand Down