|
|
@ -43,6 +43,8 @@ public class AnyListResource {
|
|
|
|
return new AnyListResource(new org.hl7.fhir.dstu3.model.ListResource());
|
|
|
|
return new AnyListResource(new org.hl7.fhir.dstu3.model.ListResource());
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
return new AnyListResource(new org.hl7.fhir.r4.model.ListResource());
|
|
|
|
return new AnyListResource(new org.hl7.fhir.r4.model.ListResource());
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
return new AnyListResource(new org.hl7.fhir.r5.model.ListResource());
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(version + " not supported");
|
|
|
|
throw new UnsupportedOperationException(version + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -63,6 +65,11 @@ public class AnyListResource {
|
|
|
|
myListResource = theListResourceR4;
|
|
|
|
myListResource = theListResourceR4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AnyListResource(org.hl7.fhir.r5.model.ListResource theListResourceR5) {
|
|
|
|
|
|
|
|
myFhirVersion = FhirVersionEnum.R5;
|
|
|
|
|
|
|
|
myListResource = theListResourceR5;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static AnyListResource fromResource(IBaseResource theListResource) {
|
|
|
|
public static AnyListResource fromResource(IBaseResource theListResource) {
|
|
|
|
if (theListResource instanceof ca.uhn.fhir.model.dstu2.resource.ListResource) {
|
|
|
|
if (theListResource instanceof ca.uhn.fhir.model.dstu2.resource.ListResource) {
|
|
|
|
return new AnyListResource((ca.uhn.fhir.model.dstu2.resource.ListResource) theListResource);
|
|
|
|
return new AnyListResource((ca.uhn.fhir.model.dstu2.resource.ListResource) theListResource);
|
|
|
@ -70,6 +77,8 @@ public class AnyListResource {
|
|
|
|
return new AnyListResource((org.hl7.fhir.dstu3.model.ListResource) theListResource);
|
|
|
|
return new AnyListResource((org.hl7.fhir.dstu3.model.ListResource) theListResource);
|
|
|
|
} else if (theListResource instanceof org.hl7.fhir.r4.model.ListResource) {
|
|
|
|
} else if (theListResource instanceof org.hl7.fhir.r4.model.ListResource) {
|
|
|
|
return new AnyListResource((org.hl7.fhir.r4.model.ListResource) theListResource);
|
|
|
|
return new AnyListResource((org.hl7.fhir.r4.model.ListResource) theListResource);
|
|
|
|
|
|
|
|
} else if (theListResource instanceof org.hl7.fhir.r5.model.ListResource) {
|
|
|
|
|
|
|
|
return new AnyListResource((org.hl7.fhir.r5.model.ListResource) theListResource);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new UnsupportedOperationException("Cannot convert " + theListResource.getClass().getName() + " to AnyList");
|
|
|
|
throw new UnsupportedOperationException("Cannot convert " + theListResource.getClass().getName() + " to AnyList");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -94,6 +103,11 @@ public class AnyListResource {
|
|
|
|
return (org.hl7.fhir.r4.model.ListResource) get();
|
|
|
|
return (org.hl7.fhir.r4.model.ListResource) get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public org.hl7.fhir.r5.model.ListResource getR5() {
|
|
|
|
|
|
|
|
Validate.isTrue(myFhirVersion == FhirVersionEnum.R5);
|
|
|
|
|
|
|
|
return (org.hl7.fhir.r5.model.ListResource) get();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FhirVersionEnum getFhirVersion() {
|
|
|
|
public FhirVersionEnum getFhirVersion() {
|
|
|
|
return myFhirVersion;
|
|
|
|
return myFhirVersion;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -106,6 +120,9 @@ public class AnyListResource {
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
getR4().getCode().addCoding().setSystem(theSystem).setCode(theCode);
|
|
|
|
getR4().getCode().addCoding().setSystem(theSystem).setCode(theCode);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
getR5().getCode().addCoding().setSystem(theSystem).setCode(theCode);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -119,6 +136,9 @@ public class AnyListResource {
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
getR4().getIdentifier().add(new org.hl7.fhir.r4.model.Identifier().setSystem(theSystem).setValue(theValue));
|
|
|
|
getR4().getIdentifier().add(new org.hl7.fhir.r4.model.Identifier().setSystem(theSystem).setValue(theValue));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
getR5().getIdentifier().add(new org.hl7.fhir.r5.model.Identifier().setSystem(theSystem).setValue(theValue));
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -132,6 +152,9 @@ public class AnyListResource {
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
getR4().addExtension().setUrl(theUrl).setValue(new org.hl7.fhir.r4.model.StringType(theValue));
|
|
|
|
getR4().addExtension().setUrl(theUrl).setValue(new org.hl7.fhir.r4.model.StringType(theValue));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
getR5().addExtension().setUrl(theUrl).setValue(new org.hl7.fhir.r5.model.StringType(theValue));
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,6 +166,8 @@ public class AnyListResource {
|
|
|
|
return getStringExtensionValueOrNullDstu3(theUrl);
|
|
|
|
return getStringExtensionValueOrNullDstu3(theUrl);
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
return getStringExtensionValueOrNullR4(theUrl);
|
|
|
|
return getStringExtensionValueOrNullR4(theUrl);
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
return getStringExtensionValueOrNullR5(theUrl);
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -166,6 +191,15 @@ public class AnyListResource {
|
|
|
|
return targetType.getValue();
|
|
|
|
return targetType.getValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getStringExtensionValueOrNullR5(String theUrl) {
|
|
|
|
|
|
|
|
List<org.hl7.fhir.r5.model.Extension> targetTypes = getR5().getExtensionsByUrl(theUrl);
|
|
|
|
|
|
|
|
if (targetTypes.size() < 1) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
org.hl7.fhir.r5.model.StringType targetType = (org.hl7.fhir.r5.model.StringType) targetTypes.get(0).getValue();
|
|
|
|
|
|
|
|
return targetType.getValue();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addReference(IBaseReference theReference) {
|
|
|
|
public void addReference(IBaseReference theReference) {
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
case DSTU3:
|
|
|
|
case DSTU3:
|
|
|
@ -174,6 +208,9 @@ public class AnyListResource {
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
getR4().addEntry().setItem((org.hl7.fhir.r4.model.Reference) theReference);
|
|
|
|
getR4().addEntry().setItem((org.hl7.fhir.r4.model.Reference) theReference);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
getR5().addEntry().setItem((org.hl7.fhir.r5.model.Reference) theReference);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -187,6 +224,9 @@ public class AnyListResource {
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
getR4().addEntry().setItem(new org.hl7.fhir.r4.model.Reference(theReferenceId));
|
|
|
|
getR4().addEntry().setItem(new org.hl7.fhir.r4.model.Reference(theReferenceId));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
getR5().addEntry().setItem(new org.hl7.fhir.r5.model.Reference(theReferenceId));
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -202,6 +242,10 @@ public class AnyListResource {
|
|
|
|
return getR4().getEntry().stream()
|
|
|
|
return getR4().getEntry().stream()
|
|
|
|
.map(entry -> entry.getItem().getReference())
|
|
|
|
.map(entry -> entry.getItem().getReference())
|
|
|
|
.map(reference -> new org.hl7.fhir.r4.model.IdType(reference).toUnqualifiedVersionless().getValue());
|
|
|
|
.map(reference -> new org.hl7.fhir.r4.model.IdType(reference).toUnqualifiedVersionless().getValue());
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
return getR5().getEntry().stream()
|
|
|
|
|
|
|
|
.map(entry -> entry.getItem().getReference())
|
|
|
|
|
|
|
|
.map(reference -> new org.hl7.fhir.r5.model.IdType(reference).toUnqualifiedVersionless().getValue());
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -213,6 +257,8 @@ public class AnyListResource {
|
|
|
|
return removeItemDstu3(theReferenceId);
|
|
|
|
return removeItemDstu3(theReferenceId);
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
return removeItemR4(theReferenceId);
|
|
|
|
return removeItemR4(theReferenceId);
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
return removeItemR5(theReferenceId);
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -250,6 +296,22 @@ public class AnyListResource {
|
|
|
|
return removed;
|
|
|
|
return removed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean removeItemR5(String theReferenceId) {
|
|
|
|
|
|
|
|
boolean removed = false;
|
|
|
|
|
|
|
|
for (org.hl7.fhir.r5.model.ListResource.ListEntryComponent entry : getR5().getEntry()) {
|
|
|
|
|
|
|
|
if (theReferenceId.equals(entry.getItem().getReference()) && !entry.getDeleted()) {
|
|
|
|
|
|
|
|
entry.setDeleted(true);
|
|
|
|
|
|
|
|
removed = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (removed) {
|
|
|
|
|
|
|
|
getR5().getEntry().removeIf(entry -> entry.getDeleted());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return removed;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TokenParam getCodeFirstRep() {
|
|
|
|
public TokenParam getCodeFirstRep() {
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
case DSTU3:
|
|
|
|
case DSTU3:
|
|
|
@ -258,17 +320,40 @@ public class AnyListResource {
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
org.hl7.fhir.r4.model.Coding codingR4 = getR4().getCode().getCodingFirstRep();
|
|
|
|
org.hl7.fhir.r4.model.Coding codingR4 = getR4().getCode().getCodingFirstRep();
|
|
|
|
return new TokenParam(codingR4.getSystem(), codingR4.getCode());
|
|
|
|
return new TokenParam(codingR4.getSystem(), codingR4.getCode());
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
org.hl7.fhir.r5.model.Coding codingR5 = getR5().getCode().getCodingFirstRep();
|
|
|
|
|
|
|
|
return new TokenParam(codingR5.getSystem(), codingR5.getCode());
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TokenParam getIdentifierirstRep() {
|
|
|
|
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
|
|
|
|
case DSTU3:
|
|
|
|
|
|
|
|
org.hl7.fhir.dstu3.model.Identifier identDstu3 = getDstu3().getIdentifierFirstRep();
|
|
|
|
|
|
|
|
return new TokenParam(identDstu3.getSystem(), identDstu3.getValue());
|
|
|
|
|
|
|
|
case R4:
|
|
|
|
|
|
|
|
org.hl7.fhir.r4.model.Identifier identR4 = getR4().getIdentifierFirstRep();
|
|
|
|
|
|
|
|
return new TokenParam(identR4.getSystem(), identR4.getValue());
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
org.hl7.fhir.r5.model.Identifier identR5 = getR5().getIdentifierFirstRep();
|
|
|
|
|
|
|
|
return new TokenParam(identR5.getSystem(), identR5.getValue());
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isEmpty() {
|
|
|
|
public boolean isEmpty() {
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
switch (myFhirVersion) {
|
|
|
|
case DSTU3:
|
|
|
|
case DSTU3:
|
|
|
|
return getDstu3().getEntry().isEmpty();
|
|
|
|
return getDstu3().getEntry().isEmpty();
|
|
|
|
case R4:
|
|
|
|
case R4:
|
|
|
|
return getR4().getEntry().isEmpty();
|
|
|
|
return getR4().getEntry().isEmpty();
|
|
|
|
|
|
|
|
case R5:
|
|
|
|
|
|
|
|
return getR5().getEntry().isEmpty();
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
throw new UnsupportedOperationException(myFhirVersion + " not supported");
|
|
|
|
}
|
|
|
|
}
|
|
|
|