Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,26 @@ public class ComplexObsSaver {
@Qualifier(AttachmentsConstants.COMPONENT_COMPLEXDATA_HELPER)
protected ComplexDataHelper complexDataHelper;

@Autowired
@Qualifier(AttachmentsConstants.COMPONENT_VISIT_COMPATIBILITY)
protected VisitCompatibility visitCompatibility;

protected Obs obs = new Obs();

protected ConceptComplex conceptComplex;

public Obs getObs() {
Comment thread
denniskigen marked this conversation as resolved.
Resolved
return obs;
}

protected void prepareComplexObs(Visit visit, Person person, Encounter encounter, String fileCaption,
String formFieldNamespace, String formFieldPath) {
obs = new Obs(person, conceptComplex,
protected Obs prepareComplexObs(Visit visit, Person person, Encounter encounter, String fileCaption,
String formFieldNamespace, String formFieldPath, ConceptComplex conceptComplex) {
Obs obs = new Obs(person, conceptComplex,
visit == null || visit.getStopDatetime() == null ? new Date() : visit.getStopDatetime(),
encounter != null ? encounter.getLocation() : null);
obs.setEncounter(encounter); // may be null
obs.setComment(fileCaption);
if (StringUtils.isNotBlank(formFieldNamespace) && StringUtils.isNotBlank(formFieldPath)) {
obs.setFormField(formFieldNamespace, formFieldPath);
}
return obs;
}

public Obs saveImageAttachment(Visit visit, Person person, Encounter encounter, String fileCaption,
MultipartFile multipartFile, String instructions, String formFieldNamespace, String formFieldPath)
throws IOException {

conceptComplex = context.getConceptComplex(ContentFamily.IMAGE);
prepareComplexObs(visit, person, encounter, fileCaption, formFieldNamespace, formFieldPath);
ConceptComplex conceptComplex = context.getConceptComplex(ContentFamily.IMAGE);
Obs obs = prepareComplexObs(visit, person, encounter, fileCaption, formFieldNamespace, formFieldPath,
Comment thread
denniskigen marked this conversation as resolved.
Resolved
conceptComplex);

Object image = multipartFile.getInputStream();
double compressionRatio = getCompressionRatio(multipartFile.getSize(),
Expand All @@ -94,8 +84,9 @@ public Obs saveImageAttachment(Visit visit, Person person, Encounter encounter,
public Obs saveOtherAttachment(Visit visit, Person person, Encounter encounter, String fileCaption,
MultipartFile multipartFile, String instructions, String formFieldNamespace, String formFieldPath)
throws IOException {
conceptComplex = context.getConceptComplex(ContentFamily.OTHER);
prepareComplexObs(visit, person, encounter, fileCaption, formFieldNamespace, formFieldPath);
ConceptComplex conceptComplex = context.getConceptComplex(ContentFamily.OTHER);
Obs obs = prepareComplexObs(visit, person, encounter, fileCaption, formFieldNamespace, formFieldPath,
conceptComplex);

obs.setComplexData(complexDataHelper.build(instructions,
replacePipeCharactersInFilenameWithUnderscores(multipartFile.getOriginalFilename()),
Expand Down