Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse sync chief complaints of the patient #15

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ public class BeneficiaryChiefComplaint {
@Expose
@Column(name = "ReservedForChange")
private String reservedForChange;


}
shreypatidar-beehyv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package com.iemr.hwc.fhir.provider.condition;

import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.param.DateParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import com.iemr.hwc.data.benFlowStatus.BeneficiaryFlowStatus;
import com.iemr.hwc.data.quickConsultation.BenChiefComplaint;
import com.iemr.hwc.fhir.model.condition.ConditionExt;
import com.iemr.hwc.fhir.service.condition.ConditionService;
import com.iemr.hwc.fhir.service.condition.ConditionServiceImpl;
import com.iemr.hwc.repo.benFlowStatus.BeneficiaryFlowStatusRepo;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.OperationOutcome;
import org.hl7.fhir.r4.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -22,6 +29,12 @@ public class ConditionExtProvider implements IResourceProvider {
@Autowired
private ConditionService conditionService;

@Autowired
private BeneficiaryFlowStatusRepo beneficiaryFlowStatusRepo;

@Autowired
private ConditionServiceImpl conditionServiceImpl;

@Override
public Class<? extends IBaseResource> getResourceType() {
return ConditionExt.class;
Expand Down Expand Up @@ -59,4 +72,62 @@ public MethodOutcome createCondition(HttpServletRequest theRequest, @ResourcePar
method.setResource(conditionService.addNewChiefComplaint(theRequest,conditionExt));
return method;
}

@Search()
public List<ConditionExt> findChiefComplaintByDistrictAndLastModifDate(HttpServletRequest theRequest, @RequiredParam(name = "providerServiceMapId") StringParam providerServiceMapId, @RequiredParam(name = "vanID") StringParam vanID, @RequiredParam(name = "lastModif") DateParam lastModifyDate) {

List<ConditionExt> listRes = new ArrayList<>();
try {
String authorization = theRequest.getHeader("Authorization");
List<BenChiefComplaint> listChiefComplaint = conditionServiceImpl.getChiefComplaintByLocationAndLastModifDate(Integer.parseInt(providerServiceMapId.getValue()), Integer.parseInt(vanID.getValue()),
new Timestamp(lastModifyDate.getValue().getTime()));

for (BenChiefComplaint benef:listChiefComplaint) {
BeneficiaryFlowStatus beneficiaryFlowStatus = beneficiaryFlowStatusRepo.getBenFlowByVisitIDAndVisitCode(benef.getBenVisitID(), benef.getVisitCode());
ConditionExt condition = new ConditionExt();
condition.setId(benef.getBenChiefComplaintID()+"");
condition.setProviderServiceMapId(new StringType(benef.getProviderServiceMapID()+""));
condition.setVanID(new StringType(benef.getVanID()+""));
condition.setParkingPlaceID(new StringType(benef.getParkingPlaceID()+""));
condition.setCreatedBy(new StringType(benef.getCreatedBy()));
condition.setBeneficiaryRegID(new StringType(benef.getBeneficiaryRegID()+""));
if (beneficiaryFlowStatus != null){
condition.setBeneficiaryID(new StringType(beneficiaryFlowStatus.getBeneficiaryID()+""));
condition.setBenFlowID(new StringType(beneficiaryFlowStatus.getBenFlowID()+""));
}

Coding coding = new Coding();
coding.setCode(benef.getUnitOfDuration());
coding.setDisplay(benef.getDuration()+"");
condition.setDuration(coding);

Reference ref= new Reference();
ref.setReference(benef.getBenChiefComplaintID()+"");
condition.setSubject(ref);

CodeableConcept concept = new CodeableConcept();
List<Coding> listCoding = new ArrayList<>();
Coding coding1 = new Coding();
coding1.setSystem("http://snomed.info/sct");
coding1.setCode(benef.getChiefComplaintID()+"");
coding1.setDisplay(benef.getChiefComplaint());
listCoding.add(coding1);
concept.setCoding(listCoding);
condition.setCode(concept);

List<Annotation> listAnnot = new ArrayList<>();
Annotation annot = new Annotation();
annot.setText(benef.getDescription());
listAnnot.add(annot);
condition.setNote(listAnnot);

listRes.add(condition);
}
}
catch (Exception e){
e.printStackTrace();
}

return listRes;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.iemr.hwc.fhir.service.condition;

import com.iemr.hwc.data.quickConsultation.BenChiefComplaint;
import com.iemr.hwc.fhir.model.condition.ConditionExt;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.List;

public interface ConditionService {
ConditionExt addNewChiefComplaint(HttpServletRequest theRequest, ConditionExt conditionExt) throws Exception;
public List<BenChiefComplaint> getChiefComplaintByLocationAndLastModifDate(Integer providerServiceMapId, Integer vanID, Timestamp lastModifDate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.iemr.hwc.fhir.utils.mapper.MapperUtils;
import com.iemr.hwc.fhir.utils.validation.ConditionValidation;
import com.iemr.hwc.repo.benFlowStatus.BeneficiaryFlowStatusRepo;
import com.iemr.hwc.repo.quickConsultation.BenChiefComplaintRepo;
import com.iemr.hwc.service.common.transaction.CommonNurseServiceImpl;
import com.iemr.hwc.service.snomedct.SnomedService;
import com.iemr.hwc.utils.exception.IEMRException;
Expand All @@ -24,6 +25,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.List;

Expand All @@ -40,6 +42,9 @@ public class ConditionServiceImpl implements ConditionService {
@Autowired
private BeneficiaryFlowStatusRepo beneficiaryFlowStatusRepo;

@Autowired
private BenChiefComplaintRepo benChiefComplaintRepo;

@Autowired
private SnomedService snomedService;

Expand Down Expand Up @@ -92,4 +97,9 @@ public ConditionExt addNewChiefComplaint(HttpServletRequest theRequest, Conditio

return conditionExt;
}

public List<BenChiefComplaint> getChiefComplaintByLocationAndLastModifDate(Integer providerServiceMapId, Integer vanID, Timestamp lastModifDate) {
List<BenChiefComplaint> listBenChiefCompalintOBJs = benChiefComplaintRepo.getChiefComplaintByLocationAndLastModDate(providerServiceMapId, vanID, lastModifDate);
return listBenChiefCompalintOBJs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public int updateBenFlowStatusAfterNurseActivityANC(@Param("benFlowID") Long ben
@Query("SELECT t FROM BeneficiaryFlowStatus t Where t.benFlowID = :benFlowID ")
public BeneficiaryFlowStatus getBenDetailsForLeftSidePanel(@Param("benFlowID") Long benFlowID);

@Query("SELECT t FROM BeneficiaryFlowStatus t Where t.benVisitID = :benVisitID AND t.visitCode = :visitCode")
public BeneficiaryFlowStatus getBenFlowByVisitIDAndVisitCode(@Param("benVisitID") Long benVisitID, @Param("visitCode") Long visitCode);

// MMU doc work-list
@Query("SELECT t from BeneficiaryFlowStatus t WHERE (t.doctorFlag = 1 OR t.doctorFlag = 2 OR "
+ " t.doctorFlag = 3 OR t.nurseFlag = 2 OR t.doctorFlag = 9) AND t.deleted = false "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
*/
package com.iemr.hwc.repo.quickConsultation;

import java.sql.Timestamp;
import java.util.ArrayList;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
Expand All @@ -38,6 +38,10 @@
@RestResource(exported = false)
public interface BenChiefComplaintRepo extends CrudRepository<BenChiefComplaint, Long> {

@Query("SELECT t from BenChiefComplaint t WHERE (t.providerServiceMapID = :providerServiceMapId OR t.vanID = :vanID) AND t.lastModDate> :lastModDate ORDER BY t.lastModDate DESC ")
public ArrayList<BenChiefComplaint> getChiefComplaintByLocationAndLastModDate(
@Param("providerServiceMapId") Integer providerServiceMapId, @Param("vanID") Integer vanID, @Param("lastModDate") Timestamp lastModDate);

@Query(" SELECT benChiefComplaintID, beneficiaryRegID, benVisitID, providerServiceMapID, chiefComplaintID, chiefComplaint, "
+ "duration, unitOfDuration, description, visitCode,conceptID "
+ "from BenChiefComplaint ba WHERE ba.beneficiaryRegID = :benRegID "
Expand Down