Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/24/08 14:37:02 (8 months ago)
Author:
bwolfe
Message:

Merging api-refactoring to trunk [3595]:[4355]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/Obs.java

    r4095 r4358  
    9595        } 
    9696 
     97        /** 
     98         * Required parameters constructor  
     99         *  
     100         * A value is also required, but that can be one of: 
     101         * valueCoded,  
     102         * valueDrug, 
     103         * valueNumeric, or 
     104         * valueText 
     105         *  
     106         * @param person The Person this obs is acting on 
     107         * @param question The question concept this obs is related to 
     108         * @param obsDatetime The time this obs took place 
     109         * @param location The location this obs took place 
     110         */ 
     111        public Obs(Person person, Concept question, Date obsDatetime, Location location) { 
     112                this.person = person; 
     113                this.personId = person.getPersonId(); 
     114                this.concept = question; 
     115                this.obsDatetime = obsDatetime; 
     116                this.location = location; 
     117        } 
     118 
    97119        /** constructor with id */ 
    98120        public Obs(Integer obsId) { 
    99121                this.obsId = obsId; 
     122        } 
     123 
     124        /** 
     125         * This is an equivalent to a copy constructor. 
     126         *  
     127         * Creates a new copy of the given <code>obsToCopy</code> with a null obs id 
     128         *  
     129         * @param obsToCopy The Obs that is going to be copied 
     130         * @return a new Obs object with all the same attributes as the given obs 
     131         */ 
     132        public static Obs newInstance(Obs obsToCopy) { 
     133                Obs newObs = new Obs(obsToCopy.getPerson(), obsToCopy.getConcept(),  
     134                                     obsToCopy.getObsDatetime(), obsToCopy.getLocation()); 
     135                 
     136                newObs.setObsGroup(obsToCopy.getObsGroup()); 
     137                newObs.setAccessionNumber(obsToCopy.getAccessionNumber()); 
     138                newObs.setValueCoded(obsToCopy.getValueCoded()); 
     139                newObs.setValueDrug(obsToCopy.getValueDrug()); 
     140                newObs.setValueGroupId(obsToCopy.getValueGroupId()); 
     141                newObs.setValueDatetime(obsToCopy.getValueDatetime()); 
     142                newObs.setValueNumeric(obsToCopy.getValueNumeric()); 
     143                newObs.setValueModifier(obsToCopy.getValueModifier()); 
     144                newObs.setValueText(obsToCopy.getValueText()); 
     145                newObs.setComment(obsToCopy.getComment()); 
     146                newObs.setOrder(obsToCopy.getOrder()); 
     147                newObs.setEncounter(obsToCopy.getEncounter()); 
     148                newObs.setDateStarted(obsToCopy.getDateStarted()); 
     149                newObs.setDateStopped(obsToCopy.getDateStopped()); 
     150                newObs.setCreator(obsToCopy.getCreator()); 
     151                newObs.setDateCreated(obsToCopy.getDateCreated()); 
     152                newObs.setVoided(obsToCopy.getVoided()); 
     153                newObs.setVoidedBy(obsToCopy.getVoidedBy()); 
     154                newObs.setDateVoided(obsToCopy.getDateVoided()); 
     155                newObs.setVoidReason(obsToCopy.getVoidReason()); 
     156                 
     157                if (obsToCopy.getGroupMembers() != null) 
     158                        for (Obs member : obsToCopy.getGroupMembers()) { 
     159                                // if the obs hasn't been saved yet, no need to duplicate it 
     160                                if (member.getObsId() == null) 
     161                                        newObs.addGroupMember(member); 
     162                                else 
     163                                        newObs.addGroupMember(Obs.newInstance(member)); 
     164                        } 
     165 
     166                return newObs; 
    100167        } 
    101168 
     
    143210        } 
    144211 
     212        /** 
     213         * Sets the required Obs properties: 
     214         * creator and dateCreated 
     215         *  
     216         * @param creator 
     217         * @param dateCreated 
     218         */ 
     219        public void setRequiredProperties(User creator, Date dateCreated ) { 
     220                if (this.getCreator() == null) 
     221                        setCreator(creator); 
     222 
     223                if (this.getDateCreated() == null) 
     224                        setDateCreated(dateCreated); 
     225                 
     226                if (getGroupMembers() != null) { 
     227                        for (Obs member : getGroupMembers()) { 
     228                                // if statement does a quick sanity check to 
     229                                // avoid the simplest of infinite loops 
     230                                if (member.getCreator() == null ||  
     231                                        member.getDateCreated() == null) 
     232                                                member.setRequiredProperties(creator, dateCreated); 
     233                        } 
     234                } 
     235        } 
     236         
    145237        // Property accessors 
    146238 
     
    655747        /** 
    656748         * @return Returns the voided. 
     749         * @see #isVoided() 
    657750         */ 
    658751        public Boolean getVoided() { 
    659                 return voided
     752                return isVoided()
    660753        } 
    661754