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 2 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
shreypatidar-beehyv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,4 @@ 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,26 @@
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 ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
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.repo.benFlowStatus.BeneficiaryFlowStatusRepo;
import com.iemr.hwc.service.quickConsultation.QuickConsultationServiceImpl;
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 +30,12 @@ public class ConditionExtProvider implements IResourceProvider {
@Autowired
private ConditionService conditionService;

@Autowired
private BeneficiaryFlowStatusRepo beneficiaryFlowStatusRepo;

@Autowired
private QuickConsultationServiceImpl quickConsultationServiceImpl;

@Override
public Class<? extends IBaseResource> getResourceType() {
return ConditionExt.class;
Expand Down Expand Up @@ -59,4 +73,65 @@ 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 = quickConsultationServiceImpl.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()+""));
}
else {
throw new ResourceNotFoundException("No record found for given benVisitID and BenVisitCode");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of throwing exception, log it as no benVisitID and BenvisitCode. Add continue statement to ignore the record. Can we write in the query to get only records with benVistiID and BenvisitCode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I even think that we don't need to generate an exception because the benVisitID and the visitCode will exist all the time. So I removed the generation of an exception @roopesh-beehyv

}

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
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the imports and auto wiring, I don't see any changes here. Undo this as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
import java.util.Map;

import com.iemr.hwc.data.benFlowStatus.BeneficiaryFlowStatus;
import com.iemr.hwc.data.nurse.BeneficiaryChiefComplaint;
import com.iemr.hwc.data.quickConsultation.BenChiefComplaint;
import com.iemr.hwc.fhir.dto.visitDetailsMain.visitDetails.BenVisitsDTO;
import com.iemr.hwc.repo.benFlowStatus.BeneficiaryFlowStatusRepo;
import com.iemr.hwc.repo.quickConsultation.BenChiefComplaintRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
Expand All @@ -49,6 +52,9 @@ public class NurseServiceImpl implements NurseService {
@Autowired
private BeneficiaryFlowStatusRepo benFlowStatusRepo;

@Autowired
private BenChiefComplaintRepo benChiefComplaintRepo;

@Autowired
public void setBenVisitDetailRepo(BenVisitDetailRepo benVisitDetailRepo) {
this.benVisitDetailRepo = benVisitDetailRepo;
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this logic is related to the condition controller, it's better to write it in the condition service class(already present). That way our code will be better isolated from theirs and easy to follow and we will not be modifying their code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,9 @@ public Integer updateBeneficiaryClinicalObservations(JsonObject caseSheet) throw
return r;
}

public List<BenChiefComplaint> getChiefComplaintByLocationAndLastModifDate(Integer providerServiceMapId, Integer vanID, Timestamp lastModifDate) {
List<BenChiefComplaint> listBenChiefCompalintOBJs = benChiefComplaintRepo.getChiefComplaintByLocationAndLastModDate(providerServiceMapId, vanID, lastModifDate);
return listBenChiefCompalintOBJs;
}

}