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
9 changes: 4 additions & 5 deletions src/main/environment/common_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ cron-scheduler-sms=0 0/1 * * * ? *
firebase.enabled=@env.FIREBASE_ENABLE@
# if using file
firebase.credential-file=@env.FIREBASE_CREDENTIAL@
# for CI/CD
firebase.credential-base64=@env.CREDENTIAL_BASE64@

#### Email Configuration
send-email=@env.SEND_EMAIL@
Expand Down Expand Up @@ -177,7 +175,7 @@ springdoc.swagger-ui.enabled=false
isProduction=@env.IS_PRODUCTION@
grievanceAllocationRetryConfiguration=3

start-grievancedatasync-scheduler=false
start-grievancedatasync-scheduler=true
cron-scheduler-grievancedatasync=0 0/2 * * * ?

captcha.secret-key=@env.CAPTCHA_SECRET_KEY@
Expand All @@ -186,5 +184,6 @@ captcha.enable-captcha=@env.ENABLE_CAPTCHA@

cors.allowed-origins=@env.CORS_ALLOWED_ORIGINS@



video-call-url=@env.VIDEO_CALL_URL@
jibri.output.path=@env.JIBRI_OUTPUT_PATH@
video.recording.path=@env.VIDEO_RECORDING_PATH@
7 changes: 5 additions & 2 deletions src/main/environment/common_docker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,8 @@ cors.allowed-origins=${CORS_ALLOWED_ORIGINS}
firebase.enabled=${FIREBASE_ENABLE}
# if using file
firebase.credential-file=${FIREBASE_CREDENTIAL}
# for CI/CD
firebase.credential-base64=${CREDENTIAL_BASE64}


video-call-url=${VIDEO_CALL_URL}
jibri.output.path={JIBRI_OUTPUT_PATH}
video.recording.path={VIDEO_RECORDING_PATH}
12 changes: 8 additions & 4 deletions src/main/environment/common_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ cti-server-ip=10.208.122.99
cti-logger_base_url=http://10.208.122.99/logger

# Identity Config
identity-api-url = http://localhost:8094/
identity-api-url = http://localhost:8094
#Verify whether 1097 and identity are same?
identity-1097-api-url = http://localhost:8095/
identity-1097-api-url = http://localhost:8095
##Generate Benificiary Config
genben-api=http://localhost:8092/
genben-api=http://localhost:8092

#### SMS Configuration
send-sms=false
sendSMSUrl = http://localhost:8080/sms/sendSMS
sendSMSUrl = http://localhost:8083/sms/sendSMS
source-address=AIDSHL
sms-username=<Enter SMS username>
sms-password=<Enter SMS password>
Expand Down Expand Up @@ -198,6 +198,10 @@ grievanceAllocationRetryConfiguration=3
logging.path=logs/
logging.file.name=logs/common-api.log

video-call-url=https://vc.piramalswasthya.org/
jibri.output.path=/srv/jibri/recordings
video.recording.path=/srv/recordings

captcha.secret-key= <Enter Cloudflare Secret Key>
captcha.verify-url= https://challenges.cloudflare.com/turnstile/v0/siteverify
captcha.enable-captcha=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public class FirebaseMessagingConfig {
@Value("${firebase.credential-file:}")
private String firebaseCredentialFile;

@Value("${firebase.credential-base64:}")
private String firebaseCredentialBase64;

@Bean
public FirebaseMessaging firebaseMessaging() throws IOException {
Expand All @@ -33,10 +31,7 @@ public FirebaseMessaging firebaseMessaging() throws IOException {

GoogleCredentials credentials;

if (!firebaseCredentialBase64.isBlank()) {
byte[] decoded = Base64.getDecoder().decode(firebaseCredentialBase64);
credentials = GoogleCredentials.fromStream(new ByteArrayInputStream(decoded));
} else if (!firebaseCredentialFile.isBlank()) {
if (!firebaseCredentialFile.isBlank()) {
credentials = GoogleCredentials.fromStream(
new ClassPathResource(firebaseCredentialFile).getInputStream()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.iemr.common.controller.videocall;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.iemr.common.model.videocall.UpdateCallRequest;
import com.iemr.common.model.videocall.VideoCallRequest;
import com.iemr.common.service.videocall.VideoCallService;
import com.iemr.common.utils.response.OutputResponse;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.RequestBody;

@RestController
@RequestMapping(value = "/video-consultation")
public class VideoCallController {
final Logger logger = LoggerFactory.getLogger(this.getClass().getName());

@Autowired
private VideoCallService videoCallService;

@PostMapping(value = "/generate-link", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public ResponseEntity<Map<String, String>> generateJitsiLink() {
Map<String, String> response = new HashMap<>();
try {
String link = videoCallService.generateMeetingLink();
response.put("meetingLink", link);
return ResponseEntity.ok(response);
} catch (Exception e) {
response.put("error", e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
}
}

@PostMapping(value = "/send-link", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public String sendVideoLink(@RequestBody String requestModel, HttpServletRequest request) {
OutputResponse response = new OutputResponse();

try {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
VideoCallRequest requestData = objectMapper.readValue(requestModel, VideoCallRequest.class);
String serviceResponse = videoCallService.sendMeetingLink(requestData);

return serviceResponse;

} catch (Exception e) {
logger.error("send MeetingLink failed with error: " + e.getMessage(), e);
response.setError(e);
return response.toString();
}
}

@PostMapping(value = "/update-call-status", produces = MediaType.APPLICATION_JSON_VALUE, headers = "Authorization")
public ResponseEntity<String> updateCallStatus(@RequestBody UpdateCallRequest requestModel, HttpServletRequest request) {
OutputResponse response = new OutputResponse();

try {
if (requestModel.getMeetingLink() == null || requestModel.getCallStatus() == null) {
throw new IllegalArgumentException("Meeting Link and Status are required");
}

String result = videoCallService.updateCallStatus(requestModel);

JSONObject responseObj = new JSONObject();
responseObj.put("status", "success");
responseObj.put("message", result);
response.setResponse(responseObj.toString());

} catch (IllegalArgumentException e) {
logger.error("Validation error: " + e.getMessage(), e);
return ResponseEntity.badRequest().body("{\"status\":\"error\",\"message\":\"" + e.getMessage() + "\"}");
} catch (Exception e) {
logger.error("updateCallStatus failed with error: " + e.getMessage(), e);
response.setError(e);
}

return ResponseEntity.ok(response.toString());
}



}
14 changes: 9 additions & 5 deletions src/main/java/com/iemr/common/data/sms/SMSParametersMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import java.sql.Timestamp;

import com.iemr.common.utils.mapper.OutputMapper;

import com.google.gson.GsonBuilder;
import com.google.gson.LongSerializationPolicy;
import com.google.gson.annotations.Expose;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand Down Expand Up @@ -69,9 +71,11 @@ public class SMSParametersMap
@Column(name = "LastModDate", insertable = false, updatable = false)
Timestamp lastModDate;

@Override
public String toString()
{
return OutputMapper.gsonWithoutExposeRestriction().toJson(this);
@Override
public String toString() {

return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setLongSerializationPolicy(LongSerializationPolicy.STRING).serializeNulls()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create().toJson(this);
}

}
10 changes: 7 additions & 3 deletions src/main/java/com/iemr/common/data/sms/SMSTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import com.iemr.common.utils.mapper.OutputMapper;

import com.google.gson.GsonBuilder;
import com.google.gson.LongSerializationPolicy;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
Expand Down Expand Up @@ -77,8 +79,10 @@ public class SMSTemplate
Timestamp lastModDate;

@Override
public String toString()
{
return OutputMapper.gsonWithoutExposeRestriction().toJson(this);
public String toString() {

return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().setLongSerializationPolicy(LongSerializationPolicy.STRING).serializeNulls()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create().toJson(this);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.iemr.common.data.videocall;

import java.sql.Timestamp;

import com.iemr.common.utils.mapper.OutputMapper;

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 lombok.Data;

@Entity
@Table(name = "t_videocallparameter")
@Data
public class VideoCallParameters {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "MeetingID")
private Integer meetingID;

@Column(name = "DateOfCall")
private Timestamp dateOfCall;

@Column(name = "CallerPhoneNumber")
private String callerPhoneNumber;

@Column(name = "AgentID")
private String agentID;

@Column(name = "AgentName")
private String agentName;

@Column(name = "MeetingLink")
private String meetingLink;

@Column(name = "CallStatus")
private String callStatus;

@Column(name = "CallDuration")
private String callDuration;

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

@Column(name = "BeneficiaryRegID")
private Long beneficiaryRegID;

@Column(name = "ClosureRemark")
private String closureRemark;

@Column(name = "LinkGeneratedAt")
private Timestamp linkGeneratedAt;

@Column(name = "IsLinkUsed")
private boolean linkUsed;

@Column(name = "Deleted", insertable = false, updatable = true)
private Boolean deleted;

@Column(name = "CreatedBy", insertable = true, updatable = false)
private String createdBy;

@Column(name = "CreatedDate", insertable = false, updatable = false)
private Timestamp createdDate;

@Column(name = "ModifiedBy", insertable = false, updatable = true)
private String modifiedBy;

@Column(name = "LastModDate", insertable = false, updatable = false)
private Timestamp lastModDate;

@Override
public String toString()
{
return OutputMapper.gsonWithoutExposeRestriction().toJson(this);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/iemr/common/mapper/sms/SMSMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public interface SMSMapper

SMSMapper INSTANCE = Mappers.getMapper(SMSMapper.class);

@Mappings({ @Mapping(source = "request.smsTemplateTypeID", target = "smsTypeID"), })
@Mappings({ @Mapping(source = "request.smsTemplateTypeID", target = "smsTypeID") })
SMSTemplate requestToSMSTemplate(SMSRequest request);

@IterableMapping(elementTargetType = SMSTemplate.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.iemr.common.mapper.videocall;

import java.util.List;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.mapstruct.IterableMapping;
import org.mapstruct.factory.Mappers;

import com.iemr.common.data.videocall.VideoCallParameters;
import com.iemr.common.model.videocall.UpdateCallRequest;
import com.iemr.common.model.videocall.UpdateCallResponse;
import com.iemr.common.model.videocall.VideoCallRequest;

@Mapper(componentModel = "spring")
public interface VideoCallMapper {
VideoCallMapper INSTANCE = Mappers.getMapper(VideoCallMapper.class);

VideoCallRequest videoCallToRequest(VideoCallParameters videoCall);

VideoCallParameters videoCallToEntity(VideoCallRequest videoCallRequest);

@IterableMapping(elementTargetType = VideoCallRequest.class)
List<VideoCallRequest> videoCallToRequestList(List<VideoCallParameters> videoCallList);

@IterableMapping(elementTargetType = VideoCallParameters.class)
List<VideoCallParameters> videoCallToEntityList(List<VideoCallRequest> videoCallRequestList);

VideoCallParameters updateRequestToVideoCall(UpdateCallRequest updateCallStatusRequest);

UpdateCallResponse videoCallToResponse(VideoCallParameters videoCall);

@IterableMapping(elementTargetType = VideoCallParameters.class)
List<VideoCallParameters> updateRequestToVideoCall(List<UpdateCallRequest> updateCallStatusRequests);

@IterableMapping(elementTargetType = UpdateCallResponse.class)
List<UpdateCallResponse> videoCallToResponse(List<VideoCallParameters> videoCalls);
}
4 changes: 3 additions & 1 deletion src/main/java/com/iemr/common/model/sms/SMSRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import java.sql.Timestamp;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iemr.common.data.telemedicine.PrescribedDrugDetail;

import lombok.Data;
Expand Down Expand Up @@ -78,4 +78,6 @@ public class SMSRequest {
private Long beneficiaryId;
private String appointmentDate;
private String appointmentTime;
@JsonProperty("sms_Advice")
private String smsAdvice;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.iemr.common.model.videocall;

import lombok.Data;

@Data
public class UpdateCallRequest {

private String meetingLink;
private String callStatus;
private String callDuration;
private String modifiedBy;
}
Loading
Loading