-
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-421: Fix Immunization requirements
- Loading branch information
Showing
39 changed files
with
431 additions
and
148 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
api/src/main/java/org/openmrs/module/fhir2/api/translators/LocationReferenceTranslator.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,36 @@ | ||
/* | ||
* 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.api.translators; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import org.hl7.fhir.r4.model.Reference; | ||
import org.openmrs.Location; | ||
|
||
public interface LocationReferenceTranslator extends OpenmrsFhirTranslator<Location, Reference> { | ||
|
||
/** | ||
* Maps an {@link Location} to a FHIR reference | ||
* | ||
* @param location the location to translate | ||
* @return the corresponding FHIR reference | ||
*/ | ||
@Override | ||
Reference toFhirResource(@Nonnull Location location); | ||
|
||
/** | ||
* Maps a FHIR reference to a {@link Location} | ||
* | ||
* @param locationReference the location reference to translate | ||
* @return the corresponding location | ||
*/ | ||
@Override | ||
Location toOpenmrsType(@Nonnull Reference locationReference); | ||
} |
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
53 changes: 53 additions & 0 deletions
53
...n/java/org/openmrs/module/fhir2/api/translators/impl/LocationReferenceTranslatorImpl.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,53 @@ | ||
/* | ||
* 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.api.translators.impl; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.openmrs.Location; | ||
import org.openmrs.module.fhir2.FhirConstants; | ||
import org.openmrs.module.fhir2.api.dao.FhirLocationDao; | ||
import org.openmrs.module.fhir2.api.translators.LocationReferenceTranslator; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Setter(AccessLevel.PACKAGE) | ||
public class LocationReferenceTranslatorImpl extends BaseReferenceHandlingTranslator implements LocationReferenceTranslator { | ||
|
||
@Autowired | ||
private FhirLocationDao locationDao; | ||
|
||
@Override | ||
public Reference toFhirResource(@Nonnull Location location) { | ||
if (location == null || location.getRetired()) { | ||
return null; | ||
} | ||
|
||
return createLocationReference(location); | ||
} | ||
|
||
@Override | ||
public Location toOpenmrsType(@Nonnull Reference locationReference) { | ||
if (locationReference == null || !locationReference.hasReference()) { | ||
return null; | ||
} | ||
|
||
if (getReferenceType(locationReference).map(ref -> !ref.equals(FhirConstants.LOCATION)).orElse(true)) { | ||
throw new IllegalArgumentException( | ||
"Reference must be to a Location not a " + getReferenceType(locationReference).orElse("")); | ||
} | ||
|
||
return getReferenceId(locationReference).map(uuid -> locationDao.get(uuid)).orElse(null); | ||
} | ||
} |
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
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
Oops, something went wrong.