diff --git a/pom.xml b/pom.xml
index 2a4ea48..f61b4ea 100755
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.smartregister
fhir-common-utils
- 0.0.1-SNAPSHOT
+ 0.0.2-SNAPSHOT
diff --git a/src/main/java/org/smartregister/model/practitioner/FhirCareTeamExtension.java b/src/main/java/org/smartregister/model/practitioner/FhirCareTeamExtension.java
deleted file mode 100755
index 98bc4f0..0000000
--- a/src/main/java/org/smartregister/model/practitioner/FhirCareTeamExtension.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2021 Ona Systems, Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.smartregister.model.practitioner;
-
-import ca.uhn.fhir.model.api.annotation.DatatypeDef;
-import org.hl7.fhir.r4.model.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@DatatypeDef(name = "FhirCareTeamExtension")
-public class FhirCareTeamExtension extends CareTeam {
-
- @Override
- public CareTeam copy() {
- CareTeam careTeam = new CareTeam();
- Bundle bundle = new Bundle();
- List theEntry = new ArrayList<>();
- Bundle.BundleEntryComponent entryComponent = new Bundle.BundleEntryComponent();
- entryComponent.setResource(new Bundle());
- theEntry.add(entryComponent);
- bundle.setEntry(theEntry);
- this.copyValues(careTeam);
- return careTeam;
- }
-
- public FhirCareTeamExtension mapValues(CareTeam careTeam) {
- FhirCareTeamExtension fhirCareTeamExtension = new FhirCareTeamExtension();
- if (careTeam != null) {
- if (careTeam.getId() != null) {
- fhirCareTeamExtension.setId(careTeam.getId());
- }
- if (careTeam.getIdentifier() != null) {
- fhirCareTeamExtension.setIdentifier(careTeam.getIdentifier());
- }
- if (careTeam.getStatus() != null) {
- fhirCareTeamExtension.setStatus(careTeam.getStatus());
- }
- if (careTeam.getCategory() != null) {
- fhirCareTeamExtension.setCategory(careTeam.getCategory());
- }
- if (careTeam.getName() != null) {
- fhirCareTeamExtension.setName(careTeam.getName());
- }
- if (careTeam.getSubject() != null) {
- fhirCareTeamExtension.setSubject(careTeam.getSubject());
- }
- if (careTeam.getEncounter() != null) {
- fhirCareTeamExtension.setEncounter(careTeam.getEncounter());
- }
- if (careTeam.getPeriod() != null) {
- fhirCareTeamExtension.setPeriod(careTeam.getPeriod());
- }
- if (careTeam.getParticipant() != null) {
- fhirCareTeamExtension.setParticipant(careTeam.getParticipant());
- }
-
- if (careTeam.getReasonCode() != null) {
- fhirCareTeamExtension.setReasonCode(careTeam.getReasonCode());
- }
- if (careTeam.getReasonReference() != null) {
- fhirCareTeamExtension.setReasonReference(careTeam.getReasonReference());
- }
- if (careTeam.getManagingOrganization() != null) {
- fhirCareTeamExtension.setManagingOrganization(careTeam.getManagingOrganization());
- }
- if (careTeam.getTelecom() != null) {
- fhirCareTeamExtension.setTelecom(careTeam.getTelecom());
- }
- if (careTeam.getNote() != null) {
- fhirCareTeamExtension.setNote(careTeam.getNote());
- }
- }
-
- return fhirCareTeamExtension;
- }
-}
diff --git a/src/main/java/org/smartregister/model/practitioner/FhirOrganizationExtension.java b/src/main/java/org/smartregister/model/practitioner/FhirOrganizationExtension.java
deleted file mode 100755
index 9abb081..0000000
--- a/src/main/java/org/smartregister/model/practitioner/FhirOrganizationExtension.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2021 Ona Systems, Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.smartregister.model.practitioner;
-
-import ca.uhn.fhir.model.api.annotation.DatatypeDef;
-import org.hl7.fhir.r4.model.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@DatatypeDef(name = "FhirOrganizationExtension")
-public class FhirOrganizationExtension extends Organization {
-
- @Override
- public Organization copy() {
- Organization organization = new Organization();
- Bundle bundle = new Bundle();
- List theEntry = new ArrayList<>();
- Bundle.BundleEntryComponent entryComponent = new Bundle.BundleEntryComponent();
- entryComponent.setResource(new Bundle());
- theEntry.add(entryComponent);
- bundle.setEntry(theEntry);
- this.copyValues(organization);
- return organization;
- }
-
- public FhirOrganizationExtension mapValues(Organization organization) {
- FhirOrganizationExtension fhirOrganizationExtension = new FhirOrganizationExtension();
- if (organization != null) {
- if (organization.getId() != null) {
- fhirOrganizationExtension.setId(organization.getId());
- }
- if (organization.getIdentifier() != null) {
- fhirOrganizationExtension.setIdentifier(organization.getIdentifier());
- }
-
- fhirOrganizationExtension.setActive(organization.getActive());
- if (organization.getType() != null) {
- fhirOrganizationExtension.setType(organization.getType());
- }
- if (organization.getName() != null) {
- fhirOrganizationExtension.setName(organization.getName());
- }
- if (organization.getAlias() != null) {
- fhirOrganizationExtension.setAlias(organization.getAlias());
- }
- if (organization.getTelecom() != null) {
- fhirOrganizationExtension.setTelecom(organization.getTelecom());
- }
- if (organization.getAddress() != null) {
- fhirOrganizationExtension.setAddress(organization.getAddress());
- }
- if (organization.getPartOf() != null) {
- fhirOrganizationExtension.setPartOf(organization.getPartOf());
- }
- if (organization.getContact() != null) {
- fhirOrganizationExtension.setContact(organization.getContact());
- }
-
- if (organization.getEndpoint() != null) {
- fhirOrganizationExtension.setEndpoint(organization.getEndpoint());
- }
- }
-
- return fhirOrganizationExtension;
- }
-}
diff --git a/src/main/java/org/smartregister/model/practitioner/FhirPractitionerDetails.java b/src/main/java/org/smartregister/model/practitioner/FhirPractitionerDetails.java
index 5da3117..d204cbe 100755
--- a/src/main/java/org/smartregister/model/practitioner/FhirPractitionerDetails.java
+++ b/src/main/java/org/smartregister/model/practitioner/FhirPractitionerDetails.java
@@ -19,8 +19,7 @@
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.util.ElementUtil;
import org.hl7.fhir.instance.model.api.ICompositeType;
-import org.hl7.fhir.r4.model.StringType;
-import org.hl7.fhir.r4.model.Type;
+import org.hl7.fhir.r4.model.*;
import org.smartregister.model.location.LocationHierarchy;
import java.util.List;
@@ -30,28 +29,39 @@ public class FhirPractitionerDetails extends Type implements ICompositeType {
@Child(
name = "careteams",
- type = {FhirCareTeamExtension.class},
+ type = {CareTeam.class},
order = 1,
min = 0,
max = -1,
modifier = false,
summary = false)
- List fhirCareTeamExtensionList;
+ List careTeams;
@Child(
name = "teams",
- type = {FhirOrganizationExtension.class},
+ type = {Organization.class},
order = 2,
min = 0,
max = -1,
modifier = false,
summary = false)
- List fhirOrganizationExtensions;
+ List organizations;
+
+
+ @Child(
+ name = "locations",
+ type = {Location.class},
+ order = 3,
+ min = 0,
+ max = -1,
+ modifier = false,
+ summary = false)
+ private List locations;
@Child(
name = "locationHierarchyList",
type = {LocationHierarchy.class},
- order = 3,
+ order = 4,
min = 0,
max = -1,
modifier = false,
@@ -61,29 +71,36 @@ public class FhirPractitionerDetails extends Type implements ICompositeType {
@Child(
name = "practitionerId",
type = {StringType.class},
- order = 4,
+ order = 5,
min = 0,
max = -1,
modifier = false,
summary = false)
private StringType practitionerId;
- public List getFhirCareTeamExtensionList() {
- return fhirCareTeamExtensionList;
+ public List getCareTeams() {
+ return careTeams;
+ }
+
+ public void setCareTeams(
+ List careTeams) {
+ this.careTeams = careTeams;
+ }
+
+ public List getOrganizations() {
+ return organizations;
}
- public void setFhirCareTeamExtensionList(
- List fhirCareTeamExtensionList) {
- this.fhirCareTeamExtensionList = fhirCareTeamExtensionList;
+ public void setOrganizations(List organizations) {
+ this.organizations = organizations;
}
- public List getFhirOrganizationExtensions() {
- return fhirOrganizationExtensions;
+ public List getLocations() {
+ return locations;
}
- public void setFhirOrganizationExtensions(
- List fhirOrganizationExtensions) {
- this.fhirOrganizationExtensions = fhirOrganizationExtensions;
+ public void setLocations(List locations) {
+ this.locations = locations;
}
public List getLocationHierarchyList() {
diff --git a/src/test/java/org/smartregister/model/practitioner/FhirCareTeamExtensionTest.java b/src/test/java/org/smartregister/model/practitioner/FhirCareTeamExtensionTest.java
deleted file mode 100644
index 3558064..0000000
--- a/src/test/java/org/smartregister/model/practitioner/FhirCareTeamExtensionTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2022 Ona Systems, Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.smartregister.model.practitioner;
-
-import org.hl7.fhir.r4.model.CareTeam;
-import org.hl7.fhir.r4.model.Identifier;
-import org.hl7.fhir.r4.model.Reference;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class FhirCareTeamExtensionTest {
-
- @Test
- public void testMapValues() {
-
- CareTeam careTeam = new CareTeam();
- List identifierList = new ArrayList<>();
- Identifier identifier = new Identifier();
- identifier.setUse(Identifier.IdentifierUse.OFFICIAL);
- identifierList.add(identifier);
- identifier.setValue("a2788d06-fdad-4a74-90ac-3ac4e243eee5");
- careTeam.setIdentifier(identifierList);
- careTeam.setName("Care Team A");
- careTeam.setStatus(CareTeam.CareTeamStatus.ACTIVE);
- Reference subjectRef = new Reference();
- subjectRef.setDisplay("Demo FHIR Groups");
- subjectRef.setReference("Group/206");
- careTeam.setSubject(subjectRef);
- List participantComponents = new ArrayList<>();
- CareTeam.CareTeamParticipantComponent careTeamParticipantComponent =
- new CareTeam.CareTeamParticipantComponent();
- Reference member = new Reference();
- member.setReference("Practitioner/152");
- member.setDisplay("Test Practitioner");
- careTeamParticipantComponent.setMember(member);
- participantComponents.add(careTeamParticipantComponent);
- careTeam.setParticipant(participantComponents);
-
- FhirCareTeamExtension fhirCareTeamExtension = new FhirCareTeamExtension();
- fhirCareTeamExtension = fhirCareTeamExtension.mapValues(careTeam);
-
- assertNotNull(fhirCareTeamExtension);
- assertEquals(careTeam.getId(), fhirCareTeamExtension.getId());
- assertEquals(careTeam.getIdentifier(), fhirCareTeamExtension.getIdentifier());
- assertEquals(careTeam.getStatus(), fhirCareTeamExtension.getStatus());
- assertEquals(careTeam.getCategory(), fhirCareTeamExtension.getCategory());
- assertEquals(careTeam.getName(), fhirCareTeamExtension.getName());
- assertEquals(careTeam.getSubject(), fhirCareTeamExtension.getSubject());
- assertEquals(careTeam.getEncounter(), fhirCareTeamExtension.getEncounter());
- assertEquals(careTeam.getPeriod(), fhirCareTeamExtension.getPeriod());
- assertEquals(careTeam.getParticipant(), fhirCareTeamExtension.getParticipant());
- assertEquals(careTeam.getReasonCode(), fhirCareTeamExtension.getReasonCode());
- assertEquals(careTeam.getReasonReference(), fhirCareTeamExtension.getReasonReference());
- assertEquals(
- careTeam.getManagingOrganization(),
- fhirCareTeamExtension.getManagingOrganization());
- assertEquals(careTeam.getTelecom(), fhirCareTeamExtension.getTelecom());
- assertEquals(careTeam.getNote(), fhirCareTeamExtension.getNote());
- }
-}
diff --git a/src/test/java/org/smartregister/model/practitioner/FhirOrganizationExtensionTest.java b/src/test/java/org/smartregister/model/practitioner/FhirOrganizationExtensionTest.java
deleted file mode 100644
index b967f65..0000000
--- a/src/test/java/org/smartregister/model/practitioner/FhirOrganizationExtensionTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2022 Ona Systems, Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.smartregister.model.practitioner;
-
-import org.hl7.fhir.r4.model.*;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class FhirOrganizationExtensionTest {
-
- @Test
- public void testMapValues() {
- Organization organization = new Organization();
- List identifierList = new ArrayList<>();
- Identifier identifier = new Identifier();
- identifier.setUse(Identifier.IdentifierUse.OFFICIAL);
- identifierList.add(identifier);
- identifier.setValue("a2788d06-fdad-4a74-90ac-3ac4e243eee5");
- organization.setIdentifier(identifierList);
- organization.setId("");
- organization.setActive(true);
- List typeList = new ArrayList<>();
- CodeableConcept type = new CodeableConcept();
- type.setId("Test type");
- List codings = new ArrayList<>();
- Coding coding = new Coding();
- coding.setCode("A");
- codings.add(coding);
- type.setCoding(codings);
- typeList.add(type);
- organization.setType(typeList);
- organization.setName("Organization A");
- List aliasList = new ArrayList<>();
- StringType alias = new StringType();
- alias.setValue("Organization A");
- aliasList.add(alias);
- organization.setAlias(aliasList);
-
- FhirOrganizationExtension fhirOrganizationExtension = new FhirOrganizationExtension();
- fhirOrganizationExtension = fhirOrganizationExtension.mapValues(organization);
-
- assertNotNull(fhirOrganizationExtension);
- assertEquals(organization.getId(), fhirOrganizationExtension.getId());
- assertEquals(organization.getIdentifier(), fhirOrganizationExtension.getIdentifier());
- assertEquals(organization.getActive(), fhirOrganizationExtension.getActive());
- assertEquals(organization.getType(), fhirOrganizationExtension.getType());
- assertEquals(organization.getName(), fhirOrganizationExtension.getName());
- assertEquals(organization.getAlias(), fhirOrganizationExtension.getAlias());
- assertEquals(organization.getTelecom(), fhirOrganizationExtension.getTelecom());
- assertEquals(organization.getAddress(), fhirOrganizationExtension.getAddress());
- assertEquals(organization.getPartOf(), fhirOrganizationExtension.getPartOf());
- assertEquals(organization.getContact(), fhirOrganizationExtension.getContact());
- assertEquals(organization.getEndpoint(), fhirOrganizationExtension.getEndpoint());
- }
-}