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
44 changes: 44 additions & 0 deletions src/main/java/com/iemr/common/data/location/NikshayDistrict.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.common.data.location;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

/**
* Nikshay's own district master (m_nikshay_district) — an isolated ID space
* from AMRIT's standard m_district, used only for Stop TB location mapping.
*/
@Entity
@Table(name = "m_nikshay_district")
@Data
public class NikshayDistrict {
@Id
@Column(name = "NikshayDistrictID")
private Integer nikshayDistrictID;

@Column(name = "DistrictName")
private String districtName;
}
44 changes: 44 additions & 0 deletions src/main/java/com/iemr/common/data/location/NikshayTU.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.common.data.location;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

/**
* Nikshay's Tuberculosis Unit master (m_nikshay_tu) — Stop TB's equivalent
* of a "block", but scoped to Nikshay's own hierarchy, not m_districtblock.
*/
@Entity
@Table(name = "m_nikshay_tu")
@Data
public class NikshayTU {
@Id
@Column(name = "NikshayTUID")
private Integer nikshayTUID;

@Column(name = "TUName")
private String tuName;
}
44 changes: 44 additions & 0 deletions src/main/java/com/iemr/common/data/location/NikshayVillage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.common.data.location;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;

/**
* Nikshay's own village master (m_nikshay_village) — an isolated ID space
* from AMRIT's standard m_DistrictBranchMapping, used only for Stop TB.
*/
@Entity
@Table(name = "m_nikshay_village")
@Data
public class NikshayVillage {
@Id
@Column(name = "NikshayVillageID")
private Integer nikshayVillageID;

@Column(name = "VillageName")
private String villageName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
import com.iemr.common.dto.identity.Identity;
import com.iemr.common.model.beneficiary.BeneficiaryDemographicsModel;
import com.iemr.common.model.beneficiary.BeneficiaryModel;
import com.iemr.common.service.location.NikshayAddressResolver;

public abstract class CommonIdentityMapperDecorator implements CommonIdentityMapper {
@Autowired
NikshayAddressResolver nikshayAddressResolver;
@Autowired
StateMapper stateMapper;
@Autowired
Expand Down Expand Up @@ -69,11 +72,13 @@ public CommonIdentityDTO beneficiaryModelCommonIdentityDTO(BeneficiaryModel bene
return null;
}
CommonIdentityDTO commonIdentityDTO = new CommonIdentityDTO();
commonIdentityDTO
.setPermanentAddress(beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics()));
commonIdentityDTO.setCurrentAddress(beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics()));
commonIdentityDTO
.setEmergencyAddress(beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics()));
boolean isStopTB = nikshayAddressResolver.isStopTB(beneficiary.getProviderServiceMapID());
commonIdentityDTO.setPermanentAddress(
beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics(), isStopTB));
commonIdentityDTO.setCurrentAddress(
beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics(), isStopTB));
commonIdentityDTO.setEmergencyAddress(
beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics(), isStopTB));
commonIdentityDTO.setPlaceOfWork(beneficiary.getPlaceOfWork());
commonIdentityDTO.setMarriageDate(beneficiary.getMarriageDate());
commonIdentityDTO.setIsHIVPositive(beneficiary.getIsHIVPos());
Expand Down Expand Up @@ -210,6 +215,11 @@ public CommonIdentityDTO beneficiaryModelCommonIdentityDTO(BeneficiaryModel bene
}

protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsModel beneficiaryDemographicsModel) {
return beneficiaryDemographicsModelToAddress(beneficiaryDemographicsModel, false);
}

protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsModel beneficiaryDemographicsModel,
boolean isStopTB) {
if (beneficiaryDemographicsModel == null) {
return null;
}
Expand All @@ -222,8 +232,10 @@ protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsM
address.setStateId(beneficiaryDemographicsModel.getStateID());
address.setDistrictId(beneficiaryDemographicsModel.getDistrictID());
if (beneficiaryDemographicsModel.getDistrictID() != null) {
address.setDistrict(
districtMapper.districtToModelByID(beneficiaryDemographicsModel.getDistrictID()).getDistrictName());
address.setDistrict(isStopTB
? nikshayAddressResolver.resolveDistrictName(beneficiaryDemographicsModel.getDistrictID())
: districtMapper.districtToModelByID(beneficiaryDemographicsModel.getDistrictID())
.getDistrictName());
}
address.setServicePointName(beneficiaryDemographicsModel.getServicePointName());
address.setCountry(beneficiaryDemographicsModel.getCountryName());
Expand All @@ -239,14 +251,17 @@ protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsM
address.setParkingPlaceID(beneficiaryDemographicsModel.getParkingPlaceID());
address.setServicePointID(beneficiaryDemographicsModel.getServicePointID());
if (beneficiaryDemographicsModel.getDistrictBranchID() != null) {
address.setVillage(branchMapper
.districtBranchToModelByID(beneficiaryDemographicsModel.getDistrictBranchID()).getVillageName());
address.setVillage(isStopTB
? nikshayAddressResolver.resolveVillageName(beneficiaryDemographicsModel.getDistrictBranchID())
: branchMapper.districtBranchToModelByID(beneficiaryDemographicsModel.getDistrictBranchID())
.getVillageName());
}
address.setSubDistrictId(beneficiaryDemographicsModel.getBlockID());
address.setCountryId(beneficiaryDemographicsModel.getCountryID());
if (beneficiaryDemographicsModel.getBlockID() != null) {
address.setSubDistrict(
blockMapper.districtBlockToModelByID(beneficiaryDemographicsModel.getBlockID()).getBlockName());
address.setSubDistrict(isStopTB
? nikshayAddressResolver.resolveTUName(beneficiaryDemographicsModel.getBlockID())
: blockMapper.districtBlockToModelByID(beneficiaryDemographicsModel.getBlockID()).getBlockName());
}
address.setGpsLatitude(beneficiaryDemographicsModel.getLatitude());
address.setGpsLongitude(beneficiaryDemographicsModel.getLongitude());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
import com.iemr.common.model.beneficiary.BenPhoneMapModel;
import com.iemr.common.model.beneficiary.BeneficiaryDemographicsModel;
import com.iemr.common.model.beneficiary.BeneficiaryModel;
import com.iemr.common.service.location.NikshayAddressResolver;

public abstract class IdentityBenEditMapperDecorator implements IdentityBenEditMapper {
@Autowired
NikshayAddressResolver nikshayAddressResolver;
@Autowired
StateMapper stateMapper;
@Autowired
Expand Down Expand Up @@ -69,6 +72,11 @@ public abstract class IdentityBenEditMapperDecorator implements IdentityBenEditM
MaritalStatusMapper maritalStatusMapper;

protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsModel beneficiaryDemographicsModel) {
return beneficiaryDemographicsModelToAddress(beneficiaryDemographicsModel, false);
}

protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsModel beneficiaryDemographicsModel,
boolean isStopTB) {
if (beneficiaryDemographicsModel == null) {
return null;
}
Expand All @@ -81,8 +89,10 @@ protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsM
address.setStateId(beneficiaryDemographicsModel.getStateID());
address.setDistrictId(beneficiaryDemographicsModel.getDistrictID());
if (beneficiaryDemographicsModel.getDistrictID() != null) {
address.setDistrict(
districtMapper.districtToModelByID(beneficiaryDemographicsModel.getDistrictID()).getDistrictName());
address.setDistrict(isStopTB
? nikshayAddressResolver.resolveDistrictName(beneficiaryDemographicsModel.getDistrictID())
: districtMapper.districtToModelByID(beneficiaryDemographicsModel.getDistrictID())
.getDistrictName());
}
address.setServicePointName(beneficiaryDemographicsModel.getServicePointName());
address.setCountry(beneficiaryDemographicsModel.getCountryName());
Expand All @@ -98,14 +108,17 @@ protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsM
address.setParkingPlaceID(beneficiaryDemographicsModel.getParkingPlaceID());
address.setServicePointID(beneficiaryDemographicsModel.getServicePointID());
if (beneficiaryDemographicsModel.getDistrictBranchID() != null) {
address.setVillage(branchMapper
.districtBranchToModelByID(beneficiaryDemographicsModel.getDistrictBranchID()).getVillageName());
address.setVillage(isStopTB
? nikshayAddressResolver.resolveVillageName(beneficiaryDemographicsModel.getDistrictBranchID())
: branchMapper.districtBranchToModelByID(beneficiaryDemographicsModel.getDistrictBranchID())
.getVillageName());
}
address.setSubDistrictId(beneficiaryDemographicsModel.getBlockID());
address.setCountryId(beneficiaryDemographicsModel.getCountryID());
if (beneficiaryDemographicsModel.getBlockID() != null) {
address.setSubDistrict(
blockMapper.districtBlockToModelByID(beneficiaryDemographicsModel.getBlockID()).getBlockName());
address.setSubDistrict(isStopTB
? nikshayAddressResolver.resolveTUName(beneficiaryDemographicsModel.getBlockID())
: blockMapper.districtBlockToModelByID(beneficiaryDemographicsModel.getBlockID()).getBlockName());
}
address.setGpsLatitude(beneficiaryDemographicsModel.getLatitude());
address.setGpsLongitude(beneficiaryDemographicsModel.getLongitude());
Expand All @@ -124,9 +137,13 @@ public IdentityEditDTO BenToIdentityEditMapper(BeneficiaryModel beneficiary) {
}

IdentityEditDTO identityEditDTO = new IdentityEditDTO();
identityEditDTO.setPermanentAddress(beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics()));
identityEditDTO.setCurrentAddress(beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics()));
identityEditDTO.setEmergencyAddress(beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics()));
boolean isStopTB = nikshayAddressResolver.isStopTB(beneficiary.getProviderServiceMapID());
identityEditDTO.setPermanentAddress(
beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics(), isStopTB));
identityEditDTO.setCurrentAddress(
beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics(), isStopTB));
identityEditDTO.setEmergencyAddress(
beneficiaryDemographicsModelToAddress(beneficiary.getI_bendemographics(), isStopTB));
identityEditDTO.setPlaceOfWork(beneficiary.getPlaceOfWork());
identityEditDTO.setMarriageDate(beneficiary.getMarriageDate());
identityEditDTO.setIsHIVPositive(beneficiary.getIsHIVPos());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.common.repository.location;

import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import com.iemr.common.data.location.NikshayDistrict;

@Repository
public interface NikshayDistrictRepository extends CrudRepository<NikshayDistrict, Integer> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.common.repository.location;

import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import com.iemr.common.data.location.NikshayTU;

@Repository
public interface NikshayTURepository extends CrudRepository<NikshayTU, Integer> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.common.repository.location;

import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import com.iemr.common.data.location.NikshayVillage;

@Repository
public interface NikshayVillageRepository extends CrudRepository<NikshayVillage, Integer> {
}
Loading
Loading