From 46e39d228fedd6cbb77bac46af5cd908c53894e0 Mon Sep 17 00:00:00 2001
From: KOPPIREDDY DURGA PRASAD
<144464542+DurgaPrasad-54@users.noreply.github.com>
Date: Tue, 20 Jan 2026 10:20:02 +0530
Subject: [PATCH 1/6] docs(readme): add documentation badge (#124)
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4d24c6ce..37d6505e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,8 @@
# AMRIT - Telemedicine (TM) Service
[](https://www.gnu.org/licenses/gpl-3.0)
-
+[](https://deepwiki.com/PSMRI/TM-API)
+
The AMRIT Telemedicine (TM) Service enhances the capabilities of Health and Wellness Centers (HWCs) by providing remote healthcare services, improving accessibility, enabling collaborative care, and integrating with other facilities such as drug dispensing and laboratory services. This service aims to extend the reach and convenience of HWCs, ensuring that patients receive necessary medical advice and services without the need for in-person visits.
From 732e6e78b051e3affd162e96d495248fa80df74d Mon Sep 17 00:00:00 2001
From: KOPPIREDDY DURGA PRASAD
<144464542+DurgaPrasad-54@users.noreply.github.com>
Date: Wed, 11 Feb 2026 19:46:04 +0530
Subject: [PATCH 2/6] chore(swagger): automate swagger sync to amrit-docs
(#127)
* docs(readme): add documentation badge
* chore(swagger): automate swagger sync to amrit-docs
* chore(swagger): automate swagger sync to amrit-docs
* chore(swagger): update swagger work flow and properties
---
.github/workflows/swagger-json.yml | 107 ++++++++++++++++++
pom.xml | 5 +
.../resources/application-swagger.properties | 51 +++++++++
3 files changed, 163 insertions(+)
create mode 100644 .github/workflows/swagger-json.yml
create mode 100644 src/main/resources/application-swagger.properties
diff --git a/.github/workflows/swagger-json.yml b/.github/workflows/swagger-json.yml
new file mode 100644
index 00000000..a92bd78a
--- /dev/null
+++ b/.github/workflows/swagger-json.yml
@@ -0,0 +1,107 @@
+name: Sync Swagger to AMRIT-Docs
+
+on:
+ push:
+ branches: [ main ]
+ workflow_dispatch:
+
+jobs:
+ swagger-sync:
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+
+ steps:
+ - name: Checkout API repo
+ uses: actions/checkout@v4
+
+ - name: Set up Java 17
+ uses: actions/setup-java@v4
+ with:
+ distribution: temurin
+ java-version: 17
+ cache: maven
+
+ - name: Build API (skip tests)
+ run: mvn -B clean package -DskipTests
+
+ - name: Install jq
+ run: sudo apt-get update && sudo apt-get install -y jq
+
+ - name: Run API in swagger profile
+ run: |
+ nohup java -jar target/tm-api-*.war \
+ --spring.profiles.active=swagger \
+ --server.port=9090 \
+ > app.log 2>&1 &
+ echo $! > api_pid.txt
+
+ - name: Wait for API & fetch Swagger
+ run: |
+ for i in {1..40}; do
+ CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true)
+
+ if [ "$CODE" = "200" ]; then
+ jq . swagger_raw.json > tm-api.json || {
+ echo "Swagger JSON invalid"
+ cat swagger_raw.json
+ exit 1
+ }
+
+ if [ "$(jq '.paths | length' tm-api.json)" -eq 0 ]; then
+ echo "Swagger paths empty – failing"
+ exit 1
+ fi
+
+ echo "Swagger generated successfully"
+ exit 0
+ fi
+
+ echo "Waiting for API... ($i)"
+ sleep 4
+ done
+
+ echo "Swagger not generated"
+ cat app.log || true
+ exit 1
+
+ - name: Stop API
+ if: always()
+ run: |
+ # Graceful shutdown of the process group
+ sleep 5
+ # Force kill the process group if still running
+ if [ -f api_pid.txt ]; then
+ PID=$(cat api_pid.txt)
+ kill -TERM -- -"$PID" 2>/dev/null || true
+ sleep 2
+ kill -9 -- -"$PID" 2>/dev/null || true
+ fi
+ # Fallback: kill any remaining java process on port 9090
+ fuser -k 9090/tcp 2>/dev/null || true
+
+ - name: Checkout AMRIT-Docs
+ uses: actions/checkout@v4
+ with:
+ repository: PSMRI/AMRIT-Docs
+ token: ${{ secrets.DOCS_REPO_TOKEN }}
+ path: amrit-docs
+ fetch-depth: 0
+
+ - name: Copy Swagger JSON
+ run: |
+ mkdir -p amrit-docs/docs/swagger
+ cp tm-api.json amrit-docs/docs/swagger/tm-api.json
+
+ - name: Create Pull Request
+ uses: peter-evans/create-pull-request@v8
+ with:
+ token: ${{ secrets.DOCS_REPO_TOKEN }}
+ path: amrit-docs
+ branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }}
+ base: main
+ commit-message: "chore(docs): auto-update TM-API swagger"
+ title: "chore(docs): auto-update TM-API swagger"
+ delete-branch: true
+ body: |
+ This PR automatically updates TM-API Swagger JSON
+ from the latest main branch build.
diff --git a/pom.xml b/pom.xml
index cd3a8f6d..56d3b951 100644
--- a/pom.xml
+++ b/pom.xml
@@ -294,6 +294,11 @@
0.12.6
runtime
+
+ com.h2database
+ h2
+ runtime
+
diff --git a/src/main/resources/application-swagger.properties b/src/main/resources/application-swagger.properties
new file mode 100644
index 00000000..fb4b94b3
--- /dev/null
+++ b/src/main/resources/application-swagger.properties
@@ -0,0 +1,51 @@
+spring.datasource.url=jdbc:h2:mem:swaggerdb
+spring.datasource.driver-class-name=org.h2.Driver
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.redis.host=${REDIS_HOST:localhost}
+spring.redis.port=${REDIS_PORT:6379}
+cors.allowed-origins=${CORS_ALLOWED_ORIGINS:http://localhost:9090,http://localhost:8080}
+logging.level.root=INFO
+jwt.secret=${JWT_SECRET_KEY:#{T(java.util.UUID).randomUUID().toString()}}
+common-api-url-searchBeneficiary=http://localhost:8080/beneficiary/search
+common-api-url-searchuserbyid=http://localhost:8080/user/searchbyid
+openkmDocUrl=http://localhost:8080/openkm
+nurseWL=90
+nurseTCWL=90
+pharmaWL=90
+pharmaTCWL=90
+ashaWL=90
+ashaTCWL=90
+labWL=90
+labTCWL=90
+radioWL=90
+radioTCWL=90
+oncoWL=90
+oncoTCWL=90
+tcSpecialistSlotBook=true
+tcSpecialistSlotCancel=true
+TMReferredWL=90
+docWL=90
+docTCWL=90
+swymed_dnsname=swymed://psmri.swymed.com
+jitsi_dnsname=https://meet.jit.si
+fotesenseFilePath=${FETOSENSE_FILE_PATH:/tmp/fetosense-report}
+fetosenseAPIKey=${FETOSENSE_API_KEY:defualt-key}
+scheduling-slotsize=5
+schedule=default
+tcSpeclistWL=90
+tcSpeclistTCWL=90
+sendSMSUrl=http://localhost:8080/sms/send
+prescription=default
+cancel=default
+reSchedule=default
+snomedCTPageSize=50
+registrarQuickSearchByIdUrl=http://localhost:8080/registrar/quicksearchbyid
+registrarQuickSearchByPhoneNoUrl=http://localhost:8080/registrar/quicksearchbyphoneno
+registrarAdvanceSearchUrl=http://localhost:8080/registrar/advancesearch
+carestreamOrderCreateURL=http://localhost:8080/carestream/order/create
+getBenImageFromIdentity=http://localhost:8080/identity/ben/image
+dataSyncUploadUrl=http://localhost:8080/datasync/upload
+dataSyncDownloadUrl=
+registrationUrl=http://localhost:8080/registration
+beneficiaryEditUrl=http://localhost:8080/beneficiary/edit
From 5b646dcf5369e7ee4cf3d02e576302538b1a9653 Mon Sep 17 00:00:00 2001
From: KOPPIREDDY DURGA PRASAD
<144464542+DurgaPrasad-54@users.noreply.github.com>
Date: Tue, 17 Feb 2026 16:32:09 +0530
Subject: [PATCH 3/6] Add new workflow and server urls (#129)
* docs(readme): add documentation badge
* chore(swagger): automate swagger sync to amrit-docs
* chore(swagger): automate swagger sync to amrit-docs
* chore(swagger): update swagger work flow and properties
* chore(swagger): update swagger workflow and add server urls
* chore(swagger): fix the version issue in swaggerconfig.java
---
.github/workflows/swagger-json.yml | 2 +-
.../com/iemr/tm/config/SwaggerConfig.java | 29 ++++++++++++++-----
.../resources/application-swagger.properties | 4 +++
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/swagger-json.yml b/.github/workflows/swagger-json.yml
index a92bd78a..c658d340 100644
--- a/.github/workflows/swagger-json.yml
+++ b/.github/workflows/swagger-json.yml
@@ -97,7 +97,7 @@ jobs:
with:
token: ${{ secrets.DOCS_REPO_TOKEN }}
path: amrit-docs
- branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }}
+ branch: auto/swagger-update-tm-api
base: main
commit-message: "chore(docs): auto-update TM-API swagger"
title: "chore(docs): auto-update TM-API swagger"
diff --git a/src/main/java/com/iemr/tm/config/SwaggerConfig.java b/src/main/java/com/iemr/tm/config/SwaggerConfig.java
index 6ebc2666..82883a43 100644
--- a/src/main/java/com/iemr/tm/config/SwaggerConfig.java
+++ b/src/main/java/com/iemr/tm/config/SwaggerConfig.java
@@ -2,6 +2,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
@@ -11,14 +12,26 @@
@Configuration
public class SwaggerConfig {
-
- @Bean
- public OpenAPI customOpenAPI() {
- return new OpenAPI().info(new
- Info().title("TeleMedicine(TM) API").version("version").description("A microservice for the creation and management of beneficiaries."))
- .addSecurityItem(new SecurityRequirement().addList("my security"))
- .components(new Components().addSecuritySchemes("my security",
- new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer")));
+ private static final String DEFAULT_SERVER_URL = "http://localhost:9090";
+
+ @Bean
+ public OpenAPI customOpenAPI(Environment env) {
+ String devUrl = env.getProperty("api.dev.url", DEFAULT_SERVER_URL);
+ String uatUrl = env.getProperty("api.uat.url", DEFAULT_SERVER_URL);
+ String demoUrl = env.getProperty("api.demo.url", DEFAULT_SERVER_URL);
+ return new OpenAPI()
+ .info(new Info()
+ .title("TeleMedicine(TM) API")
+ .version("1.0.0")
+ .description("A microservice for TeleMedicine, providing APIs for remote healthcare consultations, patient management, and related telehealth operations."))
+ .addSecurityItem(new SecurityRequirement().addList("my security"))
+ .components(new Components().addSecuritySchemes("my security",
+ new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer")))
+ .servers(java.util.Arrays.asList(
+ new io.swagger.v3.oas.models.servers.Server().url(devUrl).description("Dev"),
+ new io.swagger.v3.oas.models.servers.Server().url(uatUrl).description("UAT"),
+ new io.swagger.v3.oas.models.servers.Server().url(demoUrl).description("Demo")
+ ));
}
}
diff --git a/src/main/resources/application-swagger.properties b/src/main/resources/application-swagger.properties
index fb4b94b3..826b83dd 100644
--- a/src/main/resources/application-swagger.properties
+++ b/src/main/resources/application-swagger.properties
@@ -1,3 +1,7 @@
+# Swagger server URLs
+api.dev.url=${API_DEV_URL:https://amritwprdev.piramalswasthya.org}
+api.uat.url=${API_UAT_URL:https://uatamrit.piramalswasthya.org}
+api.demo.url=${API_DEMO_URL:https://amritdemo.piramalswasthya.org}
spring.datasource.url=jdbc:h2:mem:swaggerdb
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
From 0c6c8287729b53a4bb5656939d58fe2fdce86760 Mon Sep 17 00:00:00 2001
From: KOPPIREDDY DURGA PRASAD
<144464542+DurgaPrasad-54@users.noreply.github.com>
Date: Mon, 2 Mar 2026 10:11:52 +0530
Subject: [PATCH 4/6] feat(health,version): add health and version endpoints
(#130)
* feat(healt,version): add health and version endpoints
* fix(health): improve Redis health semantics when not configured
* fix(health): scope PROCESSLIST lock-wait check to application DB user
* fix(health): Removed the unused import
* fix(health): avoid blocking DB I/O under write lock and restore interrupt flag
* fix: add missin close brace
* fix(health): cancel in-flight futures on generic failure
* fix(health): fail-open on advanced MySQL check exceptions to avoid false degraded state
---
pom.xml | 28 +-
.../controller/health/HealthController.java | 84 +++
.../controller/version/VersionController.java | 58 +-
.../iemr/tm/service/health/HealthService.java | 526 ++++++++++++++++++
.../tm/utils/JwtUserIdValidationFilter.java | 3 +-
5 files changed, 668 insertions(+), 31 deletions(-)
create mode 100644 src/main/java/com/iemr/tm/controller/health/HealthController.java
create mode 100644 src/main/java/com/iemr/tm/service/health/HealthService.java
diff --git a/pom.xml b/pom.xml
index 56d3b951..40e64be4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -304,7 +304,7 @@
- ${artifactId}-${version}
+ ${project.artifactId}-${project.version}
@@ -348,6 +348,32 @@
maven-jar-plugin
3.0.2
+
+ io.github.git-commit-id
+ git-commit-id-maven-plugin
+ 9.0.2
+
+
+ get-the-git-infos
+
+ revision
+
+ initialize
+
+
+
+ true
+ ${project.build.outputDirectory}/git.properties
+
+ ^git.branch$
+ ^git.commit.id.abbrev$
+ ^git.build.version$
+ ^git.build.time$
+
+ false
+ false
+
+
org.springframework.boot
spring-boot-maven-plugin
diff --git a/src/main/java/com/iemr/tm/controller/health/HealthController.java b/src/main/java/com/iemr/tm/controller/health/HealthController.java
new file mode 100644
index 00000000..650bf402
--- /dev/null
+++ b/src/main/java/com/iemr/tm/controller/health/HealthController.java
@@ -0,0 +1,84 @@
+/*
+* 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.controller.health;
+
+import java.time.Instant;
+import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.iemr.tm.service.health.HealthService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
+import io.swagger.v3.oas.annotations.tags.Tag;
+
+@RestController
+@RequestMapping("/health")
+@Tag(name = "Health Check", description = "APIs for checking infrastructure health status")
+public class HealthController {
+
+ private static final Logger logger = LoggerFactory.getLogger(HealthController.class);
+
+ private final HealthService healthService;
+
+ public HealthController(HealthService healthService) {
+ this.healthService = healthService;
+ }
+
+ @GetMapping
+ @Operation(summary = "Check infrastructure health",
+ description = "Returns the health status of MySQL, Redis, and other configured services")
+ @ApiResponses({
+ @ApiResponse(responseCode = "200", description = "Services are UP or DEGRADED (operational with warnings)"),
+ @ApiResponse(responseCode = "503", description = "One or more critical services are DOWN")
+ })
+ public ResponseEntity