All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nedap.archie.rm.ehr.Ehr Maven / Gradle / Ivy

There is a newer version: 3.11.0
Show newest version
package com.nedap.archie.rm.ehr;

import com.nedap.archie.rm.RMObject;
import com.nedap.archie.rm.datavalues.quantity.datetime.DvDateTime;
import com.nedap.archie.rm.support.identification.HierObjectId;
import com.nedap.archie.rm.support.identification.ObjectId;
import com.nedap.archie.rm.support.identification.ObjectRef;
import com.nedap.archie.rminfo.Invariant;
import com.nedap.archie.rmutil.InvariantUtil;

import javax.annotation.Nullable;
import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * RM Object for an Ehr. Not entirely sure if it is useful in a library. Generally, this could be something you map yourself
 * in some kind of persistence framework. But it can be useful for transferring information
 * Created by pieter.bos on 08/07/16.
 */
@XmlRootElement(name="EHR")
@XmlType(name = "EHR", propOrder = {
        "systemId",
        "ehrId",
        "timeCreated",
        "contributions",
        "ehrAccess",
        "ehrStatus",
        "directory",
        "compositions",
        "folders"
})
@XmlAccessorType(XmlAccessType.FIELD)
public class Ehr extends RMObject {

    @XmlElement(name="system_id")
    private HierObjectId systemId;
    @XmlElement(name="ehr_id")
    private HierObjectId ehrId;

    private List> contributions = new ArrayList<>();
    @XmlElement(name="ehr_status")
    private ObjectRef ehrStatus;
    @XmlElement(name="ehr_access")
    private ObjectRef ehrAccess;
    @Nullable
    private List> compositions = new ArrayList<>();

    @Nullable
    private ObjectRef directory;

    @Nullable
    private List> folders = new ArrayList<>();

    @XmlElement(name="time_created")
    private DvDateTime timeCreated;

    public Ehr() {
    }

    public Ehr(HierObjectId systemId, HierObjectId ehrId, DvDateTime timeCreated, List> contributions, ObjectRef ehrStatus, ObjectRef ehrAccess, @Nullable ObjectRef directory, @Nullable List> compositions) {
        this.systemId = systemId;
        this.ehrId = ehrId;
        this.contributions = contributions;
        this.ehrStatus = ehrStatus;
        this.ehrAccess = ehrAccess;
        this.compositions = compositions;
        this.directory = directory;
        this.timeCreated = timeCreated;
    }

    public HierObjectId getSystemId() {
        return systemId;
    }

    public void setSystemId(HierObjectId systemId) {
        this.systemId = systemId;
    }

    public HierObjectId getEhrId() {
        return ehrId;
    }

    public void setEhrId(HierObjectId ehrId) {
        this.ehrId = ehrId;
    }

    @Nullable
    public List> getContributions() {
        return contributions;
    }

    public void setContributions(@Nullable List> contributions) {
        this.contributions = contributions;
    }

    public void addContribution(ObjectRef contribution) {
        this.contributions.add(contribution);
    }

    public ObjectRef getEhrStatus() {
        return ehrStatus;
    }

    public void setEhrStatus(ObjectRef ehrStatus) {
        this.ehrStatus = ehrStatus;
    }

    public ObjectRef getEhrAccess() {
        return ehrAccess;
    }

    public void setEhrAccess(ObjectRef ehrAccess) {
        this.ehrAccess = ehrAccess;
    }

    @Nullable
    public List> getCompositions() {
        return compositions;
    }

    public void setCompositions(@Nullable List> compositions) {
        this.compositions = compositions;
    }

    public void addComposition(ObjectRef composition) {
        this.compositions.add(composition);
    }

    @Nullable
    public ObjectRef getDirectory() {
        return directory;
    }

    public void setDirectory(@Nullable ObjectRef directory) {
        this.directory = directory;
    }

    public DvDateTime getTimeCreated() {
        return timeCreated;
    }

    public void setTimeCreated(DvDateTime timeCreated) {
        this.timeCreated = timeCreated;
    }

    @Nullable
    public List> getFolders() {
        return folders;
    }

    public void setFolders(@Nullable List> folders) {
        this.folders = folders;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Ehr ehr = (Ehr) o;
        return Objects.equals(systemId, ehr.systemId) &&
                Objects.equals(ehrId, ehr.ehrId) &&
                Objects.equals(contributions, ehr.contributions) &&
                Objects.equals(ehrStatus, ehr.ehrStatus) &&
                Objects.equals(ehrAccess, ehr.ehrAccess) &&
                Objects.equals(compositions, ehr.compositions) &&
                Objects.equals(directory, ehr.directory) &&
                Objects.equals(timeCreated, ehr.timeCreated) &&
                Objects.equals(folders, ehr.folders);
    }

    @Override
    public int hashCode() {
        return Objects.hash(systemId, ehrId, contributions, ehrStatus, ehrAccess, compositions, directory, timeCreated, folders);
    }

    @Invariant("Contributions valid")
    public boolean contributionsValid() {
        return InvariantUtil.objectRefTypeEquals(contributions, "CONTRIBUTION");
    }

    @Invariant("Ehr_access_valid")
    public boolean ehrAccessValid() {
        return InvariantUtil.objectRefTypeEquals(ehrAccess, "VERSIONED_EHR_ACCESS");

    }

    @Invariant("Ehr_status_valid")
    public boolean ehrStatusValid() {
        return InvariantUtil.objectRefTypeEquals(ehrStatus, "VERSIONED_EHR_STATUS");

    }

    @Invariant("Compositions_valid")
    public boolean compositionsValid() {
        return InvariantUtil.objectRefTypeEquals(compositions, "VERSIONED_COMPOSITION");

    }

    @Invariant("Directory_valid")
    public boolean directoryValid() {
        return InvariantUtil.objectRefTypeEquals(directory, "VERSIONED_FOLDER");

    }


    @Invariant("Folderss_valid")
    public boolean foldersValid() {
        return InvariantUtil.objectRefTypeEquals(folders, "VERSIONED_FOLDER");

    }

    @Invariant("Directory_in_folders")
    public boolean directoryInFolders() {
        if (folders != null && directory != null) {
            return folders.size() >= 1 && folders.get(0).equals(directory);
        }
        return true;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy