-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FM2-648 fix NPE when querying deceased patient with openmrsPatients n… (
#553)
- Loading branch information
Showing
9 changed files
with
167 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
api/src/test/java/org/openmrs/module/fhir2/matchers/FhirMatchers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.matchers; | ||
|
||
import org.hamcrest.Matcher; | ||
import org.hl7.fhir.r4.model.Patient; | ||
|
||
public class FhirMatchers { | ||
|
||
public static Matcher<Patient> isDeceased() { | ||
return new IsDeceasedMatcher(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
api/src/test/java/org/openmrs/module/fhir2/matchers/IsDeceasedMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.fhir2.matchers; | ||
|
||
import org.hamcrest.Description; | ||
import org.hamcrest.TypeSafeDiagnosingMatcher; | ||
import org.hl7.fhir.r4.model.Patient; | ||
|
||
public class IsDeceasedMatcher extends TypeSafeDiagnosingMatcher<Patient> { | ||
|
||
@Override | ||
protected boolean matchesSafely(Patient p, Description description) { | ||
if (!p.hasDeceased()) { | ||
description.appendText("patient does not have a deceased attribute"); | ||
return false; | ||
} else if (p.hasDeceasedBooleanType() && !p.getDeceasedBooleanType().booleanValue()) { | ||
description.appendText("patient is not marked as deceased"); | ||
return false; | ||
} else if (p.hasDeceasedDateTimeType() && p.getDeceasedDateTimeType().isEmpty()) { | ||
description.appendText("patient does not have a deceased date"); | ||
return false; | ||
} else { | ||
description.appendText("patient is marked as deceased"); | ||
return true; | ||
} | ||
} | ||
|
||
@Override | ||
public void describeTo(Description description) { | ||
description.appendText("a patient who is deceased"); | ||
} | ||
} |