Skip to content
Open
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
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.hwc</groupId>
<artifactId>hwc-api</artifactId>
<version>3.8.1</version>
<version>3.10.0</version>
<packaging>war</packaging>

<name>HWC-API</name>
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/iemr/hwc/data/nurse/BeneficiaryVisitDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,22 @@ public class BeneficiaryVisitDetail {
@Column(name = "VisitFlowStatusFlag", insertable = false)
private @SQLInjectionSafe String visitFlowStatusFlag;

@Expose
@Column(name = "NurseID")
private Long nurseID;

@Expose
@Column(name = "DoctorID")
private Long doctorID;

@Expose
@Column(name = "PharmacistID")
private Long pharmacistID;

@Expose
@Column(name = "LabTechnicianID")
private Long labTechnicianID;

@Expose
@Column(name = "VanSerialNo")
private Long vanSerialNo;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/iemr/hwc/repo/nurse/BenVisitDetailRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ public List<Objects[]> getBeneficiaryVisitDetails(@Param("benRegID") Long benReg
@Query("UPDATE BeneficiaryVisitDetail set subVisitCategory = :subVisitCategory where visitCode = :visitCode ")
public Integer updateSubVisitCategory(@Param("subVisitCategory") String subVisitCategory, @Param("visitCode") Long visitCode);

// store responsible doctor's user ID against the visit
@Transactional
@Modifying
@Query("UPDATE BeneficiaryVisitDetail set doctorID = :doctorID where visitCode = :visitCode ")
public Integer updateDoctorID(@Param("doctorID") Long doctorID, @Param("visitCode") Long visitCode);

// store responsible lab technician's user ID against the visit
@Transactional
@Modifying
@Query("UPDATE BeneficiaryVisitDetail set labTechnicianID = :labTechnicianID where visitCode = :visitCode ")
public Integer updateLabTechnicianID(@Param("labTechnicianID") Long labTechnicianID, @Param("visitCode") Long visitCode);


// get file uuid from file id
@Query(nativeQuery = true, value = " SELECT FileUID from t_kmfilemanager where KmFileManagerID = :fileID ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,37 @@ public class CommonDoctorServiceImpl {
@Autowired
private PNCDiagnosisRepo pNCDiagnosisRepo;
@Autowired
private com.iemr.hwc.repo.nurse.BenVisitDetailRepo benVisitDetailRepo;
@Autowired
private com.iemr.hwc.repo.login.UserLoginRepo userLoginRepo;

/**
* Resolve the numeric user ID of the responsible staff member from the username
* captured in createdBy/modifiedBy. Returns null if it cannot be resolved so an
* unknown staff member never blocks the flow.
*/
private Long resolveUserId(String username) {
if (username == null || username.trim().isEmpty())
return null;
com.iemr.hwc.data.login.Users user = userLoginRepo.getUserByUsername(username.trim());
return user != null ? user.getUserID() : null;
}

/**
* Store the responsible doctor's user ID on the visit record. The doctor's
* identity is taken from createdBy, falling back to modifiedBy.
*/
private void storeDoctorIDOnVisit(CommonUtilityClass commonUtilityClass) {
if (commonUtilityClass == null || commonUtilityClass.getVisitCode() == null)
return;
String username = commonUtilityClass.getCreatedBy();
if (username == null || username.trim().isEmpty())
username = commonUtilityClass.getModifiedBy();
Long doctorID = resolveUserId(username);
if (doctorID != null)
benVisitDetailRepo.updateDoctorID(doctorID, commonUtilityClass.getVisitCode());
}
@Autowired
private PrescriptionDetailRepo prescriptionDetailRepo;
@Autowired
private NCDCareDiagnosisRepo NCDCareDiagnosisRepo;
Expand Down Expand Up @@ -755,6 +786,9 @@ public int updateBenFlowtableAfterDocDataSave(CommonUtilityClass commonUtilityCl
Long tmpBenVisitID = commonUtilityClass.getBenVisitID();
Long tmpbeneficiaryRegID = commonUtilityClass.getBeneficiaryRegID();

// Store the responsible doctor's user ID against the visit
storeDoctorIDOnVisit(commonUtilityClass);

if (commonUtilityClass != null && commonUtilityClass.getVisitCategoryID() != null
&& commonUtilityClass.getVisitCategoryID() == 9) {
ArrayList<FoetalMonitor> foetalMonitorData = foetalMonitorRepo
Expand Down Expand Up @@ -895,6 +929,9 @@ public int updateBenFlowtableAfterDocDataUpdate(CommonUtilityClass commonUtility
Long tmpBenVisitID = commonUtilityClass.getBenVisitID();
Long tmpbeneficiaryRegID = commonUtilityClass.getBeneficiaryRegID();

// Store the responsible doctor's user ID against the visit
storeDoctorIDOnVisit(commonUtilityClass);

if (commonUtilityClass != null && commonUtilityClass.getVisitCategoryID() != null
&& commonUtilityClass.getVisitCategoryID() == 9) {
ArrayList<FoetalMonitor> foetalMonitorData = foetalMonitorRepo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ public class CommonNurseServiceImpl implements CommonNurseService {

private BenVisitDetailRepo benVisitDetailRepo;

@Autowired
private com.iemr.hwc.repo.login.UserLoginRepo userLoginRepo;

/**
* Resolve the numeric user ID of the responsible staff member from the username
* captured in createdBy/modifiedBy. Returns null if the username is blank or
* cannot be resolved, so an unknown staff member never blocks the save.
*/
private Long resolveUserId(String username) {
if (username == null || username.trim().isEmpty())
return null;
com.iemr.hwc.data.login.Users user = userLoginRepo.getUserByUsername(username.trim());
return user != null ? user.getUserID() : null;
}

private BenChiefComplaintRepo benChiefComplaintRepo;
private BenMedHistoryRepo benMedHistoryRepo;
private BencomrbidityCondRepo bencomrbidityCondRepo;
Expand Down Expand Up @@ -449,6 +464,10 @@ public Long saveBeneficiaryVisitDetails(BeneficiaryVisitDetail beneficiaryVisitD

}

// Store the responsible nurse's user ID (resolved from the createdBy username)
if (beneficiaryVisitDetail.getNurseID() == null)
beneficiaryVisitDetail.setNurseID(resolveUserId(beneficiaryVisitDetail.getCreatedBy()));

response = benVisitDetailRepo.save(beneficiaryVisitDetail);

if (response != null) {
Expand Down Expand Up @@ -507,6 +526,10 @@ public Long saveBeneficiaryVisitDetails(BeneficiaryVisitDetail beneficiaryVisitD
}

Integer facilityIdObj = beneficiaryVisitDetail.getFacilityID();
// Store the responsible nurse's user ID (resolved from the createdBy username)
if (beneficiaryVisitDetail.getNurseID() == null)
beneficiaryVisitDetail.setNurseID(resolveUserId(beneficiaryVisitDetail.getCreatedBy()));

response = benVisitDetailRepo.save(beneficiaryVisitDetail);

if (response != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@
private CommonBenStatusFlowServiceImpl commonBenStatusFlowServiceImpl;
private ProcedureCompMappedMasterRepo procedureCompMappedMasterRepo;

@org.springframework.beans.factory.annotation.Autowired

Check warning on line 53 in src/main/java/com/iemr/hwc/service/labtechnician/LabTechnicianServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this field injection and use constructor injection instead.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZ_Xd4FID-hhx3PWVkx6&open=AZ_Xd4FID-hhx3PWVkx6&pullRequest=220
private com.iemr.hwc.repo.nurse.BenVisitDetailRepo benVisitDetailRepo;
@org.springframework.beans.factory.annotation.Autowired

Check warning on line 55 in src/main/java/com/iemr/hwc/service/labtechnician/LabTechnicianServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this field injection and use constructor injection instead.

See more on https://sonarcloud.io/project/issues?id=PSMRI_HWC-API&issues=AZ_Xd4FID-hhx3PWVkx7&open=AZ_Xd4FID-hhx3PWVkx7&pullRequest=220
private com.iemr.hwc.repo.login.UserLoginRepo userLoginRepo;

/**
* Resolve the numeric user ID of the responsible staff member from the username
* captured in createdBy. Returns null if it cannot be resolved.
*/
private Long resolveUserId(String username) {
if (username == null || username.trim().isEmpty())
return null;
com.iemr.hwc.data.login.Users user = userLoginRepo.getUserByUsername(username.trim());
return user != null ? user.getUserID() : null;
}


@Autowired
public void setCommonBenStatusFlowServiceImpl(CommonBenStatusFlowServiceImpl commonBenStatusFlowServiceImpl) {
Expand Down Expand Up @@ -359,6 +375,12 @@
labResultSaveFlag = saveLabTestResult(wrapperLabResults);

if (labResultSaveFlag == 1) {
// Store the responsible lab technician's user ID against the visit
if (wrapperLabResults.getVisitCode() != null) {
Long labTechnicianID = resolveUserId(wrapperLabResults.getCreatedBy());
if (labTechnicianID != null)
benVisitDetailRepo.updateLabTechnicianID(labTechnicianID, wrapperLabResults.getVisitCode());
}
int i = updateBenFlowStatusFlagAfterLabResultEntry(wrapperLabResults.getLabCompleted(),
wrapperLabResults.getBenFlowID(), wrapperLabResults.getBeneficiaryRegID(),
wrapperLabResults.getVisitID(), wrapperLabResults.getNurseFlag(),
Expand Down