Skip to content
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.iemr.common</groupId>
<artifactId>helpline-104-api</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
<packaging>war</packaging>
<name>Helpline-104-API</name>
<description>Piramal Helpline 104 API</description>
Expand Down
47 changes: 38 additions & 9 deletions src/main/java/com/iemr/helpline104/config/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
/*
* 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.helpline104.config;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.session.data.redis.config.ConfigureRedisAction;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.iemr.helpline104.data.users.M_User;

import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
@EnableCaching
public class RedisConfig {

@Bean
Expand All @@ -21,18 +44,24 @@ public ConfigureRedisAction configureRedisAction() {
}

@Bean
public RedisTemplate<String, M_User> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, M_User> template = new RedisTemplate<>();
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);

// Use StringRedisSerializer for keys (userId)
template.setKeySerializer(new StringRedisSerializer());

// Use Jackson2JsonRedisSerializer for values (Users objects)
Jackson2JsonRedisSerializer<M_User> serializer = new Jackson2JsonRedisSerializer<>(M_User.class);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);
Comment thread
vanitha1822 marked this conversation as resolved.

return template;
}

// new bean for rate limiting & counters
@Bean
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
return new StringRedisTemplate(factory);
}
Comment thread
vanitha1822 marked this conversation as resolved.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
* 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.helpline104.controller.outbound;

import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.iemr.helpline104.data.comoOutbound.OutboundCallActivity;
import com.iemr.helpline104.data.comoOutbound.T_104CoMoOutboundCallDetails;
import com.iemr.helpline104.service.outbound.OutboundCallActivityService;
import com.iemr.helpline104.utils.mapper.InputMapper;
import com.iemr.helpline104.utils.response.OutputResponse;

@RestController
@RequestMapping(value = "/outbound")
public class OutboundCallActivityController {

@Autowired
private OutboundCallActivityService activityService;

@Autowired
private InputMapper inputMapper;

// Get activities by providerServiceMapID
@PostMapping(value = "/activities", headers = "Authorization")
public String getActiveActivities(@RequestBody String request) {
OutputResponse output = new OutputResponse();
try {
JsonObject obj = new JsonParser().parse(request).getAsJsonObject();

ArrayList<OutboundCallActivity> activities;

if (obj.has("providerServiceMapID") && obj.get("providerServiceMapID") != null
&& !obj.get("providerServiceMapID").isJsonNull()) {
Integer providerServiceMapID = obj.get("providerServiceMapID").getAsInt();
activities = activityService.getActiveActivitiesByProvider(providerServiceMapID);
} else {
// Return all active activities if providerServiceMapID not provided
activities = activityService.getActiveActivitiesByProvider(null);
}

output.setResponse(new Gson().toJson(activities));
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}

// Get ALL active activities (for admin/supervisor)
@GetMapping(value = "/activities/all", headers = "Authorization")
public String getAllActiveActivities() {
OutputResponse output = new OutputResponse();
try {
ArrayList<OutboundCallActivity> activities = activityService.getAllActivities();
output.setResponse(new Gson().toJson(activities));
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}

// Save/Create activity
@PostMapping(value = "/activity", headers = "Authorization")
public String saveActivity(@RequestBody String request) {
OutputResponse output = new OutputResponse();
try {
OutboundCallActivity activity = inputMapper.gson().fromJson(request, OutboundCallActivity.class);
OutboundCallActivity savedObj = activityService.saveActivity(activity);
output.setResponse("Activity saved successfully with ID: " + savedObj.getActivityID());
Comment thread
vanitha1822 marked this conversation as resolved.
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}

// Update activity name
@PutMapping(value = "/activity/name", headers = "Authorization")
public String updateActivityName(@RequestBody String request) {
OutputResponse output = new OutputResponse();
try {
JsonObject obj = new JsonParser().parse(request).getAsJsonObject();
Long activityID = obj.get("activityID").getAsLong();
String activityName = obj.get("activityName").getAsString();
String modifiedBy = obj.get("modifiedBy").getAsString();

Integer updated = activityService.updateActivityName(activityID, activityName, modifiedBy);
output.setResponse("Activity name updated successfully. Rows affected: " + updated);
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}

// Toggle activity status (enable/disable)
@PutMapping(value = "/activity/status", headers = "Authorization")
public String toggleActivityStatus(@RequestBody String request) {
OutputResponse output = new OutputResponse();
try {
JsonObject obj = new JsonParser().parse(request).getAsJsonObject();
Long activityID = obj.get("activityID").getAsLong();
Boolean deleted = obj.get("deleted").getAsBoolean();
String modifiedBy = obj.get("modifiedBy").getAsString();

Integer updated = activityService.toggleActivityStatus(activityID, deleted, modifiedBy);
output.setResponse("Activity status updated successfully. Rows affected: " + updated);
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}

// Save call details on close
@PostMapping(value = "/callDetails/save", headers = "Authorization")
public String saveCallDetails(@RequestBody String request) {
OutputResponse output = new OutputResponse();
try {
T_104CoMoOutboundCallDetails callDetails = inputMapper.gson().fromJson(request,
T_104CoMoOutboundCallDetails.class);
T_104CoMoOutboundCallDetails savedObj = activityService.saveCallDetails(callDetails);
output.setResponse(new Gson().toJson(savedObj));
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}

// Get call activity history
@GetMapping(value = "/callActivity/history", headers = "Authorization")
public String getCallActivityHistory() {
OutputResponse output = new OutputResponse();
try {
ArrayList<?> history = activityService.getCallActivityHistory();
output.setResponse(new Gson().toJson(history));
} catch (Exception e) {
output.setError(e);
}
return output.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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.helpline104.data.comoOutbound;

import java.sql.Timestamp;

import com.google.gson.annotations.Expose;
import com.iemr.helpline104.utils.mapper.OutputMapper;

import jakarta.persistence.*;
import lombok.Data;

@Entity
@Table(name = "m_outbound_call_activity")
@Data
public class OutboundCallActivity {
Comment thread
vanitha1822 marked this conversation as resolved.

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Expose
@Column(name = "ActivityID")
private Long activityID;

@Expose
@Column(name = "ActivityName")
private String activityName;

@Expose
@Column(name = "ProviderServiceMapID")
private Integer providerServiceMapID;

@Expose
@Column(name = "Deleted")
private Boolean deleted;

@Expose
@Column(name = "CreatedBy")
private String createdBy;

@Expose
@Column(name = "CreatedDate")
private Timestamp createdDate;

@Expose
@Column(name = "ModifiedBy")
private String modifiedBy;

@Expose
@Column(name = "LastModDate")
private Timestamp lastModDate;

@Transient
private OutputMapper outputMapper = new OutputMapper();

@Override
public String toString() {
return outputMapper.gson().toJson(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@

import java.sql.Date;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.*;
import lombok.Data;

import com.google.gson.Gson;

@Entity
@Table(name="t_104CoMoOutboundCallDetails")
@Table(name = "t_104CoMoOutboundCallDetails")
@Data
public class T_104CoMoOutboundCallDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long iD;
private Integer uSRMappingID;
@Column(name = "CzentrixCallID")
private String callId;
private String callType;
private String callSubType;
Expand All @@ -47,13 +45,26 @@ public class T_104CoMoOutboundCallDetails {
private String feedback;
private Boolean deleted;
private String createdBy;
@Column(name = "CreatedDate", insertable=false, updatable=false)
@Column(name = "CreatedDate", insertable = false, updatable = false)
private Date createdDate;
@Column(name = "ModifiedBy")
private String modifiedBy;
@Column(name = "LastModDate", insertable=false, updatable=false)
@Column(name = "LastModDate", insertable = false, updatable = false)
private Date lastModDate;


@Column(name = "ActivityID")
private Long activityID;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ActivityID", insertable = false, updatable = false)
private OutboundCallActivity activity;

@Column(name = "CallStatus")
private String callStatus; // Fixed values: Answered, Not Answered, Did Not Want Further Call

@Column(name = "CallRemarks", length = 500)
private String callRemarks; // specifically for call activity to avoid conflicts with Remarks field

public T_104CoMoOutboundCallDetails() {
super();
}
Expand Down Expand Up @@ -170,7 +181,7 @@ public void setLastModDate(Date lastModDate) {
public Long getiD() {
return iD;
}

public String toString() {
return new Gson().toJson(this);
}
Expand Down
Loading