-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathBeneficiaryModel.java
More file actions
475 lines (424 loc) · 12.5 KB
/
BeneficiaryModel.java
File metadata and controls
475 lines (424 loc) · 12.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.common.model.beneficiary;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
import org.json.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.iemr.common.model.user.TitleModel;
import com.iemr.common.model.userbeneficiary.BeneficiaryIdentityModel;
import com.iemr.common.model.userbeneficiary.GenderModel;
import com.iemr.common.model.userbeneficiary.GovtIdentityTypeModel;
import com.iemr.common.model.userbeneficiary.MaritalStatusModel;
import com.iemr.common.model.userbeneficiary.SexualOrientationModel;
import com.iemr.common.model.userbeneficiary.StatusModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BeneficiaryModel implements Comparable<BeneficiaryModel> {
private static final Integer DAYS_IN_YEAR = 365;
private static final Integer DAYS_IN_MONTH = 30;
private static final Integer HOURS_IN_DAY = 24;
private static final Integer MINUTES_IN_HOUR = 60;
private static final Integer SECONDS_IN_MINUTE = 60;
private static final Integer MILLIS_IN_SECOND = 1000;
private static final Long DAY_IN_MILLIS = HOURS_IN_DAY * MINUTES_IN_HOUR * SECONDS_IN_MINUTE
* MILLIS_IN_SECOND.longValue();
private static final Long MONTH_IN_MILLIS = DAYS_IN_MONTH * HOURS_IN_DAY * MINUTES_IN_HOUR * SECONDS_IN_MINUTE
* MILLIS_IN_SECOND.longValue();
private static final Long YEAR_IN_MILLIS = DAYS_IN_YEAR * HOURS_IN_DAY * MINUTES_IN_HOUR * SECONDS_IN_MINUTE
* MILLIS_IN_SECOND.longValue();
@Expose
private Long beneficiaryRegID;
@Expose
private BeneficiaryDemographicsModel i_bendemographics;
// private List<BenMedHistoryModel> t_benmedhistory;
@Expose
private List<BenPhoneMapModel> benPhoneMaps;
@Expose
private List<BenPhoneMapModel> parentBenPhoneMaps;
// private List<OutboundCallRequestModel> outboundCallRequests;
// private List<BeneficiaryCallModel> beneficiaryCalls;
// private List<FeedbackDetailsModel> feedbacks;
@Expose
private Boolean isConsent=false;
@Expose
private Boolean isDeath;
@Expose
private String dateOfDeath;
@Expose
private String isDeathValue;
@Expose
private String timeOfDeath;
@Expose
private String reasonOfDeath;
@Expose
private Integer reasonOfDeathId;
@Expose
private String placeOfDeath;
@Expose
private Integer placeOfDeathId;
@Expose
private String otherPlaceOfDeath;
@Expose
private Boolean isSpouseAdded;
@Expose
private Boolean isChildrenAdded;
@Expose
private Boolean isMarried;
@Expose
private boolean doYouHavechildren;
@Expose
private Integer noOfchildren;
@Expose
private Integer noofAlivechildren;
@Expose
private String beneficiaryID;
@Expose
private Short titleId;
@Expose
private String titleName;
@Expose
private TitleModel m_title;
@Expose
private String firstName;
@Expose
private String middleName;
@Expose
private String lastName;
@Expose
private Short statusID;
@Expose
private String statusName;
@Expose
private StatusModel status;
@Expose
private Integer genderID;
@Expose
private String genderName;
@Expose
private GenderModel m_gender;
@Expose
private Short maritalStatusID;
@Expose
private String maritalStatusName;
@Expose
private MaritalStatusModel maritalStatus;
@Expose
private Short sexualOrientationID;
@Expose
private String sexualOrientationName;
@Expose
private SexualOrientationModel sexualOrientation;
// @Expose
// private Timestamp dob;
@Expose
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private Timestamp dOB;
@Expose
private Integer age;
@Expose
private String fatherName;
@Expose
private String spouseName;
private SimpleDateFormat formatYear/* = new SimpleDateFormat("yyyy") */;
@Expose
private String govtIdentityNo;
@Expose
private Integer govtIdentityTypeID;
@Expose
private GovtIdentityTypeModel govtIdentityType;
@Expose
private Short registeredServiceID;
@Expose
private String sourceOfInformation;
@Expose
private String isHIVPos;
@Expose
private String placeOfWork;
@Expose
private String remarks;
@Expose
private Boolean changeInSelfDetails = false;
@Expose
private Boolean changeInAddress = false;
@Expose
private Boolean changeInContacts = false;
@Expose
private Boolean changeInIdentities = false;
@Expose
private Boolean changeInOtherDetails = false;
@Expose
private Boolean changeInFamilyDetails = false;
@Expose
private Boolean changeInAssociations = false;
@Expose
private Boolean is1097 = false;
@Expose
private Boolean deleted;
@Expose
private String createdBy;
@Expose
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private Timestamp createdDate;
@Expose
private String modifiedBy;
@Expose
private Timestamp lastModDate;
// Start Outreach
// New columns added for MMU integration 09-04-2018
@Expose
private Boolean changeInBankDetails = false;
@Expose
private List<BeneficiaryIdentityModel> beneficiaryIdentities;
@Expose
private Timestamp marriageDate;
@Expose
private Integer ageAtMarriage;
@Expose
private String literacyStatus;
@Expose
private String motherName;
@Expose
private String email;
@Expose
private String bankName;
@Expose
private String branchName;
@Expose
private String ifscCode;
@Expose
private String accountNo;
@Expose
private Long benAccountID;
@Expose
private Boolean changeInBenImage = false;
@Expose
private String benImage;
@Expose
private Long benImageId;
@Expose
private String phoneNo;
@Expose
private Integer occupationId;
@Expose
@JsonProperty("occupationOther")
private String occupationName;
@Expose
private String occupation;
@Expose
@JsonProperty("incomeName")
private String incomeStatus;
@Expose
private BigInteger religionId;
@Expose
private String religion;
@Expose
@JsonProperty("educationQualificationName")
private String education;
@Expose
private Integer providerServiceMapID;
@Expose
private Integer actualAge;
@Expose
private String ageUnits;
// End Outreach
// new column added for data sync
// 17-06-2018
@Expose
private Integer vanID;
@Expose
private Integer parkingPlaceID;
// new column added for D2D, 21-01-2021
@Expose
private Long houseHoldID;
@Expose
private String guideLineID;
@Expose
private String rchID;
@Expose
private Boolean isD2D;
// END OF new column added for data sync
// new column added for face recognitiom
@Expose
private List<Float> faceEmbedding;
// END OF new column added for face recognitiom
// ABHA address
List<AbhaAddressDTO> abhaDetails;
@Expose
private String HealthID;
@Expose
private String HealthIDNumber;
@Expose
private String familyId;
@Expose
private String identity;
@Expose
private Integer headOfFamily_RelationID;
@Expose
private String other;
@Expose
private String headOfFamily_Relation;
@Expose
private Boolean beneficiaryConsent;
@Expose
private String monthlyFamilyIncome;
@Expose
private boolean emergencyRegistration;
@Expose
private String communityName;
@Expose
private Boolean passToNurse = false;
private String otherFields;
@Expose
private String religionName;
// private Object otherFields;
public static Timestamp getTimestampData(Timestamp timestamp) {
return timestamp;
}
public static Integer setAge(Integer ageFromBenDetails, Integer ageFromBenDTO) {
if (ageFromBenDetails != null) {
return ageFromBenDetails;
} else {
return ageFromBenDTO;
}
}
public static String ageUnits(Timestamp dob) {
String beneficiaryAgeUnit = null;
Date current = new Date();
if (dob != null) {
ZoneId defaultZoneId = ZoneId.systemDefault();
Instant instant1 = dob.toInstant();
LocalDate localeDateMyDob = instant1.atZone(defaultZoneId).toLocalDate();
Instant instant2 = current.toInstant();
LocalDate localeDateCurrent = instant2.atZone(defaultZoneId).toLocalDate();
Period period = Period.between(localeDateMyDob, localeDateCurrent);
if (localeDateMyDob.equals(localeDateCurrent)) {
beneficiaryAgeUnit = "Day";
} else if (period.getYears() > 0) {
beneficiaryAgeUnit = "Year" + (period.getYears() > 1 ? "s" : "");
} else if (period.getMonths() > 0) {
beneficiaryAgeUnit = "Month" + (period.getMonths() > 1 ? "s" : "");
} else if (period.getDays() > 0) {
beneficiaryAgeUnit = "Day" + (period.getDays() > 1 ? "s" : "");
}
}
return beneficiaryAgeUnit;
}
// public static Long actualAge(Timestamp dob) {
// Long beneficiaryAge = null;
// Date current = new Date();
// if (dob != null) {
//
// ZoneId defaultZoneId = ZoneId.systemDefault();
// Instant instant1 = dob.toInstant();
// LocalDate localeDateMyDob = instant1.atZone(defaultZoneId).toLocalDate();
// Instant instant2 = current.toInstant();
// LocalDate localeDateCurrent = instant2.atZone(defaultZoneId).toLocalDate();
//
// Period period = Period.between(localeDateMyDob, localeDateCurrent);
// if (localeDateMyDob.equals(localeDateCurrent)) {
// beneficiaryAge = 1L;
// } else if (period.getYears() > 0) {
// beneficiaryAge = (long) period.getYears();
// } else if (period.getMonths() > 0) {
// beneficiaryAge = (long) period.getMonths();
// } else if (period.getDays() > 0) {
// beneficiaryAge = (long) period.getDays();
// }
//
// }
// return beneficiaryAge;
// }
public static Integer actualAge(Timestamp dob) {
Integer beneficiaryAge = null;
Date current = new Date();
if (dob != null) {
ZoneId defaultZoneId = ZoneId.systemDefault();
Instant instant1 = dob.toInstant();
LocalDate localeDateMyDob = instant1.atZone(defaultZoneId).toLocalDate();
Instant instant2 = current.toInstant();
LocalDate localeDateCurrent = instant2.atZone(defaultZoneId).toLocalDate();
Period period = Period.between(localeDateMyDob, localeDateCurrent);
if (localeDateMyDob.equals(localeDateCurrent)) {
beneficiaryAge = 1;
} else if (period.getYears() > 0) {
beneficiaryAge = period.getYears();
} else if (period.getMonths() > 0) {
beneficiaryAge = period.getMonths();
} else if (period.getDays() > 0) {
beneficiaryAge = period.getDays();
}
}
return beneficiaryAge;
}
//Age Calculation-Old
// public static String ageUnits(Timestamp dOB) {
// String ageUnits = null;
// if (dOB != null) {
// Calendar cal = Calendar.getInstance();
// Long ageInMillis = cal.getTime().getTime() - dOB.getTime();
// if (ageInMillis > YEAR_IN_MILLIS) {
// ageUnits = "year" + ((ageInMillis / YEAR_IN_MILLIS) > 1 ? "s" : "");
// } else if (ageInMillis > MONTH_IN_MILLIS) {
// ageUnits = "month" + ((ageInMillis / MONTH_IN_MILLIS) > 1 ? "s" : "");
// } else if (ageInMillis > DAY_IN_MILLIS) {
// ageUnits = "day" + ((ageInMillis / DAY_IN_MILLIS) > 1 ? "s" : "");
// }
// }
// return ageUnits;
// }
//
// public static Long actualAge(Timestamp dOB) {
// Long actualAge = null;
// if (dOB != null) {
// Calendar cal = Calendar.getInstance();
// Long ageInMillis = cal.getTime().getTime() - dOB.getTime();
// if (ageInMillis > YEAR_IN_MILLIS) {
// actualAge = ageInMillis / YEAR_IN_MILLIS;
// } else if (ageInMillis > MONTH_IN_MILLIS) {
// actualAge = ageInMillis / MONTH_IN_MILLIS;
// } else if (ageInMillis > DAY_IN_MILLIS) {
// actualAge = ageInMillis / DAY_IN_MILLIS;
// }
// }
// return actualAge;
// }
@Override
public int compareTo(BeneficiaryModel ben) {
return this.beneficiaryRegID.compareTo(ben.beneficiaryRegID);
}
}