-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathCommonServiceImpl.java
More file actions
621 lines (506 loc) · 23.7 KB
/
CommonServiceImpl.java
File metadata and controls
621 lines (506 loc) · 23.7 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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
/*
* 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.tm.service.common.transaction;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.iemr.tm.data.benFlowStatus.BeneficiaryFlowStatus;
import com.iemr.tm.data.nurse.CommonUtilityClass;
import com.iemr.tm.data.tele_consultation.TCRequestModel;
import com.iemr.tm.data.tele_consultation.TcSpecialistSlotBookingRequestOBJ;
import com.iemr.tm.data.tele_consultation.TeleconsultationRequestOBJ;
import com.iemr.tm.repo.benFlowStatus.BeneficiaryFlowStatusRepo;
import com.iemr.tm.repo.nurse.BenVisitDetailRepo;
import com.iemr.tm.repo.provider.ProviderServiceMappingRepo;
import com.iemr.tm.service.anc.ANCServiceImpl;
import com.iemr.tm.service.anc.Utility;
import com.iemr.tm.service.cancerScreening.CSNurseServiceImpl;
import com.iemr.tm.service.cancerScreening.CSServiceImpl;
import com.iemr.tm.service.covid19.Covid19ServiceImpl;
import com.iemr.tm.service.generalOPD.GeneralOPDServiceImpl;
import com.iemr.tm.service.ncdCare.NCDCareServiceImpl;
import com.iemr.tm.service.ncdscreening.NCDScreeningServiceImpl;
import com.iemr.tm.service.pnc.PNCServiceImpl;
import com.iemr.tm.service.quickConsultation.QuickConsultationServiceImpl;
import com.iemr.tm.service.tele_consultation.TeleConsultationServiceImpl;
import com.iemr.tm.utils.CookieUtil;
import com.iemr.tm.utils.RestTemplateUtil;
import com.iemr.tm.utils.exception.IEMRException;
import com.iemr.tm.utils.mapper.InputMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jakarta.servlet.http.HttpServletRequest;
@Service
@PropertySource("classpath:application.properties")
public class CommonServiceImpl implements CommonService {
private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
@Value("${openkmDocUrl}")
private String openkmDocUrl;
@Autowired
private Covid19ServiceImpl covid19ServiceImpl;
private BeneficiaryFlowStatusRepo beneficiaryFlowStatusRepo;
private ANCServiceImpl ancServiceImpl;
private PNCServiceImpl pncServiceImpl;
private GeneralOPDServiceImpl generalOPDServiceImpl;
private NCDCareServiceImpl ncdCareServiceImpl;
private QuickConsultationServiceImpl quickConsultationServiceImpl;
private CommonNurseServiceImpl commonNurseServiceImpl;
private CSNurseServiceImpl cSNurseServiceImpl;
private CSServiceImpl csServiceImpl;
private NCDScreeningServiceImpl ncdScreeningServiceImpl;
@Autowired
private CommonDoctorServiceImpl commonDoctorServiceImpl;
@Autowired
private TeleConsultationServiceImpl teleConsultationServiceImpl;
@Autowired
private ProviderServiceMappingRepo providerServiceMappingRepo;
@Autowired
private BenVisitDetailRepo benVisitDetailRepo;
@Autowired
private CookieUtil cookieUtil;
@Autowired
public void setCsServiceImpl(CSServiceImpl csServiceImpl) {
this.csServiceImpl = csServiceImpl;
}
@Autowired
public void setcSNurseServiceImpl(CSNurseServiceImpl cSNurseServiceImpl) {
this.cSNurseServiceImpl = cSNurseServiceImpl;
}
@Autowired
public void setCommonNurseServiceImpl(CommonNurseServiceImpl commonNurseServiceImpl) {
this.commonNurseServiceImpl = commonNurseServiceImpl;
}
@Autowired
public void setQuickConsultationServiceImpl(QuickConsultationServiceImpl quickConsultationServiceImpl) {
this.quickConsultationServiceImpl = quickConsultationServiceImpl;
}
@Autowired
public void setNcdCareServiceImpl(NCDCareServiceImpl ncdCareServiceImpl) {
this.ncdCareServiceImpl = ncdCareServiceImpl;
}
@Autowired
public void setGeneralOPDServiceImpl(GeneralOPDServiceImpl generalOPDServiceImpl) {
this.generalOPDServiceImpl = generalOPDServiceImpl;
}
@Autowired
public void setPncServiceImpl(PNCServiceImpl pncServiceImpl) {
this.pncServiceImpl = pncServiceImpl;
}
@Autowired
public void setAncServiceImpl(ANCServiceImpl ancServiceImpl) {
this.ancServiceImpl = ancServiceImpl;
}
@Autowired
public void setBeneficiaryFlowStatusRepo(BeneficiaryFlowStatusRepo beneficiaryFlowStatusRepo) {
this.beneficiaryFlowStatusRepo = beneficiaryFlowStatusRepo;
}
@Autowired
public void setNcdScreeningServiceImpl(NCDScreeningServiceImpl ncdScreeningServiceImpl) {
this.ncdScreeningServiceImpl = ncdScreeningServiceImpl;
}
public String getCaseSheetPrintDataForBeneficiary(BeneficiaryFlowStatus benFlowOBJ, String Authorization)
throws JsonProcessingException, ParseException {
String visitCategory = benFlowOBJ.getVisitCategory();
String caseSheetData = null;
if (null != visitCategory && visitCategory.length() > 0) {
switch (visitCategory) {
case "ANC": {
caseSheetData = getANC_PrintData(benFlowOBJ);
}
break;
case "PNC": {
caseSheetData = getPNC_PrintData(benFlowOBJ);
}
break;
case "General OPD": {
caseSheetData = getGenOPD_PrintData(benFlowOBJ);
}
break;
case "NCD care": {
caseSheetData = getNCDcare_PrintData(benFlowOBJ);
}
break;
case "General OPD (QC)": {
caseSheetData = getQC_PrintData(benFlowOBJ);
}
break;
case "Cancer Screening": {
caseSheetData = getCancerScreening_PrintData(benFlowOBJ);
}
break;
case "COVID-19 Screening": {
caseSheetData = getCovid19_PrintData(benFlowOBJ);
}
break;
case "NCD screening": {
caseSheetData = getNCDScreening_PrintData(benFlowOBJ);
}
break;
default: {
caseSheetData = "Invalid VisitCategory";
}
}
}
return caseSheetData;
}
private String getANC_PrintData(BeneficiaryFlowStatus benFlowOBJ) throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData",
ancServiceImpl.getBenANCNurseData(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", ancServiceImpl.getBenCaseRecordFromDoctorANC(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getCancerScreening_PrintData(BeneficiaryFlowStatus benFlowOBJ) {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData", csServiceImpl.getBenNurseDataForCaseSheet(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", csServiceImpl.getBenCaseRecordFromDoctorCS(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("ImageAnnotatedData",
new Gson().toJson(cSNurseServiceImpl.getCancerExaminationImageAnnotationCasesheet(
benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode())));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getGenOPD_PrintData(BeneficiaryFlowStatus benFlowOBJ)
throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData", generalOPDServiceImpl.getBenGeneralOPDNurseData(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", generalOPDServiceImpl
.getBenCaseRecordFromDoctorGeneralOPD(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getNCDcare_PrintData(BeneficiaryFlowStatus benFlowOBJ)
throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData", ncdCareServiceImpl.getBenNCDCareNurseData(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", ncdCareServiceImpl
.getBenCaseRecordFromDoctorNCDCare(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getPNC_PrintData(BeneficiaryFlowStatus benFlowOBJ) throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData",
pncServiceImpl.getBenPNCNurseData(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", pncServiceImpl.getBenCaseRecordFromDoctorPNC(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getQC_PrintData(BeneficiaryFlowStatus benFlowOBJ) throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData", quickConsultationServiceImpl
.getBenQuickConsultNurseData(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", quickConsultationServiceImpl.getBenCaseRecordFromDoctorQuickConsult(
benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getCovid19_PrintData(BeneficiaryFlowStatus benFlowOBJ)
throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData", covid19ServiceImpl.getBenCovidNurseData(benFlowOBJ.getBeneficiaryRegID(),
benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", covid19ServiceImpl
.getBenCaseRecordFromDoctorCovid19(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getNCDScreening_PrintData(BeneficiaryFlowStatus benFlowOBJ)
throws JsonProcessingException, ParseException {
Map<String, Object> caseSheetData = new HashMap<>();
caseSheetData.put("nurseData", ncdScreeningServiceImpl
.getBenNCDScreeningNurseData(benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("doctorData", ncdScreeningServiceImpl.getBenCaseRecordFromDoctorNCDScreening(
benFlowOBJ.getBeneficiaryRegID(), benFlowOBJ.getBenVisitCode()));
caseSheetData.put("BeneficiaryData",
getBenDetails(benFlowOBJ.getBenFlowID(), benFlowOBJ.getBeneficiaryRegID()));
caseSheetData.put("serviceID", 4);
return caseSheetData.toString();
}
private String getBenDetails(Long benFlowID, Long benRegID) {
ArrayList<Object[]> tmpOBJ = beneficiaryFlowStatusRepo.getBenDetailsForLeftSidePanel(benRegID, benFlowID);
BeneficiaryFlowStatus obj = BeneficiaryFlowStatus.getBeneficiaryFlowStatusForLeftPanel(tmpOBJ);
Integer tcspID = beneficiaryFlowStatusRepo.getTCspecialistID(benRegID, benFlowID);
if (tcspID != null && tcspID > 0) {
obj.settCSpecialistUserID(tcspID);
}
return new Gson().toJson(obj);
}
// ------- Fetch beneficiary all past history data ------------------
public String getBenPastHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPastMedicalHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all past history data ----------
// ------- Fetch beneficiary all Comorbid conditions history data
// ------------------
public String getComorbidHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenComorbidityHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Comorbid conditions history data
/// --------
// ------- Fetch beneficiary all Medication history data -----------
public String getMedicationHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPersonalMedicationHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Medication history data --
// ------- Fetch beneficiary all Personal Tobacco history data
// ---------------
public String getPersonalTobaccoHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPersonalTobaccoHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Personal Tobacco history data------
// ------- Fetch beneficiary all Personal Alcohol history data
// ---------------
public String getPersonalAlcoholHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPersonalAlcoholHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Personal Alcohol history data
/// ------
// ------- Fetch beneficiary all Personal Allergy history data
// ---------------
public String getPersonalAllergyHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPersonalAllergyHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Personal Allergy history data------
// ------- Fetch beneficiary all Family history data ---------------
public String getFamilyHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPersonalFamilyHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Family history data ------
public String getProviderSpecificData(String request) throws IEMRException {
return commonNurseServiceImpl.fetchProviderSpecificdata(request);
}
// ------- Fetch beneficiary all Physical history data ---------------
public String getBenPhysicalHistory(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPhysicalHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Physical history data ------
// ------- Fetch beneficiary all Menstrual history data -----------
public String getMenstrualHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenMenstrualHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Menstrual history data --
// ------- Fetch beneficiary all past obstetric history data ---------------
public String getObstetricHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPastObstetricHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all past obstetric history data ------
// ------- Fetch beneficiary all Immunization history data ---------------
public String getImmunizationHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenImmunizationHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Immunization history data ------
// ------- Fetch beneficiary all Child Vaccine history data ---------------
public String getChildVaccineHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenOptionalVaccineHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Child Vaccine history data ------
// ------- Fetch beneficiary all Perinatal history data ---------------
public String getBenPerinatalHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenPerinatalHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Perinatal history data ------
// ------- Fetch beneficiary all Feeding history data ---------------
public String getBenFeedingHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenFeedingHistory(beneficiaryRegID);
}
/// ------- End of Fetch beneficiary all Feeding history data ------
// ------- Fetch beneficiary all Development history data ---------------
public String getBenDevelopmentHistoryData(Long beneficiaryRegID) {
return commonNurseServiceImpl.fetchBenDevelopmentHistory(beneficiaryRegID);
}
// -- Fetch beneficiary previous visit details for case-record ---
/**
* date : 08-09-2018
*
* @throws IEMRException
*/
public String getBenPreviousVisitDataForCaseRecord(String comingRequest) throws IEMRException {
CommonUtilityClass obj = InputMapper.gson().fromJson(comingRequest, CommonUtilityClass.class);
// List<Short> flagList = new ArrayList<>();
// flagList.add((short) 9);
// flagList.add((short) 3);
List<Integer> psmIDList = providerServiceMappingRepo.getProviderServiceMapIdForServiceID((short) 4);
psmIDList.add(0);
ArrayList<Object[]> resultList = beneficiaryFlowStatusRepo.getBenPreviousHistory(obj.getBeneficiaryRegID(),
psmIDList);
return new Gson().toJson(BeneficiaryFlowStatus.getBeneficiaryPastVisitHistory(resultList));
}
// end of Fetch beneficiary previous visit details for case-record
/***
*
* @param requestOBJ
* @param commonUtilityClass
* @param Authorization
* @return
* @throws Exception
* @date 05-02-2019
*/
// create Teleconsultation request. Common for all module
public TeleconsultationRequestOBJ createTcRequest(JsonObject requestOBJ, CommonUtilityClass commonUtilityClass,
String Authorization) throws Exception {
TeleconsultationRequestOBJ tcRequestOBJ = null;
Long tcRequestStatusFlag = null;
TcSpecialistSlotBookingRequestOBJ tcSpecialistSlotBookingRequestOBJ = null;
//
// if (commonUtilityClass != null && commonUtilityClass.getServiceID() != null
// && commonUtilityClass.getServiceID() == 4 && requestOBJ != null &&
// requestOBJ.has("tcRequest")
// && requestOBJ.get("tcRequest") != null) {
if (commonUtilityClass != null && requestOBJ != null && requestOBJ.has("tcRequest")
&& requestOBJ.get("tcRequest") != null) {
tcRequestOBJ = InputMapper.gson().fromJson(requestOBJ.get("tcRequest"), TeleconsultationRequestOBJ.class);
// create TC request
if (tcRequestOBJ != null && tcRequestOBJ.getUserID() != null && tcRequestOBJ.getUserID() > 0
&& tcRequestOBJ.getAllocationDate() != null) {
tcRequestOBJ.setAllocationDate(Utility.combineDateAndTimeToDateTime(
tcRequestOBJ.getAllocationDate().toString(), tcRequestOBJ.getFromTime()));
// tc request model
TCRequestModel tRequestModel = InputMapper.gson().fromJson(requestOBJ, TCRequestModel.class);
tRequestModel.setBeneficiaryRegID(commonUtilityClass.getBeneficiaryRegID());
tRequestModel.setProviderServiceMapID(commonUtilityClass.getProviderServiceMapID());
tRequestModel.setVisitCode(commonUtilityClass.getVisitCode());
if (commonUtilityClass.getBenVisitID() != null)
tRequestModel.setBenVisitID(commonUtilityClass.getBenVisitID());
tRequestModel.setUserID(tcRequestOBJ.getUserID());
tRequestModel.setSpecializationID(tcRequestOBJ.getSpecializationID());
tRequestModel.setRequestDate(tcRequestOBJ.getAllocationDate());
tRequestModel
.setDuration_minute(Utility.timeDiff(tcRequestOBJ.getFromTime(), tcRequestOBJ.getToTime()));
tRequestModel.setVanID(commonUtilityClass.getVanID());
// tc speciaist slot booking model
tcSpecialistSlotBookingRequestOBJ = new TcSpecialistSlotBookingRequestOBJ();
tcSpecialistSlotBookingRequestOBJ.setUserID(tRequestModel.getUserID());
tcSpecialistSlotBookingRequestOBJ.setDate(tRequestModel.getRequestDate());
tcSpecialistSlotBookingRequestOBJ.setFromTime(tcRequestOBJ.getFromTime());
tcSpecialistSlotBookingRequestOBJ.setToTime(tcRequestOBJ.getToTime());
tcSpecialistSlotBookingRequestOBJ.setCreatedBy(commonUtilityClass.getCreatedBy());
tcSpecialistSlotBookingRequestOBJ.setModifiedBy(commonUtilityClass.getCreatedBy());
int j = commonDoctorServiceImpl.callTmForSpecialistSlotBook(tcSpecialistSlotBookingRequestOBJ,
Authorization);
if (j > 0) {
tcRequestStatusFlag = teleConsultationServiceImpl.createTCRequest(tRequestModel);
if (tcRequestStatusFlag != null && tcRequestStatusFlag > 0) {
tcRequestOBJ.setTmRequestID(tcRequestStatusFlag);
} else {
throw new RuntimeException("Error while creating TC request.");
}
} else
throw new RuntimeException("Already Booked Slot, Please choose another slot");
}
}
return tcRequestOBJ;
}
// end
public String getOpenKMDocURL(String requestOBJ, String Authorization) throws JSONException {
RestTemplate restTemplate = new RestTemplate();
HttpServletRequest requestHeader = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String fileUUID = null;
JSONObject obj = new JSONObject(requestOBJ);
if (obj.has("fileID")) {
fileUUID = benVisitDetailRepo.getFileUUID(obj.getInt("fileID"));
logger.info("fileUUID for fileID " + obj.getInt("fileID") + " is " + fileUUID);
logger.info("openkmDocUrl is " + openkmDocUrl);
if (fileUUID != null) {
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("fileUID", fileUUID);
HttpEntity<Object> request = RestTemplateUtil.createRequestEntity(requestBody, Authorization);
ResponseEntity<String> response = restTemplate.exchange(openkmDocUrl, HttpMethod.POST, request,
String.class);
logger.info("Response=" + response.getBody());
String responseBody = response.getBody();
if (responseBody != null) {
JSONObject responseObj = new JSONObject(responseBody);
if (responseObj.has("data")) {
Object dataVal = responseObj.get("data");
if (dataVal instanceof JSONObject) {
JSONObject dataObj = (JSONObject) dataVal;
if (dataObj.has("response")) {
String fileUrl = dataObj.getString("response");
// Fix malformed URL: https://user:pass@https://host -> https://user:pass@host
fileUrl = fileUrl.replaceAll("@https?://", "@");
return fileUrl;
}
}
return dataVal.toString();
}
}
return responseBody;
} else
return null;
} else
return null;
}
@Override
public String getBenSymptomaticQuestionnaireDetailsData(Long beneficiaryRegID) throws Exception {
return commonNurseServiceImpl.getBenSymptomaticData(beneficiaryRegID);
}
@Override
public String getBenPreviousDiabetesData(Long beneficiaryRegID) throws Exception {
return commonNurseServiceImpl.getBenPreviousDiabetesData(beneficiaryRegID);
}
@Override
public String getBenPreviousReferralData(Long beneficiaryRegID) throws Exception {
return commonNurseServiceImpl.getBenPreviousReferralData(beneficiaryRegID);
}
}