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-640: added FHIR Flag resource #80

Merged
merged 33 commits into from
Aug 17, 2024
Merged

Conversation

ManojLL
Copy link
Contributor

@ManojLL ManojLL commented Jul 9, 2024

Description of what I changed

added fhir resource provider, flag dao, translator and service for FHIR flag mapping

Issue I worked on

see https://openmrs.atlassian.net/browse/FM2-640

Checklist: I completed these to help reviewers :)

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

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

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

    No? -> write tests and add them to this commit git add . && git commit --amend

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

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

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

    No? Unsure? -> execute command git pull --rebase upstream master

Comment on lines 44 to 50
Narrative narrative = new Narrative();
narrative.setStatus(Narrative.NarrativeStatus.GENERATED);

XhtmlNode xhtmlNode = new XhtmlNode();
xhtmlNode.setName(patientFlag.getMessage());
narrative.setDiv(xhtmlNode);
flag.setText(narrative);
Copy link
Member

Choose a reason for hiding this comment

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

Don't do this in a translator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ibacher where should I add this ?

Copy link
Member

Choose a reason for hiding this comment

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

It'd be best if you could plug into the narrative generation system here, otherwise, just leave it alone for now (I don't, off-hand, remember how that system works).

Comment on lines 53 to 55
Identifier identifier = new Identifier();
identifier.setValue(String.valueOf(patientFlag.getPatientFlagId()));
flag.setIdentifier(Collections.singletonList(identifier));
Copy link
Member

Choose a reason for hiding this comment

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

identifier is always the UUID. Never use the database identifier for anything except internal operations.

flag.addCategory(codeableConcept);
});

flag.setCode(priorityTranslator.toFhirResource(patientFlag.getFlag().getPriority()));
Copy link
Member

Choose a reason for hiding this comment

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

Code should be the actual message to display to the user.

Copy link
Member

Choose a reason for hiding this comment

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

Module name has a typo here.

Copy link
Member

Choose a reason for hiding this comment

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

Also, instead of just copying this, you should be able to rely on the FhirConstants file from the FHIR2 module, i.e., the fhir submodule should have the fhir2 OMOD as part of its dependencies.

public IBundleProvider searchFlags(ReferenceAndListParam patient) {
SearchParameterMap theParams = new SearchParameterMap();
if(patient != null ){
theParams.addParameter("aa",patient);
Copy link
Member

Choose a reason for hiding this comment

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

  1. The parameter should probably be FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, which will (hopefully) make things easier.
  2. There no issue adding the value null to the SearchParameterMap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ibacher I made some changes on the search operation, could you please review ?

Currently, flags can be searched by patient ID, name, and identifiers and also I am working on implementing the ability to search flags using code (flag message), date, and category.

@ManojLL ManojLL marked this pull request as ready for review July 26, 2024 10:11
@ManojLL ManojLL requested a review from ibacher July 26, 2024 10:24
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.

Thanks @ManojLL! Mostly looks good. A few comments though.

omod/src/main/resources/config.xml Show resolved Hide resolved
pom.xml Outdated
Comment on lines 37 to 38
<module>omod</module>
<module>fhir</module>
Copy link
Member

Choose a reason for hiding this comment

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

OMOD is the final artifact, so it always goes last.

Suggested change
<module>omod</module>
<module>fhir</module>
<module>fhir</module>
<module>omod</module>

pom.xml Outdated
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<uiframeworkVersion>3.11.0</uiframeworkVersion>
<metadatadeployVersion>1.8.1</metadatadeployVersion>
<metadatasharingVersion>1.2.2</metadatasharingVersion>
<webservices.rest-omod.version>2.40.0</webservices.rest-omod.version>
<legacyuiVersion>1.16.0</legacyuiVersion>
<fhirversion>2.2.0</fhirversion>
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 probably depend on an older version of the FHIR2 module. Maybe 1.9.0?

Copy link
Member

Choose a reason for hiding this comment

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

Also fhirVersion like the others

Copy link
Contributor Author

@ManojLL ManojLL Aug 1, 2024

Choose a reason for hiding this comment

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

@ibacher if use fhir version 1.9.0 , I get this error: https://pastebin.com/kz3RRTbX. with version 2.0.0 working correctly.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, fair enough.

omod/pom.xml Outdated
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>patientflags-fhir</artifactId>
<version>3.0.8-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<version>3.0.8-SNAPSHOT</version>
<version>${project.parent.version}</version>

<patientflags_patient_flag patient_flag_id="1" patient_id="1" flag_id="1" message="Test" creator="1" date_created="2007-05-01 00:00:00.0" voided="false" uuid="7d89924e-e8df-4553-a956-95de80529735"/>
<patientflags_patient_flag patient_flag_id="2" patient_id="2" flag_id="1" message="Test" creator="1" date_created="2007-05-01 00:00:00.0" voided="true" uuid="7d89924e-e8df-4543-a956-95de80529735"/>

</dataset>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
</dataset>
</dataset>

Comment on lines 45 to 47
if (system == null) {
coding.setDisplay(flag.getName());
}
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be localizable in some fashion?

Copy link
Member

Choose a reason for hiding this comment

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

Specifically something like FhirUtils#getMetadataTranslation(), but I'm not entirely sure how the flag name gets populated, etc.

public IBundleProvider searchFlags(@OptionalParam(name = Flag.SP_PATIENT, chainWhitelist = { "", Patient.SP_IDENTIFIER,
Patient.SP_GIVEN, Patient.SP_FAMILY, Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam patientReference,
@OptionalParam(name = Flag.SP_RES_ID) TokenAndListParam id,
@OptionalParam(name = "code") StringAndListParam codeParam,
Copy link
Member

Choose a reason for hiding this comment

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

Code should always be TokenAndListParam

Patient.SP_GIVEN, Patient.SP_FAMILY, Patient.SP_NAME }, targetTypes = Patient.class) ReferenceAndListParam patientReference,
@OptionalParam(name = Flag.SP_RES_ID) TokenAndListParam id,
@OptionalParam(name = "code") StringAndListParam codeParam,
@OptionalParam(name = "category") StringAndListParam category,
Copy link
Member

Choose a reason for hiding this comment

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

Ditto category

Copy link
Member

Choose a reason for hiding this comment

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

Also shouldn't category at least have an SP constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, we don't have constant for category and code like flag.SP_CODE and flag.SP_CATEGORY

public IBundleProvider searchFlags(FlagSearchParams patient) {
return searchQuery.getQueryResults(patient.toSearchParameterMap(), dao, translator, searchQueryInclude);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
}

fhir/pom.xml Outdated
Comment on lines 106 to 111
<properties>
<MODULE_ID>${project.parent.artifactId}</MODULE_ID>
<MODULE_NAME>${project.parent.name}</MODULE_NAME>
<MODULE_VERSION>${project.parent.version}</MODULE_VERSION>
<MODULE_PACKAGE>${project.parent.groupId}.${project.parent.artifactId}</MODULE_PACKAGE>
</properties>
Copy link
Member

Choose a reason for hiding this comment

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

What are these for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not needed, I will remove this.

@ManojLL
Copy link
Contributor Author

ManojLL commented Aug 1, 2024

@ibacher I made the requested changes.

@ManojLL ManojLL requested a review from ibacher August 1, 2024 19:30
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.

Small things, but basically looks fine.

Comment on lines 99 to 101
@Override
protected void validateObject(PatientFlag object) {
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this override strictly necessary? We shouldn't be invoking any of the endpoints that use it (create, update, patch).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this. I just added here as it is used in other services

<modules>
<module>
<moduleId>fhir2</moduleId>
<version>1.9.0</version>
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 you could use ${fhirversion} here instead and have that correctly filled in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed hard coded fhir version to ${fhirversion}

@ManojLL
Copy link
Contributor Author

ManojLL commented Aug 7, 2024

@ibacher Do I need to update the OpenMRS FHIR Implementation Guide, or is it sufficient to update the flag module documentation to include information about the FHIR flag mapping?

@ibacher
Copy link
Member

ibacher commented Aug 7, 2024

I think just documenting it here is sufficient. We need to give some thought about how we handle these things with IGs.

@wikumChamith wikumChamith merged commit 28a792a into openmrs:master Aug 17, 2024
3 checks passed
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.

3 participants