diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Patient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Patient.java index 594bcd4c6e0..e78fbafe2f2 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Patient.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Patient.java @@ -62,10 +62,10 @@ public class Patient extends BaseResource { private List myCommunication; @Child(name="careProvider", order=13, min=0, max=Child.MAX_UNLIMITED) - private List myCareProvider; + private List myCareProvider; @Child(name="managingOrganization", order=14, min=0, max=1) - private OrganizationDt myManagingOrganization; + private ResourceReference myManagingOrganization; @Child(name="link", order=15, min=0, max=Child.MAX_UNLIMITED) private List myLink; @@ -394,7 +394,7 @@ public class Patient extends BaseResource { * Patient's nominated care provider *

*/ - public List getCareProvider() { + public List getCareProvider() { return myCareProvider; } @@ -406,7 +406,7 @@ public class Patient extends BaseResource { * Patient's nominated care provider *

*/ - public void setCareProvider(List theValue) { + public void setCareProvider(List theValue) { myCareProvider = theValue; } @@ -418,7 +418,7 @@ public class Patient extends BaseResource { * Organization that is the custodian of the patient record *

*/ - public OrganizationDt getManagingOrganization() { + public ResourceReference getManagingOrganization() { return myManagingOrganization; } @@ -430,7 +430,7 @@ public class Patient extends BaseResource { * Organization that is the custodian of the patient record *

*/ - public void setManagingOrganization(OrganizationDt theValue) { + public void setManagingOrganization(ResourceReference theValue) { myManagingOrganization = theValue; } @@ -483,16 +483,337 @@ public class Patient extends BaseResource { } + /** + * Block class for child element: Patient.contact (A contact party (e.g. guardian, partner, friend) for the patient) + * + *

+ * Definition: + * A contact party (e.g. guardian, partner, friend) for the patient + *

+ */ @Block(name="Patient.contact") public static class Contact { + @Child(name="relationship", order=0, min=0, max=Child.MAX_UNLIMITED) + private List myRelationship; + + @Child(name="name", order=1, min=0, max=1) + private HumanNameDt myName; + + @Child(name="telecom", order=2, min=0, max=Child.MAX_UNLIMITED) + private List myTelecom; + + @Child(name="address", order=3, min=0, max=1) + private AddressDt myAddress; + + @Child(name="gender", order=4, min=0, max=1) + private CodeableConceptDt myGender; + + @Child(name="organization", order=5, min=0, max=1) + private ResourceReference myOrganization; + + /** + * Gets the value(s) for relationship (The kind of relationship) + * + *

+ * Definition: + * The nature of the relationship between the patient and the contact person + *

+ */ + public List getRelationship() { + return myRelationship; + } + + /** + * Sets the value(s) for relationship (The kind of relationship) + * + *

+ * Definition: + * The nature of the relationship between the patient and the contact person + *

+ */ + public void setRelationship(List theValue) { + myRelationship = theValue; + } + + /** + * Gets the value(s) for name (A name associated with the person) + * + *

+ * Definition: + * A name associated with the person + *

+ */ + public HumanNameDt getName() { + return myName; + } + + /** + * Sets the value(s) for name (A name associated with the person) + * + *

+ * Definition: + * A name associated with the person + *

+ */ + public void setName(HumanNameDt theValue) { + myName = theValue; + } + + /** + * Gets the value(s) for telecom (A contact detail for the person) + * + *

+ * Definition: + * A contact detail for the person, e.g. a telephone number or an email address. + *

+ */ + public List getTelecom() { + return myTelecom; + } + + /** + * Sets the value(s) for telecom (A contact detail for the person) + * + *

+ * Definition: + * A contact detail for the person, e.g. a telephone number or an email address. + *

+ */ + public void setTelecom(List theValue) { + myTelecom = theValue; + } + + /** + * Gets the value(s) for address (Address for the contact person) + * + *

+ * Definition: + * Address for the contact person + *

+ */ + public AddressDt getAddress() { + return myAddress; + } + + /** + * Sets the value(s) for address (Address for the contact person) + * + *

+ * Definition: + * Address for the contact person + *

+ */ + public void setAddress(AddressDt theValue) { + myAddress = theValue; + } + + /** + * Gets the value(s) for gender (Gender for administrative purposes) + * + *

+ * Definition: + * Administrative Gender - the gender that the person is considered to have for administration and record keeping purposes. + *

+ */ + public CodeableConceptDt getGender() { + return myGender; + } + + /** + * Sets the value(s) for gender (Gender for administrative purposes) + * + *

+ * Definition: + * Administrative Gender - the gender that the person is considered to have for administration and record keeping purposes. + *

+ */ + public void setGender(CodeableConceptDt theValue) { + myGender = theValue; + } + + /** + * Gets the value(s) for organization (Organization that is associated with the contact) + * + *

+ * Definition: + * Organization on behalf of which the contact is acting or for which the contact is working. + *

+ */ + public ResourceReference getOrganization() { + return myOrganization; + } + + /** + * Sets the value(s) for organization (Organization that is associated with the contact) + * + *

+ * Definition: + * Organization on behalf of which the contact is acting or for which the contact is working. + *

+ */ + public void setOrganization(ResourceReference theValue) { + myOrganization = theValue; + } + } + /** + * Block class for child element: Patient.animal (If this patient is an animal (non-human)) + * + *

+ * Definition: + * This element has a value if the patient is an animal + *

+ */ @Block(name="Patient.animal") public static class Animal { + @Child(name="species", order=0, min=1, max=1) + private CodeableConceptDt mySpecies; + + @Child(name="breed", order=1, min=0, max=1) + private CodeableConceptDt myBreed; + + @Child(name="genderStatus", order=2, min=0, max=1) + private CodeableConceptDt myGenderStatus; + + /** + * Gets the value(s) for species (E.g. Dog, Cow) + * + *

+ * Definition: + * Identifies the high level categorization of the kind of animal + *

+ */ + public CodeableConceptDt getSpecies() { + return mySpecies; + } + + /** + * Sets the value(s) for species (E.g. Dog, Cow) + * + *

+ * Definition: + * Identifies the high level categorization of the kind of animal + *

+ */ + public void setSpecies(CodeableConceptDt theValue) { + mySpecies = theValue; + } + + /** + * Gets the value(s) for breed (E.g. Poodle, Angus) + * + *

+ * Definition: + * Identifies the detailed categorization of the kind of animal. + *

+ */ + public CodeableConceptDt getBreed() { + return myBreed; + } + + /** + * Sets the value(s) for breed (E.g. Poodle, Angus) + * + *

+ * Definition: + * Identifies the detailed categorization of the kind of animal. + *

+ */ + public void setBreed(CodeableConceptDt theValue) { + myBreed = theValue; + } + + /** + * Gets the value(s) for genderStatus (E.g. Neutered, Intact) + * + *

+ * Definition: + * Indicates the current state of the animal's reproductive organs + *

+ */ + public CodeableConceptDt getGenderStatus() { + return myGenderStatus; + } + + /** + * Sets the value(s) for genderStatus (E.g. Neutered, Intact) + * + *

+ * Definition: + * Indicates the current state of the animal's reproductive organs + *

+ */ + public void setGenderStatus(CodeableConceptDt theValue) { + myGenderStatus = theValue; + } + } + /** + * Block class for child element: Patient.link (Link to another patient resource that concerns the same actual person) + * + *

+ * Definition: + * Link to another patient resource that concerns the same actual person + *

+ */ @Block(name="Patient.link") public static class Link { + @Child(name="other", order=0, min=1, max=1) + private ResourceReference myOther; + + @Child(name="type", order=1, min=1, max=1) + private CodeDt myType; + + /** + * Gets the value(s) for other (The other patient resource that the link refers to) + * + *

+ * Definition: + * The other patient resource that the link refers to + *

+ */ + public ResourceReference getOther() { + return myOther; + } + + /** + * Sets the value(s) for other (The other patient resource that the link refers to) + * + *

+ * Definition: + * The other patient resource that the link refers to + *

+ */ + public void setOther(ResourceReference theValue) { + myOther = theValue; + } + + /** + * Gets the value(s) for type (replace | refer | seealso - type of link) + * + *

+ * Definition: + * The type of link between this patient resource and another patient resource. + *

+ */ + public CodeDt getType() { + return myType; + } + + /** + * Sets the value(s) for type (replace | refer | seealso - type of link) + * + *

+ * Definition: + * The type of link between this patient resource and another patient resource. + *

+ */ + public void setType(CodeDt theValue) { + myType = theValue; + } + } diff --git a/hapi-fhir-starter/.classpath b/hapi-fhir-starter/.classpath index 3cd1c7592b8..aebbc12fa86 100644 --- a/hapi-fhir-starter/.classpath +++ b/hapi-fhir-starter/.classpath @@ -254,5 +254,6 @@ + diff --git a/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/BaseParser.java b/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/BaseParser.java index fa651ae2e2e..c10788d917f 100644 --- a/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/BaseParser.java +++ b/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/BaseParser.java @@ -18,6 +18,8 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import ca.uhn.fhir.model.api.IDatatype; +import ca.uhn.fhir.model.api.ResourceReference; import ca.uhn.fhir.starter.model.BaseElement; import ca.uhn.fhir.starter.model.Child; import ca.uhn.fhir.starter.model.Resource; @@ -72,7 +74,9 @@ public abstract class BaseParser { parseBasicElements(nextRow, elem); - if (elem.getType().size() == 1) { + if (elem.isResourceRef()) { + elem.setReferenceType(ResourceReference.class.getSimpleName()); + } else if (elem.getType().size() == 1) { String elemName = elem.getType().get(0); elemName = elemName.substring(0, 1).toUpperCase() + elemName.substring(1); if (elem instanceof ResourceBlock) { @@ -81,7 +85,7 @@ public abstract class BaseParser { elem.setReferenceType(elemName + "Dt"); } } else { - elem.setReferenceType("IDatatype"); + elem.setReferenceType(IDatatype.class.getSimpleName()); } if (elem.isRepeatable()) { diff --git a/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/ResourceParser.java b/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/ResourceParser.java index aeb5aa564f3..c609b8f1021 100644 --- a/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/ResourceParser.java +++ b/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/ResourceParser.java @@ -1,8 +1,5 @@ package ca.uhn.fhir.starter; -import java.util.Arrays; - -import org.apache.commons.lang3.StringUtils; import org.w3c.dom.Element; import ca.uhn.fhir.starter.model.BaseElement; @@ -26,7 +23,7 @@ public class ResourceParser extends BaseParser { public static void main(String[] args) throws Exception { ResourceParser p = new ResourceParser(); - p.setDirectory("src/test/resources"); + p.setDirectory("src/test/resources/res"); p.setResourceName("patient"); p.setOutputFile("../hapi-fhir-base/src/main/java/ca/uhn/fhir/model/resource/Patient.java"); p.parse(); diff --git a/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/model/BaseElement.java b/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/model/BaseElement.java index c572ed28f81..39465d2faa0 100644 --- a/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/model/BaseElement.java +++ b/hapi-fhir-starter/src/main/java/ca/uhn/fhir/starter/model/BaseElement.java @@ -138,6 +138,7 @@ public abstract class BaseElement { String typeString = theType; if (typeString.startsWith("Resource(")) { typeString = typeString.substring("Resource(".length(), typeString.length() - 1); + myResourceRef=true; } if (StringUtils.isNotBlank(typeString)) { String[] types = typeString.replace("=", "").split("\\|"); diff --git a/hapi-fhir-starter/src/main/resources/resource.vm b/hapi-fhir-starter/src/main/resources/resource.vm index 66cda5ed2be..dd56dbcb233 100644 --- a/hapi-fhir-starter/src/main/resources/resource.vm +++ b/hapi-fhir-starter/src/main/resources/resource.vm @@ -56,8 +56,47 @@ public class ${className} extends BaseResource { #end #foreach ( $child in $resourceBlockChildren ) + /** + * Block class for child element: ${child.name} (${child.shortName}) + * + *

+ * Definition: + * ${child.definition} + *

+ */ @Block(name="${child.name}") public static class ${child.className} { +#foreach ( $subChild in $child.children ) + @Child(name="${subChild.elementName}", order=${foreach.index}, min=${subChild.cardMin}, max=${subChild.cardMaxForChildAnnotation}) + private ${subChild.referenceType} ${subChild.variableName}; + +#end +#foreach ( $subChild in $child.children ) + /** + * Gets the value(s) for ${subChild.elementName} (${subChild.shortName}) + * + *

+ * Definition: + * ${subChild.definition} + *

+ */ + public ${subChild.referenceType} get${subChild.methodName}() { + return ${subChild.variableName}; + } + + /** + * Sets the value(s) for ${subChild.elementName} (${subChild.shortName}) + * + *

+ * Definition: + * ${subChild.definition} + *

+ */ + public void set${subChild.methodName}(${subChild.referenceType} theValue) { + ${subChild.variableName} = theValue; + } + +#end } #end diff --git a/hapi-fhir-starter/src/test/resources/patient-spreadsheet.xml b/hapi-fhir-starter/src/test/resources/res/patient-spreadsheet.xml similarity index 100% rename from hapi-fhir-starter/src/test/resources/patient-spreadsheet.xml rename to hapi-fhir-starter/src/test/resources/res/patient-spreadsheet.xml