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

ATT-47: Support for concept parameter when saving/fetching attachments. #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

samuelmale
Copy link
Member

@samuelmale samuelmale marked this pull request as ready for review March 30, 2021 18:24
@mks-d mks-d self-requested a review April 6, 2021 15:51
public Obs saveImageAttachment(Visit visit, Person person, Encounter encounter, String fileCaption,
MultipartFile multipartFile, String instructions) throws IOException {

conceptComplex = context.getConceptComplex(ContentFamily.IMAGE);
return saveImageAttachment(visit, person, encounter, null, fileCaption, multipartFile, instructions);
Copy link
Member

Choose a reason for hiding this comment

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

Why deprecate it? Just keep it and make sure it invokes the new signature as such:

conceptComplex = context.getConceptComplex(ContentFamily.IMAGE);
return saveImageAttachment(visit, person, encounter, conceptComplex, fileCaption, multipartFile, instructions);

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved

@@ -207,7 +213,7 @@ public Obs saveImageAttachment(String imagePath, String mimeType) throws IOExcep
mimeType, IOUtils.toByteArray(getClass().getClassLoader().getResourceAsStream(imagePath)));

String fileCaption = RandomStringUtils.randomAlphabetic(12);
return obsSaver.saveImageAttachment(visit, patient, encounter, fileCaption, lastSavedMultipartImageFile,
return obsSaver.saveImageAttachment(visit, patient, encounter, null, fileCaption, lastSavedMultipartImageFile,
Copy link
Member

Choose a reason for hiding this comment

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

Without the deprecation this change is not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved

* @param concept
* @throws APIException if non-complex obs are mistakenly returned
*/
List<Attachment> getAttachments(Patient patient, Concept concept);
Copy link
Member

Choose a reason for hiding this comment

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

This is my main issue, the changes to AttachmentsService are possibly much wider than thought here.

I believe this is where the existing API could be deprecated and a new one is to be introduced that caters for the new concept argument.

Copy link
Member Author

@samuelmale samuelmale May 11, 2021

Choose a reason for hiding this comment

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

I believe this is where the existing API could be deprecated and a new one is to be introduced that caters for the new concept argument.

@mks-d Looks like some good time is required for this one; do you think its okay to handle this in a different/followup ticket?

Comment on lines 311 to 328
public Obs saveComplexObs(Patient patient, Concept concept) throws IOException {
Obs obs = new Obs();
byte[] randomData = new byte[20];
obs.setConcept(concept);
obs.setObsDatetime(new Date());
obs.setPerson(patient);

new Random().nextBytes(randomData);

String filename = RandomStringUtils.randomAlphabetic(7) + ".ext";
MockMultipartFile multipartRandomFile = new MockMultipartFile(FilenameUtils.getBaseName(filename), filename,
"application/octet-stream", randomData);
obs.setComplexData(
complexDataHelper.build(ValueComplex.INSTRUCTIONS_DEFAULT, multipartRandomFile.getOriginalFilename(),
multipartRandomFile.getBytes(), multipartRandomFile.getContentType()).asComplexData());

return context.getObsService().saveObs(obs, null);
}
Copy link
Member

Choose a reason for hiding this comment

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

Why didn't you make this parameterizable with a concept argument?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 335 to 348
public Concept createComplexConcept(String uuid, String name, String handler, String description) {
ConceptService conceptService = Context.getConceptService();
ConceptComplex conceptComplex = new ConceptComplex();
conceptComplex.setUuid(uuid);
conceptComplex.setHandler(handler);
ConceptName conceptName = new ConceptName(name, Locale.ENGLISH);
conceptComplex.setFullySpecifiedName(conceptName);
conceptComplex.setPreferredName(conceptName);
conceptComplex.setConceptClass(conceptService.getConceptClassByName("Question"));
conceptComplex.setDatatype(conceptService.getConceptDatatypeByUuid(ConceptDatatype.COMPLEX_UUID));
conceptComplex.addDescription(new ConceptDescription(description, Locale.ENGLISH));

return conceptService.saveConcept(conceptComplex);
}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there any such concept in the standard test dataset, or one of Core's datasets?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not to my knowledge. The standard dataset has limited complex concepts.

@mks-d mks-d changed the title ATT-47: Support for concept parameter when saving/fetching attachments ATT-47: Support for concept parameter when saving/fetching attachments. Apr 7, 2021
Copy link
Member

@mks-d mks-d left a comment

Choose a reason for hiding this comment

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

@samuelmale any chance you could look at this?

Comment on lines 316 to 317
Concept concept = testHelper.createComplexConcept("f4fab86d-4a1d-4245-8aa2-19f49b5ab07a", "Random files",
DefaultAttachmentHandler.class.getSimpleName(), "Random binary files");
Copy link
Member

Choose a reason for hiding this comment

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

A detail but why is "files" plural?

ATT-47: Improved ComplexObsSaver and other APIs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants