-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d40fb4
commit 9909a1e
Showing
2 changed files
with
428 additions
and
385 deletions.
There are no files selected for viewing
166 changes: 104 additions & 62 deletions
166
src/main/java/edu/gatech/chai/VRDR/model/DeathCertificate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,105 @@ | ||
package edu.gatech.chai.VRDR.model; | ||
|
||
import java.util.Date; | ||
|
||
import org.hl7.fhir.r4.model.Composition; | ||
import org.hl7.fhir.r4.model.Organization; | ||
import org.hl7.fhir.r4.model.Patient; | ||
import org.hl7.fhir.r4.model.Practitioner; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.hl7.fhir.r4.model.Resource; | ||
|
||
import ca.uhn.fhir.model.api.annotation.ResourceDef; | ||
import edu.gatech.chai.VRDR.model.util.CommonUtil; | ||
import edu.gatech.chai.VRDR.model.util.DeathCertificateUtil; | ||
|
||
@ResourceDef(name = "Composition", profile = "http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-death-certificate") | ||
public class DeathCertificate extends Composition { | ||
public DeathCertificate() { | ||
super(); | ||
CommonUtil.initResource(this); | ||
setType(DeathCertificateUtil.typeFixedValue); | ||
setStatus(DeathCertificateUtil.status); | ||
setDate(new Date()); | ||
} | ||
|
||
public DeathCertificate(DeathCertification resource) { | ||
this(); | ||
addEvent(resource); | ||
} | ||
|
||
private CompositionAttesterComponent addAttesterCommon() { | ||
CompositionAttesterComponent component = new CompositionAttesterComponent(); | ||
component.setMode(CompositionAttestationMode.LEGAL); | ||
return component; | ||
} | ||
|
||
public void addAttester(Patient resource, Date time) { | ||
addAttesterBase(resource,time); | ||
} | ||
|
||
public void addAttester(Practitioner resource, Date time) { | ||
addAttesterBase(resource,time); | ||
} | ||
|
||
public void addAttester(Organization resource, Date time) { | ||
addAttesterBase(resource,time); | ||
} | ||
|
||
private void addAttesterBase(Resource resource,Date time) { | ||
CompositionAttesterComponent component = addAttesterCommon(); | ||
component.setTime(time); | ||
component.setParty(new Reference(resource.getId())); | ||
addAttester(component); | ||
} | ||
|
||
public void addEvent(DeathCertification resource) { | ||
CompositionEventComponent component = new CompositionEventComponent(); | ||
component.addCode(DeathCertificateUtil.eventCodeFixedValue); | ||
component.addDetail(new Reference(resource.getId())); | ||
addEvent(component); | ||
} | ||
|
||
package edu.gatech.chai.VRDR.model; | ||
|
||
import java.util.Date; | ||
|
||
import org.hl7.fhir.r4.model.CodeableConcept; | ||
import org.hl7.fhir.r4.model.Composition; | ||
import org.hl7.fhir.r4.model.Organization; | ||
import org.hl7.fhir.r4.model.Patient; | ||
import org.hl7.fhir.r4.model.Practitioner; | ||
import org.hl7.fhir.r4.model.Reference; | ||
import org.hl7.fhir.r4.model.Resource; | ||
|
||
import ca.uhn.fhir.model.api.annotation.ResourceDef; | ||
import edu.gatech.chai.VRDR.model.util.CommonUtil; | ||
import edu.gatech.chai.VRDR.model.util.DeathCertificateUtil; | ||
|
||
@ResourceDef(name = "Composition", profile = "http://hl7.org/fhir/us/vrdr/StructureDefinition/vrdr-death-certificate") | ||
public class DeathCertificate extends Composition { | ||
public DeathCertificate() { | ||
super(); | ||
CommonUtil.initResource(this); | ||
setType(DeathCertificateUtil.typeFixedValue); | ||
setStatus(DeathCertificateUtil.status); | ||
setDate(new Date()); | ||
} | ||
|
||
public DeathCertificate(CompositionStatus status, Decedent decedent, DeathCertificationProcedure resource) { | ||
this(); | ||
setStatus(status); | ||
setSubject(new Reference(decedent)); | ||
addEvent(resource); | ||
} | ||
|
||
public DeathCertificate(DeathCertificationProcedure resource) { | ||
this(); | ||
addEvent(resource); | ||
} | ||
|
||
private CompositionAttesterComponent addAttesterCommon() { | ||
CompositionAttesterComponent component = new CompositionAttesterComponent(); | ||
component.setMode(CompositionAttestationMode.LEGAL); | ||
return component; | ||
} | ||
|
||
public void addAttester(Patient resource, Date time) { | ||
addAttesterBase(resource,time); | ||
} | ||
|
||
public void addAttester(Practitioner resource, Date time) { | ||
addAttesterBase(resource,time); | ||
} | ||
|
||
public void addAttester(Organization resource, Date time) { | ||
addAttesterBase(resource,time); | ||
} | ||
|
||
private void addAttesterBase(Resource resource,Date time) { | ||
CompositionAttesterComponent component = addAttesterCommon(); | ||
component.setTime(time); | ||
component.setParty(new Reference(resource.getId())); | ||
addAttester(component); | ||
} | ||
|
||
public void addEvent(DeathCertificationProcedure resource) { | ||
CompositionEventComponent component = new CompositionEventComponent(); | ||
component.addCode(DeathCertificateUtil.eventCodeFixedValue); | ||
component.addDetail(new Reference(resource.getId())); | ||
addEvent(component); | ||
} | ||
|
||
public void addResource(Resource resource) { | ||
if(CommonUtil.assignableFrom(resource.getClass(), DeathCertificateUtil.decedentDemographicResources)) { | ||
addResource(resource, DeathCertificateUtil.decendentDemographicsSectionCode); | ||
} | ||
else if(CommonUtil.assignableFrom(resource.getClass(), DeathCertificateUtil.deathInvestigationResources)) { | ||
addResource(resource, DeathCertificateUtil.deathInvestigationSectionCode); | ||
} | ||
else if(CommonUtil.assignableFrom(resource.getClass(), DeathCertificateUtil.deathCertificationResources)) { | ||
addResource(resource, DeathCertificateUtil.deathCertificationSectionCode); | ||
} | ||
else if(CommonUtil.assignableFrom(resource.getClass(), DeathCertificateUtil.decedentDispositionResources)) { | ||
addResource(resource, DeathCertificateUtil.decedentDispositionSectionCode); | ||
} | ||
else if(CommonUtil.assignableFrom(resource.getClass(), DeathCertificateUtil.codedContentResources)) { | ||
addResource(resource, DeathCertificateUtil.codedContentSectionCode); | ||
} | ||
} | ||
|
||
public void addResource(Resource resource, CodeableConcept sectionCode) { | ||
SectionComponent section = findOrCreateSection(sectionCode); | ||
section.addEntry(new Reference(resource.getId())); | ||
} | ||
|
||
public SectionComponent findOrCreateSection(CodeableConcept sectionCode) { | ||
for(SectionComponent section: this.getSection()) { | ||
if(section.getCode().equals(sectionCode)) { | ||
return section; | ||
} | ||
} | ||
SectionComponent newSection = new SectionComponent(); | ||
newSection.setCode(sectionCode); | ||
this.addSection(newSection); | ||
return newSection; | ||
} | ||
} |
Oops, something went wrong.