4141import com .iemr .tm .service .common .transaction .CommonDoctorServiceImpl ;
4242import com .iemr .tm .service .common .transaction .CommonNurseServiceImpl ;
4343import com .iemr .tm .service .common .transaction .CommonServiceImpl ;
44+ import com .iemr .tm .utils .CookieUtil ;
45+ import com .iemr .tm .utils .JwtUtil ;
4446import com .iemr .tm .utils .mapper .InputMapper ;
4547import com .iemr .tm .utils .response .OutputResponse ;
4648
4749import io .lettuce .core .dynamic .annotation .Param ;
4850import io .swagger .v3 .oas .annotations .Operation ;
51+ import jakarta .servlet .http .HttpServletRequest ;
4952
5053@ RestController
5154@ RequestMapping (value = "/common" , headers = "Authorization" , consumes = "application/json" , produces = "application/json" )
@@ -57,6 +60,9 @@ public class WorklistController {
5760 private CommonServiceImpl commonServiceImpl ;
5861 private InputMapper inputMapper = new InputMapper ();
5962
63+ @ Autowired
64+ private JwtUtil jwtUtil ;
65+
6066 @ Autowired
6167 public void setCommonServiceImpl (CommonServiceImpl commonServiceImpl ) {
6268 this .commonServiceImpl = commonServiceImpl ;
@@ -676,20 +682,24 @@ public String getBeneficiaryCaseSheetHistory(
676682
677683 // TC specialist worklist new
678684 @ Operation (summary = "Get teleconsultation specialist worklist" )
679- @ GetMapping (value = { "/getTCSpecialistWorklist/{providerServiceMapID}/{serviceID}/{userID} " })
685+ @ GetMapping (value = { "/getTCSpecialistWorklist/{providerServiceMapID}/{serviceID}" })
680686 public String getTCSpecialistWorkListNew (@ PathVariable ("providerServiceMapID" ) Integer providerServiceMapID ,
681- @ PathVariable ( "userID" ) Integer userID , @ PathVariable ("serviceID" ) Integer serviceID ) {
687+ @ PathVariable ("serviceID" ) Integer serviceID , HttpServletRequest request ) {
682688 OutputResponse response = new OutputResponse ();
683689 try {
684- if (providerServiceMapID != null && userID != null ) {
690+ String jwtToken = CookieUtil .getJwtTokenFromCookie (request );
691+ String userId = jwtUtil .getUserIdFromToken (jwtToken );
692+ Integer userID =Integer .parseInt (userId );
693+ if (providerServiceMapID != null && userId != null ) {
685694 String s = commonDoctorServiceImpl .getTCSpecialistWorkListNewForTM (providerServiceMapID , userID ,
686695 serviceID );
687696 if (s != null )
688697 response .setResponse (s );
698+ } else if (userId == null || jwtToken == null ) {
699+ response .setError (403 , "Unauthorized access!" );
689700 } else {
690- logger .error ("Invalid request, either ProviderServiceMapID or userID is invalid. PSMID = "
691- + providerServiceMapID + " SID = " + userID );
692- response .setError (5000 , "Invalid request, either ProviderServiceMapID or userID is invalid" );
701+ logger .error ("Invalid request" );
702+ response .setError (5000 , "Invalid request" );
693703 }
694704
695705 } catch (Exception e ) {
@@ -702,21 +712,25 @@ public String getTCSpecialistWorkListNew(@PathVariable("providerServiceMapID") I
702712 // TC specialist worklist new, patient App, 14-08-2020
703713 @ Operation (summary = "Get teleconsultation specialist worklist for patient app" )
704714 @ GetMapping (value = {
705- "/getTCSpecialistWorklistPatientApp/{providerServiceMapID}/{serviceID}/{userID}/{ vanID}" })
715+ "/getTCSpecialistWorklistPatientApp/{providerServiceMapID}/{serviceID}/{vanID}" })
706716 public String getTCSpecialistWorkListNewPatientApp (
707- @ PathVariable ("providerServiceMapID" ) Integer providerServiceMapID , @ PathVariable ( "userID" ) Integer userID ,
708- @ PathVariable ("serviceID" ) Integer serviceID , @ PathVariable ("vanID" ) Integer vanID ) {
717+ @ PathVariable ("providerServiceMapID" ) Integer providerServiceMapID ,
718+ @ PathVariable ("serviceID" ) Integer serviceID , @ PathVariable ("vanID" ) Integer vanID , HttpServletRequest request ) {
709719 OutputResponse response = new OutputResponse ();
710720 try {
721+ String jwtToken = CookieUtil .getJwtTokenFromCookie (request );
722+ String userId = jwtUtil .getUserIdFromToken (jwtToken );
723+ Integer userID =Integer .parseInt (userId );
711724 if (providerServiceMapID != null && userID != null ) {
712725 String s = commonDoctorServiceImpl .getTCSpecialistWorkListNewForTMPatientApp (providerServiceMapID ,
713726 userID , serviceID , vanID );
714727 if (s != null )
715728 response .setResponse (s );
729+ } else if (userId == null || jwtToken == null ) {
730+ response .setError (403 , "Unauthorized access!" );
716731 } else {
717- logger .error ("Invalid request, either ProviderServiceMapID or userID is invalid. PSMID = "
718- + providerServiceMapID + " SID = " + userID );
719- response .setError (5000 , "Invalid request, either ProviderServiceMapID or userID is invalid" );
732+ logger .error ("Invalid request" );
733+ response .setError (5000 , "Invalid request" );
720734 }
721735
722736 } catch (Exception e ) {
@@ -729,21 +743,26 @@ public String getTCSpecialistWorkListNewPatientApp(
729743 // TC specialist worklist new future scheduled
730744 @ Operation (summary = "Get teleconsultation specialist future scheduled" )
731745 @ GetMapping (value = {
732- "/getTCSpecialistWorklistFutureScheduled/{providerServiceMapID}/{serviceID}/{userID} " })
746+ "/getTCSpecialistWorklistFutureScheduled/{providerServiceMapID}/{serviceID}" })
733747 public String getTCSpecialistWorklistFutureScheduled (
734- @ PathVariable ("providerServiceMapID" ) Integer providerServiceMapID , @ PathVariable ( "userID" ) Integer userID ,
735- @ PathVariable ("serviceID" ) Integer serviceID ) {
748+ @ PathVariable ("providerServiceMapID" ) Integer providerServiceMapID ,
749+ @ PathVariable ("serviceID" ) Integer serviceID , HttpServletRequest request ) {
736750 OutputResponse response = new OutputResponse ();
737751 try {
738- if (providerServiceMapID != null && userID != null ) {
752+
753+ String jwtToken = CookieUtil .getJwtTokenFromCookie (request );
754+ String userId = jwtUtil .getUserIdFromToken (jwtToken );
755+ Integer userID =Integer .parseInt (userId );
756+ if (providerServiceMapID != null && userID != null ) {
739757 String s = commonDoctorServiceImpl .getTCSpecialistWorkListNewFutureScheduledForTM (providerServiceMapID ,
740758 userID , serviceID );
741759 if (s != null )
742760 response .setResponse (s );
761+ } else if (userId == null || jwtToken == null ) {
762+ response .setError (403 , "Unauthorized access!" );
743763 } else {
744- logger .error ("Invalid request, either ProviderServiceMapID or userID is invalid. PSMID = "
745- + providerServiceMapID + " UserID = " + userID );
746- response .setError (5000 , "Invalid request, either ProviderServiceMapID or userID is invalid" );
764+ logger .error ("Invalid request" );
765+ response .setError (5000 , "Invalid request" );
747766 }
748767
749768 } catch (Exception e ) {
0 commit comments