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 1 commit
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
208 changes: 205 additions & 3 deletions src/main/java/com/iemr/hwc/data/nurse/BeneficiaryChiefComplaint.java
shreypatidar-beehyv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class BeneficiaryChiefComplaint {
@Column(name = "BenVisitID")
private Long benVisitID;
@Expose
@OneToOne(fetch = FetchType.LAZY)
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(updatable = false, insertable = false, name = "BenVisitID")
private BeneficiaryVisitDetail t_benVisitDetail;

Expand Down Expand Up @@ -110,6 +110,10 @@ public class BeneficiaryChiefComplaint {
@Expose
@Column(name = "VanSerialNo")
private Long vanSerialNo;

@Expose
@Column(name = "VanID")
private Integer vanID;

@Expose
@Column(name = "VehicalNo")
Expand All @@ -130,6 +134,204 @@ public class BeneficiaryChiefComplaint {
@Expose
@Column(name = "ReservedForChange")
private String reservedForChange;



public Long getID() {
return ID;
}

public void setID(Long ID) {
this.ID = ID;
}

public Long getBeneficiaryRegID() {
return beneficiaryRegID;
}

public void setBeneficiaryRegID(Long beneficiaryRegID) {
this.beneficiaryRegID = beneficiaryRegID;
}

public BeneficiaryData getBeneficiaryData() {
return beneficiaryData;
}

public void setBeneficiaryData(BeneficiaryData beneficiaryData) {
this.beneficiaryData = beneficiaryData;
}

public Long getBenVisitID() {
return benVisitID;
}

public void setBenVisitID(Long benVisitID) {
this.benVisitID = benVisitID;
}

public BeneficiaryVisitDetail getT_benVisitDetail() {
return t_benVisitDetail;
}

public void setT_benVisitDetail(BeneficiaryVisitDetail t_benVisitDetail) {
this.t_benVisitDetail = t_benVisitDetail;
}

public Integer getProviderServiceMapID() {
return providerServiceMapID;
}

public void setProviderServiceMapID(Integer providerServiceMapID) {
this.providerServiceMapID = providerServiceMapID;
}

public Long getVisitCode() {
return visitCode;
}

public void setVisitCode(Long visitCode) {
this.visitCode = visitCode;
}

public Integer getChiefComplaintID() {
return chiefComplaintID;
}

public void setChiefComplaintID(Integer chiefComplaintID) {
this.chiefComplaintID = chiefComplaintID;
}

public String getChiefComplaint() {
return chiefComplaint;
}

public void setChiefComplaint(String chiefComplaint) {
this.chiefComplaint = chiefComplaint;
}

public Integer getDuration() {
return duration;
}

public void setDuration(Integer duration) {
this.duration = duration;
}

public String getUnitOfDuration() {
return unitOfDuration;
}

public void setUnitOfDuration(String unitOfDuration) {
this.unitOfDuration = unitOfDuration;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Boolean getDeleted() {
return deleted;
}

public void setDeleted(Boolean deleted) {
this.deleted = deleted;
}

public String getProcessed() {
return processed;
}

public void setProcessed(String processed) {
this.processed = processed;
}

public String getCreatedBy() {
return createdBy;
}

public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}

public Timestamp getCreatedDate() {
return createdDate;
}

public void setCreatedDate(Timestamp createdDate) {
this.createdDate = createdDate;
}

public String getModifiedBy() {
return modifiedBy;
}

public void setModifiedBy(String modifiedBy) {
this.modifiedBy = modifiedBy;
}

public Timestamp getLastModDate() {
return lastModDate;
}

public void setLastModDate(Timestamp lastModDate) {
this.lastModDate = lastModDate;
}

public Long getVanSerialNo() {
return vanSerialNo;
}

public void setVanSerialNo(Long vanSerialNo) {
this.vanSerialNo = vanSerialNo;
}

public Integer getVanID() {
return vanID;
}

public void setVanID(Integer vanID) {
this.vanID = vanID;
}

public String getVehicalNo() {
return vehicalNo;
}

public void setVehicalNo(String vehicalNo) {
this.vehicalNo = vehicalNo;
}

public Integer getParkingPlaceID() {
return parkingPlaceID;
}

public void setParkingPlaceID(Integer parkingPlaceID) {
this.parkingPlaceID = parkingPlaceID;
}

public String getSyncedBy() {
return syncedBy;
}

public void setSyncedBy(String syncedBy) {
this.syncedBy = syncedBy;
}

public Timestamp getSyncedDate() {
return syncedDate;
}

public void setSyncedDate(Timestamp syncedDate) {
this.syncedDate = syncedDate;
}

public String getReservedForChange() {
return reservedForChange;
}

public void setReservedForChange(String reservedForChange) {
this.reservedForChange = reservedForChange;
}
}
shreypatidar-beehyv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected void initialize() throws ServletException{
resourceProviders.add(applicationContext.getBean(ConditionExtProvider.class));
resourceProviders.add(applicationContext.getBean(ObservationExtProvider.class));
resourceProviders.add(applicationContext.getBean(ImmunizationExtProvider.class));
resourceProviders.add(applicationContext.getBean(ConditionExtProvider.class));
setResourceProviders(resourceProviders);

//Registering Interceptors
Expand Down
shreypatidar-beehyv marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
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.nurse.BeneficiaryChiefComplaint;
import com.iemr.hwc.fhir.model.condition.ConditionExt;
import com.iemr.hwc.fhir.service.condition.ConditionService;
import com.iemr.hwc.service.nurse.NurseServiceImpl;
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 +27,9 @@ public class ConditionExtProvider implements IResourceProvider {
@Autowired
private ConditionService conditionService;

@Autowired
private NurseServiceImpl nurseServiceImpl;

@Override
public Class<? extends IBaseResource> getResourceType() {
return ConditionExt.class;
Expand Down Expand Up @@ -59,4 +67,60 @@ 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<BeneficiaryChiefComplaint> listChiefComplaint = nurseServiceImpl.getChiefComplaintByLocationAndLastModifDate(Integer.parseInt(providerServiceMapId.getValue()), Integer.parseInt(vanID.getValue()),
new Timestamp(lastModifyDate.getValue().getTime()));
//
System.out.println("List chief compliant "+listChiefComplaint.size());
for (BeneficiaryChiefComplaint benef:listChiefComplaint) {
ConditionExt condition = new ConditionExt();
condition.setId(benef.getID()+"");
condition.setBeneficiaryID(new StringType(benef.getBeneficiaryRegID()+""));
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()+""));
condition.setBenFlowID(new StringType(""));

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

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

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

List<Annotation> listAnnot = new ArrayList<>();
Annotation annot = new Annotation();
annot.setText(benef.getT_benVisitDetail().getVisitReason());
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 @@ -21,10 +21,12 @@
*/
package com.iemr.hwc.repo.quickConsultation;

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

import javax.transaction.Transactional;

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

@Query("SELECT t from BeneficiaryChiefComplaint t WHERE (t.providerServiceMapID = :providerServiceMapId OR t.vanID = :vanID) AND t.lastModDate> :lastModDate ORDER BY t.lastModDate DESC ")
public ArrayList<BeneficiaryChiefComplaint> 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
10 changes: 10 additions & 0 deletions src/main/java/com/iemr/hwc/service/nurse/NurseServiceImpl.java
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,10 @@
import java.util.Map;

import com.iemr.hwc.data.benFlowStatus.BeneficiaryFlowStatus;
import com.iemr.hwc.data.nurse.BeneficiaryChiefComplaint;
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 +51,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 Expand Up @@ -112,4 +117,9 @@ public List<BenVisitsDTO> getVisitByLocationAndLastModifDate(Integer villageID,
return benVisitDetailsList;
}

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

}