Thanks for the reply. This is how Patient resource looks like -
package com.macrohealth.platform.fhir.common;
import ca.uhn.fhir.model.api.annotation.*;
import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.util.ElementUtil;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import org.hl7.fhir.r4.model.*;
import java.util.ArrayList;
import java.util.List;
@ResourceDef(profile="http://fhirserver/fhir/StructureDefinition/Patient")
public class MHPatient extends Patient {
private static final long serialVersionUID = 1L;
@Child(name = "responsiblePersons")
@Extension(url = "http://fhirserver/fhir/MHPatient#responsiblePersons", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save responsible person information from 2100G loop in X12")
private List<MHResponsiblePerson> responsiblePersons;
@Child(name = "employmentClasses")
@Extension(url = "http://fhirserver/fhir/MHPatient#employmentClasses", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save employment class information from 2100A loop in X12")
private List<MHEmploymentClass> employmentClasses;
@Child(name = "memberIncome")
@Extension(url = "http://fhirserver/fhir/MHPatient#memberIncome", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save member income information from 2100A loop in X12")
private MHMemberIncome memberIncome;
@Child(name = "memberPolicies")
@Extension(url = "http://fhirserver/fhir/MHPatient#memberPolicies", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save member policy information from 2100A loop in X12")
private List<MHX12Policy> memberPolicies;
@Child(name = "healthInformation")
@Extension(url = "http://fhirserver/fhir/MHPatient#healthInformation", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save member health information from 2100A loop in X12")
private MHMemberHealthInformation healthInformation;
@Child(name = "schoolOrganizations")
@Extension(url = "http://fhirserver/fhir/MHPatient#schoolOrganizations", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save member school information from 2100E loop in X12")
private List<Reference> schoolOrganizations;
@Child(name = "memberDates")
@Extension(url = "http://fhirserver/fhir/MHPatient#memberDates", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to save member level dates from DTP segment in 2000 loop in X12")
private List<MHX12Date> memberDates;
@Child(name = "insuredBenefitCodeInformation")
@Extension(url = "http://fhirserver/fhir/MHPatient#insuredBenefitCodeInformation", definedLocally = false, isModifier = false)
@Description(shortDefinition = "This is to insured benefit code details from INS segment in 2000 loop in X12")
private MHInsuredBenefitCodeInformation insuredBenefitCodeInformation;
@Child(name = "entityIdentifierCode")
@Extension(url = "http://fhirserver/fhir/MHPatient#entityIdentifierCode", definedLocally = false, isModifier = false)
@Description(shortDefinition = "entityIdentifierCode NM101 in loop 2100A")
private StringType entityIdentifierCode;
@Child(name = "citizenshipStatusCode")
@Extension(url = "http://fhirserver/fhir/MHPatient#citizenshipStatusCode", definedLocally = false, isModifier = false)
@Description(shortDefinition = "citizenshipStatusCode DMG06 in loop 2100A")
private StringType citizenshipStatusCode;
@Child(name = "isSubscriber")
@Extension(url = "http://fhirserver/fhir/MHPatient#isSubscriber", definedLocally = false, isModifier = false)
@Description(shortDefinition = "INS01 indicator in loop 2000")
private StringType isSubscriber;
@Child(name = "subscriberRelationshipCode")
@Extension(url = "http://fhirserver/fhir/MHPatient#subscriberRelationshipCode", definedLocally = false, isModifier = false)
@Description(shortDefinition = "realtionship code with subscriber from INS02 in loop 2000")
private StringType subscriberRelationshipCode;
@Child(name = "subscriberId")
@Extension(url = "http://fhirserver/fhir/MHPatient#subscriberId", definedLocally = false, isModifier = false)
@Description(shortDefinition = "subscriber ID from REF02 when REF01 is OF in loop 2000")
private StringType subscriberId;
@Child(name = "policyNumber")
@Extension(url = "http://fhirserver/fhir/MHPatient#policyNumber", definedLocally = false, isModifier = false)
@Description(shortDefinition = "policy number from REF02 when REF01 is 1L in loop 2000")
private StringType policyNumber;
@Child(name="x12Refs")
@Extension(url="http://fhirserver/fhir/MHPatient#x12Refs", definedLocally=false, isModifier=false)
@Description(shortDefinition="List of all reference identification qualifiers and corresponding reference Ids")
private List<MHX12Ref> x12Refs;
public List<Reference> getSchoolOrganizations() {
if (this.schoolOrganizations == null)
this.schoolOrganizations = new ArrayList<Reference>();
return this.schoolOrganizations;
}
public MHPatient setSchoolOrganizations(List<Reference> theSchoolOrganizations) {
this.schoolOrganizations = theSchoolOrganizations;
return this;
}
public boolean hasSchoolOrganization() {
if (this.schoolOrganizations == null)
return false;
for (Reference item : this.schoolOrganizations)
if (!item.isEmpty())
return true;
return false;
}
public Reference addSchoolOrganization() {
Reference t = new Reference();
if (this.schoolOrganizations == null)
this.schoolOrganizations = new ArrayList<Reference>();
this.schoolOrganizations.add(t);
return t;
}
public MHPatient addSchoolOrganization(Reference t) {
if (t == null)
return this;
if (this.schoolOrganizations == null)
this.schoolOrganizations = new ArrayList<Reference>();
this.schoolOrganizations.add(t);
return this;
}
public Reference getSchoolOrganizationFirstRep() {
if (getSchoolOrganizations().isEmpty()) {
addSchoolOrganization();
}
return getSchoolOrganizations().get(0);
}
public List<MHResponsiblePerson> getResponsiblePersons() {
return responsiblePersons;
}
public void setResponsiblePersons(List<MHResponsiblePerson> responsiblePersons) {
this.responsiblePersons = responsiblePersons;
}
public List<MHEmploymentClass> getEmploymentClasses() {
return employmentClasses;
}
public void setEmploymentClasses(List<MHEmploymentClass> employmentClasses) {
this.employmentClasses = employmentClasses;
}
public MHMemberIncome getMemberIncome() {
return memberIncome;
}
public void setMemberIncome(MHMemberIncome memberIncome) {
this.memberIncome = memberIncome;
}
public List<MHX12Policy> getMemberPolicies() {
return memberPolicies;
}
public void setMemberPolicies(List<MHX12Policy> memberPolicies) {
this.memberPolicies = memberPolicies;
}
public MHMemberHealthInformation getHealthInformation() {
return healthInformation;
}
public void setHealthInformation(MHMemberHealthInformation healthInformation) {
this.healthInformation = healthInformation;
}
public List<MHX12Date> getMemberDates() {
return memberDates;
}
public void setMemberDates(List<MHX12Date> memberDates) {
this.memberDates = memberDates;
}
public MHInsuredBenefitCodeInformation getInsuredBenefitCodeInformation() {
return insuredBenefitCodeInformation;
}
public void setInsuredBenefitCodeInformation(MHInsuredBenefitCodeInformation insuredBenefitCodeInformation) {
this.insuredBenefitCodeInformation = insuredBenefitCodeInformation;
}
public StringType getEntityIdentifierCode() {
return entityIdentifierCode;
}
public void setEntityIdentifierCode(StringType entityIdentifierCode) {
this.entityIdentifierCode = entityIdentifierCode;
}
public StringType getCitizenshipStatusCode() {
return citizenshipStatusCode;
}
public void setCitizenshipStatusCode(StringType citizenshipStatusCode) {
this.citizenshipStatusCode = citizenshipStatusCode;
}
public StringType getIsSubscriber() {
return isSubscriber;
}
public void setIsSubscriber(StringType isSubscriber) {
this.isSubscriber = isSubscriber;
}
public StringType getSubscriberRelationshipCode() {
return subscriberRelationshipCode;
}
public void setSubscriberRelationshipCode(StringType subscriberRelationshipCode) {
this.subscriberRelationshipCode = subscriberRelationshipCode;
}
public StringType getSubscriberId() {
return subscriberId;
}
public void setSubscriberId(StringType subscriberId) {
this.subscriberId = subscriberId;
}
public StringType getPolicyNumber() {
return policyNumber;
}
public void setPolicyNumber(StringType policyNumber) {
this.policyNumber = policyNumber;
}
public List<MHX12Ref> getX12Refs() {
return x12Refs;
}
public void setX12Refs(List<MHX12Ref> x12Refs) {
this.x12Refs = x12Refs;
}
@Override
public MHPatient copy() {
MHPatient copy = new MHPatient();
copy.responsiblePersons = responsiblePersons;
copy.employmentClasses = employmentClasses;
copy.healthInformation = healthInformation;
copy.memberIncome = memberIncome;
copy.memberPolicies = memberPolicies;
copy.schoolOrganizations = schoolOrganizations;
copy.memberDates = memberDates;
copy.insuredBenefitCodeInformation = insuredBenefitCodeInformation;
copy.entityIdentifierCode = entityIdentifierCode;
copy.citizenshipStatusCode = citizenshipStatusCode;
copy.isSubscriber = isSubscriber;
copy.subscriberRelationshipCode = subscriberRelationshipCode;
copy.subscriberId = subscriberId;
copy.policyNumber = policyNumber;
copy.x12Refs = x12Refs;
return copy;
}
@Override
public boolean isEmpty() {
return super.isEmpty() && ElementUtil.isEmpty(responsiblePersons, schoolOrganizations, employmentClasses, memberIncome,
memberPolicies, healthInformation, memberDates, insuredBenefitCodeInformation, entityIdentifierCode, citizenshipStatusCode,
isSubscriber, subscriberRelationshipCode, subscriberId, policyNumber, x12Refs);
}
}