healthStatus = healthService.checkHealth();
+
+ // Standard HTTP Status logic
+ String status = (String) healthStatus.get("status");
+ HttpStatus httpStatus = "UP".equals(status) ? HttpStatus.OK : HttpStatus.SERVICE_UNAVAILABLE;
+
+ logger.info("Health check completed with status: {}", status);
+
+ return ResponseEntity.status(httpStatus).body(healthStatus);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/controller/version/VersionController.java b/src/main/java/com/iemr/common/controller/version/VersionController.java
index 814c99a1..1c9f8960 100644
--- a/src/main/java/com/iemr/common/controller/version/VersionController.java
+++ b/src/main/java/com/iemr/common/controller/version/VersionController.java
@@ -1,30 +1,40 @@
/*
-* 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/.
-*/
+ * 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/.
+ */
+/**
+ * REST controller exposing application version and build metadata.
+ *
+ * Provides the /version endpoint which returns Git metadata
+ * in a standardized JSON format consistent across all AMRIT APIs.
+ *
+ *
+ * @author Vaishnav Bhosale
+ */
package com.iemr.common.controller.version;
-import java.io.BufferedReader;
-import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,49 +43,50 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
-import com.iemr.common.utils.response.OutputResponse;
-
import io.swagger.v3.oas.annotations.Operation;
-
@RestController
public class VersionController {
- private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
+ private final Logger logger =
+ LoggerFactory.getLogger(this.getClass().getSimpleName());
+
+ private static final String UNKNOWN_VALUE = "unknown";
- @Operation(summary = "Get version")
- @RequestMapping(value = "/version", method = { RequestMethod.GET })
- public String versionInformation() {
- OutputResponse output = new OutputResponse();
+ @Operation(summary = "Get version information")
+ @GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE)
+ public ResponseEntity