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

FM2-312: Map the order number as an identifier for MedicationRequest and ServiceRequest #306

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

Conversation

Ruhanga
Copy link
Member

@Ruhanga Ruhanga commented Nov 9, 2020

Description of what I changed

Issue I worked on

see https://issues.openmrs.org/browse/FM2-312

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

  • I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

  • All new and existing tests passed.

  • My pull request is based on the latest changes of the master branch.

@codecov
Copy link

codecov bot commented Nov 9, 2020

Codecov Report

Merging #306 (2ad8676) into master (cb69c3e) will decrease coverage by 0.03%.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #306      +/-   ##
============================================
- Coverage     84.22%   84.19%   -0.03%     
- Complexity     2084     2095      +11     
============================================
  Files           188      188              
  Lines          5305     5325      +20     
  Branches        602      604       +2     
============================================
+ Hits           4468     4483      +15     
- Misses          502      504       +2     
- Partials        335      338       +3     
Impacted Files Coverage Δ Complexity Δ
...ders/r4/MedicationRequestFhirResourceProvider.java 91.67% <ø> (ø) 12.00 <0.00> (ø)
...oviders/r4/ServiceRequestFhirResourceProvider.java 85.71% <ø> (ø) 11.00 <0.00> (ø)
...nslators/impl/MedicationRequestTranslatorImpl.java 89.47% <50.00%> (-2.19%) 8.00 <0.00> (ø)
...ir2/api/dao/impl/FhirMedicationRequestDaoImpl.java 87.10% <66.67%> (-4.90%) 21.00 <3.00> (+4.00) ⬇️
.../fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java 84.21% <66.67%> (-3.29%) 21.00 <3.00> (+4.00) ⬇️
...ir2/api/impl/FhirMedicationRequestServiceImpl.java 88.89% <100.00%> (+1.39%) 6.00 <1.00> (+1.00)
.../fhir2/api/impl/FhirServiceRequestServiceImpl.java 88.89% <100.00%> (+1.39%) 6.00 <1.00> (+1.00)
...translators/impl/ServiceRequestTranslatorImpl.java 95.56% <100.00%> (+0.21%) 23.00 <0.00> (+1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb69c3e...ead7d72. Read the comment docs.

@Ruhanga Ruhanga marked this pull request as ready for review November 16, 2020 05:58
Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

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

@Ruhanga Thanks for this! It looks mostly good and I'm sorry it's taken me a bit to get back to you. In addition to the below suggestions, I would look into adding a BaseOrderDao class that both FhirServiceRequestDaoImpl and FhirMedicationRequestDaoImpl can inherit from so we only need one definition of the the handleOrderNumber() logic (and can add other common logic for orders as needed).

@@ -25,6 +25,11 @@
@Override
MedicationRequest get(@Nonnull String uuid);

IBundleProvider searchForMedicationRequests(ReferenceAndListParam patientReference,
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, we only have on search method per service. I would just extend the existing method to also support identifier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could there not be some code already depending on the current method signature elsewhere? I was worried of the backwards compatibility by introducing another search.

Copy link
Member

Choose a reason for hiding this comment

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

No. This is a very closed set so far and, in essence, no one outside of the FHIR2 module should be depending on this (at least yet).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ohh, ok. Thank you for clarifying this.

Copy link
Member Author

@Ruhanga Ruhanga Dec 14, 2020

Choose a reason for hiding this comment

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

However, there are very many tests that are so tightly coupled to the method signature scattered all over the project. I see a huge refactor if I refactored the method(for example), could I go ahead @ibacher? Thanks.

@@ -60,6 +61,9 @@
@Autowired
private DosageTranslator dosageTranslator;

@Autowired
private OrderIdentifierTranslator orderIdentifierTranslator;
Copy link
Member

Choose a reason for hiding this comment

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

We should also have a mapping for this in toOpenmrsType()

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll let the method throw an exceptions at the moment since an order-number is read only and that it is of a string type.


orderIdentifier.setValue(order.getOrderNumber());

orderIdentifier.setUse(Identifier.IdentifierUse.OFFICIAL);
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be left as USUAL.

@Component
public class OrderIdentifierTranslatorImpl implements OrderIdentifierTranslator {

private static String ORDER_ID_TYPE = "Order Number";
Copy link
Member

Choose a reason for hiding this comment

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

I tend to prefer that constants like this go in the FhirConstants class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.


Identifier orderIdentifier = new Identifier();

orderIdentifier.setType(new CodeableConcept().setText(ORDER_ID_TYPE));
Copy link
Member

Choose a reason for hiding this comment

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

Technically, I think this should be the PLAC type:

Coding placCoding = new Coding().setSystem("http://terminology.hl7.org/CodeSystem/v2-0203").setCode("PLAC").setDisplay("Placer Identifier");
orderIdentifier.setType(new CodeableConcept().addCoding(placCoding));

We can even define the CodeableConcept as a constant.

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.

import org.hl7.fhir.r4.model.Identifier;
import org.openmrs.Order;

public interface OrderIdentifierTranslator {
Copy link
Member

Choose a reason for hiding this comment

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

This should really extend ToFhirTranslator<Order> or, better yet:

public interface OrderIdentifierTranslator<T extends Order> extends OpenmrsFhirTranslator<T, Identifier>

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd go with:

public interface OrderIdentifierTranslator extends OpenmrsFhirTranslator<Order, Identifier>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants