Skip to content

Commit 59fb6c9

Browse files
BAH-2371 | Refactor. To send consultation image and video upload as attachment
1 parent 0dc608c commit 59fb6c9

5 files changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/build_and_upload.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- master
10+
- BAH-2371
1011
workflow_dispatch:
1112
env:
1213
ORG_NAME: BahmniIndiaDistro

api/src/main/java/org/bahmni/module/hip/api/dao/impl/ConsultationDaoImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ public List<Obs> getAllObs(String programName, Date fromDate, Date toDate, Patie
9191
public List<Obs> getPhysicalExamination(Visit visit) {
9292
final String[] formNames = Config.Forms_To_Ignore_In_Physical_Examination.getValue().split("\\s*,\\s*");
9393
List<Obs> physicalExaminationObsMap = encounterDao.GetAllObsForVisit(visit,Config.CONSULTATION.getValue(),null)
94-
.stream().filter(o -> o.getValueCoded() == null && o.getObsGroup() == null
94+
.stream().filter(o -> o.getValueCoded() == null
95+
&& o.getValueComplex() == null
96+
&& o.getObsGroup() == null
9597
&& !Arrays.asList(formNames).contains(o.getConcept().getName().getName()) )
9698
.collect(Collectors.toList());
9799
return physicalExaminationObsMap;

omod/src/main/java/org/bahmni/module/hip/web/service/Constants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ public class Constants {
1212
static final String GIF = "gif";
1313
static final String PDF = "pdf";
1414
static final String MIMETYPE_PDF = "application/pdf";
15+
static final String MIMETYPE_VIDEO_MPEG = "video/mpeg";
16+
static final String MIMETYPE_VIDEO_MP4 = "video/mp4";
17+
static final String MP4 = "mp4";
18+
static final String MPEG = "mpeg";
19+
1520
}

omod/src/main/java/org/bahmni/module/hip/web/service/FHIRResourceMapper.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,15 @@ public DocumentReference mapToDocumentDocumentReference(Obs obs) {
179179
private List<Attachment> getAttachments(Obs obs) throws IOException {
180180
List<Attachment> attachments = new ArrayList<>();
181181
Attachment attachment = new Attachment();
182-
Set<Obs> obsList = obs.getGroupMembers();
183182
StringBuilder valueText = new StringBuilder();
184183
StringBuilder contentType = new StringBuilder();
185-
for(Obs obs1 : obsList){
186-
if(obs1.getConcept().getName().getName().equals(Config.DOCUMENT_TYPE.getValue())){
187-
valueText.append(obs1.getValueText());
188-
contentType.append(FHIRUtils.getTypeOfTheObsDocument(obs1.getValueText()));
189-
}
184+
if(obs.getConcept().getName().getName().equals(Config.DOCUMENT_TYPE.getValue())){
185+
valueText.append(obs.getValueText());
186+
contentType.append(FHIRUtils.getTypeOfTheObsDocument(obs.getValueText()));
187+
}
188+
if(obs.getConcept().getName().getName().equals(Config.IMAGE.getValue()) || obs.getConcept().getName().getName().equals(Config.PATIENT_VIDEO.getValue())){
189+
valueText.append(obs.getValueComplex());
190+
contentType.append(FHIRUtils.getTypeOfTheObsDocument(obs.getValueComplex()));
190191
}
191192
attachment.setContentType(contentType.toString());
192193
byte[] fileContent = Files.readAllBytes(new File(Config.PATIENT_DOCUMENTS_PATH.getValue() + valueText).toPath());
@@ -197,6 +198,8 @@ private List<Attachment> getAttachments(Obs obs) throws IOException {
197198
title.append(Config.PATIENT_DOCUMENT.getValue());
198199
else if(encounterId.equals(Config.RADIOLOGY_TYPE.getValue()))
199200
title.append(Config.RADIOLOGY_REPORT.getValue());
201+
else if(encounterId.equals(Config.CONSULTATION.getValue()))
202+
title.append("Consultation");
200203
title.append(": ").append(obs.getConcept().getName().getName());
201204
attachment.setTitle(title.toString());
202205
attachments.add(attachment);

omod/src/main/java/org/bahmni/module/hip/web/service/FHIRUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
import static org.bahmni.module.hip.web.service.Constants.JPG;
2323
import static org.bahmni.module.hip.web.service.Constants.MIMETYPE_IMAGE_JPEG;
2424
import static org.bahmni.module.hip.web.service.Constants.MIMETYPE_PDF;
25+
import static org.bahmni.module.hip.web.service.Constants.MIMETYPE_VIDEO_MP4;
26+
import static org.bahmni.module.hip.web.service.Constants.MIMETYPE_VIDEO_MPEG;
27+
import static org.bahmni.module.hip.web.service.Constants.MP4;
28+
import static org.bahmni.module.hip.web.service.Constants.MPEG;
2529
import static org.bahmni.module.hip.web.service.Constants.PDF;
2630
import static org.bahmni.module.hip.web.service.Constants.PNG;
2731

@@ -200,6 +204,10 @@ public static String getTypeOfTheObsDocument(String valueText) {
200204
return IMAGE + extension;
201205
} else if (extension.compareTo(PDF) == 0) {
202206
return MIMETYPE_PDF;
207+
} else if (extension.compareTo(MP4) == 0) {
208+
return MIMETYPE_VIDEO_MP4;
209+
} else if (extension.compareTo(MPEG) == 0) {
210+
return MIMETYPE_VIDEO_MPEG;
203211
} else {
204212
return "";
205213
}

0 commit comments

Comments
 (0)