Skip to content

Commit 6ce1896

Browse files
authored
Merge pull request #33 from hyunho-mo/main
initial check
2 parents 8b9c438 + e9e5f10 commit 6ce1896

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

src/rotterdam/Patient.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import {inputValue} from '../functionsCatalog';
2+
import {genderFHIRV3Codes} from '../codes/fhirv3codes'
3+
import {lifelinesDateToISO} from '../lifelinesFunctions'
4+
import {UnexpectedInputException,assertIsDefined} from '../unexpectedInputException'
5+
6+
/*
7+
Based on HCIM resource:
8+
https://simplifier.net/packages/nictiz.fhir.nl.stu3.zib2017/2.2.12/files/2002232/~overview
9+
10+
Related Lifelines variables:
11+
gender, age (See Lifelines data manual)
12+
13+
*/
14+
15+
/**
16+
*
17+
* @precondition in reported age is defined, it is a number
18+
*
19+
* @returns approximate birthdate given the baseline assessment date and the reported age. Undefined
20+
* if there is no reported age or undefined assessment date.
21+
*/
22+
export const birthDate = ():string|undefined => {
23+
const assessmetDate:string|undefined = inputValue("date","1a")
24+
25+
if (assessmetDate === undefined){
26+
return undefined
27+
}
28+
else{
29+
const surveyDateParts = assessmetDate.split("-");
30+
31+
const reportedAge:string|undefined = inputValue("age","1a")
32+
33+
if (reportedAge!=undefined){
34+
const surveyAge = Number(reportedAge);
35+
const surveyYear = Number(surveyDateParts[0]);
36+
return (surveyYear-surveyAge).toString()
37+
}
38+
else{
39+
return undefined;
40+
}
41+
}
42+
43+
44+
}
45+
46+
47+
export const deceasedDateTime = ():string|undefined => {
48+
const dod = inputValue("date_of_death","global")
49+
if (dod!==undefined){
50+
return lifelinesDateToISO(dod)
51+
}
52+
else{
53+
return undefined;
54+
}
55+
56+
}
57+
58+
export const gender = ():object|undefined => {
59+
if (inputValue("gender","1a")==="MALE"){
60+
return genderFHIRV3Codes.male;
61+
}
62+
else if (inputValue("gender","1a")==="FEMALE"){
63+
return genderFHIRV3Codes.female;
64+
}
65+
else{
66+
return undefined;
67+
}
68+
}

0 commit comments

Comments
 (0)