Conversation
mogoodrich
left a comment
There was a problem hiding this comment.
Can you add some tests, to demo how this works?
What was the considering with adding this as a new tag, versus a "obs" with
"style='appointmentService'" (like we have for location with "style='location')
(If this had all been discussed and decided while I was on vacay, that's fine, but if it hasn't been discussed, worth a discussion)
| throw new IllegalArgumentException("Could not find concept: " + conceptId); | ||
| } | ||
|
|
||
| existingObs = context.removeExistingObs(concept, (Concept) null); |
There was a problem hiding this comment.
We should test/document what happens if you multiple of these tags on a single form with the same concept id. At minimum, I don't think it will be able to reproduce them in the same order on reload. We should likely add support for mapping via form namespace and path via the control Id as the obs tag does, see: https://openmrs.atlassian.net/browse/HTML-788 (or if we don't make a new tag but use the obs tag we should get this out of the box).
There was a problem hiding this comment.
I don't think this will handle the rendering order correctly if we have multiple of these tags. That said, do we need to worry about that? An appointment can only be associated with one appointment service, and adding multiple of these tags for the same appointment should be a form design error.
There was a problem hiding this comment.
But you could be scheduling multiple appointments (for different services) on this form, correct? Would that work? This also ties into my previous question about why we decided to make this a new tag (instead of a obs tag with style='appointment')
There was a problem hiding this comment.
If we are going to put this tag in HFE, we should aim to support as many of the best-practice nuances that there are already established. I'm fine putting this in the ObsSubmissionElement, but I'm 100% convinced this functionality belongs in the HFE module at all (versus in pihcore, etc)
Yeah, I can add some tests. Speaking with @mseaton, I think the biggest motivation of having a separate tag is that |
Ah, okay, that makes sense then--we can keep as a separate tag. I do think we may want to add support for "controlId" attribute, but why don't you start by adding some tests so I can understand it better and then we can discuss. @chibongho |
mseaton
left a comment
There was a problem hiding this comment.
Generally looks good but see comments
| public AppointmentServiceObsElement(FormEntryContext context, Map<String, String> parameters) { | ||
| String conceptId = parameters.get("conceptId"); | ||
| if (conceptId == null) { | ||
| throw new IllegalArgumentException("appointmentServiceObs requires a conceptId parameter"); |
There was a problem hiding this comment.
All of these IllegalArgumentException should probably be BadFormDesignException
| throw new IllegalArgumentException("Could not find concept: " + conceptId); | ||
| } | ||
|
|
||
| existingObs = context.removeExistingObs(concept, (Concept) null); |
There was a problem hiding this comment.
If we are going to put this tag in HFE, we should aim to support as many of the best-practice nuances that there are already established. I'm fine putting this in the ObsSubmissionElement, but I'm 100% convinced this functionality belongs in the HFE module at all (versus in pihcore, etc)
| } | ||
|
|
||
| existingObs = context.removeExistingObs(concept, (Concept) null); | ||
| String existingUuid = existingObs != null ? existingObs.getValueText() : null; |
There was a problem hiding this comment.
So in your other active PR, you used provider id, here you are using uuid. I agree uuid is best, but why the inconsistency?
There was a problem hiding this comment.
I'll change it to the "<id> - <serviceName>" format similar to Location and Person.
There was a problem hiding this comment.
I'd be okay with keeping this as-is as this is a new domain we are capturing... I was more concerned about, say, capturing providers using "uuid" in some cases and "id" in others.
| StringBuilder sb = new StringBuilder(); | ||
| sb.append(serviceWidget.generateHtml(context)); | ||
| if (context.getMode() != Mode.VIEW) { | ||
| sb.append("<span class='required'>*</span>"); |
There was a problem hiding this comment.
Can you explain what this does? Will this always mark this type of question as required?
There was a problem hiding this comment.
It really ought to be required, but I haven't gotten a way to make it be conditionally required only if the user choose to create an appointment. What I have now is making this input technically optional in the backend, but have the subform here enforce the conditional requirement check via JS. Adding the <span> here is technically incorrect; I'll remove.
|
|
||
| serviceWidget.addOption(new Option("", "", false)); | ||
| for (AppointmentServiceDefinition svc : services) { | ||
| serviceWidget.addOption(new Option(svc.getName(), svc.getId() + " - " + svc.getName(), false)); |
There was a problem hiding this comment.
Sorry, the more I think about it, this should be uuid, regardless of what the other objects are doing... when reloading an existing obs is this doing a full match and so would fail on edit if the text name of a service as was changed?
There was a problem hiding this comment.
Yeah, this should definitely be uuid. Is there no uuid on appointmentservicedefinition?
There was a problem hiding this comment.
There is. I'll use uuid.
|
|
||
| serviceWidget.addOption(new Option("", "", false)); | ||
| for (AppointmentServiceDefinition svc : services) { | ||
| serviceWidget.addOption(new Option(svc.getName(), svc.getId() + " - " + svc.getName(), false)); |
There was a problem hiding this comment.
Yeah, this should definitely be uuid. Is there no uuid on appointmentservicedefinition?
See: https://openmrs.atlassian.net/browse/HTML-886
Adds a
<AppointmentServiceObs>tag to record appointment service as obs.