Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5b94361
chore: bump pom version to 3.9.1
vishwab1 Sep 25, 2026
1b1cf23
Merge pull request #357 from PSMRI/chore/pom-version-3.9.1
SauravBizbRolly Sep 25, 2026
dee5611
fix(diagnostic): stop the poll scheduler from nulling vanSerialNo
vishwab1 Oct 6, 2026
290265f
fix(diagnostic): stamp vanSerialNo right after the order is first saved
vishwab1 Oct 6, 2026
ff278e5
Merge pull request #365 from PSMRI/vb/fix-diagnostic-vanserialno
SauravBizbRolly Oct 6, 2026
04b46c7
feat(stoptb): save OPD prescription to standard tables and dispense s…
vishwab1 Oct 8, 2026
f634cd0
fix(stoptb): close dispensing gaps found in review
vishwab1 Oct 8, 2026
ef5697b
feat(stoptb): General OPD on AMRIT standard tables only
vishwab1 Oct 8, 2026
db518a2
feat(stoptb): calculate tablet/capsule quantity when the app sends none
vishwab1 Oct 8, 2026
0869e7e
fix(stoptb): OPD save validations from final review
vishwab1 Oct 8, 2026
5a0e2d4
feat(stoptb): default quantity 1 for non-tablet medicines when the ap…
vishwab1 Oct 8, 2026
234c936
feat(stoptb): getAll drugs list with form; SOS quantity default
vishwab1 Oct 8, 2026
b939647
Merge release-3.12.0 into vb/stoptb-drug-dispense
vishwab1 Oct 9, 2026
b23c8e0
updated version to 3.9.2
chetansaroya Oct 9, 2026
4398d78
Merge pull request #371 from chetansaroya/fix/pom
vishwab1 Oct 9, 2026
60968a7
Merge release-3.9.2 into vb/stoptb-drug-dispense
vishwab1 Oct 9, 2026
f7c8f03
fix(stoptb): fill missing service line on the day's visit
vishwab1 Oct 12, 2026
97c6672
Merge latest release-3.12.0 into vb/stoptb-drug-dispense
vishwab1 Oct 12, 2026
295d553
fix(stoptb): MMU dose-based quantity; no batch re-upload after dispense
vishwab1 Oct 16, 2026
eeb2a1d
fix(stoptb): send the batch's new stock to central after an OPD dispense
vishwab1 Oct 20, 2026
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
5 changes: 5 additions & 0 deletions src/main/java/com/iemr/flw/controller/StopTBController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.iemr.flw.service.StopTBPrescriptionService;
import com.iemr.flw.service.StopTBService;
import com.iemr.flw.utils.response.OutputResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -101,6 +102,10 @@ public String saveGeneralOpd(@RequestBody List<Map<String, Object>> dataList) {
try {
List<Map<String, Object>> result = stopTBService.saveGeneralOpd(dataList);
response.setResponse(gson.toJson(result));
} catch (StopTBPrescriptionService.InsufficientStockException e) {
// Nothing was saved; the app shows this and lets the nurse lower the quantity.
logger.warn("saveGeneralOpd rejected: " + e.getMessage());
response.setError(5000, e.getMessage());
} catch (Exception e) {
logger.error("Error in saveGeneralOpd: " + e);
response.setError(5000, "Error saving general OPD: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ public class DiagnosticDocument {
@Column(name = "parkingPlaceID")
private Integer parkingPlaceID;

@Column(name = "vanSerialNo")
@Column(name = "vanSerialNo", updatable = false)
private Long vanSerialNo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ public class DiagnosticOrder {
@Column(name = "processed")
private String processed = "N";

@Column(name = "vanSerialNo")
@Column(name = "vanSerialNo", updatable = false)
private Long vanSerialNo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public class DiagnosticProviderToken {
@Column(name = "parkingPlaceID")
private Integer parkingPlaceID;

@Column(name = "vanSerialNo")
@Column(name = "vanSerialNo", updatable = false)
private Long vanSerialNo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ public class DiagnosticResult {
@Column(name = "parkingPlaceID")
private Integer parkingPlaceID;

@Column(name = "vanSerialNo")
@Column(name = "vanSerialNo", updatable = false)
private Long vanSerialNo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ public class StopTBDiagnostics {
@Column(name = "processed")
private String processed = "N";

@Column(name = "vanSerialNo")
@Column(name = "vanSerialNo", updatable = false)
private Long vanSerialNo;
}
62 changes: 57 additions & 5 deletions src/main/java/com/iemr/flw/service/CampConfigService.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.iemr.flw.service;

import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* Camp/van identity for this deployment.
*
Expand All @@ -17,12 +23,14 @@
* No inline default β€” every properties file must set stoptb.van.id explicitly, so a forgotten
* config fails loudly at startup instead of silently running unconfigured.
*
* Scope: vanID (and the VanSerialNo stamping that depends on it) only. parkingPlaceID is out of
* scope for this change.
* The van's parking place and store (facility) come from m_van, the same source MMU uses
* (MasterVanRepo.getFacilityID), and are read once and cached since the van never changes.
*/
@Service
public class CampConfigService {

private final Logger logger = LoggerFactory.getLogger(CampConfigService.class);

@Value("${stoptb.van.id}")
private int vanID;

Expand All @@ -31,6 +39,12 @@ public class CampConfigService {
@Value("${stoptb.enforce.vanid}")
private boolean enforceVanID;

@PersistenceContext(unitName = "db_iemr")
private EntityManager entityManager;

private volatile Integer parkingPlaceID;
private volatile Integer facilityID;

public Integer getVanID() {
if (vanID <= 0) {
if (enforceVanID) {
Expand All @@ -42,13 +56,51 @@ public Integer getVanID() {
return vanID;
}

/**
* The configured van (stoptb.van.id) is always used. A vanID sent by the app is ignored, so data and
* stock never land on another camp's van/store; a different value is only logged.
*/
public Integer resolveVanID(Integer requestedVanID) {
Integer configured = getVanID();
if (requestedVanID != null && requestedVanID > 0 && !requestedVanID.equals(configured)) {
logger.warn("Ignoring vanID " + requestedVanID + " from request; using stoptb.van.id " + configured);
}
return configured;
}

public boolean isCampConfigured() {
return vanID > 0;
}

// Not sourced from Redis anymore (out of scope for this change) β€” kept only because
// callers across StopTBServiceImpl/DiagnosticOrderServiceImpl/etc. still call it.
// Parking place of the configured van (m_van.ParkingPlaceID); 0 when the camp is not configured
// or the van is not found, which is what callers received before this lookup existed.
public Integer getParkingPlaceID() {
return 0;
if (parkingPlaceID == null) loadVanDetails();
return parkingPlaceID != null ? parkingPlaceID : 0;
}

// Store mapped to the configured van (m_van.FacilityID); null when no store is mapped.
public Integer getFacilityID() {
if (facilityID == null) loadVanDetails();
return facilityID;
}

private synchronized void loadVanDetails() {
if (!isCampConfigured() || (parkingPlaceID != null && facilityID != null)) return;
try {
List<?> rows = entityManager.createNativeQuery(
"SELECT ParkingPlaceID, FacilityID FROM db_iemr.m_van WHERE VanID = :vanID AND Deleted = false")
.setParameter("vanID", vanID)
.getResultList();
if (rows.isEmpty()) {
logger.warn("stoptb.van.id " + vanID + " not found in m_van");
return;
}
Object[] row = (Object[]) rows.get(0);
parkingPlaceID = row[0] != null ? ((Number) row[0]).intValue() : null;
facilityID = row[1] != null ? ((Number) row[1]).intValue() : null;
} catch (Exception e) {
logger.error("Cannot read m_van details for vanID " + vanID, e);
}
}
}
Loading
Loading